Home   Help Search Login Register  

Author Topic: vehicle !alive  (Read 999 times)

0 Members and 1 Guest are viewing this topic.

CR_Elson

  • Guest
vehicle !alive
« 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.

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:vehicle !alive
« Reply #1 on: 28 May 2005, 21:31:23 »
Try instead:

(!canMove v1) && (!canMove v2) && (!canMove v3) && (!canMove v4)

or somesuch.

And ........Welcome to the forums   ;D ;D


Planck
« Last Edit: 28 May 2005, 21:33:44 by Planck »
I know a little about a lot, and a lot about a little.

CR_Elson

  • Guest
Re:vehicle !alive
« Reply #2 on: 28 May 2005, 21:37:23 »
yeh cheers man seems to be working

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:vehicle !alive
« Reply #3 on: 28 May 2005, 21:41:05 »
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

bluehand

  • Guest
Re:vehicle !alive
« Reply #4 on: 28 May 2005, 22:17:03 »
@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?).

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:vehicle !alive
« Reply #5 on: 29 May 2005, 08:18:31 »
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

« Last Edit: 29 May 2005, 08:32:40 by THobson »