修复换弹逻辑

This commit is contained in:
aozhiwei 2020-03-06 17:47:44 +08:00
parent b24e0e7c1f
commit 34e1dd72ab
3 changed files with 16 additions and 2 deletions

View File

@ -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];
}
}

View File

@ -245,6 +245,7 @@ protected:
void SelectSkillTargets(const a8::Vec2& target_pos, std::set<Entity*>& target_list);
Buff* GetBuffById(int buff_id);
void ProcSkillPhase(MetaData::SkillPhase* phase);
void AutoChgWeapon();
private:
void ClearFrameData();

View File

@ -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();
}