Guest User

Untitled

a guest
Jan 10th, 2017
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 4.60 KB | None | 0 0
  1.  
  2.  
  3. /*/////////////////////////////////////////////////////////
  4. //                                                       //
  5. // Zombience.sqf                                         //
  6. // Ambient Zombies Script for Ryan's Zombies and Demons  //
  7. // by -CML-CaptainMittens, edit by Bl2ck Dog [3Para]     //
  8. // v0.86 (Johnny Drama  EDIT)                            //
  9. //                                                       //
  10. // Start from onPlayerRespawn.sqf                        //
  11. //                                                       //
  12. /////////////////////////////////////////////////////////*/
  13.  
  14. hintC "SPAWNER STARTED";
  15. 0 = [] spawn {
  16.   sleep 5;
  17.  
  18.   private ["_maxZeds","_minDist","_maxDist","_addMed","_ZedsSlow","_ZedsFast","_sZedsNum","_mZedsNum","_fastSlow","_ZedType","_plusX","_plusY"];
  19.   _minDist = 150;
  20.   _maxDist = 50;
  21.   _addMed = 1;
  22.  
  23.   _ZedsSlow= ["RyanZombieC_man_1SlowOpfor","RyanZombieC_man_polo_1_FSlowOpfor","RyanZombieC_man_pilot_FSlowOpfor","RyanZombieC_journalist_FSlowOpfor","RyanZombieC_OrestesSlowOpfor","RyanZombieC_NikosSlowOpfor","RyanZombieC_man_polo_2_FSlowOpfor","RyanZombieC_man_polo_4_FSlowOpfor","RyanZombieC_man_polo_5_FSlowOpfor","RyanZombieC_man_polo_6_FSlowOpfor","RyanZombieC_man_p_fugitive_FSlowOpfor","RyanZombieC_man_w_worker_FSlowOpfor","RyanZombieC_scientist_FSlowOpfor","RyanZombieC_man_hunter_1_FSlowOpfor"];
  24.   _ZedsFast = ["RyanZombieC_man_1MediumOpfor","RyanZombieC_man_polo_1_FMediumOpfor","RyanZombieC_man_pilot_FMediumOpfor","RyanZombieC_journalist_FMediumOpfor","RyanZombieC_OrestesMediumOpfor","RyanZombieC_NikosMediumOpfor","RyanZombieC_man_polo_2_FMediumOpfor","RyanZombieC_man_polo_4_FMediumOpfor","RyanZombieC_man_polo_5_FMediumOpfor","RyanZombieC_man_polo_6_FMediumOpfor","RyanZombieC_man_p_fugitive_FMediumOpfor","RyanZombieC_man_w_worker_FMediumOpfor","RyanZombieC_scientist_FMediumOpfor","RyanZombieC_man_hunter_1_FMediumOpfor"];
  25.   _sZedsNum = count _ZedsSlow;
  26.   _mZedsNum = count _ZedsFast;
  27.   zAmbientGroup = createGroup east;
  28.  
  29.   // Checking if player alive
  30.   while {alive player} do {
  31.  
  32.     if (!(vehicle player isKindOf "Helicopter")) then { //Jets check
  33.     // Checking if group is present
  34.     if (isNull zAmbientGroup) then {zAmbientGroup = createGroup east};
  35.  
  36.     // Selecting number of zeds, more players - less zombies, too keep net load balanced.
  37.     if ((count allPlayers) < 5) then {_maxZeds = 9 - (count allPlayers)} else {_maxZeds = 4};
  38.    
  39.     // Checking if limit reached
  40.     if (count units zAmbientGroup < _maxZeds) then {   
  41.      
  42.       // Selecting type and position
  43.       _fastSlow = (floor(random 3))+1;
  44.       _ZedType = _ZedsSlow select (floor(random _sZedsNum ));
  45.  
  46.       if ( _fastSlow > 2 and _addMed == 1) then {
  47.         _ZedType =_ZedsFast select (floor(random _mZedsNum ));
  48.       };
  49.  
  50.       _plusX = random 2;
  51.       if (_plusX > 1) then {_plusX = 1};
  52.       if (_plusX < 1) then {_plusX = -1};
  53.  
  54.       _plusY = random 2;
  55.       if (_plusY > 1) then {_plusY = 1};
  56.       if (_plusY < 1) then {_plusY = -1};
  57.  
  58.       _posX = 0;
  59.       _posY = 0;
  60.      
  61.       _random = [1,2,3] call BIS_fnc_selectRandom;
  62.  
  63.       if (_random == 1) then {        
  64.         _posX = (_minDist + random _maxDist) * _plusX;  //150-200 * +-1
  65.         _posY = (random (_minDist + _maxDist)) * _plusY;  //0-200 * +-1
  66.       };
  67.  
  68.        
  69.       if (_random == 2) then {        
  70.         _posX = (random (_minDist + _maxDist)) * _plusX; //0-200 * +-1
  71.         _posY = (_minDist + random _maxDist) * _plusY; //150-200 * +-1
  72.       };
  73.  
  74.        
  75.       if (_random == 3) then {        
  76.         _posX = (_minDist + random _maxDist) * _plusX; //150-200 * +-1
  77.         _posY = (_minDist + random _maxDist) * _plusY; //150-200 * +-1
  78.       };
  79.  
  80.       while {true} do {
  81.         //selecting position
  82.         sleep 1;
  83.         spawnPos = getPos player;
  84.         spawnPos = [(spawnPos select 0) + _posX, (spawnPos select 1) + _posY,0];      
  85.         objPos = getPos Player;
  86.         // Spawning zombie
  87.         if ({_x distance2D spawnPos < (_minDist*0.75)} count allPlayers == 0) exitWith {
  88.           zUnit = zAmbientGroup createUnit [_ZedType,spawnPos,[],1,"NONE"];
  89.         };
  90.       };
  91.     };
  92.     //Checking if zombie is dead or player moved too far
  93.     {if (((player distance2D _x) > (_minDist+_maxDist)*1.5) || !(alive _x)) then {deleteVehicle _x}} forEach units zAmbientGroup;
  94.     // Removing oldest waypoint
  95.     while {(count (waypoints zAmbientGroup)) > 1} do {deleteWaypoint ((waypoints zAmbientGroup) select 0)};
  96.     // Adding waypoint
  97.     wp = zAmbientGroup addWaypoint [objPos,0];
  98.     wp setWaypointSpeed "Full";
  99.     wp setWaypointType "MOVE";
  100.     wp setWaypointBehaviour "COMBAT";    
  101.     sleep 1;
  102.   };
  103.   };
  104. };
Advertisement
Add Comment
Please, Sign In to add comment