From f3a7f1da5f74223fa67cce0f1361494c1dda96c0 Mon Sep 17 00:00:00 2001 From: Ghabry Date: Wed, 13 Sep 2023 15:37:13 +0200 Subject: [PATCH] ChangeEquipment: Prevent equipping of items that are not usable by the actor Fix #2902 --- src/game_actor.cpp | 4 ++++ src/game_interpreter.cpp | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/game_actor.cpp b/src/game_actor.cpp index e4193652a3..88b1e8d18d 100644 --- a/src/game_actor.cpp +++ b/src/game_actor.cpp @@ -352,6 +352,10 @@ int Game_Actor::SetEquipment(int equip_type, int new_item_id) { } void Game_Actor::ChangeEquipment(int equip_type, int item_id) { + if (!IsItemUsable(item_id)) { + return; + } + int prev_item = SetEquipment(equip_type, item_id); if (prev_item != 0) { diff --git a/src/game_interpreter.cpp b/src/game_interpreter.cpp index e44a0bc95a..9b1f6d9015 100644 --- a/src/game_interpreter.cpp +++ b/src/game_interpreter.cpp @@ -1862,10 +1862,6 @@ bool Game_Interpreter::CommandChangeEquipment(lcf::rpg::EventCommand const& com) continue; } - if (Main_Data::game_party->GetItemCount(item_id) == 0 && !actor->IsEquipped(item_id)) { - Main_Data::game_party->AddItem(item_id, 1); - } - if (actor->HasTwoWeapons() && slot == lcf::rpg::Item::Type_weapon && item_id != 0) { lcf::rpg::Item* new_equipment = lcf::ReaderUtil::GetElement(lcf::Data::items, item_id); lcf::rpg::Item* equipment1 = lcf::ReaderUtil::GetElement(lcf::Data::items, actor->GetWeaponId());