修复丢弃武器逻辑
This commit is contained in:
parent
1c28033fee
commit
f7a8f3671a
@ -4207,7 +4207,13 @@ void Human::DropWeapon(int weapon_idx, int num)
|
||||
break;
|
||||
case FRAG_SLOT:
|
||||
{
|
||||
weapon_ammo = std::min(weapon->ammo, num);
|
||||
if (weapon_ammo > 0) {
|
||||
drop_ok = true;
|
||||
weapon->ammo = std::max(0, weapon->ammo - weapon_ammo);
|
||||
int slot_id = weapon->meta->i->_inventory_slot();
|
||||
DecInventory(slot_id, weapon_ammo);
|
||||
if (weapon->ammo <= 0) {
|
||||
*weapon = Weapon();
|
||||
weapon->weapon_idx = weapon_idx;
|
||||
if (GetCurrWeapon() == weapon) {
|
||||
@ -4220,10 +4226,18 @@ void Human::DropWeapon(int weapon_idx, int num)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SMOKE_SLOT:
|
||||
{
|
||||
weapon_ammo = std::min(weapon->ammo, num);
|
||||
if (weapon_ammo > 0) {
|
||||
drop_ok = true;
|
||||
weapon->ammo = std::max(0, weapon->ammo - weapon_ammo);
|
||||
int slot_id = weapon->meta->i->_inventory_slot();
|
||||
DecInventory(slot_id, weapon_ammo);
|
||||
if (weapon->ammo <= 0) {
|
||||
*weapon = Weapon();
|
||||
weapon->weapon_idx = weapon_idx;
|
||||
if (GetCurrWeapon() == weapon) {
|
||||
@ -4236,6 +4250,8 @@ void Human::DropWeapon(int weapon_idx, int num)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
@ -4243,6 +4259,8 @@ void Human::DropWeapon(int weapon_idx, int num)
|
||||
if (weapon_ammo > 0) {
|
||||
drop_ok = true;
|
||||
weapon->ammo = std::max(0, weapon->ammo - weapon_ammo);
|
||||
int slot_id = weapon->meta->i->_inventory_slot();
|
||||
DecInventory(slot_id, weapon_ammo);
|
||||
if (weapon->ammo <= 0) {
|
||||
*weapon = Weapon();
|
||||
weapon->weapon_idx = weapon_idx;
|
||||
@ -4269,6 +4287,9 @@ void Human::DropWeapon(int weapon_idx, int num)
|
||||
if (weapon_ammo > 0) {
|
||||
MetaData::Equip* bullet_meta = MetaMgr::Instance()->GetEquip(weapon_meta->i->use_bullet());
|
||||
if (bullet_meta && bullet_meta->i->_inventory_slot() > 0) {
|
||||
#if 1
|
||||
int drop_num = weapon_ammo;
|
||||
#else
|
||||
int volume = GetVolume(bullet_meta->i->_inventory_slot());
|
||||
int inventory = GetInventory(bullet_meta->i->_inventory_slot());
|
||||
int add_inventory = std::min(weapon_ammo, volume - std::min(volume, inventory));
|
||||
@ -4277,6 +4298,7 @@ void Human::DropWeapon(int weapon_idx, int num)
|
||||
AddInventory(bullet_meta->i->_inventory_slot(), add_inventory);
|
||||
}
|
||||
int drop_num = weapon_ammo - add_inventory;
|
||||
#endif
|
||||
if (drop_num > 0) {
|
||||
a8::Vec2 drop_dir = a8::Vec2::UP;
|
||||
drop_dir.Rotate(a8::RandAngle());
|
||||
|
Loading…
x
Reference in New Issue
Block a user