diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index 3b6db774..cb7bc3c9 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -4283,11 +4283,54 @@ void Human::ProcAddItemDto(AddItemDTO& dto) 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__); + } + return; + } + break; + default: + { + + } + break; + } if (weapon_idx < 0 || weapon_idx >= weapons.size()) { return; } - num = std::max(1, num); bool drop_ok = false; Weapon* weapon = &weapons[weapon_idx]; int weapon_id = weapon->weapon_id; diff --git a/server/gameserver/player.cc b/server/gameserver/player.cc index 4ca009e4..37848990 100644 --- a/server/gameserver/player.cc +++ b/server/gameserver/player.cc @@ -1090,9 +1090,7 @@ void Player::_CMExecCommand(f8::MsgHdr& hdr, const cs::CMExecCommand& msg) void Player::UpdateDropWeapon() { - if (drop_weapon_idx >= 0 && - drop_weapon_idx < weapons.size() && - !FreezeOperate()) { + if (!FreezeOperate()) { DropWeapon(drop_weapon_idx, drop_num); } ResetAction(); diff --git a/server/tools/protobuild/cs_proto.proto b/server/tools/protobuild/cs_proto.proto index a8cfc55b..ea609f0a 100755 --- a/server/tools/protobuild/cs_proto.proto +++ b/server/tools/protobuild/cs_proto.proto @@ -1040,7 +1040,7 @@ message CMMove optional float fly_distance = 7; //子弹飞行距离(只有手雷和烟雾弹时这个字段才有意义) optional int32 select_weapon = 8; //切换武器(没切换是不用发) - optional int32 drop_weapon = 9; //丢弃武器 + optional int32 drop_weapon = 9; //丢弃武器 101:医疗包 102:止痛药 103:肾上腺速 optional int32 drop_num = 43; //丢弃武器(数量) optional bool cancel_action = 10; //取消当前操作(比如取消使用道具装弹等)