Forum Jump :

Author Message


Posts: 3
Rank:


Level: Member

Country: ca
Location:
Occupation:
Age:
In-game name:

 
#1 Posted at 2015-07-20 08:14        
     
someone please help me this is killing me! I'm just trying to get units from various different groups into one big Array. I have 3 squads and I want them to be in separate groups but I want every single unit within theses groups accessible through an array called 'FOX_3rdPLT'. I would very much prefer not having to name every single unit, as I would be naming units for hours and hours by the time my mission is done.

init.SQF:
FOX_3rdPLT = [];

A units init (initialization field within editor):
FOX_3rdPLT = FOX_3rdPLT + [this];

Trigger (on activation.. I know that the trigger is being activated via hint command):
{_x setUnitPos "middle";} forEach FOX_3rdPLT;

trust me I have googled and googled this issue and I have not found anything helpful (I might just be an idiot and missed something however..) links always appreciated!).
well anyways I hope someone is able to help me! I would very much appreciate it. Thank you.

this is my end game by the way. I hope it will work but please, anyone if you see a problem.. don't hesitate to point it out!
enemyArray = []; //I am adding units to this array just as I did for 'FOX_3rdPLT'
for [{_i=0}, {_i < count FOX_3rdPLT}, {_i=_i+1}] do {
_currentUnit_FOX_3rdPLT = (FOX_3rdPLT select _i);
{_x reveal _currentUnit_FOX_3rdPLT} forEach enemyArray;
};


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 60
In-game name: Kobayashi Maru

 
#2 Posted at 2015-07-20 09:20        
     
init.sqf
FOX_3rdPLT = []; // OK
In init.sqf again:
For edited units (without side consideration):
{FOX_3rdLPT pushback _x} foreach allunits;
If blue side considered: { if (side _x ==west) then {FOX_3rdLPT pushback _x}} foreach allunits;
or for 2 groups: { if (group _x == group1 or group _x == group2) then {FOX_3rdLPT pushback _x}} foreach allunits;

If these units can spawn in game, other things to do (with setvariable and loop checking for spawned units (AI),depending on how you spawn them, or even into script iniPlayerLocal.sqf for JIP (player)).

Trigger cond: choose your condition !
Trigger act field: {_x setUnitPos "middle"} forEach FOX_3rdPLT; //OK

enemyArray = []; //I am adding units to this array just as I did for 'FOX_3rdPLT'
for "_i" from 0 to (count FOX_3rdPLT - 1) do {
_currentUnit_FOX_3rdPLT = (FOX_3rdPLT select _i);
{_x reveal _currentUnit_FOX_3rdPLT} forEach enemyArray;
};

This post was edited by Pierre MGI (2015-07-20 09:28, ago)

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Advertisement


Author Message


Posts: 3
Rank:


Level: Member

Country: ca
Location:
Occupation:
Age:
In-game name:

 
#3 Posted at 2015-07-20 11:12        
     
Beautiful.. You definitely know your shit! Lots of useful content here, thank you very much for the quick response. I will get back here if I have any issues implanting the code within my mission.

Added 41 minutes later:

is there a way to add a single unit into the array from the units initialization field? I tried using FOX_3rdPLT pushBack this but arma's editor does not like it and wants it to be written with a semicolon after the group name.
(by the way this is not for multiplayer, or a spawned in unit, just a plain ol' double click in the editor)

the scenario:
FOX company is divided into three platoons (1st, 2nd, and 3rd), each platoon has 3 groups consisting of 10 or so units.
PLATOONS = [FOX_1stPLT,FOX_2ndPLT,FOX_3rdPLT] - each platoon has 3 groups, and about 30 soldiers
FOX_1stPLT = [unit,unit,unit,unit...+26ish]

so all I pretty much need to know how to do here is set the initial values of each platoon arrays contents by hopefully writing something easy in the initialization field of a unit such as.. 'FOX_3rdPLT pushBack this' or 'FOX_3rdPLT = FOX_3rdPLT + [this]' and let me know if you believe I am making this more confusing than it should be! or if more clarification on my purpose is needed

This post was edited by mr_green239 (2015-07-20 11:53, ago)


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 60
In-game name: Kobayashi Maru

 
#4 Posted at 2015-07-20 17:39        
     
No, its a bad idea, i think, trying to pushback "this" which refers to an object, in an array X all your units.
Not sure the engine understands what you want to do, in what order.

Create your groups in editor [F2] key but i'm sure you know that.
Then you can name these groups. In init field of the leader only: FOX_1stGRP = group this;

The following work is in the init.sqf:
FOX_1stPLT = [];
{FOX_1stPLT pushback _x} foreach (FOX_1stGRP + FOX_2ndGRP + FOX_3rdGRP);
...

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Author Message


Posts: 3
Rank:


Level: Member

Country: ca
Location:
Occupation:
Age:
In-game name:

 
#5 Posted at 2015-07-20 20:47        
     
okay thank you very much, I will use this.