Jump to content
Sign in to follow this  
kyfohatl

How to find the faction of units within a trigger area?

Recommended Posts

The title says it all. Note that I'm not trying to check what side they are on EAST or WEST), but specifically what faction they belong to (RUSSIA or USA or etc). Basically I'm looking for a method of constantly monitoring units of which faction are present in an area (several factions are trying to capture a base, and I want to generate reinforcements for the faction that manages to seucessfully capture the base).

Share this post


Link to post
Share on other sites

Hey ho.

Can't test it at the moment... but this should give you a hint how to solve your problem....

In the "onActivation" field of a trigger, there is the "magic variable" THISLIST. THISLIST contains all Units, wich triggers the trigger.

So you may can use something like this:

FactionList = [];
{_class = [url="http://community.bistudio.com/wiki/typeOf"]typeOf[/url] _x; _factionText = [url="http://community.bistudio.com/wiki/getText"]getText[/url] ([url="http://community.bistudio.com/wiki/configFile"]ConfigFile[/url] >> 'CfgVehicle' >> _class >> 'Faction'; FactionList = FactionList + [_factionText])} foreach thislist;
CountCDF = {_x=='CDF'} [url="http://community.bistudio.com/wiki/count"]count[/url] FactionList;
CountUSMC = {_x=='USMC'} [url="http://community.bistudio.com/wiki/count"]count[/url] FactionList;
CountRU = {_x=='RU'} count FactionList;
CountINS = {_x=='INS'} count FactionList;
CountGUE = {_x=='GUE'} count FactionList;
CountCIV = {_x=='CIV'} count FactionList;
CountCIVRU = {_x=='CIV_RU'} count FactionList;
CountBIS_TK = {_x=='BIS_TK'} count FactionList;

I don't list all factions. Don't know wich Arma version you have and wich faction you are using in you mission.

But you can use this list from "Six Config Browser" to see all of them for OA.

You should also place this into a seperate .sqf file and only call that file. It's cleaner and easier to maintain.

Something like:

[thislist] call [url="http://community.bistudio.com/wiki/compile"]compile[/url] loadFile "CountFactions.sqf";

Have fun

Share this post


Link to post
Share on other sites

Hey, thanks very much for the detailed answere. I'm playing around with it right now, and I now know how I should tackle the problem. Just a question (cause I'm a bit of a noob at scripting):

I can understand how most of your script works, except for the line:

FactionList = FactionList + [_factionText]

I couldn't find a "FactionList" command in the comfree. What does "FactionList + [_factionText]" do? (I know what _factionText does)

Anyway, thanks again for your help. Much apreciated.

Share this post


Link to post
Share on other sites

FACTIONLIST is a normal variable.

Pay attention to the difference of

FACTIONLIST=[] and

FACTIONLIST()

FACTIONLIST=[] => Setting a variable with the name "FACTIONLIST" to an empty Array.

FACTIONLIST() => Is a call to script command (in fact the command "FACTIONLIST" doesn't exist)

An Array is 'a list of values' in one variable.

I create a empty array with:

FACTONLIST = [];

Then i add the value of the "_factionText" to the array with

FACTIONLIST = FACTIONLIST + [_factionText]

See: Array addition

Some more detail for your example:

Lets say there are two units in the trigger.

One: CDF, one: CIV

Script Start:

FACTIONLIST = []

First foreach round:

FACTIONLIST = FACTIONLIST + [_factionText]

is like

FACTIONLIST = [] + ["CDF"]

so

FACTIONLIST now contains ["CDF"]

Second foreach round:

FACTIONLIST = FACTIONLIST + [_factionText]

is like

FACTIONLIST = ["CDF"] + ["CIV"]

so

FACTIONLIST now contains ["CDF","CIV"]

Got it ??? :rolleyes:

Edited by HeliJunkie

Share this post


Link to post
Share on other sites

Ahhh... very clever Heli J. I must say your explanations are excellent. They are very easy to understand :).

Anyway, thanks for that. I remember coming across adding elements to arrays in Mr-Murray's editing guide, but I skipped it, thinking it was unimportant... I can see how useful it is now.

Cheers.

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  

×