DarkflameServer/dScripts/ai/FV/FvFacilityBrick.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

98 lines
3.7 KiB
C++
Raw Normal View History

#include "FvFacilityBrick.h"
#include "GameMessages.h"
#include "dZoneManager.h"
#include "EntityManager.h"
void FvFacilityBrick::OnStartup(Entity* self) {
self->SetVar(u"ConsoleLEFTActive", false);
self->SetVar(u"ConsoleRIGHTtActive", false);
}
void FvFacilityBrick::OnNotifyObject(Entity* self, Entity* sender, const std::u16string& name, int32_t param1, int32_t param2) {
auto* brickSpawner = dZoneManager::Instance()->GetSpawnersByName("ImaginationBrick")[0];
auto* bugSpawner = dZoneManager::Instance()->GetSpawnersByName("MaelstromBug")[0];
auto* canisterSpawner = dZoneManager::Instance()->GetSpawnersByName("BrickCanister")[0];
2022-07-28 13:39:57 +00:00
if (name == u"ConsoleLeftUp") {
GameMessages::SendStopFXEffect(self, true, "LeftPipeOff");
GameMessages::SendPlayFXEffect(self->GetObjectID(), 2775, u"create", "LeftPipeEnergy");
} else if (name == u"ConsoleLeftDown") {
self->SetVar(u"ConsoleLEFTActive", false);
2022-07-28 13:39:57 +00:00
GameMessages::SendStopFXEffect(self, true, "LeftPipeEnergy");
GameMessages::SendStopFXEffect(self, true, "LeftPipeOn");
GameMessages::SendPlayFXEffect(self->GetObjectID(), 2774, u"create", "LeftPipeOff");
} else if (name == u"ConsoleLeftActive") {
self->SetVar(u"ConsoleLEFTActive", true);
2022-07-28 13:39:57 +00:00
GameMessages::SendStopFXEffect(self, true, "LeftPipeEnergy");
GameMessages::SendPlayFXEffect(self->GetObjectID(), 2776, u"create", "LeftPipeOn");
}
2022-07-28 13:39:57 +00:00
else if (name == u"ConsoleRightUp") {
GameMessages::SendStopFXEffect(self, true, "RightPipeOff");
GameMessages::SendPlayFXEffect(self->GetObjectID(), 2778, u"create", "RightPipeEnergy");
} else if (name == u"ConsoleRightDown") {
self->SetVar(u"ConsoleRIGHTActive", false);
2022-07-28 13:39:57 +00:00
GameMessages::SendStopFXEffect(self, true, "RightPipeEnergy");
GameMessages::SendStopFXEffect(self, true, "RightPipeOn");
GameMessages::SendPlayFXEffect(self->GetObjectID(), 2777, u"create", "RightPipeOff");
} else if (name == u"ConsoleRightActive") {
self->SetVar(u"ConsoleRIGHTActive", true);
2022-07-28 13:39:57 +00:00
GameMessages::SendStopFXEffect(self, true, "RightPipeOff");
GameMessages::SendPlayFXEffect(self->GetObjectID(), 2779, u"create", "RightPipeEnergy");
}
2022-07-28 13:39:57 +00:00
if (self->GetVar<bool>(u"ConsoleLEFTActive") && self->GetVar<bool>(u"ConsoleRIGHTActive")) {
auto* object = EntityManager::Instance()->GetEntitiesInGroup("Brick")[0];
2022-07-28 13:39:57 +00:00
if (object != nullptr) {
GameMessages::SendPlayFXEffect(object->GetObjectID(), 122, u"create", "bluebrick");
GameMessages::SendPlayFXEffect(object->GetObjectID(), 1034, u"cast", "imaginationexplosion");
}
2022-07-28 13:39:57 +00:00
object = EntityManager::Instance()->GetEntitiesInGroup("Canister")[0];
2022-07-28 13:39:57 +00:00
if (object != nullptr) {
object->Smash(self->GetObjectID(), eKillType::SILENT);
}
2022-07-28 13:39:57 +00:00
canisterSpawner->Reset();
canisterSpawner->Deactivate();
} else if (self->GetVar<bool>(u"ConsoleLEFTActive") || self->GetVar<bool>(u"ConsoleRIGHTActive")) {
brickSpawner->Activate();
2022-07-28 13:39:57 +00:00
auto* object = EntityManager::Instance()->GetEntitiesInGroup("Brick")[0];
2022-07-28 13:39:57 +00:00
if (object != nullptr) {
GameMessages::SendStopFXEffect(object, true, "bluebrick");
}
2022-07-28 13:39:57 +00:00
bugSpawner->Reset();
bugSpawner->Deactivate();
2022-07-28 13:39:57 +00:00
canisterSpawner->Reset();
canisterSpawner->Activate();
} else {
brickSpawner->Reset();
brickSpawner->Deactivate();
2022-07-28 13:39:57 +00:00
bugSpawner->Reset();
bugSpawner->Activate();
}
}
void FvFacilityBrick::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2,
int32_t param3) {
if (args != "PlayFX") {
return;
}
2022-07-28 13:39:57 +00:00
GameMessages::SendPlayFXEffect(self->GetObjectID(), 2774, u"create", "LeftPipeOff");
GameMessages::SendPlayFXEffect(self->GetObjectID(), 2777, u"create", "RightPipeOff");
GameMessages::SendPlayFXEffect(self->GetObjectID(), 2750, u"create", "imagination_canister");
GameMessages::SendPlayFXEffect(self->GetObjectID(), 2751, u"create", "canister_light_filler");
}