Jump to content
Sign in to follow this  
zagor64bz

[SOLVED]% of AI killed as trigger condition.

Recommended Posts

Hi all,

 

there's any way to set a % of enemy killed as trigger condition?

What I'm trying to achieve is this: an SP mission where a trigger will control the color of a marker area based on % of enemy presence.

So, for instance, if OPFOR presence falls below, let's say, 10% the area is conquered.

 

NOTE: I did ask the same question on the EOS thread, but I thought if anyone is searching for this outside EOS, it will find an answer here.

Share this post


Link to post
Share on other sites

@zagor64bz, sure, here is example:

_unitsNumber = { !(isPlayer _x) and { (side _x) == opfor } and { _x inArea _trg } } count allUnits;
 
_trg setVariable ["minAliveUnitsNumber", ceil (0.1 * _unitsNumber)];

_trg setTriggerActivation ["EAST", "NOT PRESENT", true];
_trg setTriggerStatements [
    "this or { (count thisList) <= (thisTrigger getVariable ['minAliveUnitsNumber', 0]) }",
    _onActivation,
    _onDeactivation
];

 

  • Thanks 1

Share this post


Link to post
Share on other sites
1 minute ago, Schatten said:

@zagor64bz, sure, here is example:


_unitsNumber = { !(isPlayer _x) and { (side _x) == opfor } and { _x inArea _trg } } count allUnits;
 
_trg setVariable ["minAliveUnitsNumber", ceil (0.1 * _unitsNumber)];

_trg setTriggerActivation ["EAST", "NOT PRESENT", true];
_trg setTriggerStatements [
    "this or { (count thisList) <= (thisTrigger getVariable ['minAliveUnitsNumber', 0]) }",
    _onActivation,
    _onDeactivation
];

 

THANKS MAN!!!

And just to be clear, all that goes into the condition field?

Share this post


Link to post
Share on other sites

@zagor64bz, no, that is piece of code that sets up your trigger referenced by _trg, so you need paste it in your script file (e.g., init.sqf).

The condition is

this or { (count thisList) <= (thisTrigger getVariable ["minAliveUnitsNumber", 0]) }

but it wont work on its own as you want.

Share this post


Link to post
Share on other sites
1 minute ago, Schatten said:

@zagor64bz, no, that is piece of code that sets up your trigger referenced by _trg, so you need paste it in your script file (e.g., init.sqf).

The condition is


this or { (count thisList) <= (thisTrigger getVariable ["minAliveUnitsNumber", 0]) }

but it wont work on its own as you want.

I gotcha, man. That was obvious...my old brain didn't register it quick enough..LOL.

 

Thank you.

Share this post


Link to post
Share on other sites

EDIT: Sorry @Schatten

I can't get it to work.

Just for the sake of it...

-I place down a squad of OPFOR in VR

-placed down a player

-placed a trigger 50X50 named _trig over the squad of OPFOR. Type: none Activation:none Condition field: 

this or { (count thisList) <= (thisTrigger getVariable ["minAliveUnitsNumber", 0]) }

on Act:

hint "ENEMY SQUAD DEFEATED!!!"; ///JUST TO SEE IF TRIGGER WORKS

Copy/pasted this into my init.sqf

_unitsNumber = { !(isPlayer _x) and { (side _x) == opfor } and { _x inArea _trg } } count allUnits;
 
_trg setVariable ["minAliveUnitsNumber", ceil (0.1 * _unitsNumber)];

_trg setTriggerActivation ["EAST", "NOT PRESENT", true];
_trg setTriggerStatements [
    "this or { (count thisList) <= (thisTrigger getVariable ['minAliveUnitsNumber', 0]) }",
    _onActivation,
    _onDeactivation
];

no joy!!!

It throws this error:

_trg setVariab>
14:37:44   Error position: <_trg } } count allUnits;

_trg setVariab>
14:37:44   Error Undefined variable in expression: _trg
14:37:44 File C:\Users\claudio\Documents\Arma 3 - Other Profiles\ZAGOR64BZ\mis..., line 1
14:37:44 Error in expression <d { _x inArea _trg } } count allUnits;

_trg setVariable ["minAliveUnitsNumber",>
14:37:44   Error position: <_trg setVariable ["minAliveUnitsNumber",>
14:37:44   Error Undefined variable in expression: _trg
14:37:44 File C:\Users\claudio\Documents\Arma 3 - Other Profiles\ZAGOR64BZ\mis..., line 3

and the hint shows at the beginning of test mission.:headscratch:

Share this post


Link to post
Share on other sites

@zagor64bz, sure, objects (trigger in this case) cannot have names that starts with underscore!

Next, set trigger activation to "OPFOR" and type to "NOT PRESENT".

Also, delete these lines from your init.sqf file:

_trg setTriggerActivation ["EAST", "NOT PRESENT", true];
_trg setTriggerStatements [
    "this or { (count thisList) <= (thisTrigger getVariable ['minAliveUnitsNumber', 0]) }",
    _onActivation,
    _onDeactivation
];

 

  • Like 2

Share this post


Link to post
Share on other sites
14 minutes ago, Schatten said:

@zagor64bz, sure, objects (trigger in this case) cannot have names that starts with underscore!

Next, set trigger actiovation to "OPFOR" and type to "NOT PRESENT".

Also, delete these lines from your init.sqf file:


_trg setTriggerActivation ["EAST", "NOT PRESENT", true];
_trg setTriggerStatements [
    "this or { (count thisList) <= (thisTrigger getVariable ['minAliveUnitsNumber', 0]) }",
    _onActivation,
    _onDeactivation
];

 

Work as intended now!!!!

 

THANK YOU!!!

 

Just to recap... I had this working with a trigger:

-variable name: trig01

-activation OPFOR

-not present

-condition:

 this or { (count thisList) <= (thisTrigger getVariable ["minAliveUnitsNumber", 0]) }

On Act:- whatever you need to exec.

 

 

In the init.sqf:

_unitsNumber = { !(isPlayer _x) and { (side _x) == opfor } and { _x inArea trg01 } } count allUnits;
 
trg01 setVariable ["minAliveUnitsNumber", ceil (0.2 * _unitsNumber)];

 

 

 

 

 

 

 

  • Like 1
  • Thanks 1

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  

×