Jump to content
Sign in to follow this  
lawman_actual

Animations & Lifestate in Multiplayer

Recommended Posts

As part of a multiplayer mission, there's a downed AAF pilot.

The unit is setUnconscious, and had a "revive" option. Here is it's .init:

 

  if isServer then {this setUnconscious true;};    
  this addAction [   
      "<t color='#B70000'>Revive</t>",    
              {      
     _help = [_this select 0,_this select 1] execVM "law\pilotRevive.sqf"; 
     pilotRevive = true;  
              },   
                 
      "",0,true,true,"","(side _this == west) && (lifeState _target == 'INCAPACITATED')",3   
  ];  

 

pilotRevive.sqf the following.

 

params [["_casualty",objNull],["_caller",objNull]];

if ((isNUll _caller) || (isNUll _casualty)) exitWith {};


  if (isMultiplayer) then  
        { 
         (_caller) playMove "AinvPknlMstpSnonWnonDnon_medic0";  
         sleep 5; 
         (_casualty) setUnconscious false; 
         (_casualty) playMove "AinjPpneMstpSnonWnonDnon_rolltofront"; 
         sleep 4;		//was 3 
         (_casualty) playMove "AmovPpneMstpSnonWnonDnon_AmovPercMstpSnonWnonDnon"; 
         sleep 5.25; 	//was 1.25
         [_casualty,""] remoteExec ["switchMove",0,true];
         (_casualty) enableAI "ALL"; 
         (_casualty) setUnitPos "UP"; 
         (_casualty) setHit ["legs", 1];  
         (_casualty) doMove [6675.358,11257.388,0]; 
         sleep 2; 
         (leader group (_caller)) groupChat "The pilot thanks us."; 
         sleep 3; 
         (leader group (_caller)) groupChat "He says we can go. He will radio for CasEvac."; 
         sleep 1; 
          
          
        } 
        else 
        { 
         (_caller) playMove "AinvPknlMstpSnonWnonDnon_medic0"; 
         sleep 5; 
         (_casualty) setUnconscious false; 
         (_casualty) playMove "AinjPpneMstpSnonWnonDnon_rolltofront"; 
         sleep 4; 
         (_casualty) playMove "AmovPpneMstpSnonWnonDnon_AmovPercMstpSnonWnonDnon"; 
         sleep 5; 
         (_casualty) switchMove ""; 
         (_casualty) enableAI "ALL"; 
         (_casualty) setUnitPos "UP"; 
         (_casualty) setHit ["legs", 1];  
         (_casualty) doMove [6675.358,11257.388,0]; 
         sleep 2; 
         (leader group (_caller)) groupChat "The pilot thanks us."; 
         sleep 3; 
         (leader group (_caller)) groupChat "He says we can go. He will radio for CasEvac."; 
         sleep 1; 
        }; 
		
		

 

 

The events work fine in singleplayer; the unit rolls over, gets up and hobbles to the position with his injured leg.

In multiplayer, he currently goes from down to up with no transition, and his lifestate remains unconscious.

 

I think i'm not really understanding what needs to be executed where here.

I tried executing the playMove's on each client before but I was getting reports that the unit was getting stuck in a loop of different animations and ultimately ended up still lying face down.

But then I saw that playMove has a global effect, so I stopped executing it on all clients. Except now the intermediate actions all seem to be having no effect, and the sleep commands didn't seem to appear.

 

Help would be much appreciated, since I can only test this properly on the community test server which is a pain to keep doing.

 

Thanks,

Law

 

 

 

 

Share this post


Link to post
Share on other sites

Well there can be multiple issues for this script in MP

Basically is all about locality of commands you are using.

What you need to remember is as long the pilot isn't an member  of  any player groups, he stays local to server and remote to players.

The code from addaction is called locally , at player pc where action is performed.

Now lets look at locality dependencies of command for example <playMove>.

As you can see there are "AL" arguments locality and "EG" effects locality boxes above.

AL means that the object at which playmove will be called need to be local to PC where the command executes.

So the pilot is local to server then player PC need to remote exec call this command to the server. 

Using remoteExecCall  command playmove will be executed immediately by server,  what can be usefully where you need the effect in right moment.

Command switchmove works in different way.

Argument of this command not need to be local , you could  just use target in your addaction code, but effect of this command are local. (effect will be visible only on PC where the code are executed).

That means you need to remoteececcall it from player which PC is runing addaction to everybody.

At end you should  not forget to globally  remove the addaction from pilot after done

 

Now is not that hard to understand how to script this for MP

Share this post


Link to post
Share on other sites

Thanks David, a nice clear explanation.

I'll play around with it and call back if I get more problems

Share this post


Link to post
Share on other sites

Here you have an example of something like that i just posted this:

 

 

  • Like 1

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  

×