OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: 456820 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.
-
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
-
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.
-
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
-
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.