2021-12-05 17:54:36 +00:00
|
|
|
#include "AgPropguards.h"
|
|
|
|
#include "Character.h"
|
|
|
|
#include "GameMessages.h"
|
|
|
|
#include "EntityManager.h"
|
|
|
|
#include "dZoneManager.h"
|
2023-01-07 05:17:05 +00:00
|
|
|
#include "eMissionState.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
void AgPropguards::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, eMissionState missionState) {
|
|
|
|
auto* character = target->GetCharacter();
|
|
|
|
if (character == nullptr)
|
|
|
|
return;
|
|
|
|
|
|
|
|
const auto flag = GetFlagForMission(missionID);
|
|
|
|
if (flag == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ((missionState == eMissionState::AVAILABLE || missionState == eMissionState::ACTIVE)
|
|
|
|
&& !character->GetPlayerFlag(flag)) {
|
|
|
|
// If the player just started the mission, play a cinematic highlighting the target
|
|
|
|
GameMessages::SendPlayCinematic(target->GetObjectID(), u"MissionCam", target->GetSystemAddress());
|
2023-10-18 14:17:57 +00:00
|
|
|
} else if (missionState == eMissionState::READY_TO_COMPLETE) {
|
2021-12-05 17:54:36 +00:00
|
|
|
// Makes the guard disappear once the mission has been completed
|
2023-07-15 20:56:33 +00:00
|
|
|
const auto zoneControlID = Game::entityManager->GetZoneControlEntity()->GetObjectID();
|
2021-12-05 17:54:36 +00:00
|
|
|
GameMessages::SendNotifyClientObject(zoneControlID, u"GuardChat", 0, 0, self->GetObjectID(),
|
|
|
|
"", UNASSIGNED_SYSTEM_ADDRESS);
|
|
|
|
|
|
|
|
self->AddCallbackTimer(5.0f, [self]() {
|
|
|
|
auto spawnerName = self->GetVar<std::string>(u"spawner_name");
|
|
|
|
if (spawnerName.empty())
|
|
|
|
spawnerName = "Guard";
|
|
|
|
|
2023-07-17 22:55:33 +00:00
|
|
|
auto spawners = Game::zoneManager->GetSpawnersByName(spawnerName);
|
2021-12-05 17:54:36 +00:00
|
|
|
for (auto* spawner : spawners) {
|
|
|
|
spawner->Deactivate();
|
|
|
|
}
|
|
|
|
|
|
|
|
self->Smash();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-06 18:32:26 +00:00
|
|
|
int32_t AgPropguards::GetFlagForMission(uint32_t missionID) {
|
2021-12-05 17:54:36 +00:00
|
|
|
switch (missionID) {
|
|
|
|
case 872:
|
|
|
|
return 97;
|
|
|
|
case 873:
|
|
|
|
return 98;
|
|
|
|
case 874:
|
|
|
|
return 99;
|
|
|
|
case 1293:
|
|
|
|
return 118;
|
|
|
|
case 1322:
|
|
|
|
return 122;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|