- /*
- Weapon Spawning
- Written by Horner
- */
- func_pickRandomPos = {
- private["_pos","_x","_y","_xDivider","_yDivider"];
- _pos = _this select 0;
- if (_pos distance origin > 10000) then {_pos setPos (getPos origin);};
- _x = floor(random 9000) + 1000;
- _y = floor(random 9000) + 1000;
- _xDivider = round(random 2) + 1;
- _yDivider = round(random 2) + 1;
- if (_xDivider == 1) then {_x = _x;} else {_x = -_x;};
- if (_yDivider == 1) then {_y = _y;} else {_y = -_y;};
- _pos setPos [(getPos _pos select 0) + _x, (getPos _pos select 1) + _y];
- };
- func_pickSpawnLocation = {
- private["_pos","_building","_counting","_buildingPositions","_select","_buildingPos"];
- _pos = _this select 0;
- _building = (nearestObjects [getPos _pos, ["Building"], 3500] select 0);
- _buildingPositions = 0;
- _select = 0;
- while { format ["%1", _house buildingPos _select] != "[0,0,0]" } do
- {
- _select = _select + 1;
- _buildingPositions = _buildingPositions + 1;
- };
- _buildingPos = round(random _buildingPositions);
- _pos setPos (_building buildingPos _buildingPos);
- };
- private["_i","_spawn","_selector"];
- _selector = 0;
- for "_i" from 0 to spawnArrayCount do
- {
- _selector = _selector + 1;
- };
- _spawn = "HeliHEmpty" createVehicle (getPos origin);
- private["_picker","_counter","_array","_wep","_mag","_magCount","_holder"];
- _counter = 0;
- while {_counter < initialSpawns} do
- {
- _picker = round(random _selector);
- _array = spawnArray select _picker;
- _wep = _array select 0;
- _mag = _array select 0;
- _magCount = round(random 12) + 1;
- [_spawn] call func_pickRandomPos;
- [_spawn] call func_pickSpawnLocation;
- _holder = "weaponholder" createVehicle (getPos _spawn);
- format['_holder addWeapon %1; _holder addMagazineCargo [%2,%3];', _wep, _mag, _magCount];
- _counter = _counter + 1;
- };
- _spawn setPos (getPos origin);
- private["_picker","_counter","_array","_wep","_mag","_magCount","_holder"];
- _counter = 0;
- while {true} do
- {
- _picker = round(random _selector);
- _array = spawnArray select _picker;
- _wep = _array select 0;
- _mag = _array select 0;
- _magCount = round(random 12) + 1;
- [_spawn] call func_pickRandomPos;
- [_spawn] call func_pickSpawnLocation;
- _holder = "weaponholder" createVehicle (getPos _spawn);
- format['_holder addWeaponCargo [%1,1]; _holder addMagazineCargo [%2,%3];', _wep, _mag, _magCount];
- sleep spawnSleep;
- };