添加子弹掉落

This commit is contained in:
aozhiwei 2021-08-04 05:46:49 +00:00
parent 07ee948c2a
commit c941bd2c59

View File

@ -2223,6 +2223,13 @@ void Human::DeadDrop()
) { ) {
a8::Vec2 drop_pos = GetPos(); a8::Vec2 drop_pos = GetPos();
room->DropItem(drop_pos, weapon.weapon_id, 1, weapon.weapon_lv); room->DropItem(drop_pos, weapon.weapon_id, 1, weapon.weapon_lv);
if (weapon.ammo > 0 && weapon.bullet_meta && weapon.ammo < 200) {
if (IsPlayer() &&
weapon.bullet_meta &&
IsValidSlotId(weapon.bullet_meta->i->_inventory_slot())) {
AddInventory(weapon.bullet_meta->i->_inventory_slot(), weapon.ammo);
}
}
weapon.Clear(); weapon.Clear();
} }
} }
@ -2276,6 +2283,7 @@ void Human::DeadDrop()
if (GetInventory(slot) > 0) { if (GetInventory(slot) > 0) {
MetaData::Equip* equip_meta = MetaMgr::Instance()->GetEquipBySlotId(slot); MetaData::Equip* equip_meta = MetaMgr::Instance()->GetEquipBySlotId(slot);
if (equip_meta) { if (equip_meta) {
int drop_num = equip_meta->i->group_num();
if (equip_meta->i->equip_type() == EQUIP_TYPE_BULLET) { if (equip_meta->i->equip_type() == EQUIP_TYPE_BULLET) {
switch (equip_meta->i->_inventory_slot()) { switch (equip_meta->i->_inventory_slot()) {
case IS_FRAG: case IS_FRAG:
@ -2284,18 +2292,41 @@ void Human::DeadDrop()
case IS_MOLOTOR_COCKTAIL: case IS_MOLOTOR_COCKTAIL:
case IS_TRAP: case IS_TRAP:
case IS_MINE: case IS_MINE:
case IS_C4:
case IS_SHIELD_WALL:
case IS_SINGAL_GUN:
case IS_OIL_BUCKET:
{ {
a8::Vec2 drop_pos = GetPos(); if (drop_num > 0) {
room->DropItem(drop_pos, equip_meta->i->id(), GetInventory(slot), 1); a8::Vec2 drop_pos = GetPos();
DecInventory(slot, GetInventory(slot)); if (IsPlayer()) {
room->DropItem(drop_pos, equip_meta->i->id(), GetInventory(slot), 1);
} else {
room->DropItem(drop_pos, equip_meta->i->id(), drop_num, 1);
}
DecInventory(slot, GetInventory(slot));
}
} }
break; break;
default: default:
{
if (drop_num > 0) {
a8::Vec2 drop_pos = GetPos();
if (IsPlayer()) {
room->DropItem(drop_pos, equip_meta->i->id(), GetInventory(slot), 1);
} else {
room->DropItem(drop_pos, equip_meta->i->id(), drop_num, 1);
}
DecInventory(slot, GetInventory(slot));
}
}
break; break;
} }
} else { } else {
#if 0
a8::Vec2 drop_pos = GetPos(); a8::Vec2 drop_pos = GetPos();
room->DropItem(drop_pos, equip_meta->i->id(), GetInventory(slot), 1); room->DropItem(drop_pos, equip_meta->i->id(), GetInventory(slot), 1);
#endif
} }
} }
} }