Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 5th, 2012  |  syntax: None  |  size: 2.39 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /*
  2.         Weapon Spawning
  3.         Written by Horner
  4. */
  5.  
  6. func_pickRandomPos = {
  7.  
  8.         private["_pos","_x","_y","_xDivider","_yDivider"];
  9.         _pos = _this select 0;
  10.  
  11.         if (_pos distance origin > 10000) then {_pos setPos (getPos origin);};
  12.  
  13.         _x = floor(random 9000) + 1000;
  14.         _y = floor(random 9000) + 1000;
  15.  
  16.         _xDivider = round(random 2) + 1;
  17.         _yDivider = round(random 2) + 1;
  18.  
  19.         if (_xDivider == 1) then {_x = _x;} else {_x = -_x;};
  20.         if (_yDivider == 1) then {_y = _y;} else {_y = -_y;};
  21.        
  22.         _pos setPos [(getPos _pos select 0) + _x, (getPos _pos select 1) + _y];
  23.  
  24. };
  25.  
  26. func_pickSpawnLocation = {
  27.  
  28.         private["_pos","_building","_counting","_buildingPositions","_select","_buildingPos"];
  29.         _pos = _this select 0;
  30.         _building = (nearestObjects [getPos _pos, ["Building"], 3500] select 0);
  31.         _buildingPositions = 0;
  32.         _select = 0;
  33.  
  34.         while { format ["%1", _house buildingPos _select] != "[0,0,0]" } do
  35.         {
  36.                 _select = _select + 1;
  37.                 _buildingPositions = _buildingPositions + 1;
  38.         };
  39.        
  40.         _buildingPos = round(random _buildingPositions);
  41.        
  42.         _pos setPos (_building buildingPos _buildingPos);
  43.        
  44. };
  45.        
  46.  
  47. private["_i","_spawn","_selector"];
  48. _selector = 0;
  49.  
  50. for "_i" from 0 to spawnArrayCount do
  51. {
  52.  
  53. _selector = _selector + 1;
  54.  
  55. };
  56.  
  57. _spawn = "HeliHEmpty" createVehicle (getPos origin);
  58.  
  59. private["_picker","_counter","_array","_wep","_mag","_magCount","_holder"];
  60. _counter = 0;
  61.  
  62. while {_counter < initialSpawns} do
  63. {
  64.         _picker = round(random _selector);
  65.         _array = spawnArray select _picker;
  66.         _wep = _array select 0;
  67.         _mag = _array select 0;
  68.        
  69.         _magCount = round(random 12) + 1;
  70.        
  71.         [_spawn] call func_pickRandomPos;
  72.         [_spawn] call func_pickSpawnLocation;
  73.        
  74.         _holder = "weaponholder" createVehicle (getPos _spawn);
  75.        
  76.         format['_holder addWeapon %1; _holder addMagazineCargo [%2,%3];', _wep, _mag, _magCount];
  77.         _counter = _counter + 1;
  78. };
  79.  
  80. _spawn setPos (getPos origin);
  81.  
  82.  
  83. private["_picker","_counter","_array","_wep","_mag","_magCount","_holder"];
  84. _counter = 0;
  85.  
  86. while {true} do
  87. {
  88.         _picker = round(random _selector);
  89.         _array = spawnArray select _picker;
  90.         _wep = _array select 0;
  91.         _mag = _array select 0;
  92.        
  93.         _magCount = round(random 12) + 1;
  94.        
  95.         [_spawn] call func_pickRandomPos;
  96.         [_spawn] call func_pickSpawnLocation;
  97.        
  98.         _holder = "weaponholder" createVehicle (getPos _spawn);
  99.        
  100.         format['_holder addWeaponCargo [%1,1]; _holder addMagazineCargo [%2,%3];', _wep, _mag, _magCount];
  101.         sleep spawnSleep;
  102. };