Comrades in Arms Discussion Board
Need help: Trigger fail if a Blufor dies. - Printable Version

+- Comrades in Arms Discussion Board (http://forum.ciahome.net)
+-- Forum: Comrades in Arms Life (http://forum.ciahome.net/forumdisplay.php?fid=3)
+--- Forum: Mission Making (http://forum.ciahome.net/forumdisplay.php?fid=8)
+--- Thread: Need help: Trigger fail if a Blufor dies. (/showthread.php?tid=3509)



Need help: Trigger fail if a Blufor dies. - Lightspeed - 11-08-2016

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


RE: Need help: Trigger fail if a Blufor dies. - Varanon - 11-08-2016

(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) ?


RE: Need help: Trigger fail if a Blufor dies. - Lightspeed - 11-09-2016

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.


RE: Need help: Trigger fail if a Blufor dies. - Varanon - 11-09-2016

(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 ?


RE: Need help: Trigger fail if a Blufor dies. - Variable - 11-09-2016

I'm pretty sure he wants to count only the 5 players, and ignore the other slots.


RE: Need help: Trigger fail if a Blufor dies. - Lightspeed - 11-09-2016

Count the 5 players that join the mission if playing coop.

Or count 10 if you use the AI as well.


RE: Need help: Trigger fail if a Blufor dies. - Alwarren - 11-09-2016

What if any of them disconnects? Or crashes?


RE: Need help: Trigger fail if a Blufor dies. - Lightspeed - 11-10-2016

Sounds too difficult. Don't worry, I will drop that objective.


Need help: Trigger fail if a Blufor dies. - Variable - 11-10-2016

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.


RE: Need help: Trigger fail if a Blufor dies. - Varanon - 11-10-2016

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.


RE: Need help: Trigger fail if a Blufor dies. - Lightspeed - 11-10-2016

Thanks Varanon, i will give it a try tonite. ☺