From 09e9bb2c15bd29261c66c45bb749e8750b98232f Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Sun, 9 Apr 2023 13:21:57 -0500 Subject: [PATCH] fix scripts split speed out to use target as caster fix armor skill --- dScripts/CppScripts.cpp | 5 ++-- dScripts/ai/SPEC/CMakeLists.txt | 1 + dScripts/ai/SPEC/SpecialPowerupSpawner.cpp | 5 ++-- dScripts/ai/SPEC/SpecialSpeedBuffSpawner.cpp | 26 ++++++++++++++++++++ dScripts/ai/SPEC/SpecialSpeedBuffSpawner.h | 10 ++++++++ 5 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 dScripts/ai/SPEC/SpecialSpeedBuffSpawner.cpp create mode 100644 dScripts/ai/SPEC/SpecialSpeedBuffSpawner.h diff --git a/dScripts/CppScripts.cpp b/dScripts/CppScripts.cpp index 9aea8ef9..b9b481f3 100644 --- a/dScripts/CppScripts.cpp +++ b/dScripts/CppScripts.cpp @@ -297,6 +297,7 @@ // pickups #include "SpecialCoinSpawner.h" #include "SpecialPowerupSpawner.h" +#include "SpecialSpeedBuffSpawner.h" // Wild Scripts #include "WildAndScared.h" @@ -893,9 +894,9 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_LIFE-POWERUP-SPAWNER.lua") script = new SpecialPowerupSpawner(5); else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_ARMOR-POWERUP-SPAWNER.lua") - script = new SpecialPowerupSpawner(80); + script = new SpecialPowerupSpawner(747); else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_SPEED_BUFF_SPAWNER.lua") - script = new SpecialPowerupSpawner(500); + script = new SpecialSpeedBuffSpawner(); // Wild if (scriptName == "scripts\\ai\\WILD\\L_WILD_GF_RAT.lua" || scriptName == "scripts\\ai\\WILD\\L_WILD_GF_SNAIL.lua") diff --git a/dScripts/ai/SPEC/CMakeLists.txt b/dScripts/ai/SPEC/CMakeLists.txt index d7496e9f..42dbf8f8 100644 --- a/dScripts/ai/SPEC/CMakeLists.txt +++ b/dScripts/ai/SPEC/CMakeLists.txt @@ -1,4 +1,5 @@ set(DSCRIPTS_SOURCES_AI_SPEC "SpecialCoinSpawner.cpp" "SpecialPowerupSpawner.cpp" + "SpecialSpeedBuffSpawner.cpp" PARENT_SCOPE) diff --git a/dScripts/ai/SPEC/SpecialPowerupSpawner.cpp b/dScripts/ai/SPEC/SpecialPowerupSpawner.cpp index d2a8f648..ea2e1044 100644 --- a/dScripts/ai/SPEC/SpecialPowerupSpawner.cpp +++ b/dScripts/ai/SPEC/SpecialPowerupSpawner.cpp @@ -17,8 +17,9 @@ void SpecialPowerupSpawner::OnProximityUpdate(Entity* self, Entity* entering, co GameMessages::SendPlayFXEffect(self, -1, u"pickup", "", LWOOBJID_EMPTY, 1, 1, true); - SkillComponent* skillComponent; - if (!self->TryGetComponent(eReplicaComponentType::SKILL, skillComponent)) return; + auto skillComponent = self->GetComponent(); + if (!skillComponent) return; + Game::logger->Log("SpecialPowerupSpawner", "cast skill %i on %llu", this->m_SkillId, entering->GetObjectID()); skillComponent->CastSkill(this->m_SkillId, entering->GetObjectID()); self->SetVar(u"bIsDead", true); diff --git a/dScripts/ai/SPEC/SpecialSpeedBuffSpawner.cpp b/dScripts/ai/SPEC/SpecialSpeedBuffSpawner.cpp new file mode 100644 index 00000000..d3109806 --- /dev/null +++ b/dScripts/ai/SPEC/SpecialSpeedBuffSpawner.cpp @@ -0,0 +1,26 @@ +#include "SpecialSpeedBuffSpawner.h" + +#include "GameMessages.h" +#include "SkillComponent.h" +#include "EntityManager.h" +#include "eReplicaComponentType.h" + +void SpecialSpeedBuffSpawner::OnStartup(Entity* self) { + self->SetProximityRadius(1.5f, "powerupEnter"); + self->SetVar(u"bIsDead", false); +} + +void SpecialSpeedBuffSpawner::OnProximityUpdate(Entity* self, Entity* entering, const std::string name, const std::string status) { + if (name != "powerupEnter" && status != "ENTER") return; + if (!entering->IsPlayer()) return; + if (self->GetVar(u"bIsDead")) return; + + GameMessages::SendPlayFXEffect(self, -1, u"pickup", "", LWOOBJID_EMPTY, 1, 1, true); + + auto skillComponent = entering->GetComponent(); + if (!skillComponent) return; + skillComponent->CastSkill(this->m_SkillId, entering->GetObjectID()); + + self->SetVar(u"bIsDead", true); + self->Smash(entering->GetObjectID(), eKillType::SILENT); +} diff --git a/dScripts/ai/SPEC/SpecialSpeedBuffSpawner.h b/dScripts/ai/SPEC/SpecialSpeedBuffSpawner.h new file mode 100644 index 00000000..e1741691 --- /dev/null +++ b/dScripts/ai/SPEC/SpecialSpeedBuffSpawner.h @@ -0,0 +1,10 @@ +#pragma once +#include "CppScripts.h" + +class SpecialSpeedBuffSpawner : public CppScripts::Script { +public: + void OnStartup(Entity* self) override; + void OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) override; +private: + uint32_t m_SkillId = 500; +};