From 817bf387ac17feb40b18a27f564252a6d4ad7733 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sat, 19 Feb 2022 16:21:29 +0100 Subject: [PATCH] Adds ChangeSpeed script hook to Angelscript --- src/ScriptResolving/AngelScript/AngelScriptScript.cpp | 6 ++++++ src/ScriptResolving/AngelScript/AngelScriptScript.hpp | 1 + src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp | 5 ++--- .../AngelScript/TypeRegistry/BasicScriptClass.cpp | 1 + 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/ScriptResolving/AngelScript/AngelScriptScript.cpp b/src/ScriptResolving/AngelScript/AngelScriptScript.cpp index a9a5e12..62131bd 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptScript.cpp +++ b/src/ScriptResolving/AngelScript/AngelScriptScript.cpp @@ -440,3 +440,9 @@ void AngelScriptScript::OnAfterHeldItemConsume(CreatureLib::Battling::Creature* ctx->SetArgObject(1, (void*)item); }); } +void AngelScriptScript::ChangeSpeed(CreatureLib::Battling::BaseTurnChoice* choice, uint32_t* speed) { + CALL_HOOK(ChangeSpeed, { + ctx->SetArgObject(0, (void*)choice); + ctx->SetArgAddress(1, (void*)speed); + }); +} diff --git a/src/ScriptResolving/AngelScript/AngelScriptScript.hpp b/src/ScriptResolving/AngelScript/AngelScriptScript.hpp index cf5dd9f..6cd0ac0 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptScript.hpp +++ b/src/ScriptResolving/AngelScript/AngelScriptScript.hpp @@ -121,6 +121,7 @@ public: void OverrideIncomingDamage(CreatureLib::Battling::ExecutingAttack* attack, CreatureLib::Battling::Creature* target, uint8_t hitIndex, uint32_t* damage) override; + void ChangeSpeed(CreatureLib::Battling::BaseTurnChoice* choice, uint32_t* speed) override; void ChangePriority(CreatureLib::Battling::AttackTurnChoice* choice, int8_t* priority) override; void OnFail(CreatureLib::Battling::Creature* target) override; void OnOpponentFail(CreatureLib::Battling::Creature* target) override; diff --git a/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp b/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp index 40649a3..9ab0d9c 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp +++ b/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp @@ -169,6 +169,7 @@ public: SCRIPT_HOOK_FUNCTION(DoesShareExperience, "void DoesShareExperience(Pokemon@ faintedMon, Pokemon@ winningMon, bool& shareExperience)"); + SCRIPT_HOOK_FUNCTION(ChangeSpeed, "void ChangeSpeed(BaseTurnChoice@ choice, uint32& speed)"); SCRIPT_HOOK_FUNCTION(ChangePriority, "void ChangePriority(MoveTurnChoice@ choice, int8& priority)"); SCRIPT_HOOK_FUNCTION(OnFail, "void OnFail(Pokemon@ user)"); SCRIPT_HOOK_FUNCTION(OnOpponentFail, "void OnOpponentFail(Pokemon@ user)"); @@ -190,9 +191,7 @@ public: SCRIPT_HOOK_FUNCTION( ModifyDefensiveStatValue, "void ModifyDefensiveStatValue(ExecutingMove@ attack, Pokemon@ target, uint8 hit, float& defensiveStatValue)"); - SCRIPT_HOOK_FUNCTION( - OnAfterHeldItemConsume, - "void OnAfterHeldItemConsume(Pokemon@ target, const Item@ item)"); + SCRIPT_HOOK_FUNCTION(OnAfterHeldItemConsume, "void OnAfterHeldItemConsume(Pokemon@ target, const Item@ item)"); }; #undef SCRIPT_HOOK_FUNCTION diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/BasicScriptClass.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/BasicScriptClass.cpp index 616dfa4..44d9b93 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/BasicScriptClass.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/BasicScriptClass.cpp @@ -48,6 +48,7 @@ shared abstract class PkmnScript { void OverrideDamage(ExecutingMove@ attack, Pokemon@ target, uint8 hit, uint& damage){}; void OverrideIncomingDamage(ExecutingMove@ attack, Pokemon@ target, uint8 hit, uint& damage){}; + void ChangeSpeed(BaseTurnChoice@ choice, uint32& speed){}; void ChangePriority(MoveTurnChoice@ choice, int8& priority){}; void OnFail(Pokemon@ user){}; void OnOpponentFail(Pokemon@ user){};