Home   Help Search Login Register  

Author Topic: Squad Casualtys  (Read 1074 times)

0 Members and 1 Guest are viewing this topic.

Offline 456820

  • Contributing Member
  • **
Squad Casualtys
« on: 21 Aug 2006, 17:44:14 »
Okay i have a mission where i want it to end if too many of the players squad dies.
I havent done scripting or much mission making in a long time so im very rusty again.

Basically how can i have a script check when the players squad has more then 3 members dead. Also i would like it adaptable to other missions. So one mission 3 casualtys allowed the next 4 is etc.

Thanks.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re: Squad Casualtys
« Reply #1 on: 21 Aug 2006, 17:52:30 »
It is easier to count the number still alive:

{alive _x} count units group player

To count the casulties you would need to do something like:

In init.sqs

SquadSize = {alive _x} count units group player


In the mission:

_casualties = SquadSize - {alive _x} count units group player


Or some such

Offline 456820

  • Contributing Member
  • **
Re: Squad Casualtys
« Reply #2 on: 21 Aug 2006, 20:22:31 »
Thanks alot.
But im for some reason totally clueless on how to put that into a script to end a mission when 3 men from the players squad are killed.
Ive thought of a long and complicated way but im sure there is an easier way.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re: Squad Casualtys
« Reply #3 on: 22 Aug 2006, 00:31:23 »
The trigger that ends the mission should have the Condition field:

SquadSize - {alive _x} count units group player >= 3

Initialise SquadSize at the start of the mission.

An alternative is to give each of your squad a killed Event handler that increments a counter.

In init.sqs put the line:
Casualties = 0

in the player's init field put:
{_x AddEventHandler ["killed",{Casualties = Casualties + 1}]} forEach units group this

Make a trigger that ends the mission with the condition field:

Casualties >=3
« Last Edit: 22 Aug 2006, 00:48:45 by THobson »

Offline 456820

  • Contributing Member
  • **
Re: Squad Casualtys
« Reply #4 on: 22 Aug 2006, 09:36:47 »
Thanks alot.
Think ill go with the event handler way becuase event handlers seem to be the only thing i still remember.
Anyway thanks alot.

#Topic solved.