mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-14 04:02:37 +03:00
System is done (i think)
This commit is contained in:
@@ -1,44 +1,68 @@
|
||||
private ["_type","_inVehicle","_dateNow","_maxWildZombies","_age","_radius","_position","_markerstr","_markerstr1","_markerstr2","_markerstr3","_nearByObj","_handle","_looted","_cleared","_zombied","_config","_canLoot","_dis","_players","_nearby","_nearbyCount","_onTheMove","_soundLimit"];
|
||||
//_t1 = diag_tickTime;
|
||||
|
||||
_type = _this select 0;
|
||||
_inVehicle = (vehicle player != player);
|
||||
_onTheMove = (speed (vehicle player) > 10);
|
||||
_dateNow = (DateToNumber date);
|
||||
_maxWildZombies = 3;
|
||||
private ["_isWreck","_maxControlledZombies","_looted","_zombied","_doNothing","_spawnZedRadius","_serverTime","_age","_nearbyBuildings","_position","_spawnableObjects","_speed","_radius","_maxlocalspawned","_maxWeaponHolders","_currentWeaponHolders","_maxtoCreate","_inVehicle","_isAir","_isLand","_isSea","_Controlledzeddivided","_totalcrew","_nearby","_type","_config","_canSpawn","_dis","_checkLoot","_islocal","_bPos","_zombiesNum"];
|
||||
_age = -1;
|
||||
_radius = 200;
|
||||
//_nearbyBuildings = [];
|
||||
_position = [player] call FNC_GetPos;
|
||||
_spawnableObjects = ["building", "CrashSite", "IC_Fireplace1", "IC_DomeTent", "IC_Tent"];
|
||||
_speed = speed (vehicle player);
|
||||
_radius = 300; //150*0.707; Pointless Processing (106.5)
|
||||
_spawnZedRadius = 20;
|
||||
|
||||
dayz_spawnZombies = 0;
|
||||
dayz_CurrentZombies = 0;
|
||||
/*
|
||||
//Tick Time
|
||||
PVDZ_getTickTime = player;
|
||||
publicVariableServer "PVDZ_getTickTime";
|
||||
*/
|
||||
|
||||
// experiment with adding fly sounds locally for both zombies && players.
|
||||
_soundLimit = 2;
|
||||
{
|
||||
if (!alive _x) then {
|
||||
if (!(_x isKindOf "zZombie_Base")) then {
|
||||
[player,"flysound",1,true] call dayz_zombieSpeak;
|
||||
_soundLimit = _soundLimit - 1;
|
||||
};
|
||||
};
|
||||
if (_soundLimit == 0) exitWith {};
|
||||
} count (nearestObjects [player, ["CAManBase"], 8]);
|
||||
//Total Counts
|
||||
_maxlocalspawned = round(dayz_spawnZombies);
|
||||
_maxControlledZombies = round(dayz_maxLocalZombies);
|
||||
_maxWeaponHolders = round(dayz_maxMaxWeaponHolders);
|
||||
_currentWeaponHolders = round(dayz_currentWeaponHolders);
|
||||
|
||||
_players = _position nearEntities ["CAManBase",_radius+200];
|
||||
dayz_maxGlobalZombies = dayz_maxGlobalZombiesInit;
|
||||
{
|
||||
if(isPlayer _x) then {
|
||||
dayz_maxGlobalZombies = dayz_maxGlobalZombies + dayz_maxGlobalZombiesIncrease;
|
||||
} else {
|
||||
if (_x isKindOf "zZombie_Base") then {
|
||||
if (local _x) then {
|
||||
dayz_spawnZombies = dayz_spawnZombies + 1;
|
||||
};
|
||||
dayz_CurrentZombies = dayz_CurrentZombies + 1;
|
||||
};
|
||||
};
|
||||
} count _players;
|
||||
//Limits (Land,Sea,Air)
|
||||
_inVehicle = (vehicle player != player);
|
||||
/*
|
||||
_isAir = vehicle player iskindof "Air";
|
||||
_isLand = vehicle player iskindof "Land";
|
||||
_isSea = vehicle player iskindof "Sea";
|
||||
if (_isLand) then { } else { };
|
||||
if (_isAir) then { } else { };
|
||||
if (_isSea) then { } else { };
|
||||
*/
|
||||
|
||||
_doNothing = false;
|
||||
if (_inVehicle) then {
|
||||
_Controlledzeddivided = 0;
|
||||
//exit if too fast
|
||||
if (_speed > 25) exitwith {_doNothing = true;};
|
||||
|
||||
//Crew can spawn zeds.
|
||||
_totalcrew = count (crew (vehicle player));
|
||||
if (_totalcrew > 1) then {
|
||||
_Controlledzeddivided = 2;
|
||||
|
||||
//Dont allow driver to spawn if we have other crew members.
|
||||
if (player == driver (vehicle player)) exitwith {_doNothing = true;};
|
||||
} else {
|
||||
_Controlledzeddivided = 4;
|
||||
};
|
||||
|
||||
if (_Controlledzeddivided > 0) then {
|
||||
_maxControlledZombies = round(_maxControlledZombies / _Controlledzeddivided);
|
||||
r_player_divideinvehicle = _Controlledzeddivided;
|
||||
};
|
||||
};
|
||||
|
||||
if (_doNothing) exitwith {};
|
||||
|
||||
//Logging
|
||||
diag_log (format["%1 Local.Agents: %2/%3, NearBy.Agents: %8/%9, Global.Agents: %6/%7, W.holders: %10/%11, (radius:%4m %5fps).","SpawnCheck",
|
||||
_maxlocalspawned, _maxControlledZombies, _radius, round diag_fpsmin,dayz_currentGlobalZombies,
|
||||
dayz_maxGlobalZeds, dayz_CurrentNearByZombies, dayz_maxNearByZombies, _currentWeaponHolders,_maxWeaponHolders]);
|
||||
|
||||
_nearby = nearestObjects [_position, _spawnableObjects,_radius];
|
||||
_maxlocalspawned = _maxlocalspawned max floor(_maxControlledZombies*.8);
|
||||
if (_maxlocalspawned > 0) then { _spawnZedRadius = _spawnZedRadius * 3; };
|
||||
|
||||
if ("ItemMap_Debug" in items player) then {
|
||||
deleteMarkerLocal "MaxZeds";
|
||||
@@ -83,71 +107,76 @@ diag_log ("GlobalZombies: " +str(dayz_CurrentZombies) + "/" +str(dayz_maxGlobalZ
|
||||
diag_log ("dayz_maxCurrentZeds: " +str(dayz_maxCurrentZeds) + "/" +str(dayz_maxZeds));
|
||||
|
||||
};
|
||||
|
||||
|
||||
_nearby = _position nearObjects ["building",_radius];
|
||||
_nearbyCount = count _nearby;
|
||||
if (_nearbyCount < 1) exitwith
|
||||
//Spawn Zeds & loot in buildings
|
||||
{
|
||||
if ((dayz_spawnZombies < _maxWildZombies) && !_inVehicle) then {
|
||||
[_position] call wild_spawnZombies;
|
||||
};
|
||||
};
|
||||
_type = typeOf _x;
|
||||
_config = configFile >> "CfgLoot" >> "Buildings" >> _type;
|
||||
_canSpawn = isClass (_config);
|
||||
|
||||
if (_canSpawn) then {
|
||||
_dis = _x distance player;
|
||||
_checkLoot = (count (getArray (_config >> "lootPos"))) > 0;
|
||||
_islocal = _x getVariable ["", false]; // object created locally via TownGenerator. See stream_locationFill.sqf
|
||||
|
||||
{
|
||||
_type = typeOf _x;
|
||||
_config = configFile >> "CfgBuildingLoot" >> _type;
|
||||
if (DZE_MissionLootTable) then {
|
||||
_config = missionConfigFile >> "CfgBuildingLoot" >> _type;
|
||||
};
|
||||
_canLoot = isClass (_config);
|
||||
|
||||
if(_canLoot) then {
|
||||
|
||||
_dis = _x distance player;
|
||||
|
||||
//Loot
|
||||
if ((_dis < 120) && (_dis > 30) && !_inVehicle) then {
|
||||
_looted = (_x getVariable ["looted",-0.1]);
|
||||
_cleared = (_x getVariable ["cleared",true]);
|
||||
_dateNow = (DateToNumber date);
|
||||
_age = (_dateNow - _looted) * 525948;
|
||||
//diag_log ("SPAWN LOOT: " + _type + " Building is " + str(_age) + " old" );
|
||||
if ((_age > DZE_LootSpawnTimer) && (!_cleared)) then {
|
||||
_nearByObj = nearestObjects [(getPosATL _x), ["WeaponHolder","WeaponHolderBase"],((sizeOf _type)+5)];
|
||||
{deleteVehicle _x} count _nearByObj;
|
||||
_x setVariable ["cleared",true,true];
|
||||
_x setVariable ["looted",_dateNow,true];
|
||||
};
|
||||
if ((_age > DZE_LootSpawnTimer) && (_cleared)) then {
|
||||
//Register
|
||||
_x setVariable ["looted",_dateNow,true];
|
||||
//cleanup
|
||||
_x call building_spawnLoot;
|
||||
//Make sure wrecks always spawn Zeds
|
||||
_isWreck = _x isKindOf "CrashSite";
|
||||
|
||||
//Loot
|
||||
if (getNumber(_config >> "lootChance") > 0) then {
|
||||
if (_currentWeaponHolders < _maxWeaponHolders) then {
|
||||
//Baisc loot check
|
||||
if ((_dis < 125) and (_dis > 30) and !_inVehicle and _checkLoot) then {
|
||||
_serverTime = serverTime;
|
||||
_looted = (_x getVariable ["looted",_serverTime]);
|
||||
_age = _serverTime - _looted;
|
||||
if ((_age == 0) or (_age > 900)) then {
|
||||
_x setVariable ["looted",_serverTime,!_islocal];
|
||||
_x call building_spawnLoot;
|
||||
if (!(_x in dayz_buildingBubbleMonitor)) then {
|
||||
dayz_buildingBubbleMonitor set [count dayz_buildingBubbleMonitor, _x];
|
||||
};
|
||||
//diag_log [ diag_tickTime, "new loot at",_x,"age:", _age, "serverTime:", _serverTime];
|
||||
}/*
|
||||
else {
|
||||
diag_log [ diag_tickTime, "won't spawn loot at",_x,"age:", _age, "serverTime:", _serverTime];
|
||||
}*/;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
// do not spawn zeds if player is moving faster then 10kmh
|
||||
if (!_onTheMove) then {
|
||||
//Zeds
|
||||
if ((time - dayz_spawnWait) > dayz_spawnDelay) then {
|
||||
if (dayz_maxCurrentZeds < dayz_maxZeds) then {
|
||||
if (dayz_CurrentZombies < dayz_maxGlobalZombies) then {
|
||||
if (dayz_spawnZombies < dayz_maxLocalZombies) then {
|
||||
_zombied = (_x getVariable ["zombieSpawn",-0.1]);
|
||||
_dateNow = (DateToNumber date);
|
||||
_age = (_dateNow - _zombied) * 525948;
|
||||
if (_age > 3) then {
|
||||
_x setVariable ["zombieSpawn",_dateNow,true];
|
||||
[_x] call building_spawnZombies;
|
||||
//Zeds
|
||||
if (getNumber(_config >> "zombieChance") > 0) then {
|
||||
if (_dis > _spawnZedRadius) then {
|
||||
_serverTime = serverTime;
|
||||
_zombied = (_x getVariable ["zombieSpawn",_serverTime]);
|
||||
_age = _serverTime - _zombied;
|
||||
if ((_age == 0) or (_age > 300)) then {
|
||||
if (!_isWreck) then {
|
||||
if ((dayz_spawnZombies < _maxControlledZombies) and (dayz_CurrentNearByZombies < dayz_maxNearByZombies) and (dayz_currentGlobalZombies < dayz_maxGlobalZeds)) then {
|
||||
_bPos = getPosATL _x;
|
||||
_zombiesNum = {alive _x} count (_bPos nearEntities ["zZombie_Base",(((sizeOf _type) * 2) + 10)]);
|
||||
|
||||
if (_zombiesNum == 0) then {
|
||||
_x setVariable ["zombieSpawn",_serverTime,!_islocal];
|
||||
|
||||
if (!(_x in dayz_buildingBubbleMonitor)) then {
|
||||
//add active zed to var
|
||||
dayz_buildingBubbleMonitor set [count dayz_buildingBubbleMonitor, _x];
|
||||
};
|
||||
} else {
|
||||
dayz_spawnWait = time;
|
||||
|
||||
//start spawn
|
||||
[_x] call building_spawnZombies;
|
||||
};
|
||||
//diag_log (format["%1 building. %2", __FILE__, _x]);
|
||||
};
|
||||
} else {
|
||||
_bPos = getPosATL _x;
|
||||
_zombiesNum = {alive _x} count (_bPos nearEntities ["zZombie_Base",(((sizeOf _type) * 2) + 30)]);
|
||||
//Should be a wreck
|
||||
if (_zombiesNum == 0) then { [_x,_isWreck] call building_spawnZombies; };
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
} forEach _nearby;
|
||||
};
|
||||
} forEach _nearby;
|
||||
Reference in New Issue
Block a user