Advertisement
Guest User

Zombience.sqf

a guest
Mar 4th, 2017
695
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.96 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 Edition)                          //
  9. //                                                       //
  10. // Start from onPlayerRespawn.sqf                        //
  11. //                                                       //
  12. /////////////////////////////////////////////////////////*/
  13.  
  14. // _spawner = execVM "spawn.sqf"
  15. // hintC "SPAWNER STARTED";
  16. 0 = [] spawn {
  17.   sleep 15;
  18.  
  19.   private ["_maxZeds","_minDist","_maxDist","_addMed","_isWater","_ZedsSlow","_ZedsFast","_sZedsNum","_mZedsNum","_fastSlow","_ZedType","_plusX","_plusY"];
  20.   _minDist = 150;
  21.   _maxDist = 50;
  22.   _addMed = 1;
  23.   _isWater = 0;
  24.  
  25.   _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"];
  26.   _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"];
  27.   _sZedsNum = count _ZedsSlow;
  28.   _mZedsNum = count _ZedsFast;
  29.   zAmbientGroup = createGroup east;
  30.  
  31.   // Checking if player alive
  32.   while {alive player} do {
  33.  
  34.     if (!(vehicle player isKindOf "Helicopter")) then { //Jets check
  35.     // Checking if group is present
  36.     if (isNull zAmbientGroup) then {zAmbientGroup = createGroup east};
  37.  
  38.     // Selecting number of zeds, more players - less zombies, too keep net load balanced.
  39.     if ((count allPlayers) < 5) then {_maxZeds = 6 - (count allPlayers)} else {_maxZeds = 3};
  40.    
  41.     // Checking if limit reached
  42.     if (count units zAmbientGroup < _maxZeds) then {   
  43.      
  44.       // Selecting type and position
  45.       _fastSlow = (floor(random 3))+1;
  46.       _ZedType = _ZedsSlow select (floor(random _sZedsNum ));
  47.  
  48.       if ( _fastSlow > 2 and _addMed == 1) then {
  49.         _ZedType =_ZedsFast select (floor(random _mZedsNum ));
  50.       };
  51.  
  52.       _plusX = random 2;
  53.       if (_plusX > 1) then {_plusX = 1};
  54.       if (_plusX < 1) then {_plusX = -1};
  55.  
  56.       _plusY = random 2;
  57.       if (_plusY > 1) then {_plusY = 1};
  58.       if (_plusY < 1) then {_plusY = -1};
  59.  
  60.       _posX = 0;
  61.       _posY = 0;
  62.      
  63.       _random = [1,2,3] call BIS_fnc_selectRandom;
  64.  
  65.       if (_random == 1) then {        
  66.         _posX = (_minDist + random _maxDist) * _plusX;      //150-200 * +-1
  67.         _posY = (random (_minDist + _maxDist)) * _plusY;    //0-200 * +-1
  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.       if (_random == 3) then {        
  74.         _posX = (_minDist + random _maxDist) * _plusX;      //150-200 * +-1
  75.         _posY = (_minDist + random _maxDist) * _plusY;      //150-200 * +-1
  76.       };
  77.      
  78.         objPos = getPos Player;
  79.         while {!(player inArea "protection_zone")} do {
  80.         //  while {!(player inArea "protection_zone")} do {
  81.         //  selecting position
  82.         sleep 5;
  83.         spawnPos = getPos player;
  84.         spawnPos = [(spawnPos select 0) + _posX, (spawnPos select 1) + _posY,0];      
  85.        
  86.         // Spawning zombie
  87.         if ({_x distance2D spawnPos < (_minDist*0.75)} count allPlayers == 0) exitWith { //0.75*150 =112,5 real minimum distance
  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)) then {deleteVehicle _x}} forEach units zAmbientGroup; //check for other players aswell!! ; removed: || !(alive _x)
  94.     //{if (((player distance2D _x) > (_minDist+_maxDist)*1.5) || !(alive _x)) then {deleteVehicle _x}} forEach units zAmbientGroup;
  95.     // Removing oldest waypoint
  96.     while {(count (waypoints zAmbientGroup)) > 1} do {deleteWaypoint ((waypoints zAmbientGroup) select 0)};
  97.     // Adding waypoint
  98.     wp = zAmbientGroup addWaypoint [objPos,0];
  99.     wp setWaypointSpeed "Full";
  100.     wp setWaypointType "MOVE";
  101.     wp setWaypointBehaviour "COMBAT";    
  102.     sleep 1;
  103.   };
  104.   };
  105. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement