OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: CR_Elson on 28 May 2005, 21:26:15
-
i am using a trigger to display all vehicles destroyed in the screen when all the vehicles are destroyed but sometimes when all the vehicles are blown up the messae doesnt show
in condition is
!alive v1 && !alive v2 && !alivev3 && !alive v4
and in activation is
Hint "all vehicles Destroyed"
is there another way that this can be done ive heard that !alive isnt always the best way to detect if a vehicle is alive or not but i dont know it
thanks.
-
Try instead:
(!canMove v1) && (!canMove v2) && (!canMove v3) && (!canMove v4)
or somesuch.
And ........Welcome to the forums ;D ;D
Planck
-
yeh cheers man seems to be working
-
But you can have vehicles that cannot move, but thay are still 'alive' in the sense that you can use them if you repair them. You might want to try
if (getDammage vehiclename > 0.9) then {vehiclename setDammage 1}
or if it is in a script
@(getDammage vehiclename > 0.9)
vehiclename setDammage 1
-
@THobson: Thanks for that tip - I've also fallen foul of this puzzle. You start with !alive, then blow the tracks of some BMP which stops moving and looks black but the trigger doesn't fire. So you change the trigger to !canmove, and the trigger tells you everything's ok while the BMP machine guns your squad.
Another wrinkle that caught me out: you can't use !alive with units who may not always be present. So if you use the random probability of having a unit, or if you have units not present in cadetmode (as I have), then you can't test for them being !alive - the result is not a boolean (it's some sort of null?).
-
True.
(alive unit1) and (alive unit2) ....
will always produce a false if any of the units do not exist. Better is to count the number alive in a group.
{alive _x} count units group unit1 < 1
will return true if all the units in the group that unit1 belongs to are dead irrespective of how many units started in the group
-----------------------------------------------------------------------------
Back to the original question, as an alternative to killing the vehicle you could use a combination of canMove and canFire as follows:
not (canFire unit1) and not (canMove unit1)
would do what you want. OFP allows things like this to be done quite neatly: If you have a list of vehicles and you want something to happen only when they are all out off action you could use:
if ({(canFire _x) or (canMove _x)} count [veh1,veh2,veh3,...] < 1) then {take action}
where veh1 veh2 veh3 etc are the vehicles you want to check