36 if (partyMembers.empty())
42 bool anyAlive =
false;
45 if (p !=
nullptr && p->hp > 0)
60 target = partyMembers[rand() % partyMembers.size()];
61 }
while (target ==
nullptr || target->
hp <= 0);
68 if (target ==
nullptr ||
skill ==
nullptr)
71 return {
false, 0,
false,
"Miss"};
88 bool canAfford = *resource >=
skill->cost;
91 return {
false, 0,
false,
skill->name};
94 std::string targetLog =
name +
" targets " + target->
name +
"\n";
96 *resource -=
skill->cost;
101 return {
false, 0,
false, targetLog +
"Miss"};
108 damage = (u32)(damage * 0.4f);
111 bool oneMoreResult =
false;
117 oneMoreResult =
true;
122 return {
true, -(s32)damage, oneMoreResult, targetLog +
skill->name};
131 return ae::q20_12_t{0};
140 return (
math.sqrt(
math.div(ae::q20_12_t{skill.movePower * 6 * atk},
141 ae::q20_12_t{8 * defStats->en + defender.armour.defense})) *
142 ae::q20_12_t{9} * levelDifference) *
147 return ((
math.sqrt(
math.div(ae::q20_12_t{skill.movePower * 6 * atk},
148 ae::q20_12_t{8 * defStats->en + defender.armour.defense})) *
149 ae::q20_12_t{9} * levelDifference -
155 return ae::q20_12_t{0};
161 return ae::q20_12_t{0.6};
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 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 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.
ae::q20_12_t currentTurnOrderAgility
ParticipantType participantType
virtual BattleStats * getBattleStats()=0
Basic stats / affinities. Used by Personas or directly by Enemies.
void onDead(Event::BattleResult &battleResult) override
ae::q20_12_t getTeamMultiplier() override
EnemyProfile enemyProfile
BattleParticipant * pickTarget(etl::vector< BattleParticipant *, 13 > &partyMembers)
void setCurrentTurnOrderAgility(ae::q20_12_t boost)
Enemy(const EnemyProfile &iEnemyProfile)
BattlePhase getInitalTurnPhase() override
ae::q20_12_t calculateBaseDamage(BattleParticipant &defender, Skill &skill) override
TurnResult resolve(BattleParticipant *target, Skill *skill)
Holds data on how the battle concluded.
Result of a singular turn. Note that currently multi target skills do use a seperate turn result for ...