Jump to content
Sign in to follow this  
Doodle

Enemy count in trigger condition

Recommended Posts

I know I have seen this somewhere but although I have searched I cannot find it again so I was wondering if anyone here can help me out.

I have an area that switches when all OPFOR are killed (opfor & not present) in trigger options that works fine

but what I need to happen is the trigger to activate if there are say 5 or less opfor present. This way the attacking force do not need to kill every enemy to succede the objective

I am sure it is something like "if enemycount <5"

Thanks for help in advance.

Share this post


Link to post
Share on other sites

I like to use this condition:

{alive _X && !(fleeing _X)} count thislist < 1

This is for an OPFOR (or whatever side is your enemy) is present trigger. You can of course use a number other than 1. What it does is count how many still alive enemies are not retreating (and thus still holding the area).

Share this post


Link to post
Share on other sites

Tumbus up to that one!

{alive _X && !(fleeing _X)} count thislist < 1

:D Why easy when you can do it complicated. I prefer that one aswell

Share this post


Link to post
Share on other sites
I like to use this condition:

{alive _X && !(fleeing _X)} count thislist < 1

This is for an OPFOR (or whatever side is your enemy) is present trigger. You can of course use a number other than 1. What it does is count how many still alive enemies are not retreating (and thus still holding the area).

I'm using the code above but its triggering when there are far more enemies in the area than I have stipulated.

Last test I had about 12 left in the area when I had it set to 5.

would enemy spawning in effect this at all?

Do enemy flee then change their minds and then get all brave again?

If not does anyone have any ideas what could be the cause?

Share this post


Link to post
Share on other sites
Tyson;1708925']I'm using the code above but its triggering when there are far more enemies in the area than I have stipulated.

Last test I had about 12 left in the area when I had it set to 5.

would enemy spawning in effect this at all?

Do enemy flee then change their minds and then get all brave again?

If not does anyone have any ideas what could be the cause?

that condition is looking for AI that is running away, Not how many AI are in the trigger and AI do stop fleeing after awhile ;)

Share this post


Link to post
Share on other sites

I know this is an old thread but Its relevant to ask:

Is there a way to acquire the unit array of all opfor inside a trigger, that is set to blufor detected by opfor?

i want to set all opfor into danger inside this area, once blufor is detected, but im trying to avoid using double triggers to acquire one effect.

maybe someone can help me out?

Share this post


Link to post
Share on other sites

bluefor detected will only return bluefor units that is detected.

only way is to predefine groups or use a global variable, and a second trigger over same trigger.

1st trigger:

bluefor detected by opfor, repeated.

on act:

combatmode = true;

on dea:

combatmode = false;

2nd trigger opfor present, repeated.

cond: this AND combatmode

on act:

Allgroups = []; {if ( !((group _x) in Allgroups) ) then {(group _x) setBehaviour "COMBAT"}} foreach thisList;

on dea:

Allgroups = []; {if ( !((group _x) in Allgroups) ) then {(group _x) setBehaviour "SAFE"}} foreach thisList;

Share this post


Link to post
Share on other sites
bluefor detected will only return bluefor units that is detected.

only way is to predefine groups or use a global variable, and a second trigger over same trigger.

1st trigger:

bluefor detected by opfor, repeated.

on act:

combatmode = true;

on dea:

combatmode = false;

2nd trigger opfor present, repeated.

cond: this AND combatmode

on act:

Allgroups = []; {if ( !((group _x) in Allgroups) ) then {(group _x) setBehaviour "COMBAT"}} foreach thisList;

on dea:

Allgroups = []; {if ( !((group _x) in Allgroups) ) then {(group _x) setBehaviour "SAFE"}} foreach thisList;

actually, i have found another solution that works with just using one trigger and 1 global

trigger

blufor detected by opfor, repeated

onact:

Opforguys1 = nearestObjects [AB1, ["RU_Soldier_Base", "RW_RU_Soldier_Base"], 200]; 
{_x setbehaviour "COMBAT"; _x setcombatmode "RED"} foreach Opforguys1; 
{_x reveal ((list AB1) select 0)} foreach Opforguys1

nearestobjects lets you specify what classtypes you want, so i used the base class of russian infantry (and a check for the winter reskins base class here)

i also named the trigger AB1, and made it reveal the first detected unit to all the opfor in the trigger area, to make it feel better.

Your solution works great, but the mission im working on is going to be quite dynamic and big with lots of scripts and triggers running already, so this atleast solves the problem of having to have an extra one.

Thanks for the suggestion tho I do appreciate it ;)

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  

×