| 48 | } |
| 49 | |
| 50 | static int CmpEquip(const Game_Actor* actor, const lcf::rpg::Item* new_item) { |
| 51 | auto atk = actor->GetBaseAtk(Game_Battler::WeaponAll, true, false); |
| 52 | auto def = actor->GetBaseDef(Game_Battler::WeaponAll, true, false); |
| 53 | auto spi = actor->GetBaseSpi(Game_Battler::WeaponAll, true, false); |
| 54 | auto agi = actor->GetBaseAgi(Game_Battler::WeaponAll, true, false); |
| 55 | |
| 56 | auto add_item = [&](const lcf::rpg::Item* item, int mod = 1) { |
| 57 | if (item) { |
| 58 | atk += item->atk_points1 * mod; |
| 59 | def += item->def_points1 * mod; |
| 60 | spi += item->spi_points1 * mod; |
| 61 | agi += item->agi_points1 * mod; |
| 62 | } |
| 63 | }; |
| 64 | |
| 65 | for (int i = 1; i <= 5; i++) { |
| 66 | auto* count_item = actor->GetEquipment(i); |
| 67 | add_item(count_item, 1); |
| 68 | } |
| 69 | |
| 70 | atk = Utils::Clamp(atk, 1, 999); |
| 71 | def = Utils::Clamp(def, 1, 999); |
| 72 | spi = Utils::Clamp(spi, 1, 999); |
| 73 | agi = Utils::Clamp(agi, 1, 999); |
| 74 | |
| 75 | int old_score = atk + def + spi + agi; |
| 76 | |
| 77 | atk = actor->GetBaseAtk(Game_Battler::WeaponAll, true, false); |
| 78 | def = actor->GetBaseDef(Game_Battler::WeaponAll, true, false); |
| 79 | spi = actor->GetBaseSpi(Game_Battler::WeaponAll, true, false); |
| 80 | agi = actor->GetBaseAgi(Game_Battler::WeaponAll, true, false); |
| 81 | |
| 82 | for (int i = 1; i <= 5; i++) { |
| 83 | auto* count_item = actor->GetEquipment(i); |
| 84 | add_item(count_item, 1); |
| 85 | } |
| 86 | |
| 87 | auto* old_item = actor->GetEquipment(new_item->type); |
| 88 | // If its a weapon or shield, get the other hand |
| 89 | const lcf::rpg::Item* other_old_item = nullptr; |
| 90 | if (new_item->type == lcf::rpg::Item::Type_weapon) { |
| 91 | other_old_item = actor->GetEquipment(lcf::rpg::Item::Type_shield); |
| 92 | } else if (new_item->type == lcf::rpg::Item::Type_shield) { |
| 93 | other_old_item = actor->GetEquipment(lcf::rpg::Item::Type_weapon); |
| 94 | } |
| 95 | |
| 96 | add_item(old_item, -1); |
| 97 | // If other hand had a two handed weapon, or we considering a 2 handed weapon, remove the other hand. |
| 98 | if (new_item && other_old_item && |
| 99 | ((other_old_item->type == lcf::rpg::Item::Type_weapon && other_old_item->two_handed) || (new_item->type == lcf::rpg::Item::Type_weapon && new_item->two_handed))) { |
| 100 | add_item(other_old_item, -1); |
| 101 | } |
| 102 | add_item(new_item, 1); |
| 103 | |
| 104 | int limit = actor->MaxStatBaseValue(); |
| 105 | |
| 106 | atk = Utils::Clamp(atk, 1, limit); |
| 107 | def = Utils::Clamp(def, 1, limit); |
no test coverage detected