修复手榴弹问题

This commit is contained in:
aozhiwei 2019-05-23 16:27:21 +08:00
parent 72def7cf5e
commit 173b825763
2 changed files with 29 additions and 22 deletions

View File

@ -369,19 +369,21 @@ void Player::Shot()
case 5: case 5:
{ {
//手雷 //手雷
if (GetInventory(slot_id) > 0) { if (curr_weapon->ammo <= 0) {
DecInventory(slot_id, 1); if (GetInventory(slot_id) > 0) {
++curr_weapon->ammo; DecInventory(slot_id, 1);
} else { ++curr_weapon->ammo;
int weapon_idx = curr_weapon->weapon_idx;
*curr_weapon = Weapon();
curr_weapon->weapon_idx = weapon_idx;
if (weapons[SMOKE_SLOT].weapon_id != 0) {
curr_weapon = &weapons[SMOKE_SLOT];
} else { } else {
curr_weapon = &weapons[0]; int weapon_idx = curr_weapon->weapon_idx;
*curr_weapon = Weapon();
curr_weapon->weapon_idx = weapon_idx;
if (weapons[SMOKE_SLOT].weapon_id != 0) {
curr_weapon = &weapons[SMOKE_SLOT];
} else {
curr_weapon = &weapons[0];
}
AutoLoadingBullet();
} }
AutoLoadingBullet();
} }
need_sync_active_player = true; need_sync_active_player = true;
SyncAroundPlayers(); SyncAroundPlayers();
@ -390,19 +392,21 @@ void Player::Shot()
case 6: case 6:
{ {
//烟雾弹 //烟雾弹
if (GetInventory(slot_id) > 0) { if (curr_weapon->ammo <= 0) {
DecInventory(slot_id, 1); if (GetInventory(slot_id) > 0) {
++curr_weapon->ammo; DecInventory(slot_id, 1);
} else { ++curr_weapon->ammo;
int weapon_idx = curr_weapon->weapon_idx;
*curr_weapon = Weapon();
curr_weapon->weapon_idx = weapon_idx;
if (weapons[FRAG_SLOT].weapon_id != 0) {
curr_weapon = &weapons[FRAG_SLOT];
} else { } else {
curr_weapon = &weapons[0]; int weapon_idx = curr_weapon->weapon_idx;
*curr_weapon = Weapon();
curr_weapon->weapon_idx = weapon_idx;
if (weapons[FRAG_SLOT].weapon_id != 0) {
curr_weapon = &weapons[FRAG_SLOT];
} else {
curr_weapon = &weapons[0];
}
AutoLoadingBullet();
} }
AutoLoadingBullet();
} }
need_sync_active_player = true; need_sync_active_player = true;
SyncAroundPlayers(); SyncAroundPlayers();

View File

@ -356,6 +356,9 @@ void Room::FillSMMapInfo(cs::SMMapInfo& map_info)
void Room::DropItem(Vector2D pos, int item_id, int item_count, int item_lv) void Room::DropItem(Vector2D pos, int item_id, int item_count, int item_lv)
{ {
#if 0
item_id = 12301 + rand() % 2;
#endif
MetaData::Equip* equip_meta = MetaMgr::Instance()->GetEquip(item_id); MetaData::Equip* equip_meta = MetaMgr::Instance()->GetEquip(item_id);
if (equip_meta && equip_meta->i->group_num() > 0 && item_count > 0) { if (equip_meta && equip_meta->i->group_num() > 0 && item_count > 0) {
int total_count = item_count; int total_count = item_count;