From d1ba703f7685c07d9ca06e8161696cf99bca78a0 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Fri, 19 Nov 2021 15:55:48 +0100 Subject: [PATCH] Adds OnSwitchIn script hook to Angelscript. --- src/ScriptResolving/AngelScript/AngelScriptScript.cpp | 3 +++ src/ScriptResolving/AngelScript/AngelScriptScript.hpp | 1 + src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp | 1 + .../AngelScript/TypeRegistry/BasicScriptClass.cpp | 1 + 4 files changed, 6 insertions(+) diff --git a/src/ScriptResolving/AngelScript/AngelScriptScript.cpp b/src/ScriptResolving/AngelScript/AngelScriptScript.cpp index 6ea3f5f..530e8a9 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptScript.cpp +++ b/src/ScriptResolving/AngelScript/AngelScriptScript.cpp @@ -344,3 +344,6 @@ void AngelScriptScript::BlockWeather(CreatureLib::Battling::Battle* battle, bool ctx->SetArgAddress(1, blockWeather); }) } +void AngelScriptScript::OnSwitchIn(CreatureLib::Battling::Creature* creature) { + CALL_HOOK(OnSwitchIn, { ctx->SetArgObject(0, (void*)creature); }) +} diff --git a/src/ScriptResolving/AngelScript/AngelScriptScript.hpp b/src/ScriptResolving/AngelScript/AngelScriptScript.hpp index 9270c5b..d41d146 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptScript.hpp +++ b/src/ScriptResolving/AngelScript/AngelScriptScript.hpp @@ -137,6 +137,7 @@ public: void OnFaint(CreatureLib::Battling::Creature* creature, CreatureLib::Battling::DamageSource source) override; void BlockWeather(CreatureLib::Battling::Battle* battle, bool* blockWeather) override; + void OnSwitchIn(CreatureLib::Battling::Creature* creature) override; }; #undef CALL_HOOK diff --git a/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp b/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp index d60e7fc..71b66a6 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp +++ b/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp @@ -167,6 +167,7 @@ public: SCRIPT_HOOK_FUNCTION(OnEndTurn, "void OnEndTurn()"); SCRIPT_HOOK_FUNCTION(OnFaint, "void OnFaint(Pokemon@ pokemon, DamageSource damageSource)"); SCRIPT_HOOK_FUNCTION(BlockWeather, "void BlockWeather(Battle@ battle, bool& result)"); + SCRIPT_HOOK_FUNCTION(OnSwitchIn, "void OnSwitchIn(Pokemon@ pokemon)"); }; #undef SCRIPT_HOOK_FUNCTION diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/BasicScriptClass.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/BasicScriptClass.cpp index 88a0710..f80177a 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/BasicScriptClass.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/BasicScriptClass.cpp @@ -61,6 +61,7 @@ shared abstract class PkmnScript { void ModifyExperienceGain(Pokemon@ faintedMon, Pokemon@ winningMon, uint32& critStage){}; void DoesShareExperience(Pokemon@ faintedMon, Pokemon@ winningMon, bool& shareExperience){}; void BlockWeather(Battle@ battle, bool& blockWeather){}; + void OnSwitchIn(Pokemon@ pokemon){}; } )"); Ensure(r >= 0);