Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private ["_maxControlledZombies","_looted","_zombied","_doNothing","_spawnZedRadius"];
- // Global zed spawn flag - ^bdc
- if (dayz_DisableGlobalZedSpawn) exitWith {};
- _age = -1;
- _position = getPosATL player;
- _spawnableObjects = ["building", "SpawnableWreck"];
- _speed = speed (vehicle player);
- _spawnZedRadius = dayz_LootZedSpawn_SpawnZedRadius;
- //Current amounts
- // we start by the closest buildings.
- _nearby = nearestObjects [_position, _spawnableObjects,dayz_LootZedSpawn_MaxSpawnRange];
- //Total Counts
- _maxlocalspawned = round(dayz_spawnZombies);
- _maxControlledZombies = round(dayz_maxLocalZombies);
- _maxWeaponHolders = dayz_LootZedSpawn_MaxWeaponHolders;
- _currentWeaponHolders = round(dayz_currentWeaponHolders);
- //Limits (Land,Sea,Air)
- _inVehicle = (vehicle player != player);
- _isAir = vehicle player iskindof "Air";
- _isLand = vehicle player iskindof "Land";
- _isSea = vehicle player iskindof "Sea";
- _doNothing = false;
- /*
- if (_inVehicle) then {
- //exit if too fast
- if (_speed > 25) exitwith {_doNothing = true;};
- //Crew can spawn zeds.
- _totalcrew = count (crew (vehicle player));
- if (_totalcrew > 1) then {
- _maxControlledZombies = _maxControlledZombies / 4;
- //Dont allow driver to spawn if we have other crew members.
- if (player == driver (vehicle player)) exitwith {_doNothing = true;};
- } else {
- _maxControlledZombies = 6;
- };
- };
- */
- // Added vehicle properties for more precision in-vehicle spawning by ^bdc - variables referenced in init.sqf
- if (_inVehicle) then {
- _vel = velocity (vehicle player);
- _speed = (_vel distance [0,0,0]);
- _vAltitude = ((getposATL vehicle player) select 2);
- //exit if too fast
- //if (_speed > 25) exitwith {_doNothing = true;}; - ^bdc
- // Modified vehicle speed/altitude checks for spawning zed/loot by ^bdc
- // Air vehicle check
- if (_isAir and ((_speed > dayz_LootZedSpawn_MaxAirVehicleSpeed) or (_vAltitude > dayz_LootZedSpawn_MaxAirVehicleAltitude))) then {
- _doNothing = true;
- };
- // Exclude spawn while in a plane?
- if ((dayz_LootZedSpawn_ExcludePlanes) and (_vehicle isKindOf "plane")) then {
- _doNothing = true;
- };
- // Ground vehicle check
- if (!_isAir and (_speed > dayz_LootZedSpawn_MaxGroundVehicleSpeed)) then {
- _doNothing = true;
- };
- //Crew can spawn zeds.
- _totalcrew = count (crew (vehicle player));
- if (_totalcrew > 1) then {
- _maxControlledZombies = _maxControlledZombies / 4;
- //Dont allow driver to spawn if we have other crew members.
- if (player == driver (vehicle player)) exitwith {_doNothing = true;};
- } else {
- _maxControlledZombies = 6;
- };
- };
- if (_doNothing) exitwith {lastSpawned = diag_tickTime;};
- //Make only 1/5 spawn along player's journey.
- _maxlocalspawned = _maxlocalspawned max floor(_maxControlledZombies*.8);
- //
- if (_maxlocalspawned > 0) then { _spawnZedRadius = _spawnZedRadius * 3; };
- // Spawn routine
- {
- _type = typeOf _x;
- //_config = configFile >> "CfgBuildingLoot" >> _type;
- _config = missionConfigFile >> "CfgBuildingLoot" >> _type;
- _canSpawn = isClass (_config);
- _dis = _x distance player;
- _checkLoot = ((count (getArray (_config >> "lootPos"))) > 0);
- _islocal = _x getVariable ["", false]; // object created locally via TownGenerator. See stream_locationFill.sqf
- // If given area flagged as false, then include loot spawn as restricted spawn along with zed - ^bdc
- _xpos = getPosATL _x;
- // Change Z coordinate to 0 as workaround destroyed building bug - ^bdc
- _newpos = [(_xpos select 0),(_xpos select 1),0];
- if (count PreventZedSpawnPositions > 0) then { // variables.sqf
- _count = count PreventZedSpawnPositions;
- for "_y" from 0 to _count do {
- _NoSpawnPos = PreventZedSpawnPositions select _y;
- _NoSpawnDis = PreventZedSpawnDistances select _y;
- _NoSpawnLoot = PreventZedSpawnLootInclusions select _y;
- _SpawnDis = _NoSpawnPos distance _newpos;
- if ((_SpawnDis <= _NoSpawnDis) and (_NoSpawnLoot)) then {
- _canSpawn = false; // skips entire loot/zed spawn routine below
- //diag_log format["Player_spawnCheck: NoSpawnLoot is %5; Prevent pos %1, Bldg pos %2, distance %3, NoSpawnDis %4",_NoSpawnPos,_newpos,_SpawnDis,_NoSpawnDis,_NoSpawnLoot];
- };
- };
- };
- //Loot
- if (_canSpawn) then {
- if (_currentWeaponHolders < _maxWeaponHolders) then {
- //Basic loot checks
- //if ((_dis < 125) and (_dis > 30) and !_inVehicle and _checkLoot) then {
- if ((_dis < dayz_LootZedSpawn_MaxLootSpawnDistance) and (_dis > dayz_LootZedSpawn_MinLootSpawnDistance) and _checkLoot and !(dayz_LootZedSpawn_DisableDynamicLootSpawn)) then {
- /*
- //Get var Looted
- //[_object,name,defaultValue]
- PVDZ_receiveVar = [player,_x,"looted",-0.1];
- publicVariableServer "PVDZ_receiveVar";
- _looted = (_x getVariable "looted");
- if (isNil "_looted") then {
- _looted = -0.1;
- };
- */
- _looted = (_x getVariable ["looted",diag_tickTime]);
- _age = (diag_tickTime - _looted);
- //diag_log ("SPAWN LOOT: " + _type + " Building is " + str(_age) + " old" );
- // Added for permanent building loot (bypasses loot respawn timer) - ^bdc
- _spawnsomeloot = false;
- if (dayz_LootZedSpawn_PermanentLoot) then { // init.sqf
- if (_age == 0) then { _spawnsomeloot = true; };
- } else {
- if ((_age == 0) or (_age > dayz_LootZedSpawn_LootRespawnTimer)) then { _spawnsomeloot = true; };
- };
- //if ((_age == 0) or (_age > dayz_LootZedSpawn_LootRespawnTimer)) then {
- if (_spawnsomeloot) then {
- /*
- //[object,name]
- PVDZ_serverStoreVar = [_x,"looted",(DateToNumber date)];
- publicVariableServer "PVDZ_serverStoreVar";
- sleep 0.01;
- */
- _x setVariable ["looted",diag_tickTime,!_islocal];
- _x call building_spawnLoot;
- if (!(_x in dayz_buildingBubbleMonitor)) then {
- //add active Building to var
- dayz_buildingBubbleMonitor set [count dayz_buildingBubbleMonitor, _x];
- };
- };
- };
- };
- //Zeds
- // Check to see if zed are restricted in this area or not - ^bdc
- _NoSpawnZed = false;
- _xpos = getPosATL _x;
- // Change Z coordinate to 0 as workaround destroyed building bug - ^bdc
- _newpos = [(_xpos select 0),(_xpos select 1),0];
- if (count PreventZedSpawnPositions > 0) then { // variables.sqf
- _count = (count PreventZedSpawnPositions - 1);
- for "_y" from 0 to _count do {
- _NoSpawnPos = PreventZedSpawnPositions select _y;
- _NoSpawnDis = PreventZedSpawnDistances select _y;
- _SpawnDis = _NoSpawnPos distance _newpos;
- //diag_log format["Player_spawnCheck: NoSpawnZed currently is %5; Prevent pos %1, Bldg pos %2, distance %3, NoSpawnDis %4 PreventZedSpawnPositions Count %6",_NoSpawnPos,_newpos,_SpawnDis,_NoSpawnDis,_NoSpawnZed,_count];
- if (_SpawnDis <= _NoSpawnDis) then {
- _NoSpawnZed = true;
- //diag_log format["Player_spawnCheck: NoSpawn is true; Prevent pos %1, Bldg pos %2, distance %3, NoSpawnDis %4",_NoSpawnPos,_newpos,_SpawnDis,_NoSpawnDis];
- };
- };
- };
- // Sarge AI Heli crash check - Let's make sure this spawned helicrash is not flagged for no zed spawn
- if (_x isKindOf "SpawnableWreck") then {
- _SargeHeliCrash = 0;
- _SargeHeliCrash = _x getVariable ["Sarge",0];
- if (_SargeHeliCrash == 1) then {
- _NoSpawnZed = true;
- };
- _noZedSpawn = false;
- _noZedSpawn = _x getVariable ["NoZedSpawn",false];
- if (_noZedSpawn) then {
- _NoSpawnZed = true;
- };
- };
- //if (_dis > _spawnZedRadius) then {
- if ((_dis > _spawnZedRadius) and (!_NoSpawnZed)) then {
- if ((dayz_spawnZombies < _maxControlledZombies) and (dayz_CurrentNearByZombies < dayz_maxNearByZombies) and (dayz_currentGlobalZombies < dayz_maxGlobalZeds)) then {
- /*
- //[_object,name,defaultValue]
- PVDZ_receiveVar = [player,_x,"zombieSpawn",-0.1];
- publicVariableServer "PVDZ_receiveVar";
- sleep 0.01;
- _zombied = (_x getVariable "zombieSpawn");
- if (isNil "_zombied") then {
- _zombied = -0.1;
- };
- */
- _zombied = (_x getVariable ["zombieSpawn",diag_tickTime]);
- _age = (diag_tickTime - _zombied) * 525948; // in minutes
- //diag_log format ["Player_SpawnCheck: %4 - %5: %1, %2, %3, player pos %6", _zombied, diag_tickTime, _age, "spawnCheck", _x,_position];
- if ((_age == 0) or (_age > 300)) then {
- _bPos = getPosATL _x;
- _zombiesNum = {alive _x} count (_bPos nearEntities ["zZombie_Base",(((sizeOf _type) * 2) + 10)]);
- if (_zombiesNum == 0) then {
- /*
- //[object,name]
- PVDZ_serverStoreVar = [_x,"zombieSpawn",(DateToNumber date)];
- publicVariableServer "PVDZ_serverStoreVar";
- */
- //diag_log format["Player_SpawnCheck.SQF: Passed NoZedSpawn Check; spawning zed at %1",_bPos];
- [_x] call building_spawnZombies;
- _x setVariable ["zombieSpawn",diag_tickTime,!_islocal];
- //waitUntil{scriptDone _handle};
- if (!(_x in dayz_buildingBubbleMonitor)) then {
- //add active zed to var
- dayz_buildingBubbleMonitor set [count dayz_buildingBubbleMonitor, _x];
- };
- };
- };
- //diag_log (format["%1 building. %2", __FILE__, _x]);
- };
- };
- };
- } forEach _nearby;
- //Timer system to monitor if running.
- lastSpawned = diag_tickTime;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement