This commit is contained in:
aozhiwei 2021-04-09 17:18:18 +08:00
commit 5b61f17ca1

View File

@ -1431,8 +1431,15 @@ Weapon* Creature::ChooseNextWeapon(int curr_weapon_slot_id, int begin_slot_id, i
for (int i = 1; i <= (end_slot_id - begin_slot_id); ++i) {
int slot_id = begin_slot_id +
(i + curr_weapon_slot_id - begin_slot_id) % (end_slot_id - begin_slot_id + 1);
if (weapons[slot_id].weapon_id != 0) {
next_weapon = &weapons[slot_id];
int idx = -1;
if (slot_id >= SPEC1_IS_BEGIN && slot_id <= SPEC1_IS_END) {
idx = SPEC1_SLOT_BEGIN + (slot_id - SPEC1_IS_BEGIN);
}
if (slot_id >= SPEC2_IS_BEGIN && slot_id <= SPEC2_IS_END) {
idx = SPEC2_SLOT_BEGIN + (slot_id - SPEC2_IS_BEGIN);
}
if (idx != -1 && weapons.at(idx).weapon_id != 0) {
next_weapon = &weapons[idx];
break;
}
}