Page MenuHomeFeedback Tracker

Comparing animationState on AI is broken
Closed, ResolvedPublic

Description

I've come across a weird phenomenon.

When comparing animationState as a condition it will return FALSE even though in ACTUAL FACT should/must be TRUE.

The same code applied to a player works just fine.

Details

Legacy ID
4201108379
Severity
None
Resolution
No Bug
Reproducibility
Always
Category
Scripting
Steps To Reproduce
  1. Place a unit in the editor and name it test_unit
  1. Init.sqf:

_anims = [
"ainvpknlmstpsnonwrfldnon_ainvpknlmstpsnonwrfldnon_medic",
"AinvPknlMstpSnonWrflDnon_medic0s",
"AinvPknlMstpSnonWrflDnon_medic",
"AinvPknlMstpSnonWrflDnon_medic0",
"AinvPknlMstpSnonWrflDnon_medic1",
"AinvPknlMstpSnonWrflDnon_medic2",
"AinvPknlMstpSnonWrflDnon_medic3",
"AinvPknlMstpSnonWrflDnon_medic4",
"AinvPknlMstpSnonWrflDnon_medic5",
"AinvPknlMstpSnonWrflDnon_medicend"
];

sleep 1;

test_unit playActionNow "medicStart";

sleep 1;

_anim = (animationState test_unit);
hint format["%1 (%2)", (_anim in _anims), _anim];
diag_log text format["%1 (%2)", (_anim in _anims), _anim];

while {(_anim in _anims)} do {

_anim = (animationState test_unit);

hint format["%1 (%2)", (_anim in _anims), _anim];
diag_log text format["%1 (%2)", (_anim in _anims), _anim];

sleep 1;

};

  1. Result will be:

true (ainvpknlmstpsnonwrfldnon_ainvpknlmstpsnonwrfldnon_medic)
true (ainvpknlmstpsnonwrfldnon_ainvpknlmstpsnonwrfldnon_medic)
false (ainvpknlmstpsnonwrfldnon_medic0s) <-- FALSE - EVEN THOUGH THIS IS INSIDE THE _anims ARRAY

Same is true for direct comparison like:

if ((animationState test_unit) != "ainvpknlmstpsnonwrfldnon_ainvpknlmstpsnonwrfldnon_medic"
&&
(animationState test_unit) != "AinvPknlMstpSnonWrflDnon_medic0s"
&&
(animationState test_unit) != "AinvPknlMstpSnonWrflDnon_medic"
&&
(animationState test_unit) != "AinvPknlMstpSnonWrflDnon_medic0"
&&
(animationState test_unit) != "AinvPknlMstpSnonWrflDnon_medic1"
&&
(animationState test_unit) != "AinvPknlMstpSnonWrflDnon_medic2"
&&
(animationState test_unit) != "AinvPknlMstpSnonWrflDnon_medic3"
&&
(animationState test_unit) != "AinvPknlMstpSnonWrflDnon_medic4"
&&
(animationState test_unit) != "AinvPknlMstpSnonWrflDnon_medic4"
&&
(animationState test_unit) != "AinvPknlMstpSnonWrflDnon_medicend") then {};

Condition will be FALSE although is should/must be TRUE.

WTF.

Event Timeline

sxp2high edited Steps To Reproduce. (Show Details)Oct 3 2013, 10:10 PM
sxp2high edited Additional Information. (Show Details)
sxp2high set Category to Scripting.
sxp2high set Reproducibility to Always.
sxp2high set Severity to None.
sxp2high set Resolution to No Bug.
sxp2high set Legacy ID to 4201108379.May 7 2016, 5:03 PM

Please note what the documentation for the <i>in</i> command says:
"Checks whether x is equal to any element in the array. If x is a string, the array is checked case-sensitive"

I am note sure what the second example is supposed to demonstrate. That condition will be true only when you are not performing any of the checked medic anims.

case-sensitive, you nailed it. Now I feel stupid. I used "in" so many times and never ran into this.

It's working now. Ticket can be closed... Sorry :-/