diff --git a/src/ScriptResolving/AngelScript/AngelScriptScript.cpp b/src/ScriptResolving/AngelScript/AngelScriptScript.cpp index 62edec1..4f16fe2 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptScript.cpp +++ b/src/ScriptResolving/AngelScript/AngelScriptScript.cpp @@ -342,6 +342,13 @@ CreatureLib::Battling::BattleScript* AngelScriptScript::Clone(const ArbUt::Optio return new AngelScriptScript(owner, GetAngelscriptOwner()->GetType(), _resolver, _type, obj, _ctxPool); } +void AngelScriptScript::OnDamage(CreatureLib::Battling::Creature* creature, + CreatureLib::Battling::DamageSource source) { + CALL_HOOK(OnDamage, { + ctx->SetArgObject(0, (void*)creature); + ctx->SetArgDWord(1, (i32)source); + }) +} void AngelScriptScript::OnFaint(CreatureLib::Battling::Creature* creature, CreatureLib::Battling::DamageSource source) { CALL_HOOK(OnFaint, { ctx->SetArgObject(0, (void*)creature); diff --git a/src/ScriptResolving/AngelScript/AngelScriptScript.hpp b/src/ScriptResolving/AngelScript/AngelScriptScript.hpp index 13400da..6f6e5f8 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptScript.hpp +++ b/src/ScriptResolving/AngelScript/AngelScriptScript.hpp @@ -124,6 +124,7 @@ public: void PreventOpponentRunAway(const CreatureLib::Battling::FleeTurnChoice* choice, bool* result) override; void PreventOpponentSwitch(const CreatureLib::Battling::SwitchTurnChoice* choice, bool* outResult) override; void OnEndTurn() override; + void OnDamage(CreatureLib::Battling::Creature* creature, CreatureLib::Battling::DamageSource source) override; void OnFaint(CreatureLib::Battling::Creature* creature, CreatureLib::Battling::DamageSource source) override; void OnSwitchIn(CreatureLib::Battling::Creature* creature) override; diff --git a/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp b/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp index 07070c5..fbaef51 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp +++ b/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp @@ -170,6 +170,7 @@ public: SCRIPT_HOOK_FUNCTION(PreventOpponentSwitch, "void PreventOpponentSwitch(SwitchTurnChoice@ choice, bool& result)"); SCRIPT_HOOK_FUNCTION(OnEndTurn, "void OnEndTurn()"); + SCRIPT_HOOK_FUNCTION(OnDamage, "void OnDamage(Pokemon@ pokemon, DamageSource damageSource)"); 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)"); diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/BasicScriptClass.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/BasicScriptClass.cpp index e381804..159674c 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/BasicScriptClass.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/BasicScriptClass.cpp @@ -54,6 +54,7 @@ shared abstract class PkmnScript { void PreventOpponentRunAway(FleeTurnChoice@ choice, bool& result){}; void PreventOpponentSwitch(SwitchTurnChoice@ choice, bool& result){}; void OnEndTurn(){}; + void OnDamage(Pokemon@ pokemon, DamageSource damageSource){}; void OnFaint(Pokemon@ pokemon, DamageSource damageSource){}; // PkmnLib methods