Add Damage library script hooks.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "DamageLibrary.hpp"
|
||||
#include "../ScriptHandling/ScriptMacros.cpp"
|
||||
|
||||
using namespace CreatureLib::Battling;
|
||||
int DamageLibrary::GetDamage(ExecutingAttack* attack, Creature* target, uint8_t hitIndex) const {
|
||||
@@ -6,22 +7,22 @@ int DamageLibrary::GetDamage(ExecutingAttack* attack, Creature* target, uint8_t
|
||||
auto hit = attack->GetAttackDataForTarget(target)->GetHit(hitIndex);
|
||||
auto bp = hit->GetBasePower();
|
||||
auto statMod = GetStatModifier(attack, target, hitIndex);
|
||||
// HOOK: Modify stat modifier
|
||||
int damage = static_cast<int>((((levelMod * static_cast<float>(bp) * statMod) / 50) + 2) *
|
||||
GetDamageModifier(attack, target, hitIndex));
|
||||
// HOOK: Override damage
|
||||
HOOK(ModifyStatModifier, attack, attack, target, hitIndex, &statMod);
|
||||
int32_t damage = static_cast<int32_t>((((levelMod * static_cast<float>(bp) * statMod) / 50) + 2) *
|
||||
GetDamageModifier(attack, target, hitIndex));
|
||||
HOOK(OverrideDamage, attack, attack, target, hitIndex, &damage);
|
||||
return damage;
|
||||
}
|
||||
|
||||
int DamageLibrary::GetBasePower(ExecutingAttack* attack, Creature* target, uint8_t hitIndex) const {
|
||||
auto bp = attack->GetAttack()->GetAttack()->GetBasePower();
|
||||
// HOOK: modify base power.
|
||||
HOOK(OverrideBasePower, attack, attack, target, hitIndex, &bp);
|
||||
return bp;
|
||||
}
|
||||
|
||||
float DamageLibrary::GetStatModifier(ExecutingAttack* attack, Creature* target, uint8_t hitIndex) const {
|
||||
auto user = attack->GetUser();
|
||||
// HOOK: allow overriding for which users stat we use.
|
||||
HOOK(ChangeDamageStatsUser, attack, attack, target, hitIndex, &user);
|
||||
auto hit = attack->GetAttackDataForTarget(target)->GetHit(hitIndex);
|
||||
Core::Statistic offensiveStat;
|
||||
Core::Statistic defensiveStat;
|
||||
@@ -34,9 +35,9 @@ float DamageLibrary::GetStatModifier(ExecutingAttack* attack, Creature* target,
|
||||
}
|
||||
|
||||
auto bypassDefensive = hit->IsCritical() && target->GetStatBoost(defensiveStat) > 0;
|
||||
// HOOK: allow bypassing defensive stat modifiers.
|
||||
HOOK(BypassDefensiveStat, attack, attack, target, hitIndex, &bypassDefensive);
|
||||
auto bypassOffensive = hit->IsCritical() && user->GetStatBoost(offensiveStat) < 0;
|
||||
// HOOK: Allow bypassing offensive stat modifiers.
|
||||
HOOK(BypassOffensiveStat, attack, attack, target, hitIndex, &bypassOffensive);
|
||||
|
||||
float offensiveValue;
|
||||
float defensiveValue;
|
||||
@@ -59,6 +60,6 @@ float DamageLibrary::GetDamageModifier(ExecutingAttack* attack, Creature* target
|
||||
float mod = 1;
|
||||
auto hit = attack->GetAttackDataForTarget(target)->GetHit(hitIndex);
|
||||
mod *= hit->GetEffectiveness();
|
||||
// HOOK: Modify damage modifier.
|
||||
HOOK(ModifyDamageModifier, attack, attack, target, hitIndex, &mod);
|
||||
return mod;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user