From b4acf329b492d44db939763cbece4a31ab93ceb5 Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Sat, 16 Apr 2022 23:32:15 -0500 Subject: [PATCH 01/21] implement some missing scripts --- dScripts/CppScripts.cpp | 10 +++++ dScripts/RockHydrantBroken.cpp | 46 ++++++++++++++++++++++ dScripts/RockHydrantBroken.h | 10 +++++ dScripts/WhFans.cpp | 72 ++++++++++++++++++++++++++++++++++ dScripts/WhFans.h | 17 ++++++++ 5 files changed, 155 insertions(+) create mode 100644 dScripts/RockHydrantBroken.cpp create mode 100644 dScripts/RockHydrantBroken.h create mode 100644 dScripts/WhFans.cpp create mode 100644 dScripts/WhFans.h diff --git a/dScripts/CppScripts.cpp b/dScripts/CppScripts.cpp index b9fa50ef..95269dab 100644 --- a/dScripts/CppScripts.cpp +++ b/dScripts/CppScripts.cpp @@ -274,6 +274,10 @@ #include "AgSurvivalMech.h" #include "AgSurvivalSpiderling.h" +// Frostburgh Scripts +#include "RockHydrantBroken.h" +#include "WhFans.h" + //Big bad global bc this is a namespace and not a class: InvalidScript* invalidToReturn = new InvalidScript(); std::map m_Scripts; @@ -795,6 +799,12 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr else if (scriptName == "scripts\\EquipmentScripts\\BuccaneerValiantShip.lua") script = new BuccaneerValiantShip(); + // FB + else if (scriptName = "scripts\\ai\\NS\\WH\\L_ROCKHYDRANT_BROKEN.lua") + script = new RockHydrantBroken(); + else if (scriptName = "L_NS_WH_FANS.lua") + script = new WhFans(); + //Ignore these scripts: else if (scriptName == "scripts\\02_server\\Enemy\\General\\L_SUSPEND_LUA_AI.lua") script = invalidToReturn; diff --git a/dScripts/RockHydrantBroken.cpp b/dScripts/RockHydrantBroken.cpp new file mode 100644 index 00000000..2c145b36 --- /dev/null +++ b/dScripts/RockHydrantBroken.cpp @@ -0,0 +1,46 @@ +#include "RockHydrantBroken.h" +#include "EntityManager.h" +#include "GameMessages.h" + +void RockHydrantBroken::OnStartup(Entity* self) +{ + self->AddTimer("playEffect", 1); + + const auto hydrant = "hydrant" + self->GetVar(u"hydrant"); + + const auto bouncers = EntityManager::Instance()->GetEntitiesInGroup(hydrant); + + Game::logger->Log("RockHydrantBroken", "Broken Hydrant spawned (%s)\n", hydrant.c_str()); + + for (auto* bouncer : bouncers) + { + self->SetVar(u"bouncer", bouncer->GetObjectID()); + + GameMessages::SendBouncerActiveStatus(bouncer->GetObjectID(), true, UNASSIGNED_SYSTEM_ADDRESS); + + GameMessages::SendNotifyObject(bouncer->GetObjectID(), self->GetObjectID(), u"enableCollision", UNASSIGNED_SYSTEM_ADDRESS); + } + + self->AddTimer("KillBroken", 25); +} + +void RockHydrantBroken::OnTimerDone(Entity* self, std::string timerName) +{ + if (timerName == "KillBroken") + { + auto* bouncer = EntityManager::Instance()->GetEntity(self->GetVar(u"bouncer")); + + if (bouncer != nullptr) + { + GameMessages::SendBouncerActiveStatus(bouncer->GetObjectID(), false, UNASSIGNED_SYSTEM_ADDRESS); + + GameMessages::SendNotifyObject(bouncer->GetObjectID(), self->GetObjectID(), u"disableCollision", UNASSIGNED_SYSTEM_ADDRESS); + } + + self->Kill(); + } + else if (timerName == "playEffect") + { + GameMessages::SendPlayFXEffect(self->GetObjectID(), 384, u"water", "water", LWOOBJID_EMPTY, 1, 1, true); + } +} diff --git a/dScripts/RockHydrantBroken.h b/dScripts/RockHydrantBroken.h new file mode 100644 index 00000000..3bea8341 --- /dev/null +++ b/dScripts/RockHydrantBroken.h @@ -0,0 +1,10 @@ +#pragma once +#include "CppScripts.h" + +class RockHydrantBroken : public CppScripts::Script +{ +public: + void OnStartup(Entity* self) override; + void OnTimerDone(Entity* self, std::string timerName) override; +}; + diff --git a/dScripts/WhFans.cpp b/dScripts/WhFans.cpp new file mode 100644 index 00000000..eee0cd30 --- /dev/null +++ b/dScripts/WhFans.cpp @@ -0,0 +1,72 @@ +#include "AgFans.h" + +#include "RenderComponent.h" + +void AgFans::OnStartup(Entity* self) { + self->SetVar(u"alive", true); + self->SetVar(u"on", false); + + ToggleFX(self, false); + + auto* renderComponent = static_cast(self->GetComponent(COMPONENT_TYPE_RENDER)); + + if (renderComponent == nullptr) { + return; + } + + renderComponent->PlayEffect(495, u"fanOn", "fanOn"); +} + +void AgFans::ToggleFX(Entity* self, bool hit) { + std::string fanGroup = self->GetGroups()[0]; + std::vector fanVolumes = EntityManager::Instance()->GetEntitiesInGroup(fanGroup); + + auto* renderComponent = static_cast(self->GetComponent(COMPONENT_TYPE_RENDER)); + + if (renderComponent == nullptr) { + return; + } + + if (fanVolumes.size() == 0 || !self->GetVar(u"alive")) return; + + if (self->GetVar(u"on")) { + GameMessages::SendPlayAnimation(self, u"fan-off"); + + renderComponent->StopEffect("fanOn"); + self->SetVar(u"on", false); + + for (Entity* volume : fanVolumes) { + PhantomPhysicsComponent* volumePhys = static_cast(volume->GetComponent(COMPONENT_TYPE_PHANTOM_PHYSICS)); + if (!volumePhys) continue; + volumePhys->SetPhysicsEffectActive(false); + EntityManager::Instance()->SerializeEntity(volume); + } + } + else if (!self->GetVar(u"on") && self->GetVar(u"alive")) { + GameMessages::SendPlayAnimation(self, u"fan-on"); + + self->SetVar(u"on", true); + + for (Entity* volume : fanVolumes) { + PhantomPhysicsComponent* volumePhys = static_cast(volume->GetComponent(COMPONENT_TYPE_PHANTOM_PHYSICS)); + if (!volumePhys) continue; + volumePhys->SetPhysicsEffectActive(true); + EntityManager::Instance()->SerializeEntity(volume); + } + } +} + +void AgFans::OnFireEventServerSide(Entity *self, Entity *sender, std::string args, int32_t param1, int32_t param2, + int32_t param3) { + if (args.length() == 0 || !self->GetVar(u"alive")) return; + + if ((args == "turnOn" && self->GetVar(u"on")) || (args == "turnOff" && !self->GetVar(u"on"))) return; + ToggleFX(self, false); +} + +void AgFans::OnDie(Entity* self, Entity* killer) { + if (self->GetVar(u"on")) { + ToggleFX(self, true); + } + self->SetVar(u"alive", false); +} \ No newline at end of file diff --git a/dScripts/WhFans.h b/dScripts/WhFans.h new file mode 100644 index 00000000..9b87430b --- /dev/null +++ b/dScripts/WhFans.h @@ -0,0 +1,17 @@ +#pragma once +#include "CppScripts.h" +#include "GameMessages.h" +#include "EntityManager.h" +#include "PhantomPhysicsComponent.h" + +class WhFans : public CppScripts::Script +{ +public: + void OnStartup(Entity* self); + void OnDie(Entity* self, Entity* killer); + void OnFireEventServerSide(Entity *self, Entity *sender, std::string args, int32_t param1, int32_t param2, + int32_t param3); +private: + void ToggleFX(Entity* self, bool hit); +}; + From 0e5a1c97219c224d90e53b54c5ea5ad65faf8fb5 Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Sat, 16 Apr 2022 23:33:44 -0500 Subject: [PATCH 02/21] fix comparator --- dScripts/CppScripts.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dScripts/CppScripts.cpp b/dScripts/CppScripts.cpp index 95269dab..c81b01f4 100644 --- a/dScripts/CppScripts.cpp +++ b/dScripts/CppScripts.cpp @@ -1,4 +1,4 @@ -//I can feel my soul being torn apart with every script added to this monstrosity. +//I can feel my soul being torn apart with every script added to this monstrosity. // skate fast eat trash // do you think god stays in heaven because he too lives in fear of what he's created? @@ -800,9 +800,9 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr script = new BuccaneerValiantShip(); // FB - else if (scriptName = "scripts\\ai\\NS\\WH\\L_ROCKHYDRANT_BROKEN.lua") + else if (scriptName == "scripts\\ai\\NS\\WH\\L_ROCKHYDRANT_BROKEN.lua") script = new RockHydrantBroken(); - else if (scriptName = "L_NS_WH_FANS.lua") + else if (scriptName == "L_NS_WH_FANS.lua") script = new WhFans(); //Ignore these scripts: From b3695c42b2d5697ae8c3c1d9aecc686d18bd39fd Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Sat, 16 Apr 2022 23:35:22 -0500 Subject: [PATCH 03/21] fix copy past error --- dScripts/WhFans.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dScripts/WhFans.cpp b/dScripts/WhFans.cpp index eee0cd30..da9af43f 100644 --- a/dScripts/WhFans.cpp +++ b/dScripts/WhFans.cpp @@ -1,8 +1,8 @@ -#include "AgFans.h" +#include "WhFans.h" #include "RenderComponent.h" -void AgFans::OnStartup(Entity* self) { +void WhFans::OnStartup(Entity* self) { self->SetVar(u"alive", true); self->SetVar(u"on", false); @@ -17,7 +17,7 @@ void AgFans::OnStartup(Entity* self) { renderComponent->PlayEffect(495, u"fanOn", "fanOn"); } -void AgFans::ToggleFX(Entity* self, bool hit) { +void WhFans::ToggleFX(Entity* self, bool hit) { std::string fanGroup = self->GetGroups()[0]; std::vector fanVolumes = EntityManager::Instance()->GetEntitiesInGroup(fanGroup); @@ -56,7 +56,7 @@ void AgFans::ToggleFX(Entity* self, bool hit) { } } -void AgFans::OnFireEventServerSide(Entity *self, Entity *sender, std::string args, int32_t param1, int32_t param2, +void WhFans::OnFireEventServerSide(Entity *self, Entity *sender, std::string args, int32_t param1, int32_t param2, int32_t param3) { if (args.length() == 0 || !self->GetVar(u"alive")) return; @@ -64,7 +64,7 @@ void AgFans::OnFireEventServerSide(Entity *self, Entity *sender, std::string arg ToggleFX(self, false); } -void AgFans::OnDie(Entity* self, Entity* killer) { +void WhFans::OnDie(Entity* self, Entity* killer) { if (self->GetVar(u"on")) { ToggleFX(self, true); } From 5b0f9174857dc16dd091924f80ae8db43b851a92 Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Sun, 17 Apr 2022 00:05:04 -0500 Subject: [PATCH 04/21] update script path for fans --- dScripts/CppScripts.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dScripts/CppScripts.cpp b/dScripts/CppScripts.cpp index c81b01f4..8be1c0d4 100644 --- a/dScripts/CppScripts.cpp +++ b/dScripts/CppScripts.cpp @@ -802,7 +802,7 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr // FB else if (scriptName == "scripts\\ai\\NS\\WH\\L_ROCKHYDRANT_BROKEN.lua") script = new RockHydrantBroken(); - else if (scriptName == "L_NS_WH_FANS.lua") + else if (scriptName == "scripts\\ai\\NS\\L_NS_WH_FANS.lua") script = new WhFans(); //Ignore these scripts: From 23677b4bd37fd88e86bb4a92f12e018b336c27ff Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Sun, 17 Apr 2022 12:38:12 -0500 Subject: [PATCH 05/21] Simplify some stuff Remove render component in startup --- dScripts/WhFans.cpp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/dScripts/WhFans.cpp b/dScripts/WhFans.cpp index da9af43f..b11da6e5 100644 --- a/dScripts/WhFans.cpp +++ b/dScripts/WhFans.cpp @@ -7,22 +7,13 @@ void WhFans::OnStartup(Entity* self) { self->SetVar(u"on", false); ToggleFX(self, false); - - auto* renderComponent = static_cast(self->GetComponent(COMPONENT_TYPE_RENDER)); - - if (renderComponent == nullptr) { - return; - } - - renderComponent->PlayEffect(495, u"fanOn", "fanOn"); } void WhFans::ToggleFX(Entity* self, bool hit) { std::string fanGroup = self->GetGroups()[0]; std::vector fanVolumes = EntityManager::Instance()->GetEntitiesInGroup(fanGroup); - auto* renderComponent = static_cast(self->GetComponent(COMPONENT_TYPE_RENDER)); - + auto renderComponent = self->GetComponent(); if (renderComponent == nullptr) { return; } @@ -36,7 +27,7 @@ void WhFans::ToggleFX(Entity* self, bool hit) { self->SetVar(u"on", false); for (Entity* volume : fanVolumes) { - PhantomPhysicsComponent* volumePhys = static_cast(volume->GetComponent(COMPONENT_TYPE_PHANTOM_PHYSICS)); + auto phantomPhysicsComponent = volume->GetComponent(); if (!volumePhys) continue; volumePhys->SetPhysicsEffectActive(false); EntityManager::Instance()->SerializeEntity(volume); @@ -48,7 +39,7 @@ void WhFans::ToggleFX(Entity* self, bool hit) { self->SetVar(u"on", true); for (Entity* volume : fanVolumes) { - PhantomPhysicsComponent* volumePhys = static_cast(volume->GetComponent(COMPONENT_TYPE_PHANTOM_PHYSICS)); + auto phantomPhysicsComponent = volume->GetComponent(); if (!volumePhys) continue; volumePhys->SetPhysicsEffectActive(true); EntityManager::Instance()->SerializeEntity(volume); From 67615d568872c63900c6ed78ab244f5598e08f07 Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Sun, 17 Apr 2022 12:46:41 -0500 Subject: [PATCH 06/21] fix volumen physics name --- dScripts/WhFans.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dScripts/WhFans.cpp b/dScripts/WhFans.cpp index b11da6e5..39bbab3b 100644 --- a/dScripts/WhFans.cpp +++ b/dScripts/WhFans.cpp @@ -27,7 +27,7 @@ void WhFans::ToggleFX(Entity* self, bool hit) { self->SetVar(u"on", false); for (Entity* volume : fanVolumes) { - auto phantomPhysicsComponent = volume->GetComponent(); + auto volumePhys = volume->GetComponent(); if (!volumePhys) continue; volumePhys->SetPhysicsEffectActive(false); EntityManager::Instance()->SerializeEntity(volume); @@ -39,7 +39,7 @@ void WhFans::ToggleFX(Entity* self, bool hit) { self->SetVar(u"on", true); for (Entity* volume : fanVolumes) { - auto phantomPhysicsComponent = volume->GetComponent(); + auto volumePhys = volume->GetComponent(); if (!volumePhys) continue; volumePhys->SetPhysicsEffectActive(true); EntityManager::Instance()->SerializeEntity(volume); From 1e85ae203563ebf6f5fc366aaa6a8d6b4afae8b5 Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Sun, 17 Apr 2022 15:58:26 -0500 Subject: [PATCH 07/21] tabs and log --- dScripts/RockHydrantBroken.cpp | 51 +++++++++++++++++----------------- dScripts/WhFans.cpp | 2 ++ 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/dScripts/RockHydrantBroken.cpp b/dScripts/RockHydrantBroken.cpp index 2c145b36..b3d7f717 100644 --- a/dScripts/RockHydrantBroken.cpp +++ b/dScripts/RockHydrantBroken.cpp @@ -4,43 +4,44 @@ void RockHydrantBroken::OnStartup(Entity* self) { - self->AddTimer("playEffect", 1); + self->AddTimer("playEffect", 1); - const auto hydrant = "hydrant" + self->GetVar(u"hydrant"); + const auto hydrant = "hydrant" + self->GetVar(u"hydrant"); - const auto bouncers = EntityManager::Instance()->GetEntitiesInGroup(hydrant); + const auto bouncers = EntityManager::Instance()->GetEntitiesInGroup(hydrant); - Game::logger->Log("RockHydrantBroken", "Broken Hydrant spawned (%s)\n", hydrant.c_str()); + Game::logger->Log("RockHydrantBroken", "Broken Rock Hydrant spawned (%s)\n", hydrant.c_str()); - for (auto* bouncer : bouncers) - { - self->SetVar(u"bouncer", bouncer->GetObjectID()); + for (auto* bouncer : bouncers) + { + self->SetVar(u"bouncer", bouncer->GetObjectID()); + Game::logger->Log("RockHydrantBroken", "Activate Bouncer (%s)\n", bouncer.c_str()); - GameMessages::SendBouncerActiveStatus(bouncer->GetObjectID(), true, UNASSIGNED_SYSTEM_ADDRESS); + GameMessages::SendBouncerActiveStatus(bouncer->GetObjectID(), true, UNASSIGNED_SYSTEM_ADDRESS); - GameMessages::SendNotifyObject(bouncer->GetObjectID(), self->GetObjectID(), u"enableCollision", UNASSIGNED_SYSTEM_ADDRESS); - } + GameMessages::SendNotifyObject(bouncer->GetObjectID(), self->GetObjectID(), u"enableCollision", UNASSIGNED_SYSTEM_ADDRESS); + } - self->AddTimer("KillBroken", 25); + self->AddTimer("KillBroken", 10); } void RockHydrantBroken::OnTimerDone(Entity* self, std::string timerName) { - if (timerName == "KillBroken") - { - auto* bouncer = EntityManager::Instance()->GetEntity(self->GetVar(u"bouncer")); + if (timerName == "KillBroken") + { + auto* bouncer = EntityManager::Instance()->GetEntity(self->GetVar(u"bouncer")); - if (bouncer != nullptr) - { - GameMessages::SendBouncerActiveStatus(bouncer->GetObjectID(), false, UNASSIGNED_SYSTEM_ADDRESS); + if (bouncer != nullptr) + { + GameMessages::SendBouncerActiveStatus(bouncer->GetObjectID(), false, UNASSIGNED_SYSTEM_ADDRESS); - GameMessages::SendNotifyObject(bouncer->GetObjectID(), self->GetObjectID(), u"disableCollision", UNASSIGNED_SYSTEM_ADDRESS); - } + GameMessages::SendNotifyObject(bouncer->GetObjectID(), self->GetObjectID(), u"disableCollision", UNASSIGNED_SYSTEM_ADDRESS); + } - self->Kill(); - } - else if (timerName == "playEffect") - { - GameMessages::SendPlayFXEffect(self->GetObjectID(), 384, u"water", "water", LWOOBJID_EMPTY, 1, 1, true); - } + self->Kill(); + } + else if (timerName == "playEffect") + { + GameMessages::SendPlayFXEffect(self->GetObjectID(), 384, u"water", "water", LWOOBJID_EMPTY, 1, 1, true); + } } diff --git a/dScripts/WhFans.cpp b/dScripts/WhFans.cpp index 39bbab3b..dffedc14 100644 --- a/dScripts/WhFans.cpp +++ b/dScripts/WhFans.cpp @@ -11,6 +11,8 @@ void WhFans::OnStartup(Entity* self) { void WhFans::ToggleFX(Entity* self, bool hit) { std::string fanGroup = self->GetGroups()[0]; + + Game::logger->Log("WhFans", "Toggling FX for Fan Group(%s)\n", fanGroup.c_str()); std::vector fanVolumes = EntityManager::Instance()->GetEntitiesInGroup(fanGroup); auto renderComponent = self->GetComponent(); From a8fcb4c15375c2d3e86b7430cd72106e125b8311 Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Sun, 17 Apr 2022 16:44:46 -0500 Subject: [PATCH 08/21] make the hydrant match the lua script --- dScripts/RockHydrantBroken.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dScripts/RockHydrantBroken.cpp b/dScripts/RockHydrantBroken.cpp index b3d7f717..8bae7f79 100644 --- a/dScripts/RockHydrantBroken.cpp +++ b/dScripts/RockHydrantBroken.cpp @@ -6,7 +6,7 @@ void RockHydrantBroken::OnStartup(Entity* self) { self->AddTimer("playEffect", 1); - const auto hydrant = "hydrant" + self->GetVar(u"hydrant"); + const auto hydrant = "hydrant0" + self->GetVar(u"hydrant"); const auto bouncers = EntityManager::Instance()->GetEntitiesInGroup(hydrant); From e696d26941e6240b718292aea351dc4c7153f807 Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Sun, 17 Apr 2022 17:41:10 -0500 Subject: [PATCH 09/21] update the Effect ID --- dScripts/RockHydrantBroken.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dScripts/RockHydrantBroken.cpp b/dScripts/RockHydrantBroken.cpp index 8bae7f79..681335f2 100644 --- a/dScripts/RockHydrantBroken.cpp +++ b/dScripts/RockHydrantBroken.cpp @@ -42,6 +42,6 @@ void RockHydrantBroken::OnTimerDone(Entity* self, std::string timerName) } else if (timerName == "playEffect") { - GameMessages::SendPlayFXEffect(self->GetObjectID(), 384, u"water", "water", LWOOBJID_EMPTY, 1, 1, true); + GameMessages::SendPlayFXEffect(self->GetObjectID(), 4737, u"water", "water", LWOOBJID_EMPTY, 1, 1, true); } } From cc68b0768b4538b6723def491687c19f624ea985 Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Sun, 17 Apr 2022 17:43:25 -0500 Subject: [PATCH 10/21] remove log --- dScripts/RockHydrantBroken.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dScripts/RockHydrantBroken.cpp b/dScripts/RockHydrantBroken.cpp index 681335f2..0347466c 100644 --- a/dScripts/RockHydrantBroken.cpp +++ b/dScripts/RockHydrantBroken.cpp @@ -15,7 +15,7 @@ void RockHydrantBroken::OnStartup(Entity* self) for (auto* bouncer : bouncers) { self->SetVar(u"bouncer", bouncer->GetObjectID()); - Game::logger->Log("RockHydrantBroken", "Activate Bouncer (%s)\n", bouncer.c_str()); + GameMessages::SendBouncerActiveStatus(bouncer->GetObjectID(), true, UNASSIGNED_SYSTEM_ADDRESS); From a343ed94933cb30b055d9928471e289005ece085 Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Sun, 17 Apr 2022 19:43:17 -0500 Subject: [PATCH 11/21] rock hydrants work --- dScripts/RockHydrantBroken.cpp | 2 +- dScripts/RockHydrantSmashable.cpp | 33 +++++++++++++++---------------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/dScripts/RockHydrantBroken.cpp b/dScripts/RockHydrantBroken.cpp index 0347466c..7895b00b 100644 --- a/dScripts/RockHydrantBroken.cpp +++ b/dScripts/RockHydrantBroken.cpp @@ -6,7 +6,7 @@ void RockHydrantBroken::OnStartup(Entity* self) { self->AddTimer("playEffect", 1); - const auto hydrant = "hydrant0" + self->GetVar(u"hydrant"); + const auto hydrant = "hydrant" + self->GetVar(u"hydrant"); const auto bouncers = EntityManager::Instance()->GetEntitiesInGroup(hydrant); diff --git a/dScripts/RockHydrantSmashable.cpp b/dScripts/RockHydrantSmashable.cpp index a54f0b9d..04b39c84 100644 --- a/dScripts/RockHydrantSmashable.cpp +++ b/dScripts/RockHydrantSmashable.cpp @@ -1,24 +1,23 @@ #include "RockHydrantSmashable.h" #include "EntityManager.h" -#include "SimplePhysicsComponent.h" -#include "Entity.h" -#include "GameMessages.h" -#include "Game.h" -#include "dLogger.h" +#include "GeneralUtils.h" -void RockHydrantSmashable::OnDie(Entity* self, Entity* killer) { - SimplePhysicsComponent* physics = self->GetComponent(); - NiPoint3 pos = physics->GetPosition(); +void RockHydrantSmashable::OnDie(Entity* self, Entity* killer) +{ + const auto hydrantName = self->GetVar(u"hydrant"); - EntityInfo info; + LDFBaseData* data = new LDFData(u"hydrant", GeneralUtils::UTF16ToWTF8(hydrantName)); + + EntityInfo info {}; info.lot = 12293; - info.pos = pos; - info.spawner = nullptr; + info.pos = self->GetPosition(); + info.rot = self->GetRotation(); + info.settings = {data}; info.spawnerID = self->GetSpawnerID(); - info.spawnerNodeID = 0; - Entity* newEntity = EntityManager::Instance()->CreateEntity(info, nullptr); - if (newEntity) { - EntityManager::Instance()->ConstructEntity(newEntity); - } -} \ No newline at end of file + Game::logger->Log("RockHydrantBroken", "Rock Hydrant spawned (%s)\n", data->GetString().c_str()); + + auto* hydrant = EntityManager::Instance()->CreateEntity(info); + + EntityManager::Instance()->ConstructEntity(hydrant); +} From 235934714fca427bacaa92c0eae393b06c7f6045 Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Sun, 17 Apr 2022 20:16:27 -0500 Subject: [PATCH 12/21] honor the logic in the lua script --- dScripts/WhFans.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dScripts/WhFans.cpp b/dScripts/WhFans.cpp index dffedc14..c6c798d9 100644 --- a/dScripts/WhFans.cpp +++ b/dScripts/WhFans.cpp @@ -10,7 +10,11 @@ void WhFans::OnStartup(Entity* self) { } void WhFans::ToggleFX(Entity* self, bool hit) { - std::string fanGroup = self->GetGroups()[0]; + try { + std::string fanGroup = self->GetGroups()[0]; + } catch(...) { + std::string fanGroup = "" + } Game::logger->Log("WhFans", "Toggling FX for Fan Group(%s)\n", fanGroup.c_str()); std::vector fanVolumes = EntityManager::Instance()->GetEntitiesInGroup(fanGroup); From 0778b4f81ce3e742e069c949040f7c9215584985 Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Sun, 17 Apr 2022 20:17:36 -0500 Subject: [PATCH 13/21] missed semicolon --- dScripts/WhFans.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dScripts/WhFans.cpp b/dScripts/WhFans.cpp index c6c798d9..fe1aa01a 100644 --- a/dScripts/WhFans.cpp +++ b/dScripts/WhFans.cpp @@ -13,7 +13,7 @@ void WhFans::ToggleFX(Entity* self, bool hit) { try { std::string fanGroup = self->GetGroups()[0]; } catch(...) { - std::string fanGroup = "" + std::string fanGroup = ""; } Game::logger->Log("WhFans", "Toggling FX for Fan Group(%s)\n", fanGroup.c_str()); From 6cef7a437aef98758c2cc6c4c840291b1fcdbded Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Sun, 17 Apr 2022 20:24:19 -0500 Subject: [PATCH 14/21] scope --- dScripts/WhFans.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dScripts/WhFans.cpp b/dScripts/WhFans.cpp index fe1aa01a..ccf556be 100644 --- a/dScripts/WhFans.cpp +++ b/dScripts/WhFans.cpp @@ -10,10 +10,11 @@ void WhFans::OnStartup(Entity* self) { } void WhFans::ToggleFX(Entity* self, bool hit) { + std::string fanGroup = "" try { - std::string fanGroup = self->GetGroups()[0]; + fanGroup = self->GetGroups()[0]; } catch(...) { - std::string fanGroup = ""; + fanGroup = ""; } Game::logger->Log("WhFans", "Toggling FX for Fan Group(%s)\n", fanGroup.c_str()); From 263eaf03b07eb52a757a0c632e80e31fce95c59a Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Sun, 17 Apr 2022 20:24:49 -0500 Subject: [PATCH 15/21] ugh, another semicolon --- dScripts/WhFans.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dScripts/WhFans.cpp b/dScripts/WhFans.cpp index ccf556be..0139eb1d 100644 --- a/dScripts/WhFans.cpp +++ b/dScripts/WhFans.cpp @@ -10,7 +10,7 @@ void WhFans::OnStartup(Entity* self) { } void WhFans::ToggleFX(Entity* self, bool hit) { - std::string fanGroup = "" + std::string fanGroup = ""; try { fanGroup = self->GetGroups()[0]; } catch(...) { From 2122448284a1b8f55c582a3814903fb61860a4f1 Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Sun, 17 Apr 2022 21:30:25 -0500 Subject: [PATCH 16/21] cleaning up some stuff --- dScripts/WhFans.cpp | 6 +----- dScripts/WhFans.h | 10 ++++++++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/dScripts/WhFans.cpp b/dScripts/WhFans.cpp index 0139eb1d..f2000d69 100644 --- a/dScripts/WhFans.cpp +++ b/dScripts/WhFans.cpp @@ -17,13 +17,9 @@ void WhFans::ToggleFX(Entity* self, bool hit) { fanGroup = ""; } - Game::logger->Log("WhFans", "Toggling FX for Fan Group(%s)\n", fanGroup.c_str()); std::vector fanVolumes = EntityManager::Instance()->GetEntitiesInGroup(fanGroup); - auto renderComponent = self->GetComponent(); - if (renderComponent == nullptr) { - return; - } + auto* renderComponent = static_cast(self->GetComponent(COMPONENT_TYPE_RENDER)); if (fanVolumes.size() == 0 || !self->GetVar(u"alive")) return; diff --git a/dScripts/WhFans.h b/dScripts/WhFans.h index 9b87430b..cac7236d 100644 --- a/dScripts/WhFans.h +++ b/dScripts/WhFans.h @@ -9,8 +9,14 @@ class WhFans : public CppScripts::Script public: void OnStartup(Entity* self); void OnDie(Entity* self, Entity* killer); - void OnFireEventServerSide(Entity *self, Entity *sender, std::string args, int32_t param1, int32_t param2, - int32_t param3); + void OnFireEventServerSide( + Entity *self, + Entity *sender, + std::string args, + int32_t param1, + int32_t param2, + int32_t param3 + ); private: void ToggleFX(Entity* self, bool hit); }; From d05601ce642330910c6e23c43df9e81af823068f Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Mon, 18 Apr 2022 08:27:37 -0500 Subject: [PATCH 17/21] Fixes --- dScripts/WhFans.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/dScripts/WhFans.cpp b/dScripts/WhFans.cpp index f2000d69..24e6234c 100644 --- a/dScripts/WhFans.cpp +++ b/dScripts/WhFans.cpp @@ -10,16 +10,19 @@ void WhFans::OnStartup(Entity* self) { } void WhFans::ToggleFX(Entity* self, bool hit) { - std::string fanGroup = ""; - try { - fanGroup = self->GetGroups()[0]; - } catch(...) { + std::string fanGroup; + const auto& groups = self->GetGroups(); + if (!groups.empty()) { + fanGroup = groups[0]; + } else { fanGroup = ""; } std::vector fanVolumes = EntityManager::Instance()->GetEntitiesInGroup(fanGroup); - auto* renderComponent = static_cast(self->GetComponent(COMPONENT_TYPE_RENDER)); + auto* renderComponent = self->GetComponent(); + + if (renderComponent == nullptr) return; if (fanVolumes.size() == 0 || !self->GetVar(u"alive")) return; From 8fe5c009845fbc403bc963b84092dc3aef7e115f Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Mon, 18 Apr 2022 08:36:11 -0500 Subject: [PATCH 18/21] remove dereference (I think that's what it is called) --- dScripts/WhFans.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dScripts/WhFans.cpp b/dScripts/WhFans.cpp index 24e6234c..fc8fae0f 100644 --- a/dScripts/WhFans.cpp +++ b/dScripts/WhFans.cpp @@ -20,7 +20,7 @@ void WhFans::ToggleFX(Entity* self, bool hit) { std::vector fanVolumes = EntityManager::Instance()->GetEntitiesInGroup(fanGroup); - auto* renderComponent = self->GetComponent(); + auto* renderComponent = self->GetComponent(); if (renderComponent == nullptr) return; From f3dd71ccb1653d9d1d406ea22bfdd1a8aed7ea57 Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Mon, 18 Apr 2022 21:02:04 -0500 Subject: [PATCH 19/21] cleanup logs, fix overrides, define LOTs in header --- dScripts/HydrantBroken.cpp | 8 +++----- dScripts/HydrantSmashable.cpp | 6 ++---- dScripts/HydrantSmashable.h | 6 ++++-- dScripts/RockHydrantBroken.cpp | 2 -- dScripts/RockHydrantSmashable.cpp | 8 +++----- dScripts/RockHydrantSmashable.h | 2 ++ dScripts/WhFans.cpp | 2 +- dScripts/WhFans.h | 6 +++--- 8 files changed, 18 insertions(+), 22 deletions(-) diff --git a/dScripts/HydrantBroken.cpp b/dScripts/HydrantBroken.cpp index 93424325..2b620a21 100644 --- a/dScripts/HydrantBroken.cpp +++ b/dScripts/HydrantBroken.cpp @@ -2,7 +2,7 @@ #include "EntityManager.h" #include "GameMessages.h" -void HydrantBroken::OnStartup(Entity* self) +void HydrantBroken::OnStartup(Entity* self) { self->AddTimer("playEffect", 1); @@ -10,8 +10,6 @@ void HydrantBroken::OnStartup(Entity* self) const auto bouncers = EntityManager::Instance()->GetEntitiesInGroup(hydrant); - Game::logger->Log("HydrantBroken", "Broken Hydrant spawned (%s)\n", hydrant.c_str()); - for (auto* bouncer : bouncers) { self->SetVar(u"bouncer", bouncer->GetObjectID()); @@ -20,11 +18,11 @@ void HydrantBroken::OnStartup(Entity* self) GameMessages::SendNotifyObject(bouncer->GetObjectID(), self->GetObjectID(), u"enableCollision", UNASSIGNED_SYSTEM_ADDRESS); } - + self->AddTimer("KillBroken", 25); } -void HydrantBroken::OnTimerDone(Entity* self, std::string timerName) +void HydrantBroken::OnTimerDone(Entity* self, std::string timerName) { if (timerName == "KillBroken") { diff --git a/dScripts/HydrantSmashable.cpp b/dScripts/HydrantSmashable.cpp index e39f7a35..5cdf84c9 100644 --- a/dScripts/HydrantSmashable.cpp +++ b/dScripts/HydrantSmashable.cpp @@ -2,20 +2,18 @@ #include "EntityManager.h" #include "GeneralUtils.h" -void HydrantSmashable::OnDie(Entity* self, Entity* killer) +void HydrantSmashable::OnDie(Entity* self, Entity* killer) { const auto hydrantName = self->GetVar(u"hydrant"); LDFBaseData* data = new LDFData(u"hydrant", GeneralUtils::UTF16ToWTF8(hydrantName)); EntityInfo info {}; - info.lot = 7328; + info.lot = HYDRANT_BROKEN; info.pos = self->GetPosition(); info.rot = self->GetRotation(); info.settings = {data}; info.spawnerID = self->GetSpawnerID(); - - Game::logger->Log("HydrantBroken", "Hydrant spawned (%s)\n", data->GetString().c_str()); auto* hydrant = EntityManager::Instance()->CreateEntity(info); diff --git a/dScripts/HydrantSmashable.h b/dScripts/HydrantSmashable.h index c7e23073..90b0f3a6 100644 --- a/dScripts/HydrantSmashable.h +++ b/dScripts/HydrantSmashable.h @@ -1,8 +1,10 @@ #pragma once #include "CppScripts.h" -class HydrantSmashable : public CppScripts::Script +class HydrantSmashable : public CppScripts::Script { public: - void OnDie(Entity* self, Entity* killer) override; + void OnDie(Entity* self, Entity* killer) override; +private: + LOT HYDRANT_BROKEN = 7328; }; \ No newline at end of file diff --git a/dScripts/RockHydrantBroken.cpp b/dScripts/RockHydrantBroken.cpp index 7895b00b..50e3c88d 100644 --- a/dScripts/RockHydrantBroken.cpp +++ b/dScripts/RockHydrantBroken.cpp @@ -10,8 +10,6 @@ void RockHydrantBroken::OnStartup(Entity* self) const auto bouncers = EntityManager::Instance()->GetEntitiesInGroup(hydrant); - Game::logger->Log("RockHydrantBroken", "Broken Rock Hydrant spawned (%s)\n", hydrant.c_str()); - for (auto* bouncer : bouncers) { self->SetVar(u"bouncer", bouncer->GetObjectID()); diff --git a/dScripts/RockHydrantSmashable.cpp b/dScripts/RockHydrantSmashable.cpp index 04b39c84..8d5b5861 100644 --- a/dScripts/RockHydrantSmashable.cpp +++ b/dScripts/RockHydrantSmashable.cpp @@ -9,15 +9,13 @@ void RockHydrantSmashable::OnDie(Entity* self, Entity* killer) LDFBaseData* data = new LDFData(u"hydrant", GeneralUtils::UTF16ToWTF8(hydrantName)); EntityInfo info {}; - info.lot = 12293; + info.lot = ROCK_HYDRANT_BROKEN; info.pos = self->GetPosition(); info.rot = self->GetRotation(); info.settings = {data}; info.spawnerID = self->GetSpawnerID(); - Game::logger->Log("RockHydrantBroken", "Rock Hydrant spawned (%s)\n", data->GetString().c_str()); + auto* hydrant = EntityManager::Instance()->CreateEntity(info); - auto* hydrant = EntityManager::Instance()->CreateEntity(info); - - EntityManager::Instance()->ConstructEntity(hydrant); + EntityManager::Instance()->ConstructEntity(hydrant); } diff --git a/dScripts/RockHydrantSmashable.h b/dScripts/RockHydrantSmashable.h index 12c21fb0..0578cb2e 100644 --- a/dScripts/RockHydrantSmashable.h +++ b/dScripts/RockHydrantSmashable.h @@ -5,5 +5,7 @@ class RockHydrantSmashable : public CppScripts::Script { public: void OnDie(Entity* self, Entity* killer); +private: + LOT ROCK_HYDRANT_BROKEN = 12293; }; diff --git a/dScripts/WhFans.cpp b/dScripts/WhFans.cpp index fc8fae0f..3a594a4c 100644 --- a/dScripts/WhFans.cpp +++ b/dScripts/WhFans.cpp @@ -66,4 +66,4 @@ void WhFans::OnDie(Entity* self, Entity* killer) { ToggleFX(self, true); } self->SetVar(u"alive", false); -} \ No newline at end of file +} diff --git a/dScripts/WhFans.h b/dScripts/WhFans.h index cac7236d..91aaa9d8 100644 --- a/dScripts/WhFans.h +++ b/dScripts/WhFans.h @@ -7,8 +7,8 @@ class WhFans : public CppScripts::Script { public: - void OnStartup(Entity* self); - void OnDie(Entity* self, Entity* killer); + void OnStartup(Entity* self) override; + void OnDie(Entity* self, Entity* killer) override; void OnFireEventServerSide( Entity *self, Entity *sender, @@ -16,7 +16,7 @@ public: int32_t param1, int32_t param2, int32_t param3 - ); + ) override; private: void ToggleFX(Entity* self, bool hit); }; From 8db7dfef755b61a63b6b9315a2677897a69a7692 Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Mon, 18 Apr 2022 21:09:27 -0500 Subject: [PATCH 20/21] also apply overrides to AG fans --- dScripts/AgFans.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/dScripts/AgFans.h b/dScripts/AgFans.h index 0efe9c6d..09cc89d9 100644 --- a/dScripts/AgFans.h +++ b/dScripts/AgFans.h @@ -7,10 +7,16 @@ class AgFans : public CppScripts::Script { public: - void OnStartup(Entity* self); - void OnDie(Entity* self, Entity* killer); - void OnFireEventServerSide(Entity *self, Entity *sender, std::string args, int32_t param1, int32_t param2, - int32_t param3); + void OnStartup(Entity* self) override; + void OnDie(Entity* self, Entity* killer) override; + void OnFireEventServerSide( + Entity *self, + Entity *sender, + std::string args, + int32_t param1, + int32_t param2, + int32_t param3 + ) override; private: void ToggleFX(Entity* self, bool hit); }; From 6933b2c301985de163379abe3f1157bdda54f7a4 Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Mon, 18 Apr 2022 23:33:09 -0500 Subject: [PATCH 21/21] case for putting you back into FB when leavign space blizzard --- dGame/dComponents/RacingControlComponent.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dGame/dComponents/RacingControlComponent.cpp b/dGame/dComponents/RacingControlComponent.cpp index 27df339d..8647cfb7 100644 --- a/dGame/dComponents/RacingControlComponent.cpp +++ b/dGame/dComponents/RacingControlComponent.cpp @@ -53,6 +53,11 @@ RacingControlComponent::RacingControlComponent(Entity *parent) m_MainWorld = 1200; break; + case 1261: + m_ActivityID = 60; + m_MainWorld = 1260; + break; + case 1303: m_ActivityID = 39; m_MainWorld = 1300; @@ -413,7 +418,7 @@ void RacingControlComponent::HandleMessageBoxResponse(Entity *player, missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_RACING, data->finished, (LWOOBJID)RacingTaskParam::RACING_TASK_PARAM_FIRST_PLACE_MULTIPLE_TRACKS); // Finish in 1st place on multiple tracks. if(m_Finished != 1) return; missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_RACING, dZoneManager::Instance()->GetZone()->GetWorldID(), (LWOOBJID)RacingTaskParam::RACING_TASK_PARAM_WIN_RACE_IN_WORLD); // Finished first place in specific world. - + } } else if (id == "ACT_RACE_EXIT_THE_RACE?" || id == "Exit") { auto *vehicle = EntityManager::Instance()->GetEntity(data->vehicleID);