Forum Jump :

Author Message


Posts: 1589
Rank:


Level: Member

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

 
#181903 Posted at 2015-08-13 01:21        
     
So, for the automated weapon list, you can try this script:
_weapons = [];
_configArray = ("isclass _x" configclasses (configfile >> "cfgweapons"));
_types = [1,2,4,131072];
for "_i" from 0 to 2 do {
        {
         _class = _x;
         _className = configname _x;
         _scope = getnumber (_class >> "scope");
         _type = getnumber (_class >> "type");
         _mags = getArray (_class >> "magazines");
         if (_type == _types select _i) then {
          if (_scope == 2 && {gettext (_class >> "model") != ""}) then {
            _weapons pushback [_className,_mags];
          }};
        } foreach _configArray;  };
_random_loot_array = _weapons select (floor random (count _weapons));
_random_loot_weapon = _random_loot_array select 0;
_random_loot_mags = _random_loot_array select 1 select (floor random (count (_random_loot_array select 1)));  _random_loot = [_random_loot_weapon,_random_loot_mags];
_random_loot will return an array with updated weapons (in Arma and addons) and a randomized magazine. You can limit this search as far as:
type = 1 means primary weapons;
type = 2 for handguns
type = 4 for launchers
type = 131072 for uniforms and accessories, items.

Your script isn't really optimized as you run it foreach house in map! but here is what it does with my suggest above:
_odd1 = 40;
_odd2 = 30;
_weapons = [];
_configArray = ("isclass _x" configclasses (configfile >> "cfgweapons"));
_types = [1,2,4,131072];
for "_i" from 0 to 2 do {
      {
        _class = _x;
        _className = configname _x;
        _scope = getnumber (_class >> "scope");
        _type = getnumber (_class >> "type");
        _mags = getArray (_class >> "magazines");
          if (_type == _types select _i) then {
        if (_scope == 2 && {gettext (_class >> "model") != ""}) then {
          _weapons pushback [_className,_mags];
        }};
      } foreach _configArray;
};
_pos = [0,0];
randomweapon_buildings = nearestObjects [_pos, ["house"], 60000];
{
_building = _x;
_buildingpos = [];
_endloop = false;
_poscount = 0;
while {!_endloop} do {
  if(((_building buildingPos _poscount) select 0) != 0 && ((_building buildingPos _poscount) select 1) != 0) then {
    _buildingpos = _buildingpos + [_building buildingPos _poscount];
    _poscount = _poscount + 1;
  } else {
   _endloop = true;
  };
};
_num = (random 100);
if (_num < _odd1) then {
if (count _buildingpos > 0) then {
  for "_r" from 0 to (count _buildingpos -1) do {
   _num2 = (random 100);
   if (_num2 < _odd2) then {
    _pos = _buildingpos select _r;
    _posnew = _pos;
    if(_pos select 2 < 0) then {_pos = [_pos select 0, _pos select 1, 1]};
    _z = 0;
    _testpos = true;
    while {_testpos} do {
     if((!lineIntersects[ATLtoASL(_pos), ATLtoASL([_pos select 0, _pos select 1, (_pos select 2) - (0.1 * _z)])]) && (!terrainIntersect[(_pos), ([_pos select 0, _pos select 1, (_pos select 2) - (0.1 * _z)])]) && (_pos select 2 > 0)) then {
      _posnew = [_pos select 0, _pos select 1, (_pos select 2) - (0.01 * _z)];
      _z = _z + 1;
    } else {_testpos = false};
  };
_random_loot_array = _weapons select (floor random (count _weapons));
_random_loot_weapon = _random_loot_array select 0;
_random_loot_mags = _random_loot_array select 1 select (floor random (count (_random_loot_array select 1)));
_random_loot = [_random_loot_weapon,_random_loot_mags];
_weaponholder = createVehicle ["groundWeaponHolder", _posnew, [], 0, "CAN_COLLIDE"];
_weaponholder addWeaponCargoGlobal [_random_loot_weapon, 1];
_weaponholder addMagazineCargoGlobal [_random_loot_mags, floor(random(5))];
_weaponholder setPos _posnew;
};
};
};
};
}foreach randomweapon_buildings;

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