Home   Help Search Login Register  

Author Topic: Two array questions  (Read 1059 times)

0 Members and 1 Guest are viewing this topic.

Chomps

  • Guest
Two array questions
« on: 18 Aug 2003, 03:08:00 »
1) I have an array of civilians and want a trigger to activate when a certain amount of them are dead.  What do I use as the condition to check the array?

2) I am not sure if this is array related, but I need a trigger to activate when a certain kind of weapon is present inside a certain ammo crate.  The mission objective is to deliver a radio, and this trigger is to complete the objective.  Again, what is the condition?

Thanks in advance.  :)

Unnamed

  • Guest
Re:Two array questions
« Reply #1 on: 18 Aug 2003, 04:07:42 »
Hi,

If you run this:

Code: [Select]
{if !(Alive _x) Then {Civilians=Civilians-[_x]}} ForEach Civilians

(i.e If Civilian is not alive, then delete the dead guy from your array.)

Prior to using the count command on Civilians (your array). Would that do the job?

Or you could use a trigger, but I'm not to sure about how much strain triggers put on OFP.

At least this way, you only have to check who is left alive when you need to. You would lose the original Civilian Array data, unless you made a copy.
« Last Edit: 18 Aug 2003, 04:16:58 by Unnamed »

Chomps

  • Guest
Re:Two array questions
« Reply #2 on: 18 Aug 2003, 04:17:25 »
Thanks, that's a better system you got there, I have it on a loop that runs and checks every few seconds (I want constant checking, but immediate response is not necessary, so I do not want to add any more strain.)

Also, it shouldn't it be

Code: [Select]
{if !(Alive _x) Then {Civilians=Civilians-[Civilians select _x]}} ForEach Civilians
or do both work?

Unnamed

  • Guest
Re:Two array questions
« Reply #3 on: 18 Aug 2003, 04:25:50 »
_x is the actual guy (or current element in your array) rather than his or her's position in the array.

If you get the chance, try it with a Trigger. I think the strain would depend on how many civilians your checking.

Triggers are causing me a whole load of jip at the moment, but I doubt I am using them correctly.

Chomps

  • Guest
Re:Two array questions
« Reply #4 on: 18 Aug 2003, 04:36:59 »
Oh, I didn't catch that, I keep thinking of _x as the counting variable in a loop, but I see it actually refers to the unit, you were right, thanks again.  ;D

Unnamed

  • Guest
Re:Two array questions
« Reply #5 on: 18 Aug 2003, 04:51:20 »
Quote
I keep thinking of _x as the counting variable in a loop

I know exactly what you mean. Old habits die hard ;) Perhaps BIS are all ex Ada programers?

It would have been better if OFP set every dead guy to objnull. Then you could just do:

Quote
Civilians=Civilains-[objnull]
« Last Edit: 18 Aug 2003, 05:02:01 by Unnamed »

Chomps

  • Guest
Re:Two array questions
« Reply #6 on: 18 Aug 2003, 16:14:07 »
Even better would be if when they died they no longer counted as the civilian side, or they are no longer type man, so I can just use the countSide or countType commands.

I got the first problem under control now, any suggestions for the second?

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Two array questions
« Reply #7 on: 18 Aug 2003, 17:03:44 »
I don't suppose the usual weapon commands (weapon, hasWeapon etc) will work on an ammo crate but there's no harm in trying.

You could fake it something like this with two triggers: the syntax is wrong, this is just a sketch

Condition:   loon1 hasweapon radio and loon1 distance ammocrate < 10
On activation:  playerBack=true

Condition:  playerBack and loon1 distance ammocrate < 2 and not (loon1 hasweapon radio)
On activation:  objdone

Plenty of reviewed ArmA missions for you to play