diff --git a/src/ScriptResolving/AngelScript/AngelScriptScript.cpp b/src/ScriptResolving/AngelScript/AngelScriptScript.cpp index 838d69b..4aa76ba 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptScript.cpp +++ b/src/ScriptResolving/AngelScript/AngelScriptScript.cpp @@ -332,3 +332,9 @@ CreatureLib::Battling::BattleScript* AngelScriptScript::Clone(const ArbUt::Optio return new AngelScriptScript(owner, GetAngelscriptOwner()->GetType(), _resolver, _type, obj, _ctxPool); } +void AngelScriptScript::OnFaint(CreatureLib::Battling::Creature* creature, CreatureLib::Battling::DamageSource source) { + CALL_HOOK(OnFaint, { + ctx->SetArgObject(0, (void*)creature); + ctx->SetArgWord(1, static_cast(source)); + }) +} diff --git a/src/ScriptResolving/AngelScript/AngelScriptScript.hpp b/src/ScriptResolving/AngelScript/AngelScriptScript.hpp index 3d4bbaf..50df02e 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptScript.hpp +++ b/src/ScriptResolving/AngelScript/AngelScriptScript.hpp @@ -134,6 +134,8 @@ public: uint32_t* experienceGain) override; void DoesShareExperience(CreatureLib::Battling::Creature* faintedMon, CreatureLib::Battling::Creature* winningMon, bool* shareExperience) override; + + void OnFaint(CreatureLib::Battling::Creature* creature, CreatureLib::Battling::DamageSource source) override; }; #undef CALL_HOOK diff --git a/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp b/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp index e3bf760..a8a15c3 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp +++ b/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp @@ -165,6 +165,7 @@ public: SCRIPT_HOOK_FUNCTION(PreventOpponentSwitch, "void PreventOpponentSwitch(SwitchTurnChoice@ choice, bool& result)"); SCRIPT_HOOK_FUNCTION(OnEndTurn, "void OnEndTurn()"); + SCRIPT_HOOK_FUNCTION(OnFaint, "void OnFaint(Pokemon@ pokemon, DamageSource damageSource)"); }; #undef SCRIPT_HOOK_FUNCTION diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/BasicScriptClass.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/BasicScriptClass.cpp index ff44d7c..daa33f5 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/BasicScriptClass.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/BasicScriptClass.cpp @@ -51,6 +51,7 @@ shared abstract class PkmnScript { void PreventOpponentRunAway(FleeTurnChoice@ choice, bool& result){}; void PreventOpponentSwitch(SwitchTurnChoice@ choice, bool& result){}; void OnEndTurn(){}; + void OnFaint(Pokemon@ pokemon, DamageSource damageSource){}; // PkmnLib methods void ModifyCriticalStage(ExecutingMove@ attack, Pokemon@ target, uint8 hit, uint8& critStage){};