From b17c5847367900d553c2ec8455ef3d1f1293a30c Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 18 Jun 2021 19:33:52 +0800 Subject: [PATCH] 1 --- server/gameserver/creature.cc | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/server/gameserver/creature.cc b/server/gameserver/creature.cc index 4c8c6a8..b995487 100644 --- a/server/gameserver/creature.cc +++ b/server/gameserver/creature.cc @@ -1384,6 +1384,34 @@ void Creature::Shot(a8::Vec2& target_dir, bool& shot_ok, float fly_distance) SyncAroundPlayers(__FILE__, __LINE__, __func__); } break; + case IS_C4: + case IS_SHIELD_WALL: + case IS_SINGAL_GUN: + case IS_OIL_BUCKET: + { + if (GetCurrWeapon()->ammo <= 0) { + if (GetInventory(slot_id) > 0) { + DecInventory(slot_id, 1); + ++GetCurrWeapon()->ammo; + } else { + int weapon_idx = GetCurrWeapon()->weapon_idx; + *GetCurrWeapon() = Weapon(); + GetCurrWeapon()->weapon_idx = weapon_idx; + Weapon* next_weapon = ChooseNextWeapon(slot_id, SPEC3_IS_BEGIN, SPEC3_IS_END); + if (!next_weapon) { + next_weapon = ChooseNextWeapon(SPEC1_IS_BEGIN, SPEC1_IS_BEGIN, SPEC1_IS_END); + } + if (!next_weapon) { + next_weapon = AutoChgWeapon(); + } + SetCurrWeapon(next_weapon); + AutoLoadingBullet(); + } + } + need_sync_active_player = true; + SyncAroundPlayers(__FILE__, __LINE__, __func__); + } + break; default: { }