OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: NightJay0044 on 29 Jan 2009, 05:18:55

Title: Triggering AI Units
Post by: NightJay0044 on 29 Jan 2009, 05:18:55
Hi, I'm currently making a mission.  I'm using a trigger that ends if 4 AA Soldiers are alive.  So if west enters the trigger and the 4 AA soldiers are still alive the mission will end. 

WHat's the code for this? Thank you.. :)
Title: Re: Triggering AI Units
Post by: Worldeater on 29 Jan 2009, 09:47:26
Hint #1: thisList (http://community.bistudio.com/wiki/Triggers#Condition) contains the answer.
Hint #2: You have to check the typeOf (http://community.bistudio.com/wiki/typeOf) the units.
Hint #3: Count (http://community.bistudio.com/wiki/count) the ones you are interested in.

It took me about a minute to get it working. How long have you tried?


<--
Title: Re: Triggering AI Units
Post by: Ext3rmin4tor on 29 Jan 2009, 10:07:05
Make two triggers with the following parameters

ACTIVATION: West - Present
TYPE: NONE
CONDITION: this
ON ACTIVATION: call {if ("soldierWAA" countType thisList >= 4) then {end = true};}

The second trigger is for the end

ACTIVATION: Noone
TYPE: end #1
Condition: end
ACTIVATION: //call an end cinematic script here if you have one




Title: Re: Triggering AI Units
Post by: NightJay0044 on 30 Jan 2009, 04:36:53
Thanks a lot Ext3rmin4tor, you've been helpful in the forums, kudos to you.   :D
Title: Re: Triggering AI Units
Post by: Rommel92 on 31 Jan 2009, 23:17:36
Could also be simplified (except without the 1s delay of the second trigger) too:

ACTIVATION: WEST - Present
TYPE: END #x
CONDITION: ("soldierWAA" countType thisList >= 4)
ON ACTIVATION: <any end scripts here>
Title: Re: Triggering AI Units
Post by: Ext3rmin4tor on 01 Feb 2009, 12:19:25
It doesn't work because you have as condition

Code: [Select]
"soldierWaa" countType array >= 4

as trigger condition, this means that if there are 4 AA soldiers or more EVERYWHERE on the map the trigger will fire. Besides the west activation is not considered because you have to put "this" in the condition field. Another error is that "thisList" contains the units that satisfy the trigger condition, so it doesn't even exist before the trigger is fired and thus can't be put in the condition field.

I made an error too because everything executed by an "end #" type trigger can't be seen because the mission ends immediately, so if you have a cinematic sequence, launch it from the first trigger.
Title: Re: Triggering AI Units
Post by: Rommel92 on 01 Feb 2009, 20:50:27
...Another error is that "thisList" contains the units that satisfy the trigger condition, so it doesn't even exist before the trigger is fired and thus can't be put in the condition field....

Sorry, I forgot the west activation.

Code: (WEST AA Soldiers) [Select]
ACTIVATION: Anybody
TYPE: END #x
CONDITION: ("soldierWAA" countType thisList > 3) AND (WEST countSide thisList > 4)
ON ACTIVATION: <any scripts here>

Code: (EAST AA Soldiers) [Select]
ACTIVATION: Anybody
TYPE: END #x
CONDITION: ("soldierEAA" countType thisList > 3) AND (WEST countSide thisList > 0)
ON ACTIVATION: <any scripts here>

Tested and comfirmed working.
Title: Re: Triggering AI Units
Post by: Ext3rmin4tor on 02 Feb 2009, 19:34:20
Yes but the problem of the end cinematic still remains, if he has an end cinematic it won't be displayed if launched by an end type trigger, you must launch it from a generic trigger and at the end of the cinematic fire the end trigger.
Title: Re: Triggering AI Units
Post by: Rommel92 on 02 Feb 2009, 20:35:26
This is true, however he never specified that he wanted an end cinematic, so he could just make two of these triggers, one with an end and a timeout, and the other with no timeout (and no end type) and have it execute his cinematic script (providing he had and wanted one)

 ;)