Jump to content
micklivi1

How to use array with playmove

Recommended Posts

Hi,

 

I'm setting up a scene where troops are walking down a road. I'm using playmove. I can get it to work when i have 1 unit. But i want to pass in an array of units.

 

I don't know if my syntax is right, for using playmove with an array. But i keep getting errors.

//Individual Unit
 for "_i" from 0 to 3 do  
  {  
   S1 playmove "AmovPercMwlkSlowWrflDf_ver2";    
   sleep 3.631;   
  };

//Array of units
PRIVATE troops = ["S1", "S2", "S3", "S4", "S5"]
for "_i" from 0 to 3 do
 {
  {_x playmove "AmovPercMwlkSlowWrflDf_ver2"} FOREACH troops;
 }; 

 

Share this post


Link to post
Share on other sites

Use switchmove,

Spoiler

you_fnc_anims= 
{
params	["_caller", "_currentState", "_thisMove"];
private	_grp = group _caller;
private	_animType= you_anims select _thisMove;
 
	if (_currentState=="SAFE") then { 
			{_x disableAI "ALL"; _x switchMove _animType;} foreach units _grp;
		} else {
			{_x enableAI "ALL"; _x switchmove "";} foreach units _grp;};

};

Here's an example of the array,


you_anims=["", "AmovPercMrunSnonWnonDf", "Acts_SupportTeam_Left_KneelLoop", "Acts_ShowingTheRightWay_loop", "Acts_InjuredLookingRifle01", "Acts_GetAttention_Loop", "Acts_carFixingWheel", "Acts_CivilHiding_2", "Acts_CivilShocked_1", "Acts_AidlPsitMstpSsurWnonDnon04"];

Call with: 


[actorNAME, "SAFE", 1] call you_fnc_anims;

 

Have fun!

  • Like 1

Share this post


Link to post
Share on other sites
3 minutes ago, wogz187 said:

Use switchmove,

  Hide contents


you_fnc_anims= 
{
params	["_caller", "_currentState", "_thisMove"];
private	_grp = group _caller;
private	_animType= you_anims select _thisMove;
 
	if (_currentState=="SAFE") then { 
			{_x disableAI "ALL"; _x switchMove _animType;} foreach units _grp;
		} else {
			{_x enableAI "ALL"; _x switchmove "";} foreach units _grp;};

};

Here's an example of the array,



you_anims=["", "AmovPercMrunSnonWnonDf", "Acts_SupportTeam_Left_KneelLoop", "Acts_ShowingTheRightWay_loop", "Acts_InjuredLookingRifle01", "Acts_GetAttention_Loop", "Acts_carFixingWheel", "Acts_CivilHiding_2", "Acts_CivilShocked_1", "Acts_AidlPsitMstpSsurWnonDnon04"];

Call with: 



[actorNAME, "SAFE", 1] call you_fnc_anims;

 

Have fun!

 

So would it be "_x switchmove "AmovPercMwlkSlowWrflDf_ver2"} FOREACH troops;"?

Share this post


Link to post
Share on other sites

@micklivi1,

Quote

{_x disableAI "ALL";_x switchMove "AmovPercMwlkSlowWrflDf_ver2";} foreach troops;

Have fun!

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for the reply, unfortunately i'm getting an error. "Undefined variable in expression "troops""

 

PRIVATE troops = [S1, S2,];
{_x disableAI "ALL";_x switchMove "AmovPercMwlkSlowWrflDf_ver2";} foreach troops;

I have tried with and without quotes around the variable elements and without the semi colon at the end of the array definition.

Any ideas?

Share this post


Link to post
Share on other sites

@micklivi1,

I tested by:
1) creating two units in editor and naming them Bob1 and Bob2.
2) entering in debug console,

troops=[bob1, bob2];
{_x disableAI "ALL";_x switchMove "AmovPercMwlkSlowWrflDf_ver2";} foreach troops;

should be good-to-go.

Quote

PRIVATE troops = [S1, S2,];-- the second comma


oh-- take out the second comma!

  • Like 2

Share this post


Link to post
Share on other sites

That's crazy, you're right. When i past into the debug console. All is good(i also used the Bob's!) but when i put the same thing into my sqf, i get an error!

Share this post


Link to post
Share on other sites

Hang, it's working! Must have had old crap lying around, thanks alot for your help dude!

  • Like 1

Share this post


Link to post
Share on other sites

Another quick question. I've added a while statement.

troops=[S1, S2, S3, S4 , S5, S6, S7, S8, S9, S10, S11, S12, S13, S14, S15, S16];
 while {alive t1} Do
{
{_x disableAI "ALL";_x switchMove "AmovPercMwlkSlowWrflDf_ver2";} foreach troops;
  _x disableAI "ALL";_x switchMove "Acts_Briefing_SB_Out";} foreach troops;
}

So that when "t1" dies i want them to stop marching. But what seems to happen is that on startup. My troops are skating along the ground (no animation) as soon as i kill "t1". They start doing th animation properly.

Share this post


Link to post
Share on other sites

@micklivi1,

Quote

So that when "t1" dies i want them to stop marching.

Spoiler

 


    waitUntil {!alive T1};
    {_x enableAI "ALL"; _x switchMove "";} forEach troops;

as function,


you_fnc_animTroops=
{
	{_x disableAI "ALL";_x switchMove "AmovPercMwlkSlowWrflDf_ver2";} foreach troops;
	waitUntil {!alive T1};
	{_x enableAI "ALL"; _x switchMove "";} forEach troops;
};
[] call you_fnc_animTroops;

//better maybe,

you_fnc_animTroops=
{	params [["_caller", troops], ["_deadGuy", T1]];
	{_x disableAI "ALL";_x switchMove "AmovPercMwlkSlowWrflDf_ver2";} foreach _caller;
	waitUntil {!alive _deadGuy};
	{_x enableAI "ALL"; _x switchMove "";} forEach _caller;
};
[nil,nil] call you_fnc_animTroops;

 

 

Have fun!

  • Like 4

Share this post


Link to post
Share on other sites

Thanks a lot dude, very helpfull! I've made 200 man OpFor march right into an ambush. Only way i could get them to walk in a straight line was to use animations!

  • Like 3

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

×