From 2cf92a16d2d4c6b9713f7d36b3d725c2cf2c5107 Mon Sep 17 00:00:00 2001 From: Aaron Kimbrell Date: Sun, 9 Apr 2023 10:17:05 -0500 Subject: [PATCH] Add scripts for a few wild creatures (#1051) ignore frog script --- dScripts/CppScripts.cpp | 17 +++++++++++++++++ dScripts/ai/WILD/CMakeLists.txt | 6 +++++- dScripts/ai/WILD/WildAmbientCrab.cpp | 27 +++++++++++++++++++++++++++ dScripts/ai/WILD/WildAmbientCrab.h | 9 +++++++++ dScripts/ai/WILD/WildAndScared.cpp | 6 ++++++ dScripts/ai/WILD/WildAndScared.h | 7 +++++++ dScripts/ai/WILD/WildGfGlowbug.cpp | 28 ++++++++++++++++++++++++++++ dScripts/ai/WILD/WildGfGlowbug.h | 9 +++++++++ dScripts/ai/WILD/WildPants.cpp | 10 ++++++++++ dScripts/ai/WILD/WildPants.h | 9 +++++++++ 10 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 dScripts/ai/WILD/WildAmbientCrab.cpp create mode 100644 dScripts/ai/WILD/WildAmbientCrab.h create mode 100644 dScripts/ai/WILD/WildAndScared.cpp create mode 100644 dScripts/ai/WILD/WildAndScared.h create mode 100644 dScripts/ai/WILD/WildGfGlowbug.cpp create mode 100644 dScripts/ai/WILD/WildGfGlowbug.h create mode 100644 dScripts/ai/WILD/WildPants.cpp create mode 100644 dScripts/ai/WILD/WildPants.h diff --git a/dScripts/CppScripts.cpp b/dScripts/CppScripts.cpp index 24b30dee..7ed7373f 100644 --- a/dScripts/CppScripts.cpp +++ b/dScripts/CppScripts.cpp @@ -295,6 +295,12 @@ // WBL scripts #include "WblGenericZone.h" +// Wild Scripts +#include "WildAndScared.h" +#include "WildGfGlowbug.h" +#include "WildAmbientCrab.h" +#include "WildPants.h" + //Big bad global bc this is a namespace and not a class: InvalidScript* invalidToReturn = new InvalidScript(); std::map m_Scripts; @@ -860,11 +866,22 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr else if (scriptName == "scripts\\zone\\LUPs\\WBL_generic_zone.lua") script = new WblGenericZone(); + // Wild + if (scriptName == "scripts\\ai\\WILD\\L_WILD_GF_RAT.lua" || scriptName == "scripts\\ai\\WILD\\L_WILD_GF_SNAIL.lua") + script = new WildAndScared(); + else if (scriptName == "scripts\\ai\\WILD\\L_WILD_GF_GLOWBUG.lua") + script = new WildGfGlowbug(); + else if (scriptName == "scripts\\ai\\WILD\\L_WILD_AMBIENT_CRAB.lua") + script = new WildAmbientCrab(); + else if (scriptName == "scripts\\ai\\WILD\\L_WILD_PANTS.lua") + script = new WildPants(); + // handle invalid script reporting if the path is greater than zero and it's not an ignored script // information not really needed for sys admins but is for developers else if (script == invalidToReturn) { if ((scriptName.length() > 0) && !((scriptName == "scripts\\02_server\\Enemy\\General\\L_SUSPEND_LUA_AI.lua") || (scriptName == "scripts\\02_server\\Enemy\\General\\L_BASE_ENEMY_SPIDERLING.lua") || + (scriptName == "scripts\\ai\\WILD\\L_WILD_GF_FROG.lua") || (scriptName == "scripts\\empty.lua") )) Game::logger->LogDebug("CppScripts", "LOT %i attempted to load CppScript for '%s', but returned InvalidScript.", parent->GetLOT(), scriptName.c_str()); } diff --git a/dScripts/ai/WILD/CMakeLists.txt b/dScripts/ai/WILD/CMakeLists.txt index 57470f72..d3e499db 100644 --- a/dScripts/ai/WILD/CMakeLists.txt +++ b/dScripts/ai/WILD/CMakeLists.txt @@ -1,4 +1,8 @@ -set(DSCRIPTS_SOURCES_AI_WILD +set(DSCRIPTS_SOURCES_AI_WILD "AllCrateChicken.cpp" "WildAmbients.cpp" + "WildAmbientCrab.cpp" + "WildAndScared.cpp" + "WildGfGlowbug.cpp" + "WildPants.cpp" PARENT_SCOPE) diff --git a/dScripts/ai/WILD/WildAmbientCrab.cpp b/dScripts/ai/WILD/WildAmbientCrab.cpp new file mode 100644 index 00000000..7b5b3d45 --- /dev/null +++ b/dScripts/ai/WILD/WildAmbientCrab.cpp @@ -0,0 +1,27 @@ +#include "WildAmbientCrab.h" +#include "GameMessages.h" + +void WildAmbientCrab::OnStartup(Entity* self){ + self->SetVar(u"flipped", true); + GameMessages::SendPlayAnimation(self, u"idle"); +} + +void WildAmbientCrab::OnUse(Entity* self, Entity* user) { + auto flipped = self->GetVar(u"flipped"); + if (flipped) { + self->AddTimer("Flipping", 0.6f); + GameMessages::SendPlayAnimation(self, u"flip-over"); + self->SetVar(u"flipped", false); + } else if (!flipped) { + self->AddTimer("Flipback", 0.8f); + GameMessages::SendPlayAnimation(self, u"flip-back"); + self->SetVar(u"flipped", true); + } +} + +void WildAmbientCrab::OnTimerDone(Entity* self, std::string timerName) { + if (timerName == "Flipping") GameMessages::SendPlayAnimation(self, u"over-idle"); + else if (timerName == "Flipback") GameMessages::SendPlayAnimation(self, u"idle"); +} + + diff --git a/dScripts/ai/WILD/WildAmbientCrab.h b/dScripts/ai/WILD/WildAmbientCrab.h new file mode 100644 index 00000000..0e1b3877 --- /dev/null +++ b/dScripts/ai/WILD/WildAmbientCrab.h @@ -0,0 +1,9 @@ +#pragma once +#include "CppScripts.h" + +class WildAmbientCrab final : public CppScripts::Script { +public: + void OnStartup(Entity* self) override; + void OnTimerDone(Entity* self, std::string timerName) override; + void OnUse(Entity* self, Entity* user) override; +}; diff --git a/dScripts/ai/WILD/WildAndScared.cpp b/dScripts/ai/WILD/WildAndScared.cpp new file mode 100644 index 00000000..d2e89c40 --- /dev/null +++ b/dScripts/ai/WILD/WildAndScared.cpp @@ -0,0 +1,6 @@ +#include "WildAndScared.h" +#include "GameMessages.h" + +void WildAndScared::OnUse(Entity* self, Entity* user) { + GameMessages::SendPlayAnimation(self, u"scared"); +} diff --git a/dScripts/ai/WILD/WildAndScared.h b/dScripts/ai/WILD/WildAndScared.h new file mode 100644 index 00000000..c94fb06d --- /dev/null +++ b/dScripts/ai/WILD/WildAndScared.h @@ -0,0 +1,7 @@ +#pragma once +#include "CppScripts.h" + +class WildAndScared : public CppScripts::Script { +public: + void OnUse(Entity* self, Entity* user) override; +}; diff --git a/dScripts/ai/WILD/WildGfGlowbug.cpp b/dScripts/ai/WILD/WildGfGlowbug.cpp new file mode 100644 index 00000000..d834f5b5 --- /dev/null +++ b/dScripts/ai/WILD/WildGfGlowbug.cpp @@ -0,0 +1,28 @@ +#include "WildGfGlowbug.h" +#include "GameMessages.h" + +void WildGfGlowbug::OnStartup(Entity* self){ + self->SetVar(u"switch", false); +} + +void WildGfGlowbug::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) { + if (args == "physicsReady") { + auto switchState = self->GetVar(u"switch"); + if (!switchState) { + GameMessages::SendStopFXEffect(self, true, "glowlight"); + } else if (switchState) { + GameMessages::SendPlayFXEffect(self, -1, u"light", "glowlight", LWOOBJID_EMPTY); + } + } +} + +void WildGfGlowbug::OnUse(Entity* self, Entity* user) { + auto switchState = self->GetVar(u"switch"); + if (switchState) { + GameMessages::SendStopFXEffect(self, true, "glowlight"); + self->SetVar(u"switch", false); + } else if (!switchState) { + GameMessages::SendPlayFXEffect(self, -1, u"light", "glowlight", LWOOBJID_EMPTY); + self->SetVar(u"switch", true); + } +} diff --git a/dScripts/ai/WILD/WildGfGlowbug.h b/dScripts/ai/WILD/WildGfGlowbug.h new file mode 100644 index 00000000..03242372 --- /dev/null +++ b/dScripts/ai/WILD/WildGfGlowbug.h @@ -0,0 +1,9 @@ +#pragma once +#include "CppScripts.h" + +class WildGfGlowbug : public CppScripts::Script { +public: + void OnStartup(Entity* self) override; + void OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) override; + void OnUse(Entity* self, Entity* user) override; +}; diff --git a/dScripts/ai/WILD/WildPants.cpp b/dScripts/ai/WILD/WildPants.cpp new file mode 100644 index 00000000..7c5e1cd2 --- /dev/null +++ b/dScripts/ai/WILD/WildPants.cpp @@ -0,0 +1,10 @@ +#include "WildPants.h" +#include "GameMessages.h" + +void WildPants::OnStartup(Entity* self) { + self->SetProximityRadius(5, "scardyPants"); +} + +void WildPants::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) { + if (status == "ENTER") GameMessages::SendPlayAnimation(self, u"scared"); +} diff --git a/dScripts/ai/WILD/WildPants.h b/dScripts/ai/WILD/WildPants.h new file mode 100644 index 00000000..c6968045 --- /dev/null +++ b/dScripts/ai/WILD/WildPants.h @@ -0,0 +1,9 @@ +#pragma once +#include "CppScripts.h" + +class WildPants : public CppScripts::Script +{ +public: + void OnStartup(Entity* self) override; + void OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) override; +};