Jump to content
Sign in to follow this  

Recommended Posts

I wondered If there is a list of all location name for chernarus zagrabad and takistan. I'm talking of location name like : bis_loc_acityc_Staroye, bis_loc_acityc_Msta ... that can be used, for instance with this line of command :

BIS_alice_mainscope setvariable ["TownList",[bis_loc_acityc_Staroye,bis_loc_acityc_Msta]];

EDIT: If there is no list. how could I with a script find the nearest location from my position , cause in OA they are some settlement wich does not even have a name so I cannot even try to guess the location name.

Edited by luckyhendrix

Share this post


Link to post
Share on other sites

You may access the config, there's your list. Check configFile >> "CfgWorlds" >> worldName >> "Names".

Maybe the following script comes in handy:

fn_extractConfigEntries.sqf:

/*
  Author:
   rübe

  Description:
   extracts config entries into an array with the use of custom
   selectors and a custom filter.

  Parameter(s):
   _this select 0: config/path (configFile/-Path)
   _this select 1: variables (array of strings/variable-names AND/OR 
                   code given the current class, returning any AND/OR
                   boolean to retrieve the current class itself (true) 
                   and the className (false))
   _this select 2: filter (function given the entry, returning boolean, 
                   optional)




  Example: (retrieves all CityCenters on the current island)

   // this will define the structure and contents of the arrays
   // we'll get back! (same order!)
   _cityCenterVariables = [
      false, // retrieve className
      true,  // retrieve the config itself
      "name", 
      "position", 
      // custom selector/manipulator:
      { 
        [
           (getNumber (_this >> "radiusA")), 
           (getNumber (_this >> "radiusB"))
        ] 
      },
      "type", 
      "speech",
      "neighbors",
      "demography"
   ];

   _cityCenterFilter = {
      if ((getText (_this >> "type")) in ["CityCenter"]) exitWith
      {
         true
      };
      false
   };

   _entries = [
      (configFile >> "CfgWorlds" >> worldName >> "Names"),
      _cityCenterVariables, 
      _cityCenterFilter
   ] call RUBE_extractConfigEntries;

   // (count _entries) == 46
   // (_entries select 0) returns:
   /-
      [
         "ACityC_Chernogorsk", 
         bin\config.bin/CfgWorlds/Chernarus/Names/ACityC_Chernogorsk, 
         "", 
         [6735.83,2626.6], 
         [100,100], 
         "CityCenter", 
         <null>, 
         ["ACityC_Prigorodki","ACityC_Balota","ACityC_Nadezhdino","ACityC_Mogilevka"], 
         ["CIV",1,"CIV_RU",0]
      ]
   -/


  Returns:
   array of config-entries with the desired variables in given order
*/

private ["_cfg", "_variables", "_filter", "_entries", "_extractValue", "_e"];

_cfg = _this select 0;
_variables = _this select 1;
_filter = { true };
_entries = [];

_extractValue = {
  if (isNumber _this) exitWith
  {
     (getNumber _this)
  };
  if (isText _this) exitWith
  {
     (getText _this)
  };
  if (isArray _this) exitWith
  {
     (getArray _this)
  };
  if (isClass _this) exitWith
  {
     private ["_c"];
     _c = [];
     for "_i" from 0 to ((count _this) - 1) do
     {
        _c = _c + [((_this select _i) call _extractValue)];
     };
     _c
  };
};

if ((count _this) > 2) then
{
  _filter = _this select 2;
};

for "_i" from 0 to ((count _cfg) - 1) do
{
  if ((_cfg select _i) call _filter) then
  {
     _e = [];
     {
        switch (typeName _x) do
        {
           // custom selector
           case "CODE":
           {
              _e = _e + [((_cfg select _i) call _x)];
           };
           // class selector/itself
           case "BOOL":
           {
              if (_x) then
              {
                 _e = _e + [(_cfg select _i)];
              } else {
                 _e = _e + [(configName (_cfg select _i))];
              };
           };
           // default selector
           default
           {
              _e = _e + [(((_cfg select _i) >> _x) call _extractValue)];
           };
        };
     } forEach _variables;

     _entries = _entries + [_e];
  };
};

_entries

Share this post


Link to post
Share on other sites

sorry but I don't really get how I should launch the script. Is all this the launch command ? :

_cityCenterVariables = [

false, // retrieve className

true, // retrieve the config itself

"name",

"position",

// custom selector/manipulator:

{

[

(getNumber (_this >> "radiusA")),

(getNumber (_this >> "radiusB"))

]

},

"type",

"speech",

"neighbors",

"demography"

];

_cityCenterFilter = {

if ((getText (_this >> "type")) in ["CityCenter"]) exitWith

{

true

};

false

};

_entries = [

(configFile >> "CfgWorlds" >> worldName >> "Names"),

_cityCenterVariables,

_cityCenterFilter

] call RUBE_extractConfigEntries;

Share this post


Link to post
Share on other sites

From a script I did for simulated nuclear exchange....

_TargetList =  [ nearestLocations [[0, 0, 0], ["NameCityCapital", "NameCity", "NameVillage", "NameLocal"], 30000]] call CBA_fnc_shuffle;

Just do something similar and then use diag_log to print the results to your arma.rpt file. Bingo, instant list.

Share this post


Link to post
Share on other sites

Launching the folowing script :

_TargetList = [ nearestLocations [[0, 0, 0], ["NameCityCapital", "NameCity", "NameVillage", "NameLocal"], 100000]] call CBA_fnc_shuffle;

{

diag_log Format ["%1",_x];

}foreach _TargetList;

result in this list :

"Location NameVillage at 6579, 1955"

"Location NameCityCapital at 10604, 6411"

"Location NameCity at 6031, 5659"

"Location NameLocal at 6822, 1385"

"Location NameVillage at 5313, 4741"

"Location NameLocal at 2440, 9625"

"Location NameCity at 9128, 6865"

"Location NameCity at 1891, 11867"

"Location NameLocal at 7947, 1833"

"Location NameCity at 5990, 8977"

"Location NameLocal at 9339, 9956"

"Location NameCity at 6064, 7257"

"Location NameLocal at 3573, 1284"

"Location NameCity at 4376, 755"

"Location NameLocal at 5064, 6865"

"Location NameLocal at 3960, 3119"

"Location NameCityCapital at 5073, 6158"

"Location NameLocal at 906, 7858"

"Location NameVillage at 3627, 8511"

"Location NameCity at 3589, 4284"

"Location NameVillage at 12243, 10420"

"Location NameVillage at 8888, 5181"

"Location NameLocal at 4564, 9354"

"Location NameCity at 8622, 2454"

"Location NameVillage at 2537, 5026"

"Location NameVillage at 1529, 3583"

"Location NameVillage at 11539, 8319"

"Location NameLocal at 5278, 3675"

"Location NameLocal at 9034, 4428"

"Location NameVillage at 1444, 5732"

"Location NameCityCapital at 6092, 11019"

"Location NameCityCapital at 3058, 9808"

"Location NameLocal at 3643, 11045"

"Location NameVillage at 8238, 7847"

"Location NameCity at 9952, 11651"

"Location NameLocal at 8281, 11166"

"Location NameLocal at 8113, 9147"

"Location NameLocal at 5638, 11356"

"Location NameCity at 572, 2811"

"Location NameVillage at 4078, 11844"

"Location NameVillage at 9009, 1872"

"Location NameVillage at 2009, 7676"

"Location NameVillage at 5933, 1245"

"Location NameLocal at 11858, 2657"

"Location NameVillage at 10529, 2429"

"Location NameVillage at 1951, 350"

:confused:

Share this post


Link to post
Share on other sites
Launching the folowing script :

_TargetList = [ nearestLocations [[0, 0, 0], ["NameCityCapital", "NameCity", "NameVillage", "NameLocal"], 100000]] call CBA_fnc_shuffle;

result in this list : ....

:confused:

Yes, that's a list of locations. Look here for a list of commands you may apply to these to gain further information.

Or where does your confusion come from? And why do you apply CBA_fnc_shuffle to it? Has this anything to do with this topic at all?

Share this post


Link to post
Share on other sites

what I look for is a list of location that I can use to configure the ALICE and SILVIE modules.(For instance : BIS_alice_mainscope setvariable ["TownList",[bis_loc_acityc_Staroye,bis_loc_acityc_Msta]]; that activates the ALICE module only in Staroye and Msta)

Share this post


Link to post
Share on other sites
sorry but I don't really get how I should launch the script. Is all this the launch command ? :

Uhhhm, why don't you try it and see what _entries looks like after that?

what I look for is a list of location that I can use to configure the ALICE and SILVIE modules...

As said before, I'm pretty sure you'll find all you need in the config. Looking at the main.sqf of Alice, "CityCenter" (and the class-name of it) should be exactly what you need. You were even given a function with a working example to extract exactly that... is copy and paste too much work for you? :rolleyes:

Share this post


Link to post
Share on other sites

I launched this script :

RUBE_extractConfigEntries = compile preprocessfile

"Fn_extractConfigEntries.sqf";

_entries = [

(configFile >> "CfgWorlds" >> worldName >> "Names"),

_cityCenterVariables,

_cityCenterFilter

] call RUBE_extractConfigEntries;

player sidechat format ["%1",_entries];

{

diag_log format ["%1",_x];

}foreach _entries;

_entries returns nothing

Share this post


Link to post
Share on other sites

Thats because you didn't define _cityCenterVariables and _cityCenterFilter. The first defines what config values you're going to extract, the latter defines what config entries you're going to extract.

Try this:

RUBE_extractConfigEntries = compile preprocessfile
"Fn_extractConfigEntries.sqf";

_entries = [
  (configFile >> "CfgWorlds" >> worldName >> "Names"),
  // defines what values will be extracted/what will be returned
  [
     false, // retrieve className
     true, // retrieve the config itself
     "name",
     "position"
  ],
  // acts like a filter, here we're only interested in Names of type
  // CityCenter
  {
     if ((getText (_this >> "type")) in ["CityCenter"]) exitWith
     {
        true
     };
     false
  }
] call RUBE_extractConfigEntries;

player sidechat format ["%1",_entries];

{
diag_log format ["%1",_x];
}foreach _entries;

Edited by ruebe

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  

×