Jump to content
thirith

How to check that all players are in trigger area?

Recommended Posts

Quote

{alive _x} count (allPlayers -  entities "HeadlessClient_F" ) isEqualTo {alive _x && _x inArea thisTrigger} count (allPlayers - entities "HeadlessClient_F" )  && ({alive _x} count allPlayers) > 0

I tried that latter one but got an immediate error that Arma expected a Boolean, not script. Not sure I understand why, since pierremgi's code looks like a true/false proposition to me, but then I'm pretty inexperienced with respect to Arma syntax.

 

I've now used muzzleflash's most recent version and it seems to work well.

 

Next win/lose condition I have to add: check whether the six survivors are still alive or if they're dead, excluding any that weren't spawned to begin with. (Even if the helicopter crew is still alive, as soon as the survivors are dead, the mission fails.) Is there a generally advisable way of handling triggers and units that may be alive, dead or simply not spawned?

Share this post


Link to post
Share on other sites

Okay, my idea is to have a Game Logic running a do... until loop that checks for each of the Heisenbergian survivors a) if they exist and, if so, b) if they are alive, and that then adds up all the existing survivors. Something along the following lines:

 

while {_Heisenberg > 0} do
   {
   _Heisenberg = 6;
   {
      _xString = format ["%1", _x];
      if (isNil _xString) then {_Heisenberg = _Heisenberg - 1} else
         {
         if (!alive _x) then {_Heisenberg = _Heisenberg - 1}
         }
   } forEach [b1, b2, b3, b4, b5, b6];
};
endMission "END1";

 

Does this make sense?

 

Edit: Or am I making things much too complicated and I should just have a trigger condition along the lines of this? It's ugly but it might be easiest and have a lighter footprint than the loops.

 

(isNil "b1" OR !alive b1) AND (isNil "b2" OR !alive b2) AND (isNil "b3" OR !alive b3) AND (isNil "b4" OR !alive b4) AND (isNil "b5" OR !alive b5) AND (isNil "b6" OR !alive b6)

Share this post


Link to post
Share on other sites

Not sure what you mean here:

5 hours ago, thirith said:

excluding any that weren't spawned to begin with

Do you mean if someone joins later during the game they shouldn't be counted towards the living survivors?

 

But anyways. You can do it using a game logic. But here is the condition, ready for a trigger:

{!isNil {_x} and {alive _x}} count [b1, b2, b3, b4, b5, b6] == 0

The endMission part can then go into the on activation.

Share this post


Link to post
Share on other sites

I don't think the mission needs to allow for people joining later - although seeing how often it happens that someone briefly drops out due to connectivity issues, perhaps it should. Would your condition work with people who join late? As far as I can tell, it should.

 

Another question about your code: if I checked correctly, isNil requires a string while alive requires an object. Is that taken care of by the curly brackets in !isNil {_x}? Or did I misunderstand the BIKI pages?

Share this post


Link to post
Share on other sites
26 minutes ago, thirith said:

I don't think the mission needs to allow for people joining later - although seeing how often it happens that someone briefly drops out due to connectivity issues, perhaps it should. Would your condition work with people who join late? As far as I can tell, it should.

 

Another question about your code: if I checked correctly, isNil requires a string while alive requires an object. Is that taken care of by the curly brackets in !isNil {_x}? Or did I misunderstand the BIKI pages?

Mine doesn't care about when they join. If at any time all players on the server are dead, it will activate. That means that if everybody (survivors) gets connectivity issue at the same time and get disconnected, the trigger will activate - but if that happens you probably want to restart the mission anyway. If someone joins later, they will now also have to die to lose the mission.

26 minutes ago, thirith said:

Another question about your code: if I checked correctly, isNil requires a string while alive requires an object. Is that taken care of by the curly brackets in !isNil {_x}? Or did I misunderstand the BIKI pages?

See the alternative syntax on BIKI.

  • Like 1

Share this post


Link to post
Share on other sites

Ah, good to know. What programming skills I have mainly go back to the C64 and Basic, so I look at something like "_x" and my brain fails to accept that this might still be accepted as a variable.

Share this post


Link to post
Share on other sites

Sorry, just replace isEqualTo by ==

({alive _x} count (allPlayers -  entities "HeadlessClient_F" ) == {alive _x && _x inArea thisTrigger} count (allPlayers - entities "HeadlessClient_F" ))  && ({alive _x} count allPlayers) > 0

 

or add brackets:

({alive _x} count (allPlayers -  entities "HeadlessClient_F" ) isEqualTo ({alive _x && _x inArea thisTrigger} count (allPlayers - entities "HeadlessClient_F" )))  && ({alive _x} count allPlayers) > 0

  • Like 2

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

×