From 67ec10ac0d9003d2dd9797ab913c84d9c96bd772 Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Fri, 2 Sep 2022 21:52:57 -0500 Subject: [PATCH] Add LupGenericInteraction and Robot Citizen script --- dScripts/CMakeLists.txt | 2 ++ dScripts/CppScripts.cpp | 8 +++++++- dScripts/LupGenericInteract.cpp | 7 +++++++ dScripts/LupGenericInteract.h | 9 +++++++++ dScripts/WblRobotCitizen.cpp | 24 ++++++++++++++++++++++++ dScripts/WblRobotCitizen.h | 12 ++++++++++++ 6 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 dScripts/LupGenericInteract.cpp create mode 100644 dScripts/LupGenericInteract.h create mode 100644 dScripts/WblRobotCitizen.cpp create mode 100644 dScripts/WblRobotCitizen.h diff --git a/dScripts/CMakeLists.txt b/dScripts/CMakeLists.txt index 0a907a05..cb70cd44 100644 --- a/dScripts/CMakeLists.txt +++ b/dScripts/CMakeLists.txt @@ -130,6 +130,7 @@ set(DSCRIPT_SOURCES "ActivityManager.cpp" "InvalidScript.cpp" "LegoDieRoll.cpp" "Lieutenant.cpp" + "LupGenericInteract.cpp" "MaestromExtracticatorServer.cpp" "MailBoxServer.cpp" "MastTeleport.cpp" @@ -248,6 +249,7 @@ set(DSCRIPT_SOURCES "ActivityManager.cpp" "WaveBossHorsemen.cpp" "WaveBossSpiderling.cpp" "WblGenericZone.cpp" + "WblRobotCitizen.cpp" "WhFans.cpp" "WildAmbients.cpp" "WishingWellServer.cpp" diff --git a/dScripts/CppScripts.cpp b/dScripts/CppScripts.cpp index d313f2f9..04d24bd5 100644 --- a/dScripts/CppScripts.cpp +++ b/dScripts/CppScripts.cpp @@ -290,6 +290,8 @@ // WBL scripts #include "WblGenericZone.h" +#include "LupGenericInteract.h" +#include "WblRobotCitizen.h" //Big bad global bc this is a namespace and not a class: InvalidScript* invalidToReturn = new InvalidScript(); @@ -847,6 +849,10 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr // WBL else if (scriptName == "scripts\\zone\\LUPs\\WBL_generic_zone.lua") script = new WblGenericZone(); + else if (scriptName == "scripts\\ai\\WILD\\L_LUP_generic_interact.lua") + script = new LupGenericInteract(); + else if (scriptName.rfind("scripts\\zone\\LUPs\\RobotCity Intro\\WBL_RCIntro_RobotCitizen", 0) == 0) + script = new WblRobotCitizen(); //Ignore these scripts: else if (scriptName == "scripts\\02_server\\Enemy\\General\\L_SUSPEND_LUA_AI.lua") @@ -855,7 +861,7 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr script = invalidToReturn; else if (script == invalidToReturn) { if (scriptName.length() > 0) - Game::logger->LogDebug("CppScripts", "Attempted to load CppScript for '%s', but returned InvalidScript.", scriptName.c_str()); + Game::logger->Log("CppScripts", "Lot %i attempted to load CppScript for '%s', but returned InvalidScript.", parent->GetLOT(), scriptName.c_str()); // information not really needed for sys admins but is for developers script = invalidToReturn; diff --git a/dScripts/LupGenericInteract.cpp b/dScripts/LupGenericInteract.cpp new file mode 100644 index 00000000..e9afd337 --- /dev/null +++ b/dScripts/LupGenericInteract.cpp @@ -0,0 +1,7 @@ +#include "LupGenericInteract.h" +#include "GameMessages.h" +#include "dLogger.h" + +void LupGenericInteract::OnUse(Entity* self, Entity* user) { + GameMessages::SendPlayAnimation(self, u"interact"); +} diff --git a/dScripts/LupGenericInteract.h b/dScripts/LupGenericInteract.h new file mode 100644 index 00000000..9ca6b027 --- /dev/null +++ b/dScripts/LupGenericInteract.h @@ -0,0 +1,9 @@ +#pragma once +#include "CppScripts.h" + +class LupGenericInteract : public CppScripts::Script { +public: + void OnUse(Entity* self, Entity* user) override; +private: + const uint32_t frakjawChestId = 16486; +}; diff --git a/dScripts/WblRobotCitizen.cpp b/dScripts/WblRobotCitizen.cpp new file mode 100644 index 00000000..0647375f --- /dev/null +++ b/dScripts/WblRobotCitizen.cpp @@ -0,0 +1,24 @@ +#include "WblRobotCitizen.h" +#include "GameMessages.h" +#include "MovingPlatformComponent.h" +#include "dLogger.h" + + +void WblRobotCitizen::OnStartup(Entity* self) { + auto movingPlatformComponent = self->GetComponent(); + if (movingPlatformComponent) movingPlatformComponent->StartPathing(); +} + +void WblRobotCitizen::OnUse(Entity* self, Entity* user) { + auto movingPlatformComponent = self->GetComponent(); + if (movingPlatformComponent) movingPlatformComponent->StopPathing(); + auto face = NiQuaternion::LookAt(self->GetPosition(), user->GetPosition()); + self->SetRotation(face); + GameMessages::SendPlayAnimation(self, u"wave"); + self->AddTimer("animation time", m_AnimationTime); +} + +void WblRobotCitizen::OnTimerDone(Entity* self, std::string timerName) { + auto movingPlatformComponent = self->GetComponent(); + if (movingPlatformComponent) movingPlatformComponent->ContinuePathing(); +} diff --git a/dScripts/WblRobotCitizen.h b/dScripts/WblRobotCitizen.h new file mode 100644 index 00000000..394c7add --- /dev/null +++ b/dScripts/WblRobotCitizen.h @@ -0,0 +1,12 @@ +#pragma once +#include "CppScripts.h" + +class WblRobotCitizen : public CppScripts::Script { +public: + void OnStartup(Entity* self) override; + void OnUse(Entity* self, Entity* user) override; + void OnTimerDone(Entity* self, std::string timerName) override; +private: + const float m_AnimationTime = 2.5; +}; +