diff --git a/dScripts/CppScripts.cpp b/dScripts/CppScripts.cpp index 7ed7373f..b9b481f3 100644 --- a/dScripts/CppScripts.cpp +++ b/dScripts/CppScripts.cpp @@ -160,7 +160,6 @@ #include "AgSalutingNpcs.h" #include "BossSpiderQueenEnemyServer.h" #include "RockHydrantSmashable.h" -#include "SpecialImaginePowerupSpawner.h" // Misc Scripts #include "ExplodingAsset.h" @@ -295,6 +294,11 @@ // WBL scripts #include "WblGenericZone.h" +// pickups +#include "SpecialCoinSpawner.h" +#include "SpecialPowerupSpawner.h" +#include "SpecialSpeedBuffSpawner.h" + // Wild Scripts #include "WildAndScared.h" #include "WildGfGlowbug.h" @@ -377,8 +381,6 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr script = new RemoveRentalGear(); else if (scriptName == "scripts\\02_server\\Map\\AG\\L_NPC_NJ_ASSISTANT_SERVER.lua") script = new NpcNjAssistantServer(); - else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_IMAGINE-POWERUP-SPAWNER.lua") - script = new SpecialImaginePowerupSpawner(); else if (scriptName == "scripts\\ai\\AG\\L_AG_SALUTING_NPCS.lua") script = new AgSalutingNpcs(); else if (scriptName == "scripts\\ai\\AG\\L_AG_JET_EFFECT_SERVER.lua") @@ -866,6 +868,36 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr else if (scriptName == "scripts\\zone\\LUPs\\WBL_generic_zone.lua") script = new WblGenericZone(); + // pickups + if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_1_BRONZE-COIN-SPAWNER.lua") + script = new SpecialCoinSpawner(1); + else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_1_GOLD-COIN-SPAWNER.lua") + script = new SpecialCoinSpawner(10000); + else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_1_SILVER-COIN-SPAWNER.lua") + script = new SpecialCoinSpawner(100); + else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_10_BRONZE-COIN-SPAWNER.lua") + script = new SpecialCoinSpawner(10); + else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_10_GOLD-COIN-SPAWNER.lua") + script = new SpecialCoinSpawner(100000); + else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_10_SILVER-COIN-SPAWNER.lua") + script = new SpecialCoinSpawner(1000); + else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_25_BRONZE-COIN-SPAWNER.lua") + script = new SpecialCoinSpawner(25); + else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_25_GOLD-COIN-SPAWNER.lua") + script = new SpecialCoinSpawner(250000); + else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_25_SILVER-COIN-SPAWNER.lua") + script = new SpecialCoinSpawner(2500); + else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_IMAGINE-POWERUP-SPAWNER.lua") + script = new SpecialPowerupSpawner(13); + else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_IMAGINE-POWERUP-SPAWNER-2PT.lua") + script = new SpecialPowerupSpawner(129); + 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(747); + else if (scriptName == "scripts\\ai\\SPEC\\L_SPECIAL_SPEED_BUFF_SPAWNER.lua") + script = new SpecialSpeedBuffSpawner(); + // Wild if (scriptName == "scripts\\ai\\WILD\\L_WILD_GF_RAT.lua" || scriptName == "scripts\\ai\\WILD\\L_WILD_GF_SNAIL.lua") script = new WildAndScared(); diff --git a/dScripts/ai/SPEC/CMakeLists.txt b/dScripts/ai/SPEC/CMakeLists.txt index c4c5b809..42dbf8f8 100644 --- a/dScripts/ai/SPEC/CMakeLists.txt +++ b/dScripts/ai/SPEC/CMakeLists.txt @@ -1,3 +1,5 @@ -set(DSCRIPTS_SOURCES_AI_SPEC - "SpecialImaginePowerupSpawner.cpp" +set(DSCRIPTS_SOURCES_AI_SPEC + "SpecialCoinSpawner.cpp" + "SpecialPowerupSpawner.cpp" + "SpecialSpeedBuffSpawner.cpp" PARENT_SCOPE) diff --git a/dScripts/ai/SPEC/SpecialCoinSpawner.cpp b/dScripts/ai/SPEC/SpecialCoinSpawner.cpp new file mode 100644 index 00000000..aed9e817 --- /dev/null +++ b/dScripts/ai/SPEC/SpecialCoinSpawner.cpp @@ -0,0 +1,16 @@ +#include "SpecialCoinSpawner.h" +#include "CharacterComponent.h" + +void SpecialCoinSpawner::OnStartup(Entity* self) { + self->SetProximityRadius(1.5f, "powerupEnter"); +} + +void SpecialCoinSpawner::OnProximityUpdate(Entity* self, Entity* entering, const std::string name, const std::string status) { + if (name != "powerupEnter" && status != "ENTER") return; + if (!entering->IsPlayer()) return; + auto character = entering->GetCharacter(); + if (!character) return; + GameMessages::SendPlayFXEffect(self, -1, u"pickup", "", LWOOBJID_EMPTY, 1, 1, true); + character->SetCoins(character->GetCoins() + this->m_CurrencyDenomination, eLootSourceType::LOOT_SOURCE_CURRENCY); + self->Smash(entering->GetObjectID(), eKillType::SILENT); +} diff --git a/dScripts/ai/SPEC/SpecialCoinSpawner.h b/dScripts/ai/SPEC/SpecialCoinSpawner.h new file mode 100644 index 00000000..5af6f24a --- /dev/null +++ b/dScripts/ai/SPEC/SpecialCoinSpawner.h @@ -0,0 +1,13 @@ +#pragma once +#include "CppScripts.h" + +class SpecialCoinSpawner : public CppScripts::Script { +public: + SpecialCoinSpawner(uint32_t CurrencyDenomination) { + m_CurrencyDenomination = CurrencyDenomination; + }; + void OnStartup(Entity* self) override; + void OnProximityUpdate(Entity* self, Entity* entering, const std::string name, const std::string status) override; +private: + int32_t m_CurrencyDenomination = 0; +}; diff --git a/dScripts/ai/SPEC/SpecialImaginePowerupSpawner.cpp b/dScripts/ai/SPEC/SpecialImaginePowerupSpawner.cpp deleted file mode 100644 index 43ae9e89..00000000 --- a/dScripts/ai/SPEC/SpecialImaginePowerupSpawner.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "SpecialImaginePowerupSpawner.h" - -#include "GameMessages.h" -#include "SkillComponent.h" -#include "DestroyableComponent.h" -#include "EntityManager.h" -#include "eReplicaComponentType.h" - -void SpecialImaginePowerupSpawner::OnStartup(Entity* self) { - self->SetProximityRadius(1.5f, "powerupEnter"); - self->SetVar(u"bIsDead", false); -} - -void SpecialImaginePowerupSpawner::OnProximityUpdate(Entity* self, Entity* entering, const std::string name, const std::string status) { - if (name != "powerupEnter" && status != "ENTER") { - return; - } - - if (entering->GetLOT() != 1) { - return; - } - - if (self->GetVar(u"bIsDead")) { - return; - } - - GameMessages::SendPlayFXEffect(self, -1, u"pickup", "", LWOOBJID_EMPTY, 1, 1, true); - - SkillComponent* skillComponent; - if (!self->TryGetComponent(eReplicaComponentType::SKILL, skillComponent)) { - return; - } - - const auto source = entering->GetObjectID(); - - skillComponent->CalculateBehavior(13, 20, source); - - DestroyableComponent* destroyableComponent; - if (!self->TryGetComponent(eReplicaComponentType::DESTROYABLE, destroyableComponent)) { - return; - } - - self->SetVar(u"bIsDead", true); - - self->AddCallbackTimer(1.0f, [self]() { - EntityManager::Instance()->ScheduleForKill(self); - }); -} diff --git a/dScripts/ai/SPEC/SpecialPowerupSpawner.cpp b/dScripts/ai/SPEC/SpecialPowerupSpawner.cpp new file mode 100644 index 00000000..72565923 --- /dev/null +++ b/dScripts/ai/SPEC/SpecialPowerupSpawner.cpp @@ -0,0 +1,26 @@ +#include "SpecialPowerupSpawner.h" + +#include "GameMessages.h" +#include "SkillComponent.h" +#include "EntityManager.h" +#include "eReplicaComponentType.h" + +void SpecialPowerupSpawner::OnStartup(Entity* self) { + self->SetProximityRadius(1.5f, "powerupEnter"); + self->SetVar(u"bIsDead", false); +} + +void SpecialPowerupSpawner::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 = self->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/SpecialPowerupSpawner.h b/dScripts/ai/SPEC/SpecialPowerupSpawner.h new file mode 100644 index 00000000..b27e9789 --- /dev/null +++ b/dScripts/ai/SPEC/SpecialPowerupSpawner.h @@ -0,0 +1,13 @@ +#pragma once +#include "CppScripts.h" + +class SpecialPowerupSpawner : public CppScripts::Script { +public: + SpecialPowerupSpawner(uint32_t skillId) { + m_SkillId = skillId; + }; + void OnStartup(Entity* self) override; + void OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) override; +private: + uint32_t m_SkillId = 0; +}; 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/SpecialImaginePowerupSpawner.h b/dScripts/ai/SPEC/SpecialSpeedBuffSpawner.h similarity index 66% rename from dScripts/ai/SPEC/SpecialImaginePowerupSpawner.h rename to dScripts/ai/SPEC/SpecialSpeedBuffSpawner.h index eb628951..e1741691 100644 --- a/dScripts/ai/SPEC/SpecialImaginePowerupSpawner.h +++ b/dScripts/ai/SPEC/SpecialSpeedBuffSpawner.h @@ -1,9 +1,10 @@ #pragma once #include "CppScripts.h" -class SpecialImaginePowerupSpawner final : public CppScripts::Script -{ +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; };