Adds OnFaint script hook to Angelscript.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2021-11-19 12:40:31 +01:00
parent 545e321018
commit 47e3919734
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
4 changed files with 10 additions and 0 deletions

View File

@ -332,3 +332,9 @@ CreatureLib::Battling::BattleScript* AngelScriptScript::Clone(const ArbUt::Optio
return new AngelScriptScript(owner, GetAngelscriptOwner()->GetType(), _resolver, _type, obj, _ctxPool); 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<asWORD>(source));
})
}

View File

@ -134,6 +134,8 @@ public:
uint32_t* experienceGain) override; uint32_t* experienceGain) override;
void DoesShareExperience(CreatureLib::Battling::Creature* faintedMon, CreatureLib::Battling::Creature* winningMon, void DoesShareExperience(CreatureLib::Battling::Creature* faintedMon, CreatureLib::Battling::Creature* winningMon,
bool* shareExperience) override; bool* shareExperience) override;
void OnFaint(CreatureLib::Battling::Creature* creature, CreatureLib::Battling::DamageSource source) override;
}; };
#undef CALL_HOOK #undef CALL_HOOK

View File

@ -165,6 +165,7 @@ public:
SCRIPT_HOOK_FUNCTION(PreventOpponentSwitch, "void PreventOpponentSwitch(SwitchTurnChoice@ choice, bool& result)"); SCRIPT_HOOK_FUNCTION(PreventOpponentSwitch, "void PreventOpponentSwitch(SwitchTurnChoice@ choice, bool& result)");
SCRIPT_HOOK_FUNCTION(OnEndTurn, "void OnEndTurn()"); SCRIPT_HOOK_FUNCTION(OnEndTurn, "void OnEndTurn()");
SCRIPT_HOOK_FUNCTION(OnFaint, "void OnFaint(Pokemon@ pokemon, DamageSource damageSource)");
}; };
#undef SCRIPT_HOOK_FUNCTION #undef SCRIPT_HOOK_FUNCTION

View File

@ -51,6 +51,7 @@ shared abstract class PkmnScript {
void PreventOpponentRunAway(FleeTurnChoice@ choice, bool& result){}; void PreventOpponentRunAway(FleeTurnChoice@ choice, bool& result){};
void PreventOpponentSwitch(SwitchTurnChoice@ choice, bool& result){}; void PreventOpponentSwitch(SwitchTurnChoice@ choice, bool& result){};
void OnEndTurn(){}; void OnEndTurn(){};
void OnFaint(Pokemon@ pokemon, DamageSource damageSource){};
// PkmnLib methods // PkmnLib methods
void ModifyCriticalStage(ExecutingMove@ attack, Pokemon@ target, uint8 hit, uint8& critStage){}; void ModifyCriticalStage(ExecutingMove@ attack, Pokemon@ target, uint8 hit, uint8& critStage){};