修复 选武器问题

This commit is contained in:
aozhiwei 2021-04-15 13:36:30 +08:00
parent ef57d64325
commit 0d49fb2337

View File

@ -1144,7 +1144,14 @@ void Creature::Shot(a8::Vec2& target_dir, bool& shot_ok, float fly_distance)
int weapon_idx = GetCurrWeapon()->weapon_idx; int weapon_idx = GetCurrWeapon()->weapon_idx;
*GetCurrWeapon() = Weapon(); *GetCurrWeapon() = Weapon();
GetCurrWeapon()->weapon_idx = weapon_idx; GetCurrWeapon()->weapon_idx = weapon_idx;
SetCurrWeapon(ChooseNextWeapon(slot_id, SPEC1_IS_BEGIN, SPEC1_IS_END)); Weapon* next_weapon = ChooseNextWeapon(slot_id, SPEC1_IS_BEGIN, SPEC1_IS_END);
if (!next_weapon) {
next_weapon = ChooseNextWeapon(SPEC2_IS_BEGIN, SPEC2_IS_BEGIN, SPEC2_IS_END);
}
if (!next_weapon) {
next_weapon = AutoChgWeapon();
}
SetCurrWeapon(next_weapon);
AutoLoadingBullet(); AutoLoadingBullet();
} }
} }
@ -1165,7 +1172,14 @@ void Creature::Shot(a8::Vec2& target_dir, bool& shot_ok, float fly_distance)
int weapon_idx = GetCurrWeapon()->weapon_idx; int weapon_idx = GetCurrWeapon()->weapon_idx;
*GetCurrWeapon() = Weapon(); *GetCurrWeapon() = Weapon();
GetCurrWeapon()->weapon_idx = weapon_idx; GetCurrWeapon()->weapon_idx = weapon_idx;
SetCurrWeapon(ChooseNextWeapon(slot_id, SPEC2_IS_BEGIN, SPEC2_IS_END)); Weapon* next_weapon = ChooseNextWeapon(slot_id, SPEC2_IS_BEGIN, SPEC2_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(); AutoLoadingBullet();
} }
} }
@ -1448,7 +1462,7 @@ Weapon* Creature::ChooseNextWeapon(int curr_weapon_slot_id, int begin_slot_id, i
break; break;
} }
} }
return next_weapon ? next_weapon : AutoChgWeapon(); return next_weapon;
} }
void Creature::SetCurrWeapon(Weapon* weapon) void Creature::SetCurrWeapon(Weapon* weapon)