DarkflameServer/dScripts/ai/NS/WH/RockHydrantBroken.cpp

39 lines
1.3 KiB
C++
Raw Permalink Normal View History

2022-04-17 04:32:15 +00:00
#include "RockHydrantBroken.h"
#include "EntityManager.h"
#include "GameMessages.h"
2022-07-28 13:39:57 +00:00
void RockHydrantBroken::OnStartup(Entity* self) {
2022-04-17 20:58:26 +00:00
self->AddTimer("playEffect", 1);
2022-04-17 04:32:15 +00:00
2022-04-18 00:43:17 +00:00
const auto hydrant = "hydrant" + self->GetVar<std::string>(u"hydrant");
2022-04-17 04:32:15 +00:00
2022-04-17 20:58:26 +00:00
const auto bouncers = EntityManager::Instance()->GetEntitiesInGroup(hydrant);
2022-04-17 04:32:15 +00:00
2022-07-28 13:39:57 +00:00
for (auto* bouncer : bouncers) {
2022-04-17 20:58:26 +00:00
self->SetVar<LWOOBJID>(u"bouncer", bouncer->GetObjectID());
2022-04-17 22:43:25 +00:00
2022-04-17 04:32:15 +00:00
2022-04-17 20:58:26 +00:00
GameMessages::SendBouncerActiveStatus(bouncer->GetObjectID(), true, UNASSIGNED_SYSTEM_ADDRESS);
2022-04-17 04:32:15 +00:00
2022-04-17 20:58:26 +00:00
GameMessages::SendNotifyObject(bouncer->GetObjectID(), self->GetObjectID(), u"enableCollision", UNASSIGNED_SYSTEM_ADDRESS);
}
2022-04-17 04:32:15 +00:00
2022-04-17 20:58:26 +00:00
self->AddTimer("KillBroken", 10);
2022-04-17 04:32:15 +00:00
}
2022-07-28 13:39:57 +00:00
void RockHydrantBroken::OnTimerDone(Entity* self, std::string timerName) {
if (timerName == "KillBroken") {
2022-04-17 20:58:26 +00:00
auto* bouncer = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(u"bouncer"));
2022-07-28 13:39:57 +00:00
if (bouncer != nullptr) {
2022-04-17 20:58:26 +00:00
GameMessages::SendBouncerActiveStatus(bouncer->GetObjectID(), false, UNASSIGNED_SYSTEM_ADDRESS);
GameMessages::SendNotifyObject(bouncer->GetObjectID(), self->GetObjectID(), u"disableCollision", UNASSIGNED_SYSTEM_ADDRESS);
}
self->Kill();
2022-07-28 13:39:57 +00:00
} else if (timerName == "playEffect") {
2022-04-17 22:41:10 +00:00
GameMessages::SendPlayFXEffect(self->GetObjectID(), 4737, u"water", "water", LWOOBJID_EMPTY, 1, 1, true);
2022-04-17 20:58:26 +00:00
}
2022-04-17 04:32:15 +00:00
}