Add Damage library script hooks.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
5e29f50ea1
commit
b886f0aebf
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -38,6 +38,19 @@ namespace CreatureLib::Battling {
|
|||
virtual void IsInvulnerable(ExecutingAttack* attack, Creature* target, bool* outResult){};
|
||||
virtual void OnAttackMiss(ExecutingAttack* attack, Creature* target){};
|
||||
virtual void ChangeAttackType(ExecutingAttack* attack, Creature* target, uint8_t hitNumber, uint8_t* outType){};
|
||||
|
||||
virtual void OverrideBasePower(ExecutingAttack* attack, Creature* target, uint8_t hitIndex,
|
||||
uint8_t* basePower){};
|
||||
virtual void ChangeDamageStatsUser(ExecutingAttack* attack, Creature* target, uint8_t hitIndex,
|
||||
Creature** statsUser){};
|
||||
|
||||
virtual void BypassDefensiveStat(ExecutingAttack* attack, Creature* target, uint8_t hitIndex, bool* bypass){};
|
||||
virtual void BypassOffensiveStat(ExecutingAttack* attack, Creature* target, uint8_t hitIndex, bool* bypass){};
|
||||
virtual void ModifyStatModifier(ExecutingAttack* attack, Creature* target, uint8_t hitIndex, float* modifier){};
|
||||
virtual void ModifyDamageModifier(ExecutingAttack* attack, Creature* target, uint8_t hitIndex,
|
||||
float* modifier){};
|
||||
virtual void OverrideDamage(ExecutingAttack* attack, Creature* target, uint8_t hitIndex, int32_t* damage){};
|
||||
|
||||
virtual void OnStatusMove(const ExecutingAttack* attack, Creature* target, uint8_t hitNumber){};
|
||||
virtual void PreventSecondaryEffects(const ExecutingAttack* attack, Creature* target, uint8_t hitNumber,
|
||||
bool* outResult){};
|
||||
|
|
Loading…
Reference in New Issue