Skip to content

Commit

Permalink
Split MaxStatBaseValue & MaxStatBattleValue
Browse files Browse the repository at this point in the history
  • Loading branch information
florianessl committed Feb 18, 2025
1 parent 7ce3ef3 commit b58ff3f
Show file tree
Hide file tree
Showing 14 changed files with 200 additions and 90 deletions.
78 changes: 66 additions & 12 deletions src/exe_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,17 @@ namespace ExeConstants::RT_2K {
not_def<T::MaxActorSP>(),
not_def<T::MaxEnemyHP>(),
not_def<T::MaxEnemySP>(),
not_def<T::MaxStatBattleValue>(),
not_def<T::MaxStatBaseValue>(),

not_def<T::MaxAtkBaseValue>(),
not_def<T::MaxDefBaseValue>(),
not_def<T::MaxSpiBaseValue>(),
not_def<T::MaxAgiBaseValue>(),

not_def<T::MaxAtkBattleValue>(),
not_def<T::MaxDefBattleValue>(),
not_def<T::MaxSpiBattleValue>(),
not_def<T::MaxAgiBattleValue>(),

not_def<T::MaxDamageValue>(),
not_def<T::MaxExpValue>(),
not_def<T::MaxLevel>(),
Expand All @@ -125,8 +134,17 @@ namespace ExeConstants::RT_2K {
not_def<T::MaxActorSP>(),
not_def<T::MaxEnemyHP>(),
not_def<T::MaxEnemySP>(),
not_def<T::MaxStatBattleValue>(),
not_def<T::MaxStatBaseValue>(),

not_def<T::MaxAtkBaseValue>(),
not_def<T::MaxDefBaseValue>(),
not_def<T::MaxSpiBaseValue>(),
not_def<T::MaxAgiBaseValue>(),

not_def<T::MaxAtkBattleValue>(),
not_def<T::MaxDefBattleValue>(),
not_def<T::MaxSpiBattleValue>(),
not_def<T::MaxAgiBattleValue>(),

not_def<T::MaxDamageValue>(),
not_def<T::MaxExpValue>(),
not_def<T::MaxLevel>(),
Expand All @@ -148,8 +166,17 @@ namespace ExeConstants::RT_2K {
not_def<T::MaxActorSP>(),
not_def<T::MaxEnemyHP>(),
not_def<T::MaxEnemySP>(),
not_def<T::MaxStatBattleValue>(),
not_def<T::MaxStatBaseValue>(),

not_def<T::MaxAtkBaseValue>(),
not_def<T::MaxDefBaseValue>(),
not_def<T::MaxSpiBaseValue>(),
not_def<T::MaxAgiBaseValue>(),

not_def<T::MaxAtkBattleValue>(),
not_def<T::MaxDefBattleValue>(),
not_def<T::MaxSpiBattleValue>(),
not_def<T::MaxAgiBattleValue>(),

not_def<T::MaxDamageValue>(),
not_def<T::MaxExpValue>(),
not_def<T::MaxLevel>(),
Expand All @@ -176,8 +203,17 @@ namespace ExeConstants::RT_2K3 {
not_def<T::MaxActorSP>(),
not_def<T::MaxEnemyHP>(),
not_def<T::MaxEnemySP>(),
not_def<T::MaxStatBattleValue>(),
not_def<T::MaxStatBaseValue>(),

not_def<T::MaxAtkBaseValue>(),
not_def<T::MaxDefBaseValue>(),
not_def<T::MaxSpiBaseValue>(),
not_def<T::MaxAgiBaseValue>(),

not_def<T::MaxAtkBattleValue>(),
not_def<T::MaxDefBattleValue>(),
not_def<T::MaxSpiBattleValue>(),
not_def<T::MaxAgiBattleValue>(),

not_def<T::MaxDamageValue>(),
not_def<T::MaxExpValue>(),
not_def<T::MaxLevel>(),
Expand All @@ -199,8 +235,17 @@ namespace ExeConstants::RT_2K3 {
not_def<T::MaxActorSP>(),
not_def<T::MaxEnemyHP>(),
not_def<T::MaxEnemySP>(),
not_def<T::MaxStatBattleValue>(),
not_def<T::MaxStatBaseValue>(),

not_def<T::MaxAtkBaseValue>(),
not_def<T::MaxDefBaseValue>(),
not_def<T::MaxSpiBaseValue>(),
not_def<T::MaxAgiBaseValue>(),

not_def<T::MaxAtkBattleValue>(),
not_def<T::MaxDefBattleValue>(),
not_def<T::MaxSpiBattleValue>(),
not_def<T::MaxAgiBattleValue>(),

not_def<T::MaxDamageValue>(),
not_def<T::MaxExpValue>(),
not_def<T::MaxLevel>(),
Expand All @@ -222,8 +267,17 @@ namespace ExeConstants::RT_2K3 {
not_def<T::MaxActorSP>(),
not_def<T::MaxEnemyHP>(),
not_def<T::MaxEnemySP>(),
not_def<T::MaxStatBattleValue>(),
not_def<T::MaxStatBaseValue>(),

not_def<T::MaxAtkBaseValue>(),
not_def<T::MaxDefBaseValue>(),
not_def<T::MaxSpiBaseValue>(),
not_def<T::MaxAgiBaseValue>(),

not_def<T::MaxAtkBattleValue>(),
not_def<T::MaxDefBattleValue>(),
not_def<T::MaxSpiBattleValue>(),
not_def<T::MaxAgiBattleValue>(),

not_def<T::MaxDamageValue>(),
not_def<T::MaxExpValue>(),
not_def<T::MaxLevel>(),
Expand Down
29 changes: 8 additions & 21 deletions src/game_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@ int Game_Actor::MaxSpValue() const {
return Player::Constants::MaxActorSpValue();
}

int Game_Actor::MaxStatBattleValue() const {
return Player::Constants::MaxStatBattleValue();
}

int Game_Actor::MaxStatBaseValue() const {
return Player::Constants::MaxStatBaseValue();
}

int Game_Actor::MaxExpValue() const {
return Player::Constants::MaxExpValue();
}
Expand Down Expand Up @@ -488,7 +480,7 @@ int Game_Actor::GetBaseAtk(Weapon weapon, bool mod, bool equip) const {
ForEachEquipment<true,true>(GetWholeEquipment(), [&](auto& item) { n += item.atk_points1; }, weapon);
}

return Utils::Clamp(n, 1, MaxStatBaseValue());
return Utils::Clamp(n, 1, Player::Constants::MaxAtkBaseValue());
}

int Game_Actor::GetBaseAtk(Weapon weapon) const {
Expand All @@ -511,7 +503,7 @@ int Game_Actor::GetBaseDef(Weapon weapon, bool mod, bool equip) const {
ForEachEquipment<true,true>(GetWholeEquipment(), [&](auto& item) { n += item.def_points1; }, weapon);
}

return Utils::Clamp(n, 1, MaxStatBaseValue());
return Utils::Clamp(n, 1, Player::Constants::MaxDefBaseValue());
}

int Game_Actor::GetBaseDef(Weapon weapon) const {
Expand All @@ -534,7 +526,7 @@ int Game_Actor::GetBaseSpi(Weapon weapon, bool mod, bool equip) const {
ForEachEquipment<true,true>(GetWholeEquipment(), [&](auto& item) { n += item.spi_points1; }, weapon);
}

return Utils::Clamp(n, 1, MaxStatBaseValue());
return Utils::Clamp(n, 1, Player::Constants::MaxSpiBaseValue());
}

int Game_Actor::GetBaseSpi(Weapon weapon) const {
Expand All @@ -557,7 +549,7 @@ int Game_Actor::GetBaseAgi(Weapon weapon, bool mod, bool equip) const {
ForEachEquipment<true,true>(GetWholeEquipment(), [&](auto& item) { n += item.agi_points1; }, weapon);
}

return Utils::Clamp(n, 1, MaxStatBaseValue());
return Utils::Clamp(n, 1, Player::Constants::MaxAgiBaseValue());
}

int Game_Actor::GetBaseAgi(Weapon weapon) const {
Expand Down Expand Up @@ -1134,11 +1126,6 @@ static int ClampMaxSpMod(int sp, const Game_Actor* actor) {
return Utils::Clamp(sp, -limit, limit);
}

static int ClampStatMod(int value, const Game_Actor* actor) {
auto limit = actor->MaxStatBaseValue();
return Utils::Clamp(value, -limit, limit);
}

void Game_Actor::SetBaseMaxHp(int maxhp) {
int new_hp_mod = data.hp_mod + (maxhp - GetBaseMaxHp());
data.hp_mod = ClampMaxHpMod(new_hp_mod, this);
Expand All @@ -1165,22 +1152,22 @@ int Game_Actor::SetSp(int sp) {

void Game_Actor::SetBaseAtk(int atk) {
int new_attack_mod = data.attack_mod + (atk - GetBaseAtk());
data.attack_mod = ClampStatMod(new_attack_mod, this);
data.attack_mod = Utils::Clamp(new_attack_mod, -Player::Constants::MaxAtkBaseValue(), Player::Constants::MaxAtkBaseValue());
}

void Game_Actor::SetBaseDef(int def) {
int new_defense_mod = data.defense_mod + (def - GetBaseDef());
data.defense_mod = ClampStatMod(new_defense_mod, this);
data.defense_mod = Utils::Clamp(new_defense_mod, -Player::Constants::MaxDefBaseValue(), Player::Constants::MaxDefBaseValue());
}

void Game_Actor::SetBaseSpi(int spi) {
int new_spirit_mod = data.spirit_mod + (spi - GetBaseSpi());
data.spirit_mod = ClampStatMod(new_spirit_mod, this);
data.spirit_mod = Utils::Clamp(new_spirit_mod, -Player::Constants::MaxSpiBaseValue(), Player::Constants::MaxSpiBaseValue());
}

void Game_Actor::SetBaseAgi(int agi) {
int new_agility_mod = data.agility_mod + (agi - GetBaseAgi());
data.agility_mod = ClampStatMod(new_agility_mod, this);
data.agility_mod = Utils::Clamp(new_agility_mod, -Player::Constants::MaxAgiBaseValue(), Player::Constants::MaxAgiBaseValue());
}

Game_Actor::RowType Game_Actor::GetBattleRow() const {
Expand Down
4 changes: 0 additions & 4 deletions src/game_actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,6 @@ class Game_Actor final : public Game_Battler {

int MaxSpValue() const override;

int MaxStatBattleValue() const override;

int MaxStatBaseValue() const override;

int MaxExpValue() const;

virtual PermanentStates GetPermanentStates() const override;
Expand Down
16 changes: 8 additions & 8 deletions src/game_battler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,35 +544,35 @@ static int AdjustParam(int base, int mod, int maxval, Span<const int16_t> states
}

int Game_Battler::CalcValueAfterAtkStates(int value) const {
return AdjustParam(value, 0, MaxStatBattleValue(), GetInflictedStates(), &lcf::rpg::State::affect_attack);
return AdjustParam(value, 0, Player::Constants::MaxAtkBattleValue(), GetInflictedStates(), &lcf::rpg::State::affect_attack);
}

int Game_Battler::CalcValueAfterDefStates(int value) const {
return AdjustParam(value, 0, MaxStatBattleValue(), GetInflictedStates(), &lcf::rpg::State::affect_defense);
return AdjustParam(value, 0, Player::Constants::MaxDefBattleValue(), GetInflictedStates(), &lcf::rpg::State::affect_defense);
}

int Game_Battler::CalcValueAfterSpiStates(int value) const {
return AdjustParam(value, 0, MaxStatBattleValue(), GetInflictedStates(), &lcf::rpg::State::affect_spirit);
return AdjustParam(value, 0, Player::Constants::MaxSpiBattleValue(), GetInflictedStates(), &lcf::rpg::State::affect_spirit);
}

int Game_Battler::CalcValueAfterAgiStates(int value) const {
return AdjustParam(value, 0, MaxStatBattleValue(), GetInflictedStates(), &lcf::rpg::State::affect_agility);
return AdjustParam(value, 0, Player::Constants::MaxAgiBattleValue(), GetInflictedStates(), &lcf::rpg::State::affect_agility);
}

int Game_Battler::GetAtk(Weapon weapon) const {
return AdjustParam(GetBaseAtk(weapon), atk_modifier, MaxStatBattleValue(), GetInflictedStates(), &lcf::rpg::State::affect_attack);
return AdjustParam(GetBaseAtk(weapon), atk_modifier, Player::Constants::MaxAtkBattleValue(), GetInflictedStates(), &lcf::rpg::State::affect_attack);
}

int Game_Battler::GetDef(Weapon weapon) const {
return AdjustParam(GetBaseDef(weapon), def_modifier, MaxStatBattleValue(), GetInflictedStates(), &lcf::rpg::State::affect_defense);
return AdjustParam(GetBaseDef(weapon), def_modifier, Player::Constants::MaxDefBattleValue(), GetInflictedStates(), &lcf::rpg::State::affect_defense);
}

int Game_Battler::GetSpi(Weapon weapon) const {
return AdjustParam(GetBaseSpi(weapon), spi_modifier, MaxStatBattleValue(), GetInflictedStates(), &lcf::rpg::State::affect_spirit);
return AdjustParam(GetBaseSpi(weapon), spi_modifier, Player::Constants::MaxSpiBattleValue(), GetInflictedStates(), &lcf::rpg::State::affect_spirit);
}

int Game_Battler::GetAgi(Weapon weapon) const {
return AdjustParam(GetBaseAgi(weapon), agi_modifier, MaxStatBattleValue(), GetInflictedStates(), &lcf::rpg::State::affect_agility);
return AdjustParam(GetBaseAgi(weapon), agi_modifier, Player::Constants::MaxAgiBattleValue(), GetInflictedStates(), &lcf::rpg::State::affect_agility);
}

int Game_Battler::GetDisplayX() const {
Expand Down
4 changes: 0 additions & 4 deletions src/game_battler.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,6 @@ class Game_Battler {

virtual int MaxSpValue() const = 0;

virtual int MaxStatBattleValue() const = 0;

virtual int MaxStatBaseValue() const = 0;

/**
* Gets if battler has a state.
*
Expand Down
8 changes: 0 additions & 8 deletions src/game_enemy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,6 @@ int Game_Enemy::MaxSpValue() const {
return Player::Constants::MaxEnemySpValue();
}

int Game_Enemy::MaxStatBattleValue() const {
return Player::Constants::MaxStatBattleValue();
}

int Game_Enemy::MaxStatBaseValue() const {
return Player::Constants::MaxStatBaseValue();
}

int Game_Enemy::GetStateProbability(int state_id) const {
int rate = 1; // Enemies have only B as the default state rank

Expand Down
4 changes: 0 additions & 4 deletions src/game_enemy.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ class Game_Enemy final : public Game_Battler

int MaxSpValue() const override;

int MaxStatBattleValue() const override;

int MaxStatBaseValue() const override;

Point GetOriginalPosition() const override;

void ResetBattle() override;
Expand Down
75 changes: 69 additions & 6 deletions src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1679,23 +1679,86 @@ int32_t Player::Constants::MaxEnemySpValue() {
return val;
}

int32_t Player::Constants::MaxStatBaseValue() {
int32_t Player::Constants::MaxAtkBaseValue() {
auto& val = lcf::Data::system.easyrpg_max_stat_base_value;
TryGetOverriddenConstant(GameConstantType::MaxStatBaseValue, val);
TryGetOverriddenConstant(GameConstantType::MaxAtkBaseValue, val);
if (val == -1) {
if (Player::IsPatchItalian()) {
return 9'999;
}
return 999;
return max_stat_base_value;
}
return val;
}

int32_t Player::Constants::MaxDefBaseValue() {
auto& val = lcf::Data::system.easyrpg_max_stat_base_value;
TryGetOverriddenConstant(GameConstantType::MaxDefBaseValue, val);
if (val == -1) {
if (Player::IsPatchItalian()) {
return 9'999;
}
return max_stat_base_value;
}
return val;
}

int32_t Player::Constants::MaxSpiBaseValue() {
auto& val = lcf::Data::system.easyrpg_max_stat_base_value;
TryGetOverriddenConstant(GameConstantType::MaxSpiBaseValue, val);
if (val == -1) {
if (Player::IsPatchItalian()) {
return 9'999;
}
return max_stat_base_value;
}
return val;
}

int32_t Player::Constants::MaxStatBattleValue() {
int32_t Player::Constants::MaxAgiBaseValue() {
auto& val = lcf::Data::system.easyrpg_max_stat_base_value;
TryGetOverriddenConstant(GameConstantType::MaxAgiBaseValue, val);
if (val == -1) {
if (Player::IsPatchItalian()) {
return 9'999;
}
return max_stat_base_value;
}
return val;
}

int32_t Player::Constants::MaxAtkBattleValue() {
auto& val = lcf::Data::system.easyrpg_max_stat_battle_value;
TryGetOverriddenConstant(GameConstantType::MaxStatBattleValue, val);
TryGetOverriddenConstant(GameConstantType::MaxAtkBattleValue, val);
if (val == -1) {
return 9'999;
return max_stat_battle_value;
}
return val;
}

int32_t Player::Constants::MaxDefBattleValue() {
auto& val = lcf::Data::system.easyrpg_max_stat_battle_value;
TryGetOverriddenConstant(GameConstantType::MaxDefBattleValue, val);
if (val == -1) {
return max_stat_battle_value;
}
return val;
}

int32_t Player::Constants::MaxSpiBattleValue() {
auto& val = lcf::Data::system.easyrpg_max_stat_battle_value;
TryGetOverriddenConstant(GameConstantType::MaxSpiBattleValue, val);
if (val == -1) {
return max_stat_battle_value;
}
return val;
}

int32_t Player::Constants::MaxAgiBattleValue() {
auto& val = lcf::Data::system.easyrpg_max_stat_battle_value;
TryGetOverriddenConstant(GameConstantType::MaxAgiBattleValue, val);
if (val == -1) {
return max_stat_battle_value;
}
return val;
}
Expand Down
Loading

0 comments on commit b58ff3f

Please sign in to comment.