Home   Help Search Login Register  

Author Topic: Select an alive unit from a units array in MP  (Read 1360 times)

0 Members and 1 Guest are viewing this topic.

Offline RKurtzDmitriyev

  • Former Staff
  • ****
Select an alive unit from a units array in MP
« on: 02 Jan 2010, 17:22:10 »
Hi guys. I'm making a multiplayer co-op mission. (Yes, it's a conversion of Village De-Pacification). What I want to do is set up a cutscene in which certain players do certain scripted things. These players must be alive. Some players may not be, because this cutscene will take place just before the debriefing (there is no respawn in this mission).

In singleplayer, I would do something like this:

Code: [Select]
starofshow = (units mainloons) select 0
starofshow setBehaviour "SAFE"
starofshow setpos [getpos object 90193 select 0, (getpos object 90193 select 1) + 20]

Et cetera, blah blah blah. I would do all sorts of things with "starofshow," and he would have to be alive, otherwise he couldn't be selected from the array "units mainloons." (mainloons is the name of a group).

Question: will this work in multiplayer? Will the "units" array contain any dead people? In singleplayer, it will not.

But I noticed that the "leader" command works differently in MP. It's the original leader of the group, and as such, it may return a dead unit. This feature is probably related to respawn. If so, it's also quite likely that

Code: [Select]
(units mainloons) select 0
may select a dead person.

Does anyone know how the units command behaves in multiplayer? I'd rather know beforehand, because multiplayer beta testing is so much more difficult. ;)

If it doesn't work, does anyone know of another method for getting what I'm looking for? :P
The OFP Editing Center wishes to remind you that the faithful COMREF will never threaten to stab you and, in fact, cannot speak.
However, in the event that it does speak, you are encouraged to heed its advice. ;)

Offline dr. seltsam

  • Members
  • *
Re: Select an alive unit from a units array in MP
« Reply #1 on: 05 Jan 2010, 03:05:29 »
hmm..

The command "units" can result in an array that contains dead soldiers. You know sometimes somebody of your group dies, and in MP you get a message like "Oh no.. 3 is dead" minutes later. During that timeframe the "units" command can have dead soldiers in the array, although the alive status of that soldier was updated and transmitted very fast in the network. Remember all the white death messages in MP games.

"leader" is one of the most unreliable commands in MP. The passive check of this can often have dead leaders as result (maybe until his dead body was found, or we hear "4.. taking command", or we have an order from the new leader, ... and many many other reasons), i really don't know what are the rules here that make the leader. It even is possible that for a short timeframe (1 - 2 sec) everyone is leader in the group. That mostly occurs after a groupleader dies, and we have a gamesituation with high pings. We don't use "leader" for important calculations.

What works, is this:

Code: [Select]
_u_ar=[p1,p2,p3,p4,p5,p6]
_a_ar=[]
{if (alive _x) then {_a_ar=_a_ar+[_x]}} foreach _u_ar
if (count _a_ar == 0) then {hint "Error"; exit}

starofshow = _a_ar select 0
starofshow setBehaviour "SAFE"
starofshow setpos [getpos object 90193 select 0, (getpos object 90193 select 1) + 20]


p1,p2, ... etc. are the possible soldiers. I prefer this over  _u_ar=units mainloons  because i'm not 100% sure if all network computer would result in the same array, and i don't want to have different shuffled arrays on every computer. It even works, if one of the players (p1,p2,.. ) is not present in the game, and its value is undefined. Here we have a case, where the OFP engine does it's job with undefined values. This is one of the most reliable ways to get your cutscene work.

Hope that helps
:cool2:

« Last Edit: 07 Jan 2010, 01:50:28 by dr. seltsam »