Page MenuHomeFeedback Tracker

currentWeapon function is broken.
Assigned, WishlistPublic

Description

Using currentWeapon on bots works wrong if bots are not in the same group as player. {F22582} {F22583}

Details

Legacy ID
1661660900
Severity
None
Resolution
Open
Reproducibility
Always
Category
Scripting
Steps To Reproduce

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.

Additional Information

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

edxp edited Steps To Reproduce. (Show Details)Oct 23 2013, 5:25 PM
edxp edited Additional Information. (Show Details)
edxp set Category to Scripting.
edxp set Reproducibility to Always.
edxp set Severity to None.
edxp set Resolution to Open.
edxp set Legacy ID to 1661660900.May 7 2016, 5:13 PM
Bohemia added a subscriber: AD2001.Oct 23 2013, 5:25 PM

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.

edxp added a subscriber: edxp.May 7 2016, 5:13 PM
edxp added a comment.Oct 23 2013, 8:50 PM

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

confirmed, currentweapon AI is ""

AI selectWeapon pimaryWeapon AI;
hint currentWeapon AI;

does the trick. So for some reason selectWeapon is the key here.

edxp added a comment.Oct 23 2013, 11:22 PM

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.

Is this an issue? Or is it intended?

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.