Jump to content
Alpine_gremlin

Ending the Mission Once All Players are Unconscious

Recommended Posts

Hey guys its me again :P

 

I`ve put together a small scale mission with some relatively hardcore settings. My group generally uses ACE Medical. This particular mission does not allow for respawns and rather than killing players immediately, places them into an unconscious state. Natrually this means that if all players are incapacitated like this, I would like to end the mission rather than have everyone sit there hoping they wake up.

 

I had been using the following code linked to a trigger to end the mission, which worked well until recently:

blufor countSide allUnits <= 0

Since (at least previously) when a unit went unconscious, they were set to captive state, this meant that they were no longer considered "BLUFOR" for the duration of being KO`d. As a result, this worked well. As of recent however, it seems that going unconscious no longer sets the player to captive (tested in debug console). I cannot seem to find alternate commands to use for this end mission trigger.

 

Any ideas would be greatly appreciated! Cheers! :D

 

  • Like 1

Share this post


Link to post
Share on other sites

or

 _allDead = False;
while{!_allDead} do{

    _players = if(isMultiplayer) then{ playableUnits } else{ switchableUnits };
    
    _nDead = 0;
    {
        if(alive _x && captive _x) then{ _nDead = _nDead + 1; };
    }forEach _players;

    //this will be true when all players are dead as well
    //since playableUnits returns an empty array when all are dead.
    if(_nDead == count _players) then{
        _allDead = True;
                
        sleep 6;
        hint "all players are unconcious";
       
        //Individual letters appear quickly in random order, then disappear. Bottom right corner.
        any= [
        "Everyone is unconcious"
        ] spawn BIS_fnc_infoText;
        sleep 2;

    "Mission_Failed" call BIS_fnc_endMission;
    };
    sleep 3;
};
failed = true;
publicvariable "failed"; 
  • Like 1

Share this post


Link to post
Share on other sites
On 12/21/2017 at 12:44 PM, GEORGE FLOROS GR said:

or


 _allDead = False;
while{!_allDead} do{

    _players = if(isMultiplayer) then{ playableUnits } else{ switchableUnits };
    
    _nDead = 0;
    {
        if(alive _x && captive _x) then{ _nDead = _nDead + 1; };
    }forEach _players;

    //this will be true when all players are dead as well
    //since playableUnits returns an empty array when all are dead.
    if(_nDead == count _players) then{
        _allDead = True;
                
        sleep 6;
        hint "all players are unconcious";
       
        //Individual letters appear quickly in random order, then disappear. Bottom right corner.
        any= [
        "Everyone is unconcious"
        ] spawn BIS_fnc_infoText;
        sleep 2;

    "Mission_Failed" call BIS_fnc_endMission;
    };
    sleep 3;
};
failed = true;
publicvariable "failed"; 

 

Where is this suppose to be put?

Description, Init, or a separate SQF?

  • Like 1

Share this post


Link to post
Share on other sites
On 5/29/2020 at 10:28 PM, fin_soldier said:

Where is this suppose to be put?

Description, Init, or a separate SQF?

 

Hello @fin_soldier !

In the init.sqf

  • Like 1

Share this post


Link to post
Share on other sites
15 hours ago, GEORGE FLOROS GR said:

 

Hello @fin_soldier !

In the init.sqf

 

I thought so, but I don't seem to get it working:

 

QQCIwLg.jpg

 

I don't have anything else in the init.sqf

  • Like 1

Share this post


Link to post
Share on other sites
9 hours ago, fin_soldier said:

I thought so, but I don't seem to get it working:

 

:face_palm:I'll try to check it for tomorrow ok !

  • Thanks 1

Share this post


Link to post
Share on other sites
11 hours ago, GEORGE FLOROS GR said:

 

:face_palm:I'll try to check it for tomorrow ok !

 

Thank you so much!

  • Like 1

Share this post


Link to post
Share on other sites

There is no need to script somewhere else than server, so you can place these following codes in initserver.sqf or even a trigger (server only) set to TRUE as condition.

 

For players only, the switchable or playable AIs are not taken into account:

0 = [] spawn {
  private _pass = TRUE;
  while {_pass} do {
      uisleep 0.5;
      if (allPlayers findIf {!(toLowerANSI lifeState _x in ["incapacitated","dead","dead-respawn"])} == -1) then {
      if (isMultiplayer) then {uisleep 6} else {uisleep 0.1};
      _pass = FALSE;
      if (!isMultiplayer) exitWith {enableTeamSwitch FALSE};
      if (allPlayers findIf {!(toLowerANSI lifeState _x in ["incapacitated","dead","dead-respawn"])} == -1) exitWith {  
        "EveryoneLost" call BIS_fnc_endMissionServer;
      };
     _pass = TRUE;
    };  
  };
};

 

For all playable units in MP (no interest in SP) :
 

0 = [] spawn {
  if (!isServer or !isMultiplayer) exitWith {};
  private _pass = TRUE;
  while {_pass} do {
      uisleep 0.5;
      if (playableUnits findIf {!(toLowerANSI lifeState _x in ["incapacitated","dead","dead-respawn"])} == -1) then {
      uisleep 6;
      _pass = FALSE;

      if (playableUnits findIf {!(toLowerANSI lifeState _x in ["incapacitated","dead","dead-respawn"])} == -1) exitWith {  
        "EveryoneLost" call BIS_fnc_endMissionServer;
      };
     _pass = TRUE;
    };  
  };
};

 

 

   

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites
7 hours ago, pierremgi said:

There is no need to script somewhere else than server, so you can place these following codes in initserver.sqf or even a trigger (server only) set to TRUE as condition.

 

For players only, the switchable or playable AIs are not taken into account:


0 = [] spawn {
  private _pass = TRUE;
  while {_pass} do {
      uisleep 0.5;
      if (allPlayers findIf {!(toLowerANSI lifeState _x in ["incapacitated","dead","dead-respawn"])} == -1) then {
      if (isMultiplayer) then {uisleep 6} else {uisleep 0.1};
      _pass = FALSE;
      if (!isMultiplayer) exitWith {enableTeamSwitch FALSE};
      if (allPlayers findIf {!(toLowerANSI lifeState _x in ["incapacitated","dead","dead-respawn"])} == -1) exitWith {  
        "EveryoneLost" call BIS_fnc_endMissionServer;
      };
     _pass = TRUE;
    };  
  };
};

 

For all playable units in MP (no interest in SP) :
 


0 = [] spawn {
  if (!isServer or !isMultiplayer) exitWith {};
  private _pass = TRUE;
  while {_pass} do {
      uisleep 0.5;
      if (playableUnits findIf {!(toLowerANSI lifeState _x in ["incapacitated","dead","dead-respawn"])} == -1) then {
      uisleep 6;
      _pass = FALSE;

      if (playableUnits findIf {!(toLowerANSI lifeState _x in ["incapacitated","dead","dead-respawn"])} == -1) exitWith {  
        "EveryoneLost" call BIS_fnc_endMissionServer;
      };
     _pass = TRUE;
    };  
  };
};

 

 

   

 

Thanks, I'll take a look tomorrow!

Share this post


Link to post
Share on other sites
On 6/1/2020 at 1:26 PM, pierremgi said:

There is no need to script somewhere else than server, so you can place these following codes in initserver.sqf or even a trigger (server only) set to TRUE as condition.

 

Hmm, I do get an error trying both methods...

 

initServer.sqf:

vHNsCGQ.jpg

 

Trigger:

E83FHDX.jpg

 

 

I used the script below as I don't need it to work in SP:

 

 
 
1
 Advanced issue found
 
 
On 6/1/2020 at 8:53 PM, fin_soldier said:

0 = [] spawn {
  if (!isServer or !isMultiplayer) exitWith {};
  private _pass = TRUE;
  while {_pass} do {
      uisleep 0.5;
      if (playableUnits findIf {!(toLowerANSI lifeState _x in ["incapacitated","dead","dead-respawn"])} == -1) then {
      uisleep 6;
      _pass = FALSE;

      if (playableUnits findIf {!(toLowerANSI lifeState _x in ["incapacitated","dead","dead-respawn"])} == -1) exitWith {  
        "EveryoneLost" call BIS_fnc_endMissionServer;
      };
     _pass = TRUE;
    };  
  };
};

I tried, the first one as well, but it gave the same error.

 

Share this post


Link to post
Share on other sites

My scripts are working.

So, perhaps that's the BI forum editor issue, adding for nuts some invisible character when copying/pasting. I don't know why there is no solution for that, this wasn't the case some months (years?) ago.

  • Thanks 1

Share this post


Link to post
Share on other sites
7 hours ago, pierremgi said:

My scripts are working.

So, perhaps that's the BI forum editor issue, adding for nuts some invisible character when copying/pasting. I don't know why there is no solution for that, this wasn't the case some months (years?) ago.

 

I managed to get it working by manually typing in the code character by character.

 

Strange, but it works now. Thank you!

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

×