Jump to content
Sign in to follow this  
snaiperskaya

Trigger with "not alive" not working

Recommended Posts

Hi guys, i created a script that spawns some units then give them a waypoint, setted for destroy an UAV Terminal.

So this is my script:

Antiaa = [getMarkerPos "patrolAA", WEST, ["USMC_WarfareBUAVterminal"],[],[],[],[],[],180] call BIS_fnc_spawnGroup;
patrol = [getMarkerPos "patrolspawn", EAST, ["RU_Soldier_AT", "RUS_Soldier_TL", "MVD_Soldier_GL", "RU_Soldier_MG", "RU_Soldier_AT"]] call BIS_fnc_spawnGroup;
patrolwp1 = patrol addWaypoint [getMarkerPos "patrol_marker", 50];
patrolwp1 setWaypointType "Destroy";
task1 = player createSimpleTask ["Bla bla blaa"];
task1 setSimpleTaskDestination (getMarkerPos "patrolAA"); 
hint "Bla bla bla";

(Just never mind the UAV and units' name, i changed idea so many times...)

Then i make a trigger:

Activation OpFor

Repeatedly

Present

On condition: not alive (Antiaa) --- I tried "not alive Antiaa" too

On activation: {deleteVehicle _x} forEach units patrol;

So, what's wrong?:S

Sorry for my bad english:S

Edited by snaiperskaya

Share this post


Link to post
Share on other sites
instead of : not alive (Antiaa)

use: !(alive Antiaa)

just a note:

!alive Antiaa

without paranteces works just as well, it comes down to personal preference.

Share this post


Link to post
Share on other sites

BIS_fnc_spawnGroup returns a Group, so Antiaa would be a group and not a unit, so !alive Antiaa would fail because alive checks objects not groups.

You'd need to do something like check if the count of units in Antiaa is 0 or below whatever threshold you had in mind. Might also want to add in a Timeout for the trigger a few seconds or else the trigger might trip before the units are even spawned.

Share this post


Link to post
Share on other sites

kylania is correct. My old brain is becoming a liability these days. As per kylania's advice, try using this:

_aliveCount = {alive _x} count units Antiaa;
if (_aliveCount == 0) then{        
{deleteVehicle _x} forEach units patrol;        
};

Share this post


Link to post
Share on other sites
kylania is correct. My old brain is becoming a liability these days. As per kylania's advice, try using this:
_aliveCount = {alive _x} count units Antiaa;
if (_aliveCount == 0) then{        
{deleteVehicle _x} forEach units patrol;        
};

Hi, thanks everyone for answers, i'm trying to make a script with the codes below, but seems to not work. I just used a simple trigger, with retarded activation (10 secs), and an exec to the script.

Share this post


Link to post
Share on other sites

_aliveCount = {alive _x} count units Antiaa;

if (_aliveCount == 0) then{

Why not just

if ({alive _x} count units Antiaa==0) then {

Share this post


Link to post
Share on other sites

arma2oa_2012-02-03_22-07-47-54.jpg

This isn't working yet... I've tried so many combinations with Countdown/Tmeout options...

Edited by snaiperskaya

Share this post


Link to post
Share on other sites

It isn't a script error (I already use -showscripterrors), there's something wrong with trigger settings, maybe... Ex: With Timeout setted on 12 14 16, i saw units disappear after 12 seconds...

Share this post


Link to post
Share on other sites

One important thing is that if units or only 1 of the units are inside vehicles, you cannot delete them directly it will halt or error out.

The trick is to setPos them away then delete:

{_x setPos (getPos _x); deleteVehicle _x} foreach units Antiaa;

also for the condition, dont think it matters much, but this is how i write those conditions and that works:

({alive _x} count units Antiaa) == 0

the paranteces makes sure that the one variable inside the paranteces is checked against the variable outside it, in this case 0.

Share this post


Link to post
Share on other sites
One important thing is that if units or only 1 of the units are inside vehicles, you cannot delete them directly it will halt or error out.

The trick is to setPos them away then delete:

{_x setPos (getPos _x); deleteVehicle _x} foreach units Antiaa;

also for the condition, dont think it matters much, but this is how i write those conditions and that works:

({alive _x} count units Antiaa) == 0

the paranteces makes sure that the one variable inside the paranteces is checked against the variable outside it, in this case 0.

Thanks for reply, but this doesn't work:S

How have you setted trigger's settings?

Share this post


Link to post
Share on other sites

Try adding this && to your condition....

So the trigger is fired (this) and your condition is also met.

[b][i]this &&[/i][/b] ({alive _x} count units Antiaa) == 0;

Share this post


Link to post
Share on other sites

I was curious and ran your script with some added debug msgs. count always returns a value of 0, which may explain why your other group is being deleted after the timer runs its course. This may be because you are using fnc_spawnGroup to create the UAV Terminal (I'm not sure). Use createVehicle instead.

Try this as your script:

Antiaa = "USMC_WarfareBUAVterminal" createVehicle getMarkerPos "patrolAA";
patrol = [getMarkerPos "patrolspawn", EAST, ["RU_Soldier_AT", "RUS_Soldier_TL", "MVD_Soldier_GL", "RU_Soldier_MG", "RU_Soldier_AT"]] call BIS_fnc_spawnGroup;patrolwp1 = patrol addWaypoint [getMarkerPos "patrol_marker", 50];
patrolwp1 setWaypointType "Destroy";
task1 = player createSimpleTask ["Bla bla blaa"];
task1 setSimpleTaskDestination (getMarkerPos "patrolAA"); 
hint "Bla bla bla";

Then in your trigger (with timer of your choice):

Cond: !alive Antiaa

Act: {deleteVehicle _x} forEach units patrol;

Share this post


Link to post
Share on other sites
Try adding this && to your condition....

So the trigger is fired (this) and your condition is also met.

[b][i]this &&[/i][/b] ({alive _x} count units Antiaa) == 0;

"this" is not needed when you dont want to refer to the actual trigger settings.

Share this post


Link to post
Share on other sites
I was curious and ran your script with some added debug msgs. count always returns a value of 0, which may explain why your other group is being deleted after the timer runs its course. This may be because you are using fnc_spawnGroup to create the UAV Terminal (I'm not sure). Use createVehicle instead.

Try this as your script:

Antiaa = "USMC_WarfareBUAVterminal" createVehicle getMarkerPos "patrolAA";
patrol = [getMarkerPos "patrolspawn", EAST, ["RU_Soldier_AT", "RUS_Soldier_TL", "MVD_Soldier_GL", "RU_Soldier_MG", "RU_Soldier_AT"]] call BIS_fnc_spawnGroup;patrolwp1 = patrol addWaypoint [getMarkerPos "patrol_marker", 50];
patrolwp1 setWaypointType "Destroy";
task1 = player createSimpleTask ["Bla bla blaa"];
task1 setSimpleTaskDestination (getMarkerPos "patrolAA"); 
hint "Bla bla bla";

Then in your trigger (with timer of your choice):

Cond: !alive Antiaa

Act: {deleteVehicle _x} forEach units patrol;

Finally it works! Thanks you all guys!

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×