| 356 | } |
| 357 | |
| 358 | void Game_Actor::ChangeEquipment(int equip_type, int item_id) { |
| 359 | if (item_id != 0 && !IsItemUsable(item_id)) { |
| 360 | return; |
| 361 | } |
| 362 | |
| 363 | int prev_item = SetEquipment(equip_type, item_id); |
| 364 | |
| 365 | if (prev_item != 0) { |
| 366 | Main_Data::game_party->AddItem(prev_item, 1); |
| 367 | } |
| 368 | if (item_id != 0) { |
| 369 | Main_Data::game_party->RemoveItem(item_id, 1); |
| 370 | } |
| 371 | |
| 372 | // In case you have a two_handed weapon equipped, the other weapon is removed. |
| 373 | const lcf::rpg::Item* item = GetWeapon(); |
| 374 | const lcf::rpg::Item* item2 = Get2ndWeapon(); |
| 375 | if (item2 == nullptr) { |
| 376 | item2 = GetShield(); |
| 377 | } |
| 378 | if (item && item2 && ((item->type == lcf::rpg::Item::Type_weapon && item->two_handed) || (item2->type == lcf::rpg::Item::Type_weapon && item2->two_handed))) { |
| 379 | ChangeEquipment(equip_type == lcf::rpg::Item::Type_weapon ? equip_type + 1 : equip_type - 1, 0); |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | bool Game_Actor::IsEquipped(int equip_id) const { |
| 384 | for (auto equip : GetWholeEquipment()) { |
no test coverage detected