Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*---------------------------------------------------------------------------
- Extra Zeds (Headless Client) by Player2
- www.ZombZ.net
- ---------------------------------------------------------------------------*/
- // Configuration
- P2DZ_HC_playerZedRadius = 150; //Distance around the player we should check for zeds (meters)
- P2DZ_HC_maxZedsPerPlayer = 100; //Max zeds around a player at a time (number)
- P2DZ_HC_zedRespawnTime = 10; //Time between checks for spawning new zeds (secs)
- P2DZ_HC_playerSpeedCap = 25; //Past this speed the player won't spawn zeds (kmh)
- P2DZ_HC_debug = true; //Enables logging outputs
- // Functions
- zombie_findTargetAgent = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\zombie_findTargetAgent.sqf";
- zombie_loiterHC = compile preprocessFileLineNumbers "HC\zeds\zombie_loiterHC.sqf";
- zombie_generateHC = compile preprocessFileLineNumbers "HC\zeds\zombie_generateHC.sqf";
- building_spawnZombiesHC = compile preprocessFileLineNumbers "HC\zeds\building_spawnZombiesHC.sqf";
- wild_spawnZombiesHC = compile preprocessFileLineNumbers "HC\zeds\wild_spawnZombiesHC.sqf";
- player2_spawnZedsHC = compile preprocessFileLineNumbers "HC\zeds\player2_spawnZedsHC.sqf";
- nearest_player = compile preprocessFileLineNumbers "HC\zeds\nearest_player.sqf";
- // Instructions
- private["_slp","_pos","_rd","_mz","_ms","_zc","_mn","_d"];
- //Variable Initialization
- _zc = 0;
- _mn = [];
- _pos = [];
- _rd = P2DZ_HC_playerZedRadius;
- _mz = P2DZ_HC_maxZedsPerPlayer;
- _slp = P2DZ_HC_zedRespawnTime;
- _ms = P2DZ_HC_playerSpeedCap;
- _d = P2DZ_HC_debug;
- //Debugging output
- if (_d) then {
- diag_log(format["P2HC:ZedSpawns: Initializing..."]);
- diag_log(format["P2HC:ZedSpawns: "]);
- diag_log(format["P2HC:ZedSpawns: Configuration: "]);
- diag_log(format["P2HC:ZedSpawns: "]);
- diag_log(format["P2HC:ZedSpawns: ZedCheckRadius: %1",P2DZ_HC_playerZedRadius]);
- diag_log(format["P2HC:ZedSpawns: MaxPerPlayer: %1",P2DZ_HC_maxZedsPerPlayer]);
- diag_log(format["P2HC:ZedSpawns: RespawnTimer: %1",P2DZ_HC_zedRespawnTime]);
- diag_log(format["P2HC:ZedSpawns: MaxSpeed: %1",P2DZ_HC_playerSpeedCap]);
- diag_log(format["P2HC:ZedSpawns: "]);
- };
- if (_d) then { diag_log(format["P2HC:ZedSpawns: Waiting for BIS Functions..."]); };
- //Wait for BIS Functions to load
- waitUntil {!isNil "BIS_fnc_init"};
- if (_d) then { diag_log(format["P2HC:ZedSpawns: Loop Starting..."]); };
- /* Main Loop */
- while {true} do {
- if (_d) then { diag_log(format["P2HC:ZedSpawns: Loop has Awoken from its sleep..."]); };
- //for each Player on Server run zombie spawn check
- {
- _zc = 0; //reset zed count
- _mn = []; //reset nearby array
- _pos = []; //reset player pos
- if (_d) then { diag_log(format["P2HC:ZedSpawns: Loop: PlayerObj: %1, Alive: %2, Speed: %3, InDebug?: %4", (typeOf _x), (alive _x), (speed _x), !((getMarkerPos 'respawn_west') distance (position _x) > 3000)]); };
- //Check player is alive and not survivor1 or headless itself
- if ({(_x != player) && _x != (vehicle player)} && {(alive _x) && ((typeOf _x) != "Survivor1_DZ")}) then {
- //Check players speed
- if (_ms > speed _x) then {
- //Check player is not in debug
- if ((getMarkerPos 'respawn_west') distance (position _x) > 3000) then {
- //Count All living zeds in radius
- _mn = (position _x) nearEntities ["CAManBase",_rd];
- { if (_x isKindof "zZombie_Base" && alive _x) then { _zc = _zc + 1; }; } foreach _mn;
- if (_d) then { diag_log(format["P2HC:ZedSpawns: Loop: PlayerPos: %1, ZedsNear: %2, SpawnMoreZed?: %3", (position _x), (_zc), ((_mz > _zc))]); };
- if (_mz > _zc) then {
- //Spawn Zeds
- [_x,_zc,_mz] call player2_spawnZedsHC;
- };
- };
- };
- };
- } count playableUnits;
- if (_d) then { diag_log(format["P2HC:ZedSpawns: Loop Sleeping for %1 seconds",_slp]); };
- //Sleep for zed respawn time
- uiSleep _slp;
- };
- diag_log(format["P2HC:ZedSpawns: FATAL ERROR: While {true} Loop Ended!"])
Advertisement
Add Comment
Please, Sign In to add comment