Home   Help Search Login Register  

Author Topic: How to list all units on map?  (Read 2342 times)

0 Members and 1 Guest are viewing this topic.

Walker01

  • Guest
How to list all units on map?
« on: 05 Aug 2006, 15:37:47 »
Hello.

Is there any way to list the units on the map. Or for example get a list of all WEST unit placed on map.
Well, I know it is possible to list a large trigger (covering whole map) that is activated by 'anybody' but i rather liked to have it done inside my script. I quickly scanned true the command referernce but did not found any command suitable for this.
Does anybody know if this is possible and how to do it or do i have to do it the oldschool way?

Thanx.

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re: How to list all units on map?
« Reply #1 on: 05 Aug 2006, 23:24:04 »
afaik it is the most easy way to use a trigger which is set to fire with side present and then fill an array with the units which can then be accessed by scripts as wanted. Just in the on activation box type:

Code: [Select]
MyUnitsList = thislist

this will simply create an array called "MyUnitsList" and fill in the units which fits the triggers setting i.e. "West present".

In the script you can just use the array as usual.

Walker01

  • Guest
Re: How to list all units on map?
« Reply #2 on: 06 Aug 2006, 00:11:01 »
Yes ok, i know it is possible to do it with the trigger, only  I was curious to know if it is possible to get the unit list within the script. But it is propably not. Thanx anyway...

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re: How to list all units on map?
« Reply #3 on: 06 Aug 2006, 10:50:00 »
Yes ok, i know it is possible to do it with the trigger, only  I was curious to know if it is possible to get the unit list within the script. But it is propably not. Thanx anyway...



dont understand this, can you try and re explain


using   "list triggername" the trigger returns a list of

all units


if you set the trigger to repeating / anybody present

then using a script you can return the following

1) A list of all units
..... by simply filtering from a list of all units, you can then return
2) A list of all groups
3) A list of groups / units side specific, eg east/west/res/civilian/logic
4) A list of vehicles (if i remember correctly, empty vehicles return as side civilian, but may be wrong)

the only thing that it doesnt return is a list of objects

I made a function in an addon to utilise this,




INIT.SQS
Quote
TxU_MySide    = side player   





You call on the function using the following syntax
_units = [side,    triggername ] call  TxU_fUnitList

SIDE OPTIONS are:
  • WEST
  • EAST
  • RESISTANCE
  • CIVILIAN
  • TxU_MySide
  • "All" 

TxU_fUnitList
Quote
     private ["_side","_trigger","_sidelist","_sidestr","_units"];
     _side    = _this select 0;
     _trigger = _this select 1;
     _sidelist= [];
     _units   = [];
     _sidestr=format["%1",_side];
     if(_sidestr == "WEST") then {_sidelist = [west]};
     if(_sidestr == "EAST") then {_sidelist = [east]};
     if(_sidestr == "GUER") then {_sidelist = [resistance]};
     if(_sidestr == "CIV")  then {_sidelist = [civilian]};
     if(_sidestr == "ALL")  then {_sidelist = [west,east,resistance,civilian]};

     {if( (alive _x)&&(side _x in _sideList))then{_units=_units+(crew vehicle _x)}} foreach list _trigger;
          _units



   Actual example
  _Wunits =   [    WEST   ,      TxU_MainTrig] call  TxU_fUnitList
         returns a list of all west units (_units being an array)

      Actual example
  _AllUnits =   [   "All"   ,      TxU_MainTrig] call  TxU_fUnitList
         returns a list of EVERY unit present within the trigger area     (_AllUnits being an array)

      Actual example
  _MyUnits =   [   TxU_Myside   ,      TxU_MainTrig] call  TxU_fUnitList
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Walker01

  • Guest
Re: How to list all units on map?
« Reply #4 on: 10 Aug 2006, 20:13:35 »
Oh man... thanx for your reply, nice function. Could maybe use some of this, but was not really what i was looking for.
What i really was looking for was a _list = allunitslist command to simply add to my script to make it useble without adding triggers.

Anyway there seems to be many ways to go around it, easiest way by using an trigger.  :)

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re: How to list all units on map?
« Reply #5 on: 11 Aug 2006, 13:10:32 »
To have a list of all the units on the map in a script you must obviously have a live link between the map and the script.   A trigger is the best way to do it.

I suppose in theory you could make a manual list of all the units at the start of the mission, and then have the script check if each one is alive.   
Plenty of reviewed ArmA missions for you to play

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re: How to list all units on map?
« Reply #6 on: 12 Aug 2006, 22:16:18 »
You need to have a trigger to do what you want to do reliably - or keep a manual list as macguba suggested, but that would be a pain and would need to be kept up to date as you make changes to the mission.  You can delete the trigger after it is used if that is what is bothering you. 
Note that:
1. an occupied vehicle will count as one - irrespective of how many two legged units are inside the vehicle
2. an unoccupied vehicle will be recognised as being a civilian unit.

There are work arounds to both of these.

EDIT:
Okay I have a bit more time now.  Here are the work arounds:

1. To create a list of all the two legged East units on the map:
- create a trigger that covers the map
Name: trigAllEast
Activation: East Present
On Activation: [] exec "listEast.sqs"

The code for listEast.sqs is:
Code: [Select]
_vehListE = list trigAllEast
East_loons = []
{{if (alive _x) then {East_loons = East_loons + [_x]}} forEach crew _x} forEach _vehListE
deleteVehicle trigAllEast

East_loons will then be an array of all of the two legged East units even if they are inside vehicles.  I leave the creation of West_loons and Res_loons as an exercise for the reader  :)

2. To create a list of two legged civilian units (NB ignoring empty vehicles that are also treated as civilians).  
Do exactly the same as in 1. above  except make all the obvious changes from East units to Civillian units (trigger name = trigAllCivil, activated on Civilans present etc.)  except the script listCivil.sqs (or whatever you call it) should be:
Code: [Select]
_vehListC = list trigAllCivil
Civi_loons = []
;NB empty units are treated as Civilian
{{if ((alive _x) and ("man" counttype [_x] > 0)) then {Civi_loons = Civi_loons + [_x]}} forEach crew _x} forEach _vehListC
deleteVehicle trigAllCivil

All the above could be put into one script and even activiated using only one trigger, but I am showing you how to do it small steps to make it more easily understandable.


« Last Edit: 14 Aug 2006, 17:39:38 by THobson »