Home   Help Search Login Register  

Author Topic: Detecting if 50% of an enemy is dead in an area  (Read 567 times)

0 Members and 1 Guest are viewing this topic.

Offline Kaio23

  • Members
  • *
  • I'm a llama!
Detecting if 50% of an enemy is dead in an area
« on: 28 Apr 2005, 20:54:57 »
This condition isn't working correctly:

Code: [Select]
"!Alive _x" count thislist >= 0.5 *Count thislist
Any ideas? It activates when all the enemies are dead.

And yes, I have the trigger set to "East Present"
« Last Edit: 28 Apr 2005, 20:58:44 by Kaio23 »

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Detecting if 50% of an enemy is dead in an area
« Reply #1 on: 28 Apr 2005, 21:16:36 »
thislist only contains the living unit in the trigger area.  So the only time your condition can be true is when the list is empty.

To do what you want you would need to have a list of all those that were in the area at the start and then check thislist of your trigger against 50% of the list that was originally there.
« Last Edit: 28 Apr 2005, 21:19:08 by THobson »

Offline Kaio23

  • Members
  • *
  • I'm a llama!
Re:Detecting if 50% of an enemy is dead in an area
« Reply #2 on: 28 Apr 2005, 21:27:24 »
 :o

So I need to name all my units and put them into a notepad file in my mission directory?

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Detecting if 50% of an enemy is dead in an area
« Reply #3 on: 28 Apr 2005, 21:55:09 »
I didn't say that.

Say you want to do this for all of the east units in your mission.  Create a large trigger to cover them all set it to east present and in the activation field put

AllEast = + thislist

You have now created an array of all the east units at the start of the mission (neglect to put in the + sign and this list will constantly update as units die, with the + sign it is frozen for the duration of the mission.)

Then in the trigger you refer to above have the condition

({alive _x} count thislist) < 0.5* (count AllEast)

I have not tested this and when I want to do things like this I use scripts, but the above should give you some idea of the sort of thing to do.

NB:

If it works - do an experiment.  Take out the + in + thislist, and I predict it will stop working.
« Last Edit: 28 Apr 2005, 21:55:53 by THobson »

Offline Kaio23

  • Members
  • *
  • I'm a llama!
Re:Detecting if 50% of an enemy is dead in an area
« Reply #4 on: 28 Apr 2005, 23:07:31 »
That did it, thanks :)

Offline dmakatra

  • Members
  • *
  • Better known as Armsty
Re:Detecting if 50% of an enemy is dead in an area
« Reply #5 on: 29 Apr 2005, 06:56:21 »
WTH? +? How'd you know that?

:beat: *Gets Shot* :beat:

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re:Detecting if 50% of an enemy is dead in an area
« Reply #6 on: 29 Apr 2005, 07:51:59 »
From comref:

Quote
Array assignment

Description:
Assignment used on arrays assigns only pointer to the same array to the target variable. When b is an array, after executing a = b both a and b represent the same array. When b is changed, a is changed as well. One particular situation that can lead to this behaviour is aList = list sensor_name. You can force creating a copy of array by using unary operator +Array

So without the + AllEast will just be a pointer to the list belonging to the trigger.  With the + a whole new copy is made and AllEast points to that.

Ta da!
« Last Edit: 29 Apr 2005, 08:01:43 by THobson »

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Detecting if 50% of an enemy is dead in an area
« Reply #7 on: 29 Apr 2005, 10:34:14 »
A classic example of why you must read the comref from cover to cover more than once.
Plenty of reviewed ArmA missions for you to play