Adds OnDamage script hook to Angelscript.
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Deukhoofd 2021-11-21 14:06:36 +01:00
parent 95e1e32abe
commit 0b8ebcc778
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
4 changed files with 10 additions and 0 deletions

View File

@ -342,6 +342,13 @@ 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::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) { void AngelScriptScript::OnFaint(CreatureLib::Battling::Creature* creature, CreatureLib::Battling::DamageSource source) {
CALL_HOOK(OnFaint, { CALL_HOOK(OnFaint, {
ctx->SetArgObject(0, (void*)creature); ctx->SetArgObject(0, (void*)creature);

View File

@ -124,6 +124,7 @@ public:
void PreventOpponentRunAway(const CreatureLib::Battling::FleeTurnChoice* choice, bool* result) override; void PreventOpponentRunAway(const CreatureLib::Battling::FleeTurnChoice* choice, bool* result) override;
void PreventOpponentSwitch(const CreatureLib::Battling::SwitchTurnChoice* choice, bool* outResult) override; void PreventOpponentSwitch(const CreatureLib::Battling::SwitchTurnChoice* choice, bool* outResult) override;
void OnEndTurn() 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 OnFaint(CreatureLib::Battling::Creature* creature, CreatureLib::Battling::DamageSource source) override;
void OnSwitchIn(CreatureLib::Battling::Creature* creature) override; void OnSwitchIn(CreatureLib::Battling::Creature* creature) override;

View File

@ -170,6 +170,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(OnDamage, "void OnDamage(Pokemon@ pokemon, DamageSource damageSource)");
SCRIPT_HOOK_FUNCTION(OnFaint, "void OnFaint(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(BlockWeather, "void BlockWeather(Battle@ battle, bool& result)");
SCRIPT_HOOK_FUNCTION(OnSwitchIn, "void OnSwitchIn(Pokemon@ pokemon)"); SCRIPT_HOOK_FUNCTION(OnSwitchIn, "void OnSwitchIn(Pokemon@ pokemon)");

View File

@ -54,6 +54,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 OnDamage(Pokemon@ pokemon, DamageSource damageSource){};
void OnFaint(Pokemon@ pokemon, DamageSource damageSource){}; void OnFaint(Pokemon@ pokemon, DamageSource damageSource){};
// PkmnLib methods // PkmnLib methods