Adds new script hook to prevent incoming critical hits
This commit is contained in:
parent
6444a8ce1c
commit
8522b93b7f
|
@ -8,6 +8,12 @@
|
|||
|
||||
bool PkmnLib::Battling::MiscLibrary::IsCritical(CreatureLib::Battling::ExecutingAttack* attack,
|
||||
CreatureLib::Battling::Creature* target, uint8_t hit) const {
|
||||
bool preventCrit = false;
|
||||
PKMN_HOOK(PreventIncomingCritical, target, attack, target, hit, &preventCrit);
|
||||
if (preventCrit) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t critStage = 0;
|
||||
PKMN_HOOK(ModifyCriticalStage, attack, attack, target, hit, &critStage);
|
||||
Ensure(target->GetBattle().HasValue());
|
||||
|
|
|
@ -16,6 +16,8 @@ namespace PkmnLib::Battling {
|
|||
public:
|
||||
PkmnScript(const ArbUt::OptionalBorrowedPtr<void>& owner) : CreatureLib::Battling::BattleScript(owner) {}
|
||||
|
||||
virtual void PreventIncomingCritical(CreatureLib::Battling::ExecutingAttack* attack,
|
||||
CreatureLib::Battling::Creature* target, uint8_t hit, bool* preventCrit){};
|
||||
virtual void ModifyCriticalStage(CreatureLib::Battling::ExecutingAttack* attack,
|
||||
CreatureLib::Battling::Creature* target, uint8_t hit, uint8_t* critStage){};
|
||||
virtual void OverrideCriticalModifier(CreatureLib::Battling::ExecutingAttack* attack,
|
||||
|
|
|
@ -249,6 +249,16 @@ void AngelScriptScript::OverrideIncomingDamage(CreatureLib::Battling::ExecutingA
|
|||
ctx->SetArgAddress(3, damage);
|
||||
})
|
||||
}
|
||||
void AngelScriptScript::PreventIncomingCritical(CreatureLib::Battling::ExecutingAttack* attack,
|
||||
CreatureLib::Battling::Creature* target, uint8_t hit,
|
||||
bool* preventCrit) {
|
||||
CALL_HOOK(PreventIncomingCritical, {
|
||||
ctx->SetArgObject(0, (void*)attack);
|
||||
ctx->SetArgObject(1, (void*)target);
|
||||
ctx->SetArgByte(2, hit);
|
||||
ctx->SetArgAddress(3, preventCrit);
|
||||
})
|
||||
}
|
||||
void AngelScriptScript::ModifyCriticalStage(CreatureLib::Battling::ExecutingAttack* attack,
|
||||
CreatureLib::Battling::Creature* target, uint8_t hit, uint8_t* critStage) {
|
||||
CALL_HOOK(ModifyCriticalStage, {
|
||||
|
|
|
@ -133,6 +133,8 @@ public:
|
|||
// PkmnLib methods//
|
||||
////////////////////
|
||||
|
||||
void PreventIncomingCritical(CreatureLib::Battling::ExecutingAttack* attack,
|
||||
CreatureLib::Battling::Creature* target, uint8_t hit, bool* preventCrit) override;
|
||||
void ModifyCriticalStage(CreatureLib::Battling::ExecutingAttack* attack, CreatureLib::Battling::Creature* target,
|
||||
uint8_t hit, uint8_t* critStage) override;
|
||||
void OverrideCriticalModifier(CreatureLib::Battling::ExecutingAttack* attack,
|
||||
|
|
|
@ -147,6 +147,9 @@ public:
|
|||
SCRIPT_HOOK_FUNCTION(OverrideIncomingDamage,
|
||||
"void OverrideIncomingDamage(ExecutingMove@ attack, Pokemon@ target, uint8 hit, int& damage)");
|
||||
|
||||
SCRIPT_HOOK_FUNCTION(
|
||||
PreventIncomingCritical,
|
||||
"void PreventIncomingCritical(ExecutingMove@ attack, Pokemon@ target, uint8 hit, bool& preventCrit)");
|
||||
SCRIPT_HOOK_FUNCTION(
|
||||
ModifyCriticalStage,
|
||||
"void ModifyCriticalStage(ExecutingMove@ attack, Pokemon@ target, uint8 hit, uint8& critStage)");
|
||||
|
|
|
@ -58,6 +58,7 @@ shared abstract class PkmnScript {
|
|||
void OnFaint(Pokemon@ pokemon, DamageSource damageSource){};
|
||||
|
||||
// PkmnLib methods
|
||||
void PreventIncomingCritical(ExecutingMove@ attack, Pokemon@ target, uint8 hit, bool& preventCrit){};
|
||||
void ModifyCriticalStage(ExecutingMove@ attack, Pokemon@ target, uint8 hit, uint8& critStage){};
|
||||
void OverrideCriticalModifier(ExecutingMove@ attack, Pokemon@ target, uint8 hit, float& critModifier){};
|
||||
void OverrideSTABModifier(ExecutingMove@ attack, Pokemon@ target, uint8 hit, float& stabModifier){};
|
||||
|
|
Loading…
Reference in New Issue