diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index 355c12c..e7bf733 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -2804,3 +2804,14 @@ void Human::ProcSkillPhase(MetaData::SkillPhase* phase) break; } } + +void Human::AutoChgWeapon() +{ + if (weapons[GUN_SLOT1].weapon_idx != 0) { + curr_weapon = &weapons[GUN_SLOT1]; + } else if (weapons[GUN_SLOT2].weapon_idx != 0) { + curr_weapon = &weapons[GUN_SLOT2]; + } else { + curr_weapon = &weapons[0]; + } +} diff --git a/server/gameserver/human.h b/server/gameserver/human.h index d12537a..da9a020 100644 --- a/server/gameserver/human.h +++ b/server/gameserver/human.h @@ -245,6 +245,7 @@ protected: void SelectSkillTargets(const a8::Vec2& target_pos, std::set& target_list); Buff* GetBuffById(int buff_id); void ProcSkillPhase(MetaData::SkillPhase* phase); + void AutoChgWeapon(); private: void ClearFrameData(); diff --git a/server/gameserver/player.cc b/server/gameserver/player.cc index 5f23f48..cf7e692 100644 --- a/server/gameserver/player.cc +++ b/server/gameserver/player.cc @@ -332,6 +332,7 @@ void Player::Shot() } if (action_type == AT_Reload || action_type == AT_Rescue || + action_type == AT_UseItem || action_type == AT_Relive) { CancelAction(); } @@ -380,6 +381,7 @@ void Player::Shot() --curr_weapon->ammo; } int slot_id = curr_weapon->meta->i->_inventory_slot(); + //扔完手雷,如无手雷,则优先换武器1>武器2 switch (slot_id) { case 5: { @@ -395,7 +397,7 @@ void Player::Shot() if (weapons[SMOKE_SLOT].weapon_id != 0) { curr_weapon = &weapons[SMOKE_SLOT]; } else { - curr_weapon = &weapons[0]; + AutoChgWeapon(); } AutoLoadingBullet(); } @@ -418,7 +420,7 @@ void Player::Shot() if (weapons[FRAG_SLOT].weapon_id != 0) { curr_weapon = &weapons[FRAG_SLOT]; } else { - curr_weapon = &weapons[0]; + AutoChgWeapon(); } AutoLoadingBullet(); }