This commit is contained in:
aozhiwei 2022-11-25 18:38:39 +08:00
parent 1fd175e5f5
commit f307e915f2

View File

@ -4263,41 +4263,32 @@ void Human::DropWeapon(int weapon_idx, int num)
num = std::max(1, num); num = std::max(1, num);
switch (weapon_idx) { switch (weapon_idx) {
case 101: 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: 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: case 103:
{ {
//肾上腺速 int slot_id = -1;
int slot_id = IS_SHEN_BAO; if (weapon_idx == 101) {
if (GetInventory(slot_id) > 0) { slot_id = IS_HEALTHKIT;
num = std::max(1, GetInventory(slot_id)); } else if (weapon_idx == 102) {
DecInventory(slot_id, num); slot_id = IS_PAIN_KILLER;
MarkSyncActivePlayer(__FILE__, __LINE__, __func__); } 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; return;
} }
break;
default: default:
{ {