DarkflameServer/dScripts/ai/PROPERTY/AgPropguards.cpp

58 lines
1.6 KiB
C++
Raw Normal View History

#include "AgPropguards.h"
#include "Character.h"
#include "GameMessages.h"
#include "EntityManager.h"
#include "dZoneManager.h"
#include "eMissionState.h"
void AgPropguards::OnMissionDialogueOK(Entity* self, Entity* target, int missionID, eMissionState missionState) {
2022-07-28 13:39:57 +00:00
auto* character = target->GetCharacter();
if (character == nullptr)
return;
2022-07-28 13:39:57 +00:00
const auto flag = GetFlagForMission(missionID);
if (flag == 0)
return;
if ((missionState == eMissionState::AVAILABLE || missionState == eMissionState::ACTIVE)
2022-07-28 13:39:57 +00:00
&& !character->GetPlayerFlag(flag)) {
// If the player just started the mission, play a cinematic highlighting the target
GameMessages::SendPlayCinematic(target->GetObjectID(), u"MissionCam", target->GetSystemAddress());
} else if (missionState == eMissionState::COMPLETE_READY_TO_COMPLETE) {
2022-07-28 13:39:57 +00:00
// Makes the guard disappear once the mission has been completed
const auto zoneControlID = EntityManager::Instance()->GetZoneControlEntity()->GetObjectID();
GameMessages::SendNotifyClientObject(zoneControlID, u"GuardChat", 0, 0, self->GetObjectID(),
"", UNASSIGNED_SYSTEM_ADDRESS);
2022-07-28 13:39:57 +00:00
self->AddCallbackTimer(5.0f, [self]() {
auto spawnerName = self->GetVar<std::string>(u"spawner_name");
if (spawnerName.empty())
spawnerName = "Guard";
2022-07-28 13:39:57 +00:00
auto spawners = dZoneManager::Instance()->GetSpawnersByName(spawnerName);
for (auto* spawner : spawners) {
spawner->Deactivate();
}
2022-07-28 13:39:57 +00:00
self->Smash();
});
}
}
int32_t AgPropguards::GetFlagForMission(uint32_t missionID) {
2022-07-28 13:39:57 +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;
}
}