Home   Help Search Login Register  

Author Topic: Cheking in one trigget if one of several units has been damaged  (Read 1895 times)

0 Members and 1 Guest are viewing this topic.

seanver

  • Guest
How do I check in one trigget if one of several units has been damaged and if its been damaged (i know how to check it) that unit is destroyed.

Offline Ranger

  • Members
  • *
  • Hoo-ah!
It sounds to me like you want a two-stage trigger that first sees which unit is damaged, then second sees if any damaged units are destroyed.

Why not just check outright if a unit is destroyed?  Wouldn't the result be the same?

In the condition field, put the following code:

"not (alive _x)" count [unit1,unit2,unit3,...,unitN] > 0

This code will count how many units in the array of units are not alive (are destroyed).  If more than 0 (i.e., at least 1) are destroyed, the condition is met and the trigger will activate.

If you meant something else, explain what you meant indepth, and I'll try to help.
« Last Edit: 11 Sep 2002, 20:53:46 by Ranger »
Ranger

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
If you know the syntax you can check as many things as you like in one trigger, it's just a case of how often you are prepared to type "or".

Alternatively, have a script running the background all the time.    Put in a 5 second delay or something every time it goes round the loop so it doesn't eat too much CPU/memory.  

Script might be better since it sounds like you might be trying to do an if-then sort of thing.
Plenty of reviewed ArmA missions for you to play

seanver

  • Guest
I've been misunderstood. I explain my problem, perhaps there's another solution than the one I thought:

 In a mission I'm doing, the condition to win is that the resistance isn't present on a trigger's area. I have a couple of T-72s tanks and a couple of BMPs. Moreover a shilka. Well, once the infantry units were neutrilzed, I found that a T-72 is almost destroyed. It looked like it couldn't move or fire. But it was alive so the mission didn't finish. And although it was alive, nobody attacked it. I had AT and LAW soldiers, M60 and M1A1 near it and none of them attacked. So I thought of destroying the enemy tanks if they get a determined amount of damage.

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Ah-ha!   Well this one we can answer.   Have a look at the [un]official command ref at the canMove and canFire commands.    You'll need a whole bunch of logic if you have a lot of vehicles but the cond. field of your end#1 trigger will look something like this:-

(not (canFire tank1)) and (not (canFire tank2)) and (not (canMove tank1)) and (not (canMove tank2))

I'm pretty confident you don't actually need all the brackets, but I always put 'em in to be on the safe side.    You probably don't need both canmove and canfire, I'd just choose the one which is more relevant for your particular circumstance.

What should happen then is that once all the tanks are immobile and can't fire the mission will end even if a tank has not been completely destroyed.    I have had a similar problem, when a vehicle is close enough to being destroyed that nobody shoots at it, but the game engine thinks it is still alive.     The solution also gets you out of the problem of the occasional wounded crew messing up your ending.

Hope that's closer to the right track.

Plenty of reviewed ArmA missions for you to play

Bremmer

  • Guest
I've had similar troubles SeAnVer. Here's the code I use to check if tanks are no longer a threat:

(count crew tank < 2) or (getdammage tank > 0.6)

I don't use canmove/canfire as it is possible to eliminate a tank crew, but leave the tank in working order (it doen't happen often, but it does happen). A dammage value of 0.6 should incapacitate any tank, and all tanks need at least two crew to be effective (gunner and driver).

As macguba suggested you can string a few of these conditions together using the AND command to check all your vehicles. Personally I use seperate triggers for each vehicle then sync them all to a single master AND game logic.

Good Luck

 :)

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Quote
and all tanks need at least two crew to be effective (gunner and driver).

ouch Bremmer, you're killing a guy, only because his buddy is
dead. Come on, give him a chance  ;D

~S~ CD
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

seanver

  • Guest
 Hmmm are you sure the tank is incapacitated when its damage is 0.6? I tried with setdamage and it killed me. So I think I'll use the thing of the crew and canfire and canmove together.

Bremmer

  • Guest
Quote
are you sure the tank is incapacitated when its damage is 0.6?

Pretty sure - It may still be able to move and fire, but if you try playing in the gunner position you should find that you can no longer aim. This is with generalised damage over the whole tank as well - if the damage is concentrated on one area (as it usually is) then you can be pretty sure that the tank is in a bad way.

@ Chris - I never use this sort of condition to destroy incapacitated tanks, or to end missions - but rather to make the survivors jump out of their vehicles and run for their lives.  Got to give them a fighting chance to get away at least  ;)

Cheers
« Last Edit: 12 Sep 2002, 22:11:06 by Bremmer »

seanver

  • Guest
Ooooooook I trust you :P. Now other thing. How can I end the mission if i want these conditions: all units dead on the area -infantry and perhaps BMPs included- and the tanks with the Bremmer's conditions

Bremmer

  • Guest
Re:Cheking in one trigget if one of several units has been damaged
« Reply #10 on: 12 Sep 2002, 23:19:16 »
Here's the way I do it. Its slightly complex, but the results are good:

1) set up a game logic unit. Give it two waypoint, make sure the first one is an AND type. The second one doesnt really matter.

2) set up a trigger for each of your armoured units with the conditions you have chosen to indicate that the tank is dead  - In my case (count crew tankname < 2) or (getdammage tankname > 0.6).
In the On Activation field of each trigger put "_x leavevehicle _x" foreach crew tankname. This causes any survivors to bail out.

3) sync these triggers with the first gamelogic waypoint. The game logic will now only reach the second waypoint when all the armour has been destroyed.

4) In the On Activation field of the second waypoint put armourgone = true. You should also probably define armourgone = false at the start of the mission (eg in an init line or file).

5) set up a trigger over the area you want to monitor. Make it an East (or West if the player is East) present type. Set the min,max and med timeouts to 20s. This is important as it gives the tank crews time to eject.
Make the condition armourgone and count thislist < 8. The number  you put in here will determine when the enemy will decide to retreat (ie if their side has fewer soldiers than 8 they will decide to high tail it).
In On Activation put "_x move getpos retreat" foreach thislist. Stick a game logic unit called retreat wherever you want the bad guys to run too - ie outside the area you want to monitor.

6) Finally place another trigger over your area and make it east not present (or west) and type End#1. Once you have killed all the opposition, or they have fled, the mission will end.


I know that sounds like a lot of hard work, but your mission will be much better for not having to hunt the last man.
If you need any help I can easily whip up a sample mision for you.

Cheers

seanver

  • Guest
Re:Cheking in one trigget if one of several units has been damaged
« Reply #11 on: 12 Sep 2002, 23:26:07 »
That's fine, thank u a lot for the help.