Merge branch 'main' into pickup-scripts

This commit is contained in:
Aaron Kimbre 2023-04-09 12:11:54 -05:00
commit bed269ffbe
10 changed files with 127 additions and 1 deletions

View File

@ -298,6 +298,12 @@
#include "SpecialCoinSpawner.h" #include "SpecialCoinSpawner.h"
#include "SpecialPowerupSpawner.h" #include "SpecialPowerupSpawner.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: //Big bad global bc this is a namespace and not a class:
InvalidScript* invalidToReturn = new InvalidScript(); InvalidScript* invalidToReturn = new InvalidScript();
std::map<std::string, CppScripts::Script*> m_Scripts; std::map<std::string, CppScripts::Script*> m_Scripts;
@ -891,11 +897,22 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr
else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_SPEED_BUFF_SPAWNER.lua") else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_SPEED_BUFF_SPAWNER.lua")
script = new SpecialPowerupSpawner(500); script = new SpecialPowerupSpawner(500);
// 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 // 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 // information not really needed for sys admins but is for developers
else if (script == invalidToReturn) { else if (script == invalidToReturn) {
if ((scriptName.length() > 0) && !((scriptName == "scripts\\02_server\\Enemy\\General\\L_SUSPEND_LUA_AI.lua") || 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\\02_server\\Enemy\\General\\L_BASE_ENEMY_SPIDERLING.lua") ||
(scriptName == "scripts\\ai\\WILD\\L_WILD_GF_FROG.lua") ||
(scriptName == "scripts\\empty.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()); )) Game::logger->LogDebug("CppScripts", "LOT %i attempted to load CppScript for '%s', but returned InvalidScript.", parent->GetLOT(), scriptName.c_str());
} }

View File

@ -1,4 +1,8 @@
set(DSCRIPTS_SOURCES_AI_WILD set(DSCRIPTS_SOURCES_AI_WILD
"AllCrateChicken.cpp" "AllCrateChicken.cpp"
"WildAmbients.cpp" "WildAmbients.cpp"
"WildAmbientCrab.cpp"
"WildAndScared.cpp"
"WildGfGlowbug.cpp"
"WildPants.cpp"
PARENT_SCOPE) PARENT_SCOPE)

View File

@ -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<bool>(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");
}

View File

@ -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;
};

View File

@ -0,0 +1,6 @@
#include "WildAndScared.h"
#include "GameMessages.h"
void WildAndScared::OnUse(Entity* self, Entity* user) {
GameMessages::SendPlayAnimation(self, u"scared");
}

View File

@ -0,0 +1,7 @@
#pragma once
#include "CppScripts.h"
class WildAndScared : public CppScripts::Script {
public:
void OnUse(Entity* self, Entity* user) override;
};

View File

@ -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<bool>(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<bool>(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);
}
}

View File

@ -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;
};

View File

@ -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");
}

View File

@ -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;
};