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

This commit is contained in:
Deukhoofd 2021-11-19 18:07:21 +01:00
parent d59ee9d869
commit 1d90360efe
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
4 changed files with 15 additions and 2 deletions

View File

@ -347,3 +347,11 @@ void AngelScriptScript::BlockWeather(CreatureLib::Battling::Battle* battle, bool
void AngelScriptScript::OnSwitchIn(CreatureLib::Battling::Creature* creature) {
CALL_HOOK(OnSwitchIn, { ctx->SetArgObject(0, (void*)creature); })
}
void AngelScriptScript::OnIncomingHit(const CreatureLib::Battling::ExecutingAttack* attack,
CreatureLib::Battling::Creature* target, uint8_t hitNumber) {
CALL_HOOK(OnIncomingHit, {
ctx->SetArgObject(0, (void*)attack);
ctx->SetArgObject(1, (void*)target);
ctx->SetArgByte(2, hitNumber);
})
}

View File

@ -80,6 +80,8 @@ public:
void PreventSecondaryEffects(const CreatureLib::Battling::ExecutingAttack* attack,
CreatureLib::Battling::Creature* target, uint8_t hitNumber, bool* outResult) override;
void OnIncomingHit(const CreatureLib::Battling::ExecutingAttack* attack,
CreatureLib::Battling::Creature* target, uint8_t hitNumber) override;
void OnSecondaryEffect(const CreatureLib::Battling::ExecutingAttack* attack,
CreatureLib::Battling::Creature* target, uint8_t hitNumber) override;
@ -118,6 +120,8 @@ 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 OnFaint(CreatureLib::Battling::Creature* creature, CreatureLib::Battling::DamageSource source) override;
void OnSwitchIn(CreatureLib::Battling::Creature* creature) override;
////////////////////
// PkmnLib methods//
@ -135,9 +139,7 @@ public:
void DoesShareExperience(CreatureLib::Battling::Creature* faintedMon, CreatureLib::Battling::Creature* winningMon,
bool* shareExperience) override;
void OnFaint(CreatureLib::Battling::Creature* creature, CreatureLib::Battling::DamageSource source) override;
void BlockWeather(CreatureLib::Battling::Battle* battle, bool* blockWeather) override;
void OnSwitchIn(CreatureLib::Battling::Creature* creature) override;
};
#undef CALL_HOOK

View File

@ -113,6 +113,7 @@ public:
SCRIPT_HOOK_FUNCTION(
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(OnSecondaryEffect,
"void OnSecondaryEffect(ExecutingMove@ attack, Pokemon@ target, uint8 hit)");
SCRIPT_HOOK_FUNCTION(OnAfterHits, "void OnAfterHits(ExecutingMove@ attack, Pokemon@ target)");
@ -168,6 +169,7 @@ public:
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)");
};
#undef SCRIPT_HOOK_FUNCTION

View File

@ -26,6 +26,7 @@ shared abstract class PkmnScript {
void OnAttackMiss(ExecutingMove@ attack, Pokemon@ target){};
void ChangeAttackType(ExecutingMove@ attack, Pokemon@ target, uint8 hit, uint8& outType){};
void ChangeEffectiveness(ExecutingMove@ attack, Pokemon@ target, uint8 hit, float& effectiveness){};
void OnIncomingHit(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){};