Jump to content
Sign in to follow this  
saintaw

Need help with end trigger (large defensive mission)

Recommended Posts

Hiya,

I am building a SP mission, the gist of it is:

You're at an airbase, under attack... your mission is to survive and if possible repel the attack.*

You are facing air/armor/motorised infantry as the main asault, and a few surprises.

*- You are in charge of a small squad, but many AI squads defend as well.

Now, my question(s):

I have a 'loose' end trigger as a huge trigger around the airfield with BLUFOR NOT PRESENT (I am thinking all BLUFOR dead in this area).

If I do the same for OPFOR...it doesn't work, as the engagement is too large and there is always going to be some ejected pilot lost somewhere in the woods...

Could I perchance set a trigger with a percentage of 'alive' enemy force in the area? How would I do this? Someone with more experience maybe has a better idea?

Share this post


Link to post
Share on other sites

When using area triggers, the count command is your best friend.

A few things to try for the trigger's condition:

{alive _X && !isFleeing _X} count thislist <= 5

This will make the trigger fire if the amount of units still alive and not retreating is less than or equal to 5.

Here's a trick I like to use to check if one side outnumbers another side in a given area by a certain amount. Place two triggers with the same radius right on top of eachother (or real close) so that they cover the same area. Make one BLUFOR present, give it a name (like WestInArea1) and leave the condition as is. Then make the other OPFOR present and in that trigger put this in the condition:

{alive _X && !isFleeing _X} count thislist < (({alive _X && !isFleeing _X} count (list WestInArea1)) * 2)

This will make the trigger fire when the number of BLUFOR units (who are alive and not retreating) outnumbers the OPFOR units (who are alive and not retreating) by 2:1.

Share this post


Link to post
Share on other sites

Thanks Big Dawg,

Still getting the grip of the syntax here, I have this issue;

When I entered the 1st line above in the condition it gave me a blank error message.

Step by step, I'm trying...

I currently have an empty map with 10 civilians, I am trying to fire it when there are less than 5.

The trigger is set for civilians with the condition:

this && count thislist <=5

That seems to work in this case (when I shoot 5 civilians)

I am however interested in understanding the syntax for the alive Or fleeing bit that I am guessing is:

{alive _X && !isFleeing _X} 

Doesn't _X need to be declared somewhere before I can use it?

Share this post


Link to post
Share on other sites
Doesn't _X need to be declared somewhere before I can use it?

_X is a reserved variable inside a count or forEach block that gets assigned to the current element as the code gets executed for each element in the array. If you check the comref you can get a better understanding of how count and forEach work, but let me breifly break down my example:

- thislist gives an array of objects that the trigger picks up

- <code> count <array> returns the number of elements in <array> for which <code> evaluates to true (where _X can be used to reference the current element)

- alive <object> returns a boolean indicating if the object is alive (obvious)

- isFleeing <object> returns a boolean if the unit is fleeing

So, {alive _X && !isFleeing _X} count thislist returns the number of units picked up by the trigger (in this case, all OPFOR within the area) who are alive and not fleeing.

In my other example, where I used list WestInArea1, list is the same as thislist only for referencing triggers by name (as thislist only refers to the trigger in which the command is used). And * is obviously the operator for multiplication.

Share this post


Link to post
Share on other sites

Thanks again Big Dawg,

Update: It isn't the brackets, but the Fleeing condition that gives me the blank error

{alive _X && !isFleeing _X} count thislist <= 5
//Doesn't work so far


{alive _X} count thislist <= 5
//Works!

Do I need to add the "Surrender" Module in order for units to be able to flee? (I am guessing these modules create new functions that are usable)

Meanwhile, I tried debugging on the screen and didn't figure out yet how to output a variable value on the screen.

MyCount Setvariable [MyCount, count thislist]; hint MyCount;

Didn't work as I hoped it would :D

Let alone using some sort of concatenation like:

MyCount Setvariable [MyCount, "There are " +count thislist +" alive in the group"]; hint MyCount;

This would help me understand how to better call the different objects/arrays greatly...as I might do some on screen debugging :)

Edited by saintaw

Share this post


Link to post
Share on other sites
{alive _X && !isFleeing _X} count thislist <= 5

//Doesn't work so far

I thought as much. I should have said this from the start but try using parentheses around isFleeing _X:

{alive _X && !(isFleeing _X)} count thislist <= 5

Just proves that when in doubt, add parentheses.

As for help with debugging, in order to insert other values into strings (which I can see you're trying to do with the + operator, but this isn't Java :p) use format

hint format ["There are %1 alive in the group",MyCount]

Also works with any number of values (with %2, %3, etc..., just keep adding to the array).

Share this post


Link to post
Share on other sites

Thanks for your patience :)

No dice on adding parentheses (I tried around the fleeing and alive conditions), still the same empty error/debug message.

the odd thing is that the count (with the alive condition only) seems to work; it does trigger when a certain amount are dead (or mor accurately when 7 are left alive in the zone)...

When trying to output that nr, it gives me the value "any" (???) ... and when trying to reference other array elements (%2 %3 %4...) they are empty. (At least I have an output on screen now, thanks you :))

My test:

MyCount Setvariable [MyCount,({alive _X} count thislist)];hint format ["There are %1 %2 %3 alive in the group",MyCount]

Maybe, the error is elsewhere? The map is fairly simple; a single player (blufor Mg), 8 civilians.

Only One trigger:

500/500m elipse

Activation: Civilian

Type: None

Name: CivAlive

Activation:{alive _X} count thislist <= 7;

PS: When is someone putting up an eclipse plugin for this? :D

Share this post


Link to post
Share on other sites

Ok, I know why isFleeing isn't working. As an older command that dates back to OFP, since BIS didn't use is... naming convention back then, it's just fleeing _X. So:

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

Blame it on me not having access to a comref here at work. :j:

As for the format command, you're getting errors because you have 3 of those % thingies (I can't think of the proper name for them right now and I'm in a bit of a rush), but only 1 element (minus the string) in your array:

Example of proper use:

hint format ["Today is the %1 of %2 in the year %3",date,month,year]

Or more ArmA related example:

playerWeapon = (weapons player) select 0; hint format ["Weapon: %1
\nAmmo: %2",playerWeapon,player ammo playerWeapon]

As for eclipse, well I really don't see a point to having sqf/sqs plugin for eclipse (don't get me wrong, eclipse is a wonderful IDE) since you still need to run ArmA2 to compile/execute/test it. There are some tools out there; I use ArmA Edit by Chris Henderson (google it) since it has syntax highlighting, but that's about the only benefit to using a specific editor for sqf/sqs.

Share this post


Link to post
Share on other sites

Morning Big Dawg,

Will try that out as soon as I get home. and report back. I was tweaking my current "main mission" untill the waipoints started acting up (I remember this happened in Arma as well)...

The Eclipse ref was only a 'joke' in regards to the java dev (my coleagues swear by it, I'm an UltraEdit man myself :))

Thanks again!

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  

×