From f307e915f2a381c2e6b5b5b6af98922fc390bb95 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 25 Nov 2022 18:38:39 +0800 Subject: [PATCH] 1 --- server/gameserver/human.cc | 49 ++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index 929c4222..c56aba05 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -4263,41 +4263,32 @@ void Human::DropWeapon(int weapon_idx, int num) num = std::max(1, num); switch (weapon_idx) { case 101: - { - //医疗包 - int slot_id = IS_HEALTHKIT; - if (GetInventory(slot_id) > 0) { - num = std::max(1, GetInventory(slot_id)); - DecInventory(slot_id, num); - MarkSyncActivePlayer(__FILE__, __LINE__, __func__); - } - return; - } - break; case 102: - { - //止痛药 - int slot_id = IS_PAIN_KILLER; - if (GetInventory(slot_id) > 0) { - num = std::max(1, GetInventory(slot_id)); - DecInventory(slot_id, num); - MarkSyncActivePlayer(__FILE__, __LINE__, __func__); - } - return; - } - break; case 103: { - //肾上腺速 - int slot_id = IS_SHEN_BAO; - if (GetInventory(slot_id) > 0) { - num = std::max(1, GetInventory(slot_id)); - DecInventory(slot_id, num); - MarkSyncActivePlayer(__FILE__, __LINE__, __func__); + int slot_id = -1; + if (weapon_idx == 101) { + slot_id = IS_HEALTHKIT; + } else if (weapon_idx == 102) { + slot_id = IS_PAIN_KILLER; + } else if (weapon_idx == 103) { + slot_id = IS_SHEN_BAO; + } + if (slot_id >= 0 && GetInventory(slot_id) > 0) { + MetaData::Equip* item_meta = MetaMgr::Instance()->GetEquipBySlotId(slot_id); + if (item_meta) { + num = std::max(1, GetInventory(slot_id)); + DecInventory(slot_id, num); + MarkSyncActivePlayer(__FILE__, __LINE__, __func__); + + a8::Vec2 drop_dir = a8::Vec2::UP; + drop_dir.Rotate(a8::RandAngle()); + a8::Vec2 drop_pos = GetPos() + drop_dir * (25 + rand() % 50); + room->DropItem(drop_pos, item_meta->i->id(), num, 1); + } } return; } - break; default: {