persona-3-dual
A DS demake of Persona 3
Loading...
Searching...
No Matches
PartyMember.cpp
Go to the documentation of this file.
1#include "PartyMember.hpp"
3#include "core/logger.hpp"
4#include <fpm/math.hpp>
5
6PartyMember::PartyMember(const CharacterProfile& iCharacterProfile) : characterProfile(iCharacterProfile)
7
8{
10 maxHp = characterProfile.maxHp;
12 maxSp = characterProfile.maxSp;
15
16 baseAttackAction = characterProfile.baseAttackAction;
17 participantType = characterProfile.participantType;
18
19 armourType = characterProfile.armourType;
20 armour = characterProfile.armour;
22 weaponType = characterProfile.weaponType;
23 weapon = characterProfile.weapon;
24 personas = characterProfile.personas;
26}
27
29{
30 if (curPersona == nullptr)
31 {
32 logMessage(LogSeverity::ERROR, "Called with null curPersona");
33 return ae::q20_12_t{0};
34 }
35
36 BattleStats* defStats = defender.getBattleStats();
37 if (!defStats || defStats->en == 0)
38 {
39 logMessage(LogSeverity::ERROR, "Invalid defender battleStats");
40 return ae::q20_12_t{0};
41 }
42
43 u32 atk = BattleCalcs::getAtk(curPersona->battleStats, skill);
44 ae::q20_12_t levelDifference = BattleCalcs::getLevelDifference(lv, defender.lv);
45 ae::q20_12_t affinityMtp = BattleCalcs::getAffinityMtp(*defStats, skill);
46 u32 movePower = (skill.skillType == SkillType::RegularAttack) ? (weapon.weaponPower / 2) : skill.movePower;
47
48 return fpm::floor(math.sqrt(math.div(ae::q20_12_t{movePower * 15 * atk}, ae::q20_12_t{defStats->en})) *
49 ae::q20_12_t{2} * levelDifference * affinityMtp);
50}
51
53{
54 return ae::q20_12_t{1.0};
55}
56
58{
59 if (curPersona == nullptr)
60 {
61 currentTurnOrderAgility = ae::q20_12_t{0};
62 return;
63 }
64 currentTurnOrderAgility = ae::q20_12_t{curPersona->battleStats.ag} * boost;
65}
66
71
73{
74 //TODO: clear ailments, buffs etc in the future as they get wiped when revived
75}
76
78{
79 if (hp <= 0 || knockedDown)
80 {
81 return false;
82 }
83
84 return true;
85}
86
88{
89 return action->possibleUsers == ParticipantType::Party;
90}
BattlePhase
@ RegularAttack
Definition SkillType.hpp:5
void logMessage(LogSeverity severity, std::string_view message, std::source_location location)
Logs a diagnostic message and halts only for fatal messages.
Definition logger.cpp:110
Util to handle error logging.
ParticipantType possibleUsers
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 u32 getAtk(BattleStats &attackerStats, Skill &skill)
Gets correct stat for damage calculations based on skill type.
Participant of battle.
ae::q20_12_t currentTurnOrderAgility
ParticipantType participantType
virtual BattleStats * getBattleStats()=0
Basic stats / affinities. Used by Personas or directly by Enemies.
Holds character data which a battleParticipant is created from.
Holds data on how the battle concluded.
ae::q20_12_t getTeamMultiplier() override
ArmourType armourType
etl::vector< PersonaBase *, 13 > personas
WeaponType weaponType
MathManager & math
virtual bool actorCanUse(ActionBase *action)
ae::q20_12_t calculateBaseDamage(BattleParticipant &defender, Skill &skill) override
void setCurrentTurnOrderAgility(ae::q20_12_t boost) override
bool canParticipateInAllOutAttack()
BattlePhase getInitalTurnPhase() override
PersonaBase * curPersona
CharacterProfile characterProfile
PartyMember(const CharacterProfile &iCharacterProfile)
void onDead(Event::BattleResult &battleResult) override
u32 movePower
Definition Skill.hpp:15
SkillType skillType
Definition Skill.hpp:16