1
This commit is contained in:
parent
a1a981775f
commit
140a7a1c4f
@ -895,6 +895,7 @@ void Player::UpdateDropWeapon()
|
||||
Weapon* weapon = &weapons[drop_weapon_idx];
|
||||
int weapon_id = weapon->weapon_id;
|
||||
int weapon_ammo = weapon->ammo;
|
||||
MetaData::Equip* weapon_meta = weapon->meta;
|
||||
if (weapon->weapon_id != 0) {
|
||||
if (weapon->weapon_idx == 0) {
|
||||
if (weapon->weapon_id != default_weapon.weapon_id) {
|
||||
@ -951,10 +952,31 @@ void Player::UpdateDropWeapon()
|
||||
}
|
||||
}
|
||||
if (drop_ok) {
|
||||
{
|
||||
if (drop_weapon_idx == 0 ||
|
||||
drop_weapon_idx == GUN_SLOT1 ||
|
||||
drop_weapon_idx == GUN_SLOT2
|
||||
) {
|
||||
Vector2D dir = Vector2D::UP;
|
||||
dir.Rotate(a8::RandAngle());
|
||||
room->CreateLoot(weapon_id, pos + dir * (25 + rand() % 50), std::max(1, weapon_ammo));
|
||||
room->CreateLoot(weapon_id, pos + dir * (25 + rand() % 50), 1);
|
||||
}
|
||||
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) {
|
||||
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));
|
||||
if (add_inventory > 0) {
|
||||
AddInventory(bullet_meta->i->_inventory_slot(), add_inventory);
|
||||
}
|
||||
int drop_num = weapon_ammo - add_inventory;
|
||||
if (drop_num > 0) {
|
||||
Vector2D drop_dir = Vector2D::UP;
|
||||
drop_dir.Rotate(a8::RandAngle());
|
||||
Vector2D drop_pos = pos + drop_dir * (25 + rand() % 50);
|
||||
room->DropItem(drop_pos, bullet_meta->i->id(), drop_num);
|
||||
}
|
||||
}
|
||||
}
|
||||
need_sync_active_player = true;
|
||||
SyncAroundPlayers();
|
||||
|
Loading…
x
Reference in New Issue
Block a user