Jump to content
johnnyboy

[SOLVED] Where is function BIS_fnc_UnitPlay? I want to tweak my own version

Recommended Posts

Hi guys, I browsed the function viewer and googled, but I can't find the source for BIS_fnc_UnitPlay.  

 

I'd like to make my own version and see if I can modify it to:

  • Stop vehicle movement before path script is complete.  Terminating the script handle isn't doing it for me.
  • Start and stop vehicle along the same path.   I want to pause the movement, and resume movement on demand.

 

Where can I get the code for this function?

 

I found it in the function viewer under A2OA finally...

 

  • Like 1

Share this post


Link to post
Share on other sites
Quote

I want to tweak my own version

 

Hey man, you're like totally a bro and everything but if I want to tweak my "version" I keep it off the forums.  Well these forums at any rate  ;)

  • Like 1

Share this post


Link to post
Share on other sites

Functions viewer A2OA > SCENES

In functions_f.pbo

 

The reason you cannot terminate the script handle to stop the playback is that it starts up a MEH of EachFrame. To stop the playback you need to set the variable BIS_fnc_unitPlay_terminate on the object playing back the recording to true.

Before the recording is terminated you can get the current playback info from the missionNamespace variable of..

_playbackVar = ("bis_fnc_unitPlay" + str ("bis_fnc_unitPlay_counter" call BIS_fnc_counter));
_playbackData = missionNamespace getVariable _playbackVar;
_playbackData params [
    "_object",                      //--- 0: Object
    "_recording",                   //--- 1: Recording
    "_recordingCount",              //--- 2: Recording count - size of playback array
    "_ignoreDisabled",              //--- 3: Ignore disabled
    "_startRecordingTime",          //--- 4: Start time - time to start playback from
    "_startPlaybackTime",           //--- 5: Start playback time - actual time playback started
    //** updated each loop
    "_step",                        //--- 6: Step - current index from recording that is playing
    "_currentTime",                 //--- 7: Current time - actual time currently playing( from recording ) 
    "_nextTime",                    //--- 8: Next time - next recorded time to play next
    "_velocityTransformation"       //--- 9: Velocity transformation
    //**
    "_endParams"                    //--- 10: End params - [ namespace, variable ] to set once playback has finished
];

The variable name will need to be retrieved as you start the recording as any other started recording will increase the counter.

To start the playback where it left off use the _nextTime, as retrieved from the data just before you stop the recording, in your call to BIS_fnc_unitPlay.

Quote

Parameter(s):
    0: OBJECT - unit to play movement data on
    1: ARRAY - movement data recorder by BIS_fnc_unitCapture
    2: ARRAY (Optional) - variable to set once playback has finished. The array is in the following format:
        0: NAMESPACE, GROUP or OBJECT
        1: STRING - variable name
    3: BOOL - true to allow playaback on destroyed objects (normally the playback will stop once the object is destroyed)
    4: NOTHING - obsolete param, preserved because of backward compatibility
    5: NOTHING - obsolete param, preserved because of backward compatibility
    6: NUMBER - seconds to skip at the start of playback

[ _object, _recording, _endParams, _ignoreDisabled, nil, nil, _nextTime ] spawn BIS_fnc_UnitPlay;
Spoiler

//Get current playback counter
_playbackVar = ("bis_fnc_unitPlay" + str ("bis_fnc_unitPlay_counter" call BIS_fnc_counter));

//Start intial playback
[ /*initial recording start vars*/ ] spawn BIS_fnc_UnitPlay;

//Wait nutil counter has changed for new playback
waitUntil { ("bis_fnc_unitPlay" + str ("bis_fnc_unitPlay_counter" call BIS_fnc_counter)) != _playbackVar };

//Get var name for playback
_playbackVar = ("bis_fnc_unitPlay" + str ("bis_fnc_unitPlay_counter" call BIS_fnc_counter));

//** some time later

//Get current playback data
_playbackData = missionNamespace getVariable _playbackVar;
_playbackData params [
    "_object",                      //--- 0: Object
    "_recording",                   //--- 1: Recording
    "_recordingCount",              //--- 2: Recording count - size of playback array
    "_ignoreDisabled",              //--- 3: Ignore disabled
    "_startRecordingTime",          //--- 4: Start time - time to start playback from
    "_startPlaybackTime",           //--- 5: Start playback time - actual time playback started
    //** updated each loop
    "_step",                        //--- 6: Step - current index from recording that is playing
    "_currentTime",                 //--- 7: Current time - actual time currently playing( from recording ) 
    "_nextTime",                    //--- 8: Next time - next recorded time to play next
    "_velocityTransformation"       //--- 9: Velocity transformation
    //**
    "_endParams"                    //--- 10: End params - [ namespace, variable ] to set once playback has finished
];

//Stop playback
_object setVariable [ "BIS_fnc_unitPlay_terminate", true ];

//** some time later

//Reset playback terminate
_object setVariable [ "BIS_fnc_unitPlay_terminate", nil ];

//Start recording from last position
[ _object, _recording, _endParams, _ignoreDisabled, nil, nil, _nextTime ] spawn BIS_fnc_UnitPlay;

 

 

  • Like 2

Share this post


Link to post
Share on other sites

@Larrow, thanks man, that was a seriously helpful post.  You are the man.

 

I'm going to delve into how that function uses the playback data with setvelocitytransformation function.  When stopping mid-stream, I want to actually slow to a stop, and when resuming playback, accelerate from stopped to whatever the recorded velocity is.  This means that during my "stop" and "resume" timeframes, I need to override the recorded data's velocity (to slow to a stop,  and to re-accelerate to match recorded velocity).

 

So I think I do need my own version of the sproc, and add my own variables to control stop/resume.  To restart (after slowed stop), I may have to read ahead in the playback data to find position closest to stopped position, and then restart from that _nextTime.

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

×