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