Jump to content
Sign in to follow this  
kityatyi

Mission failed if 5 (or more) buddies die

Recommended Posts

Hello!

Noob here - could you please let me know how to trigger a "Mission Failed " if 5 or more units in my group die? 

I have a simple SP scenario where I am part of an 8 strong BLUFOR squad (I am not the Team Leader, if it matters) trying to secure a compound full of CSAT soldiers. I would like to have the mission failed if five or more soldiers from my squad are dead. Please let me know what is the easiest way to achieve this, what code should I write and where?

Thank you in advance!

Share this post


Link to post
Share on other sites
//init.sqf:
killedCounter = 0;
{
  _x addEventHandler ["Killed", {
      killedCounter = killedCounter + 1;
      if (killedCounter > 4) then {
          ["fail1", false, true, true, false] spawn BIS_fnc_endMission;
      };
  }];
} forEach (units (group player);

//description.ext:
class CfgDebriefing {  
	class fail1 {
		title = "Mission failed";
		subtitle = "5 or more of your teammates died";
		description = "The mission failed because 5 or more of your teammates died.";
	};
};

Put that code in those files in your mission.  If those files don't exist yet make them. (Untested but it should work, there might be a small syntax error somewhere, been doing too much java)

  • Thanks 1

Share this post


Link to post
Share on other sites
11 minutes ago, stanhope said:

//init.sqf:
killedCounter = 0;
{
  _x addEventHandler ["Killed", {
      killedCounter = killedCounter + 1;
      if (killedCounter > 4) then {
          ["fail1", false, true, true, false] spawn BIS_fnc_endMission;
      };
  }];
} forEach (units (group player);

//description.ext:
class CfgDebriefing {  
	class fail1 {
		title = "Mission failed";
		subtitle = "5 or more of your teammates died";
		description = "The mission failed because 5 or more of your teammates died.";
	};
};

Put that code in those files in your mission.  If those files don't exist yet make them. (Untested but it should work, there might be a small syntax error somewhere, been doing too much java)


Thank you very much, will give it a try!

Share this post


Link to post
Share on other sites

Yea, no I can't blame that one on java. Add another ')' behind the one you see on that line so it'll become:

Spoiler


//init.sqf:
killedCounter = 0;
{
  _x addEventHandler ["Killed", {
      killedCounter = killedCounter + 1;
      if (killedCounter > 4) then {
          ["fail1", false, true, true, false] spawn BIS_fnc_endMission;
      };
  }];
} forEach (units (group player));

//description.ext:
class CfgDebriefing {  
	class fail1 {
		title = "Mission failed";
		subtitle = "5 or more of your teammates died";
		description = "The mission failed because 5 or more of your teammates died.";
	};
};

 

 

Share this post


Link to post
Share on other sites
1 minute ago, stanhope said:

Yea, no I can't blame that one on java. Add another ')' behind the one you see on that line so it'll become:

  Reveal hidden contents



//init.sqf:
killedCounter = 0;
{
  _x addEventHandler ["Killed", {
      killedCounter = killedCounter + 1;
      if (killedCounter > 4) then {
          ["fail1", false, true, true, false] spawn BIS_fnc_endMission;
      };
  }];
} forEach (units (group player));

//description.ext:
class CfgDebriefing {  
	class fail1 {
		title = "Mission failed";
		subtitle = "5 or more of your teammates died";
		description = "The mission failed because 5 or more of your teammates died.";
	};
};

 

 

Figured out myself too, shouldn't have bothered you with this, the error message basically tells what was the issue. Thank you very much once again, the mission launched perfectly now, let's see how it's dealing with the dead count. :-)

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  

×