3#include <aegis/ndsTypes.hpp>
9 ae::q20_12_t range = ae::q20_12_t{95} + ae::q20_12_t{(rand() % 11)};
11 static_cast<u32
>(fpm::trunc(MathManager::getInstance().div(base * ae::q20_12_t{range}, ae::q20_12_t{100}))),
22 if (!attackerStatsPtr || !defenderStatsPtr)
36 ae::q20_12_t baseAccuracy = math.
div(ae::q20_12_t{attackerStats.
ag + 200}, ae::q20_12_t{defenderStats.
ag + 200});
37 ae::q20_12_t multipliedAccuracy;
40 ae::q20_12_t shoeMultiplier =
41 math.
div(ae::q20_12_t{attackerStats.
ag + 200},
42 math.
div(ae::q20_12_t{defender.
shoe.
evasion}, ae::q20_12_t{2}) + ae::q20_12_t{200});
43 multipliedAccuracy = baseAccuracy * ae::q20_12_t{skill.
hitRate} * shoeMultiplier;
47 multipliedAccuracy = baseAccuracy * ae::q20_12_t{skill.
hitRate};
50 multipliedAccuracy = std::clamp(multipliedAccuracy, ae::q20_12_t{50}, ae::q20_12_t{99});
51 return multipliedAccuracy > ae::q20_12_t{rand() % 100};
66 ae::q20_12_t base = fpm::floor(ae::q20_12_t{skill.
movePower + magicBoost} * teamMultiplier);
67 ae::q20_12_t range = ae::q20_12_t{95} + ae::q20_12_t{(rand() % 11)};
69 return static_cast<u32
>(fpm::floor(MathManager::getInstance().div(base * range, ae::q20_12_t{100})));
82 ae::q20_12_t base = fpm::trunc(
83 math.
sqrt(math.
div(ae::q20_12_t{(attacker.weapon.weaponPower / 2) * 15 * attackerStats.st},
84 ae::q20_12_t{defenderStats.en})) *
85 ae::q20_12_t{1.6} * (levelDifference * levelDifference) * affinityMtp * ae::q20_12_t{participantCount});
87 ae::q20_12_t range = ae::q20_12_t{95} + ae::q20_12_t{(rand() % 11)};
88 return static_cast<u32
>(fpm::trunc(math.
div(base * range, ae::q20_12_t{100})));
92 ae::q20_12_t{0.5}, ae::q20_12_t{0.51}, ae::q20_12_t{0.53}, ae::q20_12_t{0.59}, ae::q20_12_t{0.66},
93 ae::q20_12_t{0.75}, ae::q20_12_t{0.84}, ae::q20_12_t{0.91}, ae::q20_12_t{0.97}, ae::q20_12_t{0.99},
94 ae::q20_12_t{1.0}, ae::q20_12_t{1.0}, ae::q20_12_t{1.0}, ae::q20_12_t{1.0}, ae::q20_12_t{1.01},
95 ae::q20_12_t{1.03}, ae::q20_12_t{1.09}, ae::q20_12_t{1.16}, ae::q20_12_t{1.25}, ae::q20_12_t{1.34},
96 ae::q20_12_t{1.41}, ae::q20_12_t{1.47}, ae::q20_12_t{1.49}, ae::q20_12_t{1.5}};
128 s32 diff = attackerLevel - defenderLevel;
129 diff = std::clamp(diff, (s32)-13, (s32)10);
142 return ae::q20_12_t{1.25};
144 return ae::q20_12_t{0.5};
146 return ae::q20_12_t{0.0};
148 return ae::q20_12_t{-1.0};
150 return ae::q20_12_t{-2.0};
153 return ae::q20_12_t{1.0};
159 uint8_t index = (magic - 1) / 5;
160 index = std::clamp(index, (uint8_t)0, (uint8_t)19);
ae::q20_12_t sqrt(ae::q20_12_t v)
Computes the square root of a Q20.12 value.
ae::q20_12_t div(ae::q20_12_t num, ae::q20_12_t den)
Divides two Q20.12 values.
void logMessage(LogSeverity severity, std::string_view message, std::source_location location)
Logs a diagnostic message and halts only for fatal messages.
Util to handle error logging.
static ae::q20_12_t getLevelDifference(u32 attackerLevel, u32 defenderLevel)
Gets a multiplier used for damage calcs based on an arbitrary hardcoded table.
static uint8_t getMagicBoostHeal(uint8_t &magic)
Calculate healing bonus based on an arbitrary hardcoded table.
static u32 healing(BattleParticipant &user, Skill &skill)
Calculates heal of a skill.
static u32 allOutAttack(Player &attacker, BattleParticipant &defender, u32 participantCount)
Calculates damage of an All out attack.
static const ae::q20_12_t levelMultipliers[24]
static ae::q20_12_t getAffinityMtp(BattleStats &battleStats, Skill &skill)
Calculate damage multiplier based on resistance & skill affinity.
static bool hit(BattleParticipant &attacker, BattleParticipant &defender, Skill &skill)
Calculates if a skill hit the target.
static const uint8_t magicBoostTableHeal[20]
static u32 attack(BattleParticipant &attacker, BattleParticipant &defender, Skill &skill)
Calculates damage of an attack.
static u32 getAtk(BattleStats &attackerStats, Skill &skill)
Gets correct stat for damage calculations based on skill type.
ParticipantType participantType
virtual ae::q20_12_t getTeamMultiplier()=0
virtual BattleStats * getBattleStats()=0
virtual ae::q20_12_t calculateBaseDamage(BattleParticipant &defender, Skill &skill)=0
Basic stats / affinities. Used by Personas or directly by Enemies.
BattleStats * getBattleStats() override
static Skill allOutAttack