From aba349301f3fe3cb50af616ae4d02ef485c5d3c1 Mon Sep 17 00:00:00 2001 From: Aaron Kimbre Date: Mon, 9 May 2022 23:21:20 -0500 Subject: [PATCH] Add AM Teapot server Resolves #224 --- dScripts/AmTeapotServer.cpp | 15 +++++++++++++++ dScripts/AmTeapotServer.h | 10 ++++++++++ dScripts/CppScripts.cpp | 3 +++ 3 files changed, 28 insertions(+) create mode 100644 dScripts/AmTeapotServer.cpp create mode 100644 dScripts/AmTeapotServer.h diff --git a/dScripts/AmTeapotServer.cpp b/dScripts/AmTeapotServer.cpp new file mode 100644 index 00000000..17b95eeb --- /dev/null +++ b/dScripts/AmTeapotServer.cpp @@ -0,0 +1,15 @@ +#include "AmTeapotServer.h" +#include "InventoryComponent.h" +#include "GameMessages.h" + + +void AmTeapotServer::OnUse(Entity* self, Entity* user) { + auto* inventoryComponent = user->GetComponent(); + if (!inventoryComponent) return; + + if (inventoryComponent->GetLotCount(BLUE_FLOWER_LEAVES) >= 10){ + inventoryComponent->RemoveItem(BLUE_FLOWER_LEAVES, 10); + inventoryComponent->AddItem(WU_S_IMAGINATION_TEA, 1); + } + GameMessages::SendTerminateInteraction(user->GetObjectID(), FROM_INTERACTION, self->GetObjectID()); +} diff --git a/dScripts/AmTeapotServer.h b/dScripts/AmTeapotServer.h new file mode 100644 index 00000000..19cb5639 --- /dev/null +++ b/dScripts/AmTeapotServer.h @@ -0,0 +1,10 @@ +#pragma once +#include "CppScripts.h" + +class AmTeapotServer : public CppScripts::Script { + public: + void OnUse(Entity* self, Entity* user) override; + private: + LOT BLUE_FLOWER_LEAVES = 12317; + LOT WU_S_IMAGINATION_TEA = 12109; +}; diff --git a/dScripts/CppScripts.cpp b/dScripts/CppScripts.cpp index 00a253dc..4381823a 100644 --- a/dScripts/CppScripts.cpp +++ b/dScripts/CppScripts.cpp @@ -226,6 +226,7 @@ #include "AmSkullkinTower.h" #include "AmDarklingDragon.h" #include "AmBlueX.h" +#include "AmTeapotServer.h" // NJ Scripts #include "NjGarmadonCelebration.h" @@ -704,6 +705,8 @@ CppScripts::Script* CppScripts::GetScript(Entity* parent, const std::string& scr script = new BaseEnemyApe(); else if (scriptName == "scripts\\02_server\\Map\\AM\\L_BLUE_X.lua") script = new AmBlueX(); + else if (scriptName == "scripts\\02_server\\Map\\AM\\L_TEAPOT_SERVER.lua") + script = new AmTeapotServer(); // Ninjago else if (scriptName == "scripts\\02_server\\Map\\njhub\\L_GARMADON_CELEBRATION_SERVER.lua")