Jump to content
Johno89

A2 Trial by Fire - port to A3 - scripting issues

Recommended Posts

Hi all,

 

I'm trying to port A2 single player scenario 'Trial by Fire' to A3 and despite making progress I'm encountering some niggling issues which i cant seem to rectify. One of these problems is group animations.

 

Group animations problem

In the original A2 mission there are a group of marines doing exercises towards the back of the ships deck. This was handled by a script called 'fitnessgroup.sqf' which I've retained in the port & updated to use RHS USMC marines and A3 working exercise animations. 

Spoiler

Fitnessgroup.jpg

 

However when previewing the mission the solders are correctly placed but just standing still. I also get 2 error messages, one about fitnessgroup.sqf and another about its relation to fn_scenesSetAnimationsForGroup.sqf which is located in the Arma 3 install directory.

Spoiler

Error Message 1                                                                                                                     Error Message 2                         

'...] call RE;                                                                                                                                {_nic = [objNull, _x, |# |rPLAYACTION, "StopRelaxed"] call RE] for...'

}else                                                                                                                                          Error Undefined variable in expression rplayaction

{                                                                                                                                                 File C:\Users\Documents\Arma 3\missions\SP_TrialByFire.utes\fitnessgroup.sqf, line 38

_nic = [objNull, _x, |# |rSWITCHMOVE, _whatAnimation] call RE;

};...'

Error Undefined variable in expression: rswitchmove

File A3\functions_f\scenes\fn_sceneSetAnimationsForGroup.sqf

[BIS_fnc_sceneSetAnimationsForGroup], line 39

 

 

I'm not the best when it comes to coding as I only have a basic understanding. I've attempted a few fixes such as swapping out rPLAYACTION with rSWITCHMOVE in fitnessgroup.sqf but none seem to work. 

 

Could anyone shed some light on why this isn't working and potentially provide a solution?

 

Thanks for your time

Edited by Johno89
Spelling

Share this post


Link to post
Share on other sites
1 hour ago, Johno89 said:

Error Message 1                                                                                                                     Error Message 2                         

 

'...] call RE;                                                                                                                                {_nic = [objNull, _x, |# |rPLAYACTION, "StopRelaxed"] call RE] for...'

}else                                                                                                                                          Error Undefined variable in expression rplayaction

{                                                                                                                                                 File C:\Users\Documents\Arma 3\missions\SP_TrialByFire.utes\fitnessgroup.sqf, line 38

_nic = [objNull, _x, |# |rSWITCHMOVE, _whatAnimation] call RE;

};...'

Error Undefined variable in expression: rswitchmove

File A3\functions_f\scenes\fn_sceneSetAnimationsForGroup.sqf

[BIS_fnc_sceneSetAnimationsForGroup], line 39

 

 

Regarding error 1 there is no "r" in switchMove, might want to remove that.

Same for error 2, playAction, there's an r in front that shouldn't be there.

Other than that animations will only work if the command is issued during mission runtime, a small

waitUntil{time > 0}

should do the trick.

 

Cheers

Share this post


Link to post
Share on other sites

Hi Grumpy

 

Regarding your answer, If you were to extract 'functions_f' from the Addons directory in Arma 3 and look in 'fn_sceneSetAnimationsForGroup.sqf' (what fitnessgroup.sqf is calling) you'd see that rSWITCHMOVE is listed here. It appears to be standard data and so i don't think i can remove the 'r'. I've attached the file here;

Spoiler

/*******************************************************************************
 *
 *    version:     1.0
 *    name:    
 *    description:    play animations recieved as parameter on group     
 *    author:        
 *    paramater:    group and animation arrays    
 *    return value:    true if all animation started     
 * 
 ******************************************************************************/     
private["_allParticipants", "_animations", "_whatAnimation", "_animCount", "_next", "_timeout", "_t", "_mode"];
_allParticipants     = _this select 0;            //who play animations on
_animations         = _this select 1;            //array of animations
if(count _this >= 2) then {_timeout = _this select 2;};        //how long to wait if anybody stuck
if(count _this >= 3) then {_mode = _this select 3;};        //switchmove = nothing | playmove = 1 
if(isNil"_timeout") then {_timeout = 10;};            //set default timeout
if(isNil"_mode") then {_mode = 0;};                //set default mode
//debuglog str (count _this);
//debuglog str (_mode);
_next             = 0;
_whatAnimation        = "";
_animCount         = (count _animations);
if(!isNil"BIS_debugModules") then
{
    DEBUGLOG "SetAnimationsForGroup: =========SetAnimationsForGroup=============";
    textLogFormat ["SetAnimationsForGroup: %1 (nil = switchmove | 0 = playmove)", _mode];
    textLogFormat ["SetAnimationsForGroup: %1", str _allParticipants];
    DEBUGLOG "SetAnimationsForGroup: ============================================";
};

{
    _whatAnimation = (_animations select (_next mod (_animCount)));
    if(_mode == 0) then
    {
        _nic = [objNull, _x, rPLAYMOVENOW, _whatAnimation] call RE;
    }else
    {
        _nic = [objNull, _x, rSWITCHMOVE, _whatAnimation] call RE;
    };
    if(!isNil"BIS_debugModules") then
    {
        textLogFormat["sceneSetAnimationsFrGroup.sqf: %3| %1 | %2",(animationState (_x)), _whatAnimation, _x];
    };
    _next = _next + 1;
    //Sleep 0.01;
}forEach _allParticipants;

_t = time;
WaitUntil{((animationState (_allParticipants select (_next - 1))) == _whatAnimation) || (time > (_t + _timeout))};
if(time > (_t + _timeout)) then
{    
    if(!isNil"BIS_debugModules") then
    {
        textLogFormat["sceneSetAnimationsFrGroup.sqf: DONE but timeout: %3| %1 | %2",(animationState (_allParticipants select (_next - 1))), _whatAnimation, (_allParticipants select (_next - 1))];
    };
}
else
{    
    if(!isNil"BIS_debugModules") then
    {
        textLogFormat["sceneSetAnimationsFrGroup.sqf: DONE: %3| %1 | %2",(animationState (_allParticipants select (_next - 1))), _whatAnimation, (_allParticipants select (_next - 1))];
    };
};

TRUE;
 

 

I did however attempt your solution but it didn't work unfortunately.

 

Cheers

 

Share this post


Link to post
Share on other sites
15 minutes ago, Johno89 said:

Hi Grumpy

 

Regarding your answer, If you were to extract 'functions_f' from the Addons directory in Arma 3 and look in 'fn_sceneSetAnimationsForGroup.sqf' (what fitnessgroup.sqf is calling) you'd see that rSWITCHMOVE is listed here. It appears to be standard data and so i don't think i can remove the 'r'. I've attached the file here;

 

I did however attempt your solution but it didn't work unfortunately.

 

Cheers

 

Well not much you can do other than replacing the BIS function with your own and trying to fix errors that might pop up.

Judging from the syntax used in this function it's either ancient or was made by someone who isn't too fond of the recently introduced qol script commands, heh.

 

Cheers

Share this post


Link to post
Share on other sites

Ancient, written for Arma2, uses RE which no longer exists and should now be remoteExec.

As @Grumpy Old Man says you will need to replace it with your own function.

  • Like 1

Share this post


Link to post
Share on other sites

lol so i'd have to write an entirely new sqf file?

 

Game over man! Game over!

Share this post


Link to post
Share on other sites
17 hours ago, Larrow said:

As @Grumpy Old Man says you will need to replace it with your own function.

 

Could you guys be more specific about 'own function'. Would this just consist of a new sqf file and in the group composition init field just call that file?

 

Cheers

Share this post


Link to post
Share on other sites
3 hours ago, Johno89 said:

Could you guys be more specific about 'own function'.

Copy the code from fn_sceneSetAnimationsForGroup.sqf.

Replace any old commands/functions with new and save as a new script/function.

Use your new script/function in place of when ever the old BIS_fnc_sceneSetAnimations was used.

Share this post


Link to post
Share on other sites
27 minutes ago, Larrow said:

Copy the code from fn_sceneSetAnimationsForGroup.sqf.

Replace any old commands/functions with new and save as a new script/function.

Use your new script/function in place of when ever the old BIS_fnc_sceneSetAnimations was used.

 

Ok so if im understanding you correctly;

1. Copy code from fn_sceneSetAnimationsForGroup.sqf.

2. Paste it in an entirely new file in the trial by fire mission folder directory. Give the file a new unique name?

3. Inside the file replace old commands/functions with up to date ones - is there a list of obsolete/new commands that i can use as reference?

4. In fitnessgroup.sqf replace any reference to 'BIS_fnc_sceneSetAnimations' with the name of my newly created file. 

Share this post


Link to post
Share on other sites
1 minute ago, Johno89 said:

Give it a new unique name?

Just change the tag, so instead of BIS_fnc_# its TBF_fnc_# (Trial By Fire ?).

Otherwise yes to all of your above.

 

From a quick glance through, all that needs changing is...

DEBUGLOG to diag_log

textLogFormat to diag_log format

calls to RE and arguments to use remoteExec

[ _x, _whatAnimation ] remoteExec[ "playMoveNow", _x ];
[ _x, _whatAnimation ] remoteExec[ "switchMove", _x ];

 

Share this post


Link to post
Share on other sites

Yeah I've attempted what you've described but can't get it to work. This is all a bit beyond me as i don't know coding all that well, i might just delete these marines as its not scenario critical stuff, just some guys exercising lol. 

Share this post


Link to post
Share on other sites

Just bumping this in case anyone would be kind enough to provide code that would enable a group of 7 marines to do a continuous loop of exercises. The only working A3 exercises I've found are  "AmovPercMstpSnonWnonDnon_exercisePushup", "AmovPercMstpSnonWnonDnon_exercisekneeBendB" and "AmovPercMstpSnonWnonDnon_exercisekneeBendA".

 

Cheers

Share this post


Link to post
Share on other sites
On 6/3/2019 at 6:25 PM, Johno89 said:

Just bumping this in case anyone would be kind enough to provide code that would enable a group of 7 marines to do a continuous loop of exercises.

 

Hello there Johno89 !

 

Check this :

 

  • Like 2

Share this post


Link to post
Share on other sites

hi George

 

Thanks for linking the video, but I've already attempted this guide and can't get it to work as Im not familiar with coding.

 

Cheers

  • Like 1

Share this post


Link to post
Share on other sites
3 hours ago, Johno89 said:

I've already attempted this guide and can't get it to work

 

Did you test the examples and tried to adapt this in your codes ?

The best is to share your tries with the community , in order to help you with and learn as well !

  • Like 1

Share this post


Link to post
Share on other sites

I've had a go and this code works but is very primitive / needs improving.

Spoiler

//Squad leader overseeing fitness regime
[] spawn {
  waitUntil {time > 0};
  while {true} do {
    BIS_fitnessgroup01 switchMove "Acts_AidlPercMstpSnonWnonDnon_warmup_3_loop";
    sleep 35;
  };
};

 

//Unlucky S.O.B's doing the exercises
[] spawn {
  waitUntil {time > 0};
  while {true} do {
    BIS_fitnessgroup02 playMove "AmovPercMstpSnonWnonDnon_exercisePushup";
    BIS_fitnessgroup03 playMove "AmovPercMstpSnonWnonDnon_exercisePushup";
    BIS_fitnessgroup04 playMove "AmovPercMstpSnonWnonDnon_exercisePushup";
    BIS_fitnessgroup05 playMove "AmovPercMstpSnonWnonDnon_exercisePushup";
    BIS_fitnessgroup06 playMove "AmovPercMstpSnonWnonDnon_exercisePushup";
    BIS_fitnessgroup07 playMove "AmovPercMstpSnonWnonDnon_exercisePushup";
    sleep 5;
  };
};
 

 

Right now all the marines are looping the animations, however it all seems very robotic as they do them in unison. Is it possible to write a loop script which enables them to switch between;

AmovPercMstpSnonWnonDnon_exercisePushup

AmovPercMstpSnonWnonDnon_exercisekneeBendB

AmovPercMstpSnonWnonDnon_exercisekneeBendA

 

I've also noticed a slight problem with the squad leads animation. After completing the first animation cycle, he suddenly starts standing still as if he's holding a rifle (has no weapon) for about 10 seconds then begins the animation again. I think it has something to do with the 'sleep 35' I've put and the fact that the animation lasts for 34 seconds, but no way to be sure.

  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, Johno89 said:

I've had a go and this code works but is very primitive / needs improving.

 

It's good to hear that you made it !  :thumbs-up:

I'll try to check this as well !

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for finding the anims.

 

Spoiler

waitUntil {time > 0};

//Squad leader overseeing fitness regime
[]spawn{
    while {sleep 1; alive BIS_fitnessgroup01} do{
        BIS_fitnessgroup01 playMove "Acts_AidlPercMstpSnonWnonDnon_warmup_3_loop";
        waitUntil {!((animationState BIS_fitnessgroup01) isEqualTo "Acts_AidlPercMstpSnonWnonDnon_warmup_3_loop")};
    };
};

//Unlucky S.O.B's doing the exercises
[]spawn{
    private _anims = ["AmovPercMstpSnonWnonDnon_exercisePushup","AmovPercMstpSnonWnonDnon_exercisekneeBendB","AmovPercMstpSnonWnonDnon_exercisekneeBendA"];
    while {sleep (5+random 5); alive BIS_fitnessgroup02} do{
       private  _anim = selectRandom _anims;
        BIS_fitnessgroup02 playMove _anim;
        waitUntil {!((animationState BIS_fitnessgroup02) isEqualTo _anim)};
    };
};
[]spawn{
    private _anims = ["AmovPercMstpSnonWnonDnon_exercisePushup","AmovPercMstpSnonWnonDnon_exercisekneeBendB","AmovPercMstpSnonWnonDnon_exercisekneeBendA"];
    while {sleep (5+random 5); alive BIS_fitnessgroup03} do{
       private  _anim = selectRandom _anims;
        BIS_fitnessgroup03 playMove _anim;
        waitUntil {!((animationState BIS_fitnessgroup03) isEqualTo _anim)};
    };
};
[]spawn{
    private _anims = ["AmovPercMstpSnonWnonDnon_exercisePushup","AmovPercMstpSnonWnonDnon_exercisekneeBendB","AmovPercMstpSnonWnonDnon_exercisekneeBendA"];
    while {sleep (5+random 5); alive BIS_fitnessgroup04} do{
       private  _anim = selectRandom _anims;
        BIS_fitnessgroup04 playMove _anim;
        waitUntil {!((animationState BIS_fitnessgroup04) isEqualTo _anim)};
    };
};
[]spawn{
    private _anims = ["AmovPercMstpSnonWnonDnon_exercisePushup","AmovPercMstpSnonWnonDnon_exercisekneeBendB","AmovPercMstpSnonWnonDnon_exercisekneeBendA"];
    while {sleep (5+random 5); alive BIS_fitnessgroup05} do{
       private  _anim = selectRandom _anims;
        BIS_fitnessgroup05 playMove _anim;
        waitUntil {!((animationState BIS_fitnessgroup05) isEqualTo _anim)};
    };
};
[]spawn{
    private _anims = ["AmovPercMstpSnonWnonDnon_exercisePushup","AmovPercMstpSnonWnonDnon_exercisekneeBendB","AmovPercMstpSnonWnonDnon_exercisekneeBendA"];
    while {sleep (5+random 5); alive BIS_fitnessgroup06} do{
       private  _anim = selectRandom _anims;
        BIS_fitnessgroup06 playMove _anim;
        waitUntil {!((animationState BIS_fitnessgroup06) isEqualTo _anim)};
    };
};
[]spawn{
    private _anims = ["AmovPercMstpSnonWnonDnon_exercisePushup","AmovPercMstpSnonWnonDnon_exercisekneeBendB","AmovPercMstpSnonWnonDnon_exercisekneeBendA"];
    while {sleep (5+random 5); alive BIS_fitnessgroup07} do{
       private  _anim = selectRandom _anims;
        BIS_fitnessgroup07 playMove _anim;
        waitUntil {!((animationState BIS_fitnessgroup07) isEqualTo _anim)};
    };
};

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

RCA3 - wow thanks for the code, works like a charm except i had to revert the squad leads section to what i had before (he was floating in the air lol). I also figured out how to prevent him from suddenly standing still every time the animation finished, I added a new line with 'BIS_fitnessgroup01 'disableAi "anim";'.

 

As follow;

Spoiler

waitUntil {time > 0};

//Squad leader overseeing fitness regime
[] spawn {
  waitUntil {time > 0};
  while {true} do {
    BIS_fitnessgroup01 switchMove "Acts_AidlPercMstpSnonWnonDnon_warmup_3_loop";
    sleep 35;
    BIS_fitnessgroup01 disableAI "anim";
  };
};

 

Everything works now as intended apart from one minor problem, one of the exercises (AmovPercMstpSnonWnonDnon_exercisekneeBendB) causes a soldier to take 2 steps backwards. If you wait long enough the group falls out of position, wait even longer and some of the troops step backwards of the deck of the ship lol. Is there a way to permanently 'fix' them to a position? For example giving them a hold waypoint?

 

The easier solution could be to just delete AmovPercMstpSnonWnonDnon_exercisekneeBendB from the mix.

 

Btw RCA3 do you mind if i credit you in the sqf file / workshop page?

 

Cheers

 

 

  • Like 1

Share this post


Link to post
Share on other sites

Hey man, all credit is yours but you can if you want.

My guys didn't move on my test, maybe it's because they're on a ship instead of land.

Try creating an invisible helipad and attach them to it.

 

Cheers

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

×