Using currentWeapon on bots works wrong if bots are not in the same group as player. {F22582} {F22583}
Description
Details
- Legacy ID
- 1661660900
- Severity
- None
- Resolution
- Open
- Reproducibility
- Always
- Category
- Scripting
Add player and bot not in your group in editor, use "hint (currentWeapon cursorTarget);" while pointing @bot. Function returns empty string, however primaryWeapon returns accurate value.
This bug appears if u are not the leader of group. Leader of group can get current weapon for any bot in his group.
Event Timeline
Cursortarget does not always return unit especially if it wasnt revealed to the player. Try hint str [cursorTarget, currentWeapon cursortarget] to make sure the object is not null.
Nice guess, but it actually reveals target correctly (just tested). Actually when we first met this bug cursorTarget wasn't involved.
The result is the same if we'll use bot name instead of cursorTarget:
hint (currentWeapon bot1); // bot1 - the name of the bot
AI selectWeapon pimaryWeapon AI;
hint currentWeapon AI;
does the trick. So for some reason selectWeapon is the key here.
Which totally means that this is AI issue and not currentWeapon issue. Bots simply deny to switch to the weapon they hold in their hands. Some sort of safety-trigger.
It's not always possible to use selectWeapon on the bot, especially if bot is server-controlled (non-local) or handled by another client and/or for security reason in MP.
I guess the only correct way (with no reinventing the wheel) to fix that is change AI behaviour in FSM.
Confirmed. This does not just apply to AIs in non-player groups. It applies to all AI units.
Until the first time an AI receives a target, its weapon is "". The moment it receives a target it returns the actual weapon, thus indicating that when it spawns it has no weapon selected, and is only holding it visually.
So it's a problem with the AI itself not technically having any weapon selected, and not currentWeapon.
Added repro mission.