OFPEC Forum

Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting General => Topic started by: Undeceived on 01 Jun 2011, 22:24:29

Title: [Solved] How to identify the _x that activates a trigger?
Post by: Undeceived on 01 Jun 2011, 22:24:29
Hi! ;)


I have the following in the condition line of a trigger (the trigger has size 0 and repeats itself):

Code: [Select]
{(Dude knowsAbout _x) > 0.0002} count (units group enmygrp) > 0
If I'm not mistaken, this should activate the trigger when "Dude" knows about any unit of the group called "enmygrp". At least I hope this happens! :D


Now my question is:

How can I identify WHO THAT UNIT IS that makes the trigger launch so I can use his name to launch a script from the activation line?

In other words: I want the name of the detected unit of the group so I can do this with it:

Code: [Select]
[nameofdetectedunit] exec "dude_kills_detected_unit.sqs";

Do you have an idea? Thanks a lot!
Title: Re: How to identify the _x?
Post by: bedges on 01 Jun 2011, 22:36:54
Personally I would us a slowly looping script for this rather than use a trigger: much more control, and a lot easier to grab the needed variables.

More to the point, is there a reason you're not using a killed event handler? Do they still have event handlers in Arma2?  :dunno:

(spot the OFP user...)
Title: [Solved] How to identify the _x?
Post by: Undeceived on 02 Jun 2011, 12:09:54
:) It works with this code in the trigger (thanks to Celery!):


To identify the trigger activator ("_x") of a certain enemy group:

Condition line: true

Activation line: 0=[] spawn {while {alive Dude} do {{if (Dude knowsAbout _x > 0.0002) then {[_x] execVM "engage.sqf"}} forEach units enemygrp; sleep 1}};



To identify the trigger activator ("_x") in a trigger area that covers all possible units:

Condition line: true

Activation line: 0=[] spawn {while {alive Dude} do {{if (Dude knowsAbout _x > 0.0002) then {[_x] execVM "engage.sqf"}} forEach list triggername; sleep 1}};

-> The trigger that covers all units has to be set to Activate by Anybody.







With this codes and a "engage.sqf" script which I'll post under this you can make the AI ("Dude") recognize the enemy in the dark night without having to set a trigger for every possible enemy unit... :)



engage.sqf

Code: [Select]
_enemy = _this select 0;

dude reveal _enemy;

dude addweapon "NVGoggles";

sleep 0.1;

dude reveal _enemy;
dude lookat _enemy;


sleep 1;

dude removeweapon "NVGoggles";

dude reveal _enemy;


sleep 5;

dude reveal _enemy;


if (true) exitWith {};

(I still didn't find another way without adding the NVGs for 1 second...)