| 91 | } |
| 92 | |
| 93 | void Scene_Equip::UpdateStatusWindow() { |
| 94 | if (equip_window->GetActive()) { |
| 95 | equipstatus_window->ClearParameters(); |
| 96 | } else if (item_window->GetActive()) { |
| 97 | const lcf::rpg::Item* current_item = item_window->GetItem(); |
| 98 | |
| 99 | const auto eidx = equip_window->GetIndex(); |
| 100 | const auto& actor = *actors[actor_index]; |
| 101 | |
| 102 | auto atk = actor.GetBaseAtk(Game_Battler::WeaponAll, true, false); |
| 103 | auto def = actor.GetBaseDef(Game_Battler::WeaponAll, true, false); |
| 104 | auto spi = actor.GetBaseSpi(Game_Battler::WeaponAll, true, false); |
| 105 | auto agi = actor.GetBaseAgi(Game_Battler::WeaponAll, true, false); |
| 106 | |
| 107 | auto add_item = [&](const lcf::rpg::Item* item, int mod = 1) { |
| 108 | if (item) { |
| 109 | atk += item->atk_points1 * mod; |
| 110 | def += item->def_points1 * mod; |
| 111 | spi += item->spi_points1 * mod; |
| 112 | agi += item->agi_points1 * mod; |
| 113 | } |
| 114 | }; |
| 115 | |
| 116 | for (int i = 1; i <= 5; i++) { |
| 117 | auto* count_item = actor.GetEquipment(i); |
| 118 | add_item(count_item, 1); |
| 119 | } |
| 120 | |
| 121 | auto* old_item = actor.GetEquipment(eidx + 1); |
| 122 | // If its a weapon or shield, get the other hand |
| 123 | const lcf::rpg::Item* other_old_item = nullptr; |
| 124 | if (eidx == 0) { |
| 125 | other_old_item = actor.GetEquipment(eidx + 2); |
| 126 | } else if (eidx == 1) { |
| 127 | other_old_item = actor.GetEquipment(eidx); |
| 128 | } |
| 129 | |
| 130 | add_item(old_item, -1); |
| 131 | // If other hand had a two handed weapon, or we considering a 2 handed weapon, remove the other hand. |
| 132 | if (current_item && other_old_item && |
| 133 | ((other_old_item->type == lcf::rpg::Item::Type_weapon && other_old_item->two_handed) || (current_item->type == lcf::rpg::Item::Type_weapon && current_item->two_handed))) { |
| 134 | add_item(other_old_item, -1); |
| 135 | } |
| 136 | add_item(current_item, 1); |
| 137 | |
| 138 | int limit = actor.MaxStatBaseValue(); |
| 139 | |
| 140 | atk = Utils::Clamp(atk, 1, limit); |
| 141 | def = Utils::Clamp(def, 1, limit); |
| 142 | spi = Utils::Clamp(spi, 1, limit); |
| 143 | agi = Utils::Clamp(agi, 1, limit); |
| 144 | |
| 145 | atk = actor.CalcValueAfterAtkStates(atk); |
| 146 | def = actor.CalcValueAfterDefStates(def); |
| 147 | spi = actor.CalcValueAfterSpiStates(spi); |
| 148 | agi = actor.CalcValueAfterAgiStates(agi); |
| 149 | |
| 150 | equipstatus_window->SetNewParameters(atk, def, spi, agi); |
nothing calls this directly
no test coverage detected