Adds hook to prevent critical hits.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2021-11-21 10:46:02 +01:00
parent f811fc0654
commit 44dbb5601f
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
2 changed files with 9 additions and 1 deletions

View File

@ -224,7 +224,13 @@ void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, const ArbUt::Bo
auto effectiveness = typeLibrary->GetEffectiveness(hitType, target->GetTypes());
HOOK(ChangeEffectiveness, attack, attack, target.GetRaw(), hitIndex, &effectiveness)
hit.SetEffectiveness(effectiveness);
bool canBeCritical = true;
HOOK(BlockCritical, attack, attack, target.GetRaw(), hitIndex, &canBeCritical);
if (canBeCritical) {
hit.SetCritical(miscLibrary->IsCritical(attack, target.GetRaw(), hitIndex));
} else {
hit.SetCritical(false);
}
hit.SetBasePower(dmgLibrary->GetBasePower(attack, target.GetRaw(), hitIndex, hit));
hit.SetDamage(dmgLibrary->GetDamage(attack, target.GetRaw(), hitIndex, hit));

View File

@ -62,6 +62,8 @@ namespace CreatureLib::Battling {
[[maybe_unused]] u8 hitNumber, [[maybe_unused]] u8* outType){};
virtual void ChangeEffectiveness([[maybe_unused]] ExecutingAttack* attack, [[maybe_unused]] Creature* target,
[[maybe_unused]] u8 hitNumber, [[maybe_unused]] float* effectiveness){};
virtual void BlockCritical([[maybe_unused]] ExecutingAttack* attack, [[maybe_unused]] Creature* target,
[[maybe_unused]] u8 hitNumber, [[maybe_unused]] bool* canBeCritical){};
virtual void OverrideBasePower([[maybe_unused]] ExecutingAttack* attack, [[maybe_unused]] Creature* target,
[[maybe_unused]] u8 hitIndex, [[maybe_unused]] u8* basePower){};