From 67df06ef040f6e394ff5480dee27c12d35867474 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sun, 21 Nov 2021 13:37:26 +0100 Subject: [PATCH] Adds OnFaintingOpponent script hook to Angelscript. --- src/ScriptResolving/AngelScript/AngelScriptScript.cpp | 8 ++++++++ src/ScriptResolving/AngelScript/AngelScriptScript.hpp | 2 ++ src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp | 2 ++ .../AngelScript/TypeRegistry/BasicScriptClass.cpp | 1 + 4 files changed, 13 insertions(+) diff --git a/src/ScriptResolving/AngelScript/AngelScriptScript.cpp b/src/ScriptResolving/AngelScript/AngelScriptScript.cpp index d1be760..62edec1 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptScript.cpp +++ b/src/ScriptResolving/AngelScript/AngelScriptScript.cpp @@ -365,3 +365,11 @@ void AngelScriptScript::OnIncomingHit(const CreatureLib::Battling::ExecutingAtta ctx->SetArgByte(2, hitNumber); }) } +void AngelScriptScript::OnFaintingOpponent(const CreatureLib::Battling::ExecutingAttack* attack, + CreatureLib::Battling::Creature* target, u8 hitNumber) { + CALL_HOOK(OnFaintingOpponent, { + ctx->SetArgObject(0, (void*)attack); + ctx->SetArgObject(1, (void*)target); + ctx->SetArgByte(2, hitNumber); + }) +} diff --git a/src/ScriptResolving/AngelScript/AngelScriptScript.hpp b/src/ScriptResolving/AngelScript/AngelScriptScript.hpp index 7c232bc..13400da 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptScript.hpp +++ b/src/ScriptResolving/AngelScript/AngelScriptScript.hpp @@ -84,6 +84,8 @@ public: void OnIncomingHit(const CreatureLib::Battling::ExecutingAttack* attack, CreatureLib::Battling::Creature* target, uint8_t hitNumber) override; + void OnFaintingOpponent(const CreatureLib::Battling::ExecutingAttack* attack, + CreatureLib::Battling::Creature* target, u8 hitNumber) override; void OnSecondaryEffect(const CreatureLib::Battling::ExecutingAttack* attack, CreatureLib::Battling::Creature* target, uint8_t hitNumber) override; diff --git a/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp b/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp index 99bb734..07070c5 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp +++ b/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp @@ -116,6 +116,8 @@ public: PreventSecondaryEffects, "void PreventSecondaryEffects(ExecutingMove@ attack, Pokemon@ target, uint8 hit, bool& outResult)"); SCRIPT_HOOK_FUNCTION(OnIncomingHit, "void OnIncomingHit(ExecutingMove@ attack, Pokemon@ target, uint8 hit)"); + SCRIPT_HOOK_FUNCTION(OnFaintingOpponent, + "void OnFaintingOpponent(ExecutingMove@ attack, Pokemon@ target, uint8 hit)"); SCRIPT_HOOK_FUNCTION(OnSecondaryEffect, "void OnSecondaryEffect(ExecutingMove@ attack, Pokemon@ target, uint8 hit)"); SCRIPT_HOOK_FUNCTION(OnAfterHits, "void OnAfterHits(ExecutingMove@ attack, Pokemon@ target)"); diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/BasicScriptClass.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/BasicScriptClass.cpp index 1fd58db..e381804 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/BasicScriptClass.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/BasicScriptClass.cpp @@ -28,6 +28,7 @@ shared abstract class PkmnScript { void ChangeEffectiveness(ExecutingMove@ attack, Pokemon@ target, uint8 hit, float& effectiveness){}; void BlockCritical(ExecutingMove@ attack, Pokemon@ target, uint8 hit, bool& blockCritical){}; void OnIncomingHit(ExecutingMove@ attack, Pokemon@ target, uint8 hit){}; + void OnFaintingOpponent(ExecutingMove@ attack, Pokemon@ target, uint8 hit){}; void PreventSecondaryEffects(ExecutingMove@ attack, Pokemon@ target, uint8 hit, bool& outResult){}; void OnSecondaryEffect(ExecutingMove@ attack, Pokemon@ target, uint8 hit){}; void OnAfterHits(ExecutingMove@ attack, Pokemon@ target){};