From c89c572aa2a45e7fba7030ac5db5de46af00679b Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sun, 28 Mar 2021 18:53:08 +0200 Subject: [PATCH] Adds new Angelscript script hooks. --- src/ScriptResolving/AngelScript/AngelScriptScript.cpp | 9 +++++++++ src/ScriptResolving/AngelScript/AngelScriptScript.hpp | 3 +++ src/ScriptResolving/AngelScript/AngelScriptTypeInfo.cpp | 1 - src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp | 3 +++ .../AngelScript/TypeRegistry/BasicScriptClass.cpp | 2 ++ 5 files changed, 17 insertions(+), 1 deletion(-) delete mode 100644 src/ScriptResolving/AngelScript/AngelScriptTypeInfo.cpp diff --git a/src/ScriptResolving/AngelScript/AngelScriptScript.cpp b/src/ScriptResolving/AngelScript/AngelScriptScript.cpp index 11d3135..9f787f0 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptScript.cpp +++ b/src/ScriptResolving/AngelScript/AngelScriptScript.cpp @@ -285,3 +285,12 @@ void AngelScriptScript::PreventOpponentRunAway(const CreatureLib::Battling::Flee ctx->SetArgAddress(1, result); }) } +void AngelScriptScript::PreventOpponentSwitch(const CreatureLib::Battling::SwitchTurnChoice* choice, bool* outResult) { + CALL_HOOK(PreventOpponentSwitch, { + ctx->SetArgObject(0, (void*)choice); + ctx->SetArgAddress(1, outResult); + }) +} +void AngelScriptScript::OnEndTurn(CreatureLib::Battling::Creature* creature) { + CALL_HOOK(OnEndTurn, { ctx->SetArgObject(0, (void*)creature); }) +} diff --git a/src/ScriptResolving/AngelScript/AngelScriptScript.hpp b/src/ScriptResolving/AngelScript/AngelScriptScript.hpp index a61e1c9..778214d 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptScript.hpp +++ b/src/ScriptResolving/AngelScript/AngelScriptScript.hpp @@ -105,6 +105,8 @@ public: void PreventRunAway(const CreatureLib::Battling::FleeTurnChoice* choice, bool* result) override; void PreventOpponentRunAway(const CreatureLib::Battling::FleeTurnChoice* choice, bool* result) override; + void PreventOpponentSwitch(const CreatureLib::Battling::SwitchTurnChoice* choice, bool* outResult) override; + void OnEndTurn(CreatureLib::Battling::Creature* creature) override; //////////////////// // PkmnLib methods// @@ -121,6 +123,7 @@ public: uint32_t* experienceGain) override; void DoesShareExperience(CreatureLib::Battling::Creature* faintedMon, CreatureLib::Battling::Creature* winningMon, bool* shareExperience) override; + }; #undef CALL_HOOK diff --git a/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.cpp b/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.cpp deleted file mode 100644 index f864f81..0000000 --- a/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "AngelScriptTypeInfo.hpp" diff --git a/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp b/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp index b661dfe..c40f1b5 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp +++ b/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp @@ -139,6 +139,9 @@ public: SCRIPT_HOOK_FUNCTION(PreventRunAway, "void PreventRunAway(FleeTurnChoice@ choice, bool& result)"); SCRIPT_HOOK_FUNCTION(PreventOpponentRunAway, "void PreventOpponentRunAway(FleeTurnChoice@ choice, bool& result)"); + SCRIPT_HOOK_FUNCTION(PreventOpponentSwitch, "void PreventOpponentSwitch(SwitchTurnChoice@ choice, bool& result)"); + + SCRIPT_HOOK_FUNCTION(OnEndTurn, "void OnEndTurn(Pokemon@ pokemon)"); }; #undef SCRIPT_HOOK_FUNCTION diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/BasicScriptClass.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/BasicScriptClass.cpp index 4d3e566..4a6b474 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/BasicScriptClass.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/BasicScriptClass.cpp @@ -42,6 +42,8 @@ shared abstract class PkmnScript { void PreventRunAway(FleeTurnChoice@ choice, bool& result){}; void PreventOpponentRunAway(FleeTurnChoice@ choice, bool& result){}; + void PreventOpponentSwitch(SwitchTurnChoice@ choice, bool& result){}; + void OnEndTurn(Pokemon@ pokemon){}; // PkmnLib methods void ModifyCriticalStage(ExecutingMove@ attack, Pokemon@ target, uint8 hit, uint8& critStage){};