Jump to content
Sign in to follow this  
doctorbutts

BIS_fnc_unitPlay varDone findings

Recommended Posts

Since I can't make an entry on the wiki I thought I'd post here just so people can know in the future if they (or I forget) want to google this.

The wiki entry only lists the following for BIS_fnc_unitPlay:

[unit, data, varDone, stateIgnore, obsolete_1, obsolete_2, skipTime] spawn BIS_fnc_unitPlay


Under varDone, they only say select 0 is the object, select 1 is the variable to be set. It can be boolean or number.


So, if I created a variable in the init:

de_plane setVariable ["argle",false,true];

I could set that variable to something different in unitPlay such as:

[de_plane, wp2,[de_plane,"argle",true,true],false] spawn BIS_fnc_Unitplay;

 

I also have a monitor script checking every 10 seconds whether or not the variable is set to something:

 

    if ((de_plane getVariable ["argle",true]) == true) then {
        [] spawn ai_takeover;
    };



So, for the varDone array: select 0 is the object. Select 1 is the variable to be set. Select 2 is the value the variable should be set to. I am also apparently able to pass whether or not it is public (select 3).

Well, as you can see above, I only used a boolean for the value of the variable. Through testing I found out that the unitPlay CAN ONLY SET A BOOLEAN VALUE. Even if you specify a number (say, 1) it will set a boolean instead.

 

For instance, previously I had tried:

de_plane setVariable ["argle",0,true];

with:

[de_plane, wp2,[de_plane,"argle",1,true],false] spawn BIS_fnc_Unitplay;

and:

    if ((de_plane getVariable ["argle",1]) == 1) then {
        [] spawn ai_takeover;
    };

 

I got a generic error in the expression when the monitor fired. hint str showed that the value for the variable was 'true' instead of 1 as I had tried to set in the unitPlay.

What happened was that the monitor script saw the initial value of the Variable set to 0, which was fine. When the variable got set to 1 the monitor script gave an error because it was no longer a number, and turned into a boolean instead.



I haven't taken the time to test, but I'm guessing since that the wiki entry only gives two selects in the array to choose from, it may be that only TRUE can be set in the variable.

  • Like 3

Share this post


Link to post
Share on other sites

Thanks Doc!

Should help those of us scripting cutscenes, specifically in timing scripts to fire after the unitPlay has finished. Keep it up, sir!

... May I ask what context you were using this in? 

Share this post


Link to post
Share on other sites

The code for the BIS_fnc_unitPlay function can be reviewed in the Functions Viewer, it lists under configfile -> A2OA -> scenes.  And reviewing, you can see that it only sets the value True.

 

I had first thought it odd you had  to post that the function only sets value as true, I was aware of that from using it in OA.  But now I realize why, seeing that the function in A3 is different from the one in OA (updated, revised, whatever...).  The function in OA explained in its header description that whatever variable was given would be set 'True'.  But the header of the function in A3 is a bit less detailed, and doesn't mention that particular fact; and the wiki entry currently follows suit with that.

 

I think the wiki entry would benefit by being updated, in its "varDone" section, to read "Variable to set true on specified Object once playback has finished".  But I too can't make an entry on the wiki.

  • Like 1

Share this post


Link to post
Share on other sites
On 11/17/2021 at 7:37 AM, Melody_Mike said:

Thanks Doc!

Should help those of us scripting cutscenes, specifically in timing scripts to fire after the unitPlay has finished. Keep it up, sir!

... May I ask what context you were using this in? 


I had a lot of trouble trying to use a trigger when an object was in an area while the object was unitplayed:
The script wouldn't necessarily take over at the right time and the object would not cooperate.

Essentially, I wrote one script to monitor when the script was done (aka when the variable was set) and then when that condition is met, to run a different script.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×