Adds damage script hooks.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2021-10-29 18:29:30 +02:00
parent 3d75e8233d
commit f447e40663
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
5 changed files with 17 additions and 1 deletions

View File

@ -57,7 +57,8 @@ uint32_t PkmnLib::Battling::DamageLibrary::GetDamage(CreatureLib::Battling::Exec
} else { } else {
damage = static_cast<uint32_t>(floatDamage); damage = static_cast<uint32_t>(floatDamage);
} }
// HOOK: Override damage PKMN_HOOK(OverrideDamage, attack, attack, target, hitIndex, &damage);
PKMN_HOOK(OverrideIncomingDamage, target, attack, target, hitIndex, &damage);
return damage; return damage;
} }
uint8_t PkmnLib::Battling::DamageLibrary::GetBasePower(CreatureLib::Battling::ExecutingAttack* attack, uint8_t PkmnLib::Battling::DamageLibrary::GetBasePower(CreatureLib::Battling::ExecutingAttack* attack,

View File

@ -208,6 +208,16 @@ void AngelScriptScript::OverrideDamage(CreatureLib::Battling::ExecutingAttack* a
ctx->SetArgAddress(3, damage); ctx->SetArgAddress(3, damage);
}) })
} }
void AngelScriptScript::OverrideIncomingDamage(CreatureLib::Battling::ExecutingAttack* attack,
CreatureLib::Battling::Creature* target, uint8_t hitIndex,
uint32_t* damage) {
CALL_HOOK(OverrideIncomingDamage, {
ctx->SetArgObject(0, (void*)attack);
ctx->SetArgObject(1, (void*)target);
ctx->SetArgByte(2, hitIndex);
ctx->SetArgAddress(3, damage);
})
}
void AngelScriptScript::ModifyCriticalStage(CreatureLib::Battling::ExecutingAttack* attack, void AngelScriptScript::ModifyCriticalStage(CreatureLib::Battling::ExecutingAttack* attack,
CreatureLib::Battling::Creature* target, uint8_t hit, uint8_t* critStage) { CreatureLib::Battling::Creature* target, uint8_t hit, uint8_t* critStage) {
CALL_HOOK(ModifyCriticalStage, { CALL_HOOK(ModifyCriticalStage, {

View File

@ -104,6 +104,8 @@ public:
uint8_t hitIndex, float* modifier) override; uint8_t hitIndex, float* modifier) override;
void OverrideDamage(CreatureLib::Battling::ExecutingAttack* attack, CreatureLib::Battling::Creature* target, void OverrideDamage(CreatureLib::Battling::ExecutingAttack* attack, CreatureLib::Battling::Creature* target,
uint8_t hitIndex, uint32_t* damage) override; uint8_t hitIndex, uint32_t* damage) override;
void OverrideIncomingDamage(CreatureLib::Battling::ExecutingAttack* attack, CreatureLib::Battling::Creature* target,
uint8_t hitIndex, uint32_t* damage) override;
void ChangePriority(CreatureLib::Battling::AttackTurnChoice* choice, int8_t* priority) override; void ChangePriority(CreatureLib::Battling::AttackTurnChoice* choice, int8_t* priority) override;
void OnFail(CreatureLib::Battling::Creature* target) override; void OnFail(CreatureLib::Battling::Creature* target) override;

View File

@ -119,6 +119,8 @@ public:
"void ModifyDamageModifier(ExecutingMove@ attack, Pokemon@ target, uint8 hit, float& modifier)"); "void ModifyDamageModifier(ExecutingMove@ attack, Pokemon@ target, uint8 hit, float& modifier)");
SCRIPT_HOOK_FUNCTION(OverrideDamage, SCRIPT_HOOK_FUNCTION(OverrideDamage,
"void OverrideDamage(ExecutingMove@ attack, Pokemon@ target, uint8 hit, int& damage)"); "void OverrideDamage(ExecutingMove@ attack, Pokemon@ target, uint8 hit, int& damage)");
SCRIPT_HOOK_FUNCTION(OverrideIncomingDamage,
"void OverrideIncomingDamage(ExecutingMove@ attack, Pokemon@ target, uint8 hit, int& damage)");
SCRIPT_HOOK_FUNCTION( SCRIPT_HOOK_FUNCTION(
ModifyCriticalStage, ModifyCriticalStage,

View File

@ -36,6 +36,7 @@ shared abstract class PkmnScript {
void ModifyStatModifier(ExecutingMove@ attack, Pokemon@ target, uint8 hit, float& modifier){}; void ModifyStatModifier(ExecutingMove@ attack, Pokemon@ target, uint8 hit, float& modifier){};
void ModifyDamageModifier(ExecutingMove@ attack, Pokemon@ target, uint8 hit, float& modifier){}; void ModifyDamageModifier(ExecutingMove@ attack, Pokemon@ target, uint8 hit, float& modifier){};
void OverrideDamage(ExecutingMove@ attack, Pokemon@ target, uint8 hit, uint& damage){}; void OverrideDamage(ExecutingMove@ attack, Pokemon@ target, uint8 hit, uint& damage){};
void OverrideIncomingDamage(ExecutingMove@ attack, Pokemon@ target, uint8 hit, uint& damage){};
void ChangePriority(MoveTurnChoice@ choice, int8& priority){}; void ChangePriority(MoveTurnChoice@ choice, int8& priority){};
void OnFail(Pokemon@ user){}; void OnFail(Pokemon@ user){};