Comrades in Arms Discussion Board

Full Version: Need help: Trigger fail if a Blufor dies.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi

As part of the next GR missions, I'd like a core objective in all missions to be No Casualties.
So I need a trigger that is clever enough to know how many of all the slots spawned in to the mission, and then, to know if one of them dies.

Possible kicker:
If person decides to play SP mode (through MP browser) and using all of the AI, then the trigger also needs to determine that one of the AI has been killed.

Thanks for any assistance on this.


Lighty  Huh
(11-08-2016, 12:18 PM)Lightspeed Wrote: [ -> ]As part of the next GR missions, I'd like a core objective in all missions to be No Casualties.
So I need a trigger that is clever enough to know how many of all the slots spawned in to the mission, and then, to know if one of them dies.

Define "spawned in the mission". All possible playable units ? All real players (no AI) ?
By spawned I mean, at start of mission when players load into the map.
So the script needs to count the number of players who join the mission, and then, if one of them gets killed, the 'No Casualties' objective fails.
(11-09-2016, 10:48 AM)Lightspeed Wrote: [ -> ]By spawned I mean, at start of mission when players load into the map.
So the script needs to count the number of players who join the mission, and then, if one of them gets killed, the 'No Casualties' objective fails.

That's what I don't get.

Say, you place 10 playable units. 5 players join. Do you want to count those 5 players, or all 10 playable units ?
I'm pretty sure he wants to count only the 5 players, and ignore the other slots.
Count the 5 players that join the mission if playing coop.

Or count 10 if you use the AI as well.
What if any of them disconnects? Or crashes?
Sounds too difficult. Don't worry, I will drop that objective.
Light speed if you don't mind mission failure if AI dies, and the only blufor on the map is the players' team, then check if any blufor died.
I've been thinking about this, and there is a simple solution, although it does not involve a trigger

Basically, you add an onKilled event handler to the units you want to "monitor".

For each of the player objects, add this line to their init fields:


Code:
this addEventHandler ["killed", {_this call OnPlayerKilledHandler}];


In Init.sqf, add the following:

Code:
OnPlayerKilledHandler = {
  /* Add this only if you want the mission NOT to fail when a playable AI is killed that is not player controlled */
  if (!isPlayer) exitWith {};

  /* Here, you add the code that you want to execute when a player is killed to fail the mission, something like this: */
  ["taskNoPlayerMustDie", "failed"] call FHQ_fnc_ttSetTaskState;
  [] spawn {
      sleep 10;
      "EveryoneLost" call BIS_fnc_EndMissionServer;
  };
};

This would, on a player death, fail the task "taskNoPlayerMusDie" (insert the name you used here), and after 10 seconds, bring up the mission failed screen.

As I wrote above, the line "if (!isPlayer") ... " basically makes the thing does nothing when an AI is killed that is not currently the player. Just leave out the whole line if you want the mission to fail if ANY playasble team member is killed.


This is IHMO the simplest method of achieving this, and should be pretty robust. Anything with a trigger is going to be too fiddly.
Thanks Varanon, i will give it a try tonite. ☺