Used ClangFormat style guide I'm happy with.
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,66 +1,64 @@
|
||||
#include "DamageLibrary.hpp"
|
||||
|
||||
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 {
|
||||
auto levelMod = static_cast<float>(2 * attack->GetUser()->GetLevel());
|
||||
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: Modify stat modifier
|
||||
int damage = static_cast<int>((((levelMod * static_cast<float>(bp) * statMod) / 50) + 2) *
|
||||
GetDamageModifier(attack, target, hitIndex));
|
||||
// HOOK: Override 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();
|
||||
//HOOK: modify base power.
|
||||
// HOOK: modify base power.
|
||||
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();
|
||||
//HOOK: allow overriding for which users stat we use.
|
||||
// HOOK: allow overriding for which users stat we use.
|
||||
auto hit = attack->GetAttackDataForTarget(target).GetHit(hitIndex);
|
||||
Core::Statistic offensiveStat;
|
||||
Core::Statistic defensiveStat;
|
||||
if (attack->GetAttack()->GetAttack()->GetCategory() == Library::AttackCategory::Physical){
|
||||
if (attack->GetAttack()->GetAttack()->GetCategory() == Library::AttackCategory::Physical) {
|
||||
offensiveStat = Core::Statistic::PhysicalAttack;
|
||||
defensiveStat = Core::Statistic::PhysicalDefense;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
offensiveStat = Core::Statistic::MagicalAttack;
|
||||
defensiveStat = Core::Statistic::MagicalDefense;
|
||||
}
|
||||
|
||||
auto bypassDefensive = hit.IsCritical() && target->GetStatBoost(defensiveStat) > 0;
|
||||
//HOOK: allow bypassing defensive stat modifiers.
|
||||
// HOOK: allow bypassing defensive stat modifiers.
|
||||
auto bypassOffensive = hit.IsCritical() && user->GetStatBoost(offensiveStat) < 0;
|
||||
//HOOK: Allow bypassing offensive stat modifiers.
|
||||
// HOOK: Allow bypassing offensive stat modifiers.
|
||||
|
||||
float offensiveValue;
|
||||
float defensiveValue;
|
||||
|
||||
if (bypassOffensive){
|
||||
if (bypassOffensive) {
|
||||
offensiveValue = user->GetFlatStat(offensiveStat);
|
||||
} else{
|
||||
} else {
|
||||
offensiveValue = user->GetBoostedStat(offensiveStat);
|
||||
}
|
||||
if (bypassDefensive){
|
||||
if (bypassDefensive) {
|
||||
defensiveValue = target->GetFlatStat(defensiveStat);
|
||||
} else{
|
||||
} else {
|
||||
defensiveValue = target->GetBoostedStat(defensiveStat);
|
||||
}
|
||||
|
||||
return offensiveValue / defensiveValue;
|
||||
}
|
||||
|
||||
float DamageLibrary::GetDamageModifier(ExecutingAttack *attack, Creature *target, uint8_t hitIndex) const{
|
||||
float DamageLibrary::GetDamageModifier(ExecutingAttack* attack, Creature* target, uint8_t hitIndex) const {
|
||||
float mod = 1;
|
||||
auto hit = attack->GetAttackDataForTarget(target).GetHit(hitIndex);
|
||||
mod *= hit.GetEffectiveness();
|
||||
//HOOK: Modify damage modifier.
|
||||
// HOOK: Modify damage modifier.
|
||||
return mod;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user