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 "DamageLibrary.hpp"
|
||||||
|
#include "../ScriptHandling/ScriptMacros.cpp"
|
||||||
|
|
||||||
using namespace CreatureLib::Battling;
|
using namespace CreatureLib::Battling;
|
||||||
int DamageLibrary::GetDamage(ExecutingAttack* attack, Creature* target, uint8_t hitIndex) const {
|
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 hit = attack->GetAttackDataForTarget(target)->GetHit(hitIndex);
|
||||||
auto bp = hit->GetBasePower();
|
auto bp = hit->GetBasePower();
|
||||||
auto statMod = GetStatModifier(attack, target, hitIndex);
|
auto statMod = GetStatModifier(attack, target, hitIndex);
|
||||||
// HOOK: Modify stat modifier
|
HOOK(ModifyStatModifier, attack, attack, target, hitIndex, &statMod);
|
||||||
int damage = static_cast<int>((((levelMod * static_cast<float>(bp) * statMod) / 50) + 2) *
|
int32_t damage = static_cast<int32_t>((((levelMod * static_cast<float>(bp) * statMod) / 50) + 2) *
|
||||||
GetDamageModifier(attack, target, hitIndex));
|
GetDamageModifier(attack, target, hitIndex));
|
||||||
// HOOK: Override damage
|
HOOK(OverrideDamage, attack, attack, target, hitIndex, &damage);
|
||||||
return damage;
|
return damage;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DamageLibrary::GetBasePower(ExecutingAttack* attack, Creature* target, uint8_t hitIndex) const {
|
int DamageLibrary::GetBasePower(ExecutingAttack* attack, Creature* target, uint8_t hitIndex) const {
|
||||||
auto bp = attack->GetAttack()->GetAttack()->GetBasePower();
|
auto bp = attack->GetAttack()->GetAttack()->GetBasePower();
|
||||||
// HOOK: modify base power.
|
HOOK(OverrideBasePower, attack, attack, target, hitIndex, &bp);
|
||||||
return bp;
|
return bp;
|
||||||
}
|
}
|
||||||
|
|
||||||
float DamageLibrary::GetStatModifier(ExecutingAttack* attack, Creature* target, uint8_t hitIndex) const {
|
float DamageLibrary::GetStatModifier(ExecutingAttack* attack, Creature* target, uint8_t hitIndex) const {
|
||||||
auto user = attack->GetUser();
|
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);
|
auto hit = attack->GetAttackDataForTarget(target)->GetHit(hitIndex);
|
||||||
Core::Statistic offensiveStat;
|
Core::Statistic offensiveStat;
|
||||||
Core::Statistic defensiveStat;
|
Core::Statistic defensiveStat;
|
||||||
|
@ -34,9 +35,9 @@ float DamageLibrary::GetStatModifier(ExecutingAttack* attack, Creature* target,
|
||||||
}
|
}
|
||||||
|
|
||||||
auto bypassDefensive = hit->IsCritical() && target->GetStatBoost(defensiveStat) > 0;
|
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;
|
auto bypassOffensive = hit->IsCritical() && user->GetStatBoost(offensiveStat) < 0;
|
||||||
// HOOK: Allow bypassing offensive stat modifiers.
|
HOOK(BypassOffensiveStat, attack, attack, target, hitIndex, &bypassOffensive);
|
||||||
|
|
||||||
float offensiveValue;
|
float offensiveValue;
|
||||||
float defensiveValue;
|
float defensiveValue;
|
||||||
|
@ -59,6 +60,6 @@ float DamageLibrary::GetDamageModifier(ExecutingAttack* attack, Creature* target
|
||||||
float mod = 1;
|
float mod = 1;
|
||||||
auto hit = attack->GetAttackDataForTarget(target)->GetHit(hitIndex);
|
auto hit = attack->GetAttackDataForTarget(target)->GetHit(hitIndex);
|
||||||
mod *= hit->GetEffectiveness();
|
mod *= hit->GetEffectiveness();
|
||||||
// HOOK: Modify damage modifier.
|
HOOK(ModifyDamageModifier, attack, attack, target, hitIndex, &mod);
|
||||||
return mod;
|
return mod;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,19 @@ namespace CreatureLib::Battling {
|
||||||
virtual void IsInvulnerable(ExecutingAttack* attack, Creature* target, bool* outResult){};
|
virtual void IsInvulnerable(ExecutingAttack* attack, Creature* target, bool* outResult){};
|
||||||
virtual void OnAttackMiss(ExecutingAttack* attack, Creature* target){};
|
virtual void OnAttackMiss(ExecutingAttack* attack, Creature* target){};
|
||||||
virtual void ChangeAttackType(ExecutingAttack* attack, Creature* target, uint8_t hitNumber, uint8_t* outType){};
|
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 OnStatusMove(const ExecutingAttack* attack, Creature* target, uint8_t hitNumber){};
|
||||||
virtual void PreventSecondaryEffects(const ExecutingAttack* attack, Creature* target, uint8_t hitNumber,
|
virtual void PreventSecondaryEffects(const ExecutingAttack* attack, Creature* target, uint8_t hitNumber,
|
||||||
bool* outResult){};
|
bool* outResult){};
|
||||||
|
|
Loading…
Reference in New Issue