Decreasing amount of zombies?

Deathcall

Well-Known Member
Hello everyone, I'd like to ask you guys if you know how I can decrease the amount of zombies that spawn in the server.

Currently, I believe it's a bit too much, when highly populated, we get about 1200 zombies spawned in the map, this lags the server something fierce.

Does anyone know what I have to modify on the files in order to tune it down a bit?
 
Zombie spawning is a client-side process. So, put a modified building_spawnZombies.sqf in your mission.pbo. Lines you might want to consider are line 8 and 9. Change it to something like:

if (dayz_CurrentZombies > 15) exitwith {};
if (dayz_spawnZombies > 10) exitwith {};

That means, if your player's computer controls more than 10 zombies, or if there are more than 15 nearby, no more zombies will be created.

You will have to look into mission file structure a bit, but all the additional files won't take more than 30-40 KB.
 
Thanks! I'll toy around with it.

EDIT

My building_spawnZombies.sqf looks like this...

Code:
private["_obj","_type","_config","_canLoot","_originalPos","_unitTypes","_min","_max","_num","_clean","_positions","_zombieChance","_rnd","_iPos","_nearBy","_nearByPlayer"];_obj =            _this select 0;
_obj = _this select 0;
_type =        typeOf _obj;
_config =        configFile >> "CfgBuildingLoot" >> _type;
_canLoot =        isClass (_config);
_originalPos =    getPosATL _obj;
 
if (_canLoot) then {
//Get zombie class
    _unitTypes =    getArray (_config >> "zombieClass");
    _min =            getNumber (_config >> "minRoaming");
    _max =            getNumber (_config >> "maxRoaming");
//Walking Zombies
    _num = round(random _max) min _min;
    _config =        configFile >> "CfgBuildingLoot" >> _type;
//Get zombie class
    _zombieChance =    getNumber (_config >> "zombieChance");
    _rnd = random 0.5;
    _chance =    round(random 20);
 
    //if (_rnd < _zombieChance) then {
    if ((_chance % 2) == 0) then {
       
        _noPlayerNear = (count ((getPosATL _obj) nearEntities ["CAManBase",30])) == 0;
       
        if (_noPlayerNear) then {
       
            _position = _obj buildingExit 0;
            if ((_position select 0) == 0) then {
                _position = getPosATL _obj;
            };
       
        //diag_log ("Class: " + _type + " / Zombies: " + str(_unitTypes) + " / Walking: " + str(_num));
            for "_i" from 1 to _num do
            {
                [_position,_unitTypes] call zombie_generate;
            };
           
        };
    };
 
    //Add Internal Zombies
    _clean = {alive _x} count ((getPosATL _obj) nearEntities ["zZombie_Base",(sizeOf _type)]) == 0;
    if (_clean) then {
        _positions =    getArray (_config >> "lootPos");
        _zombieChance =    getNumber (_config >> "zombieChance");
        //diag_log format["Building: %1 / Positions: %2 / Chance: %3",_type,_positions,_zombieChance];
        {
            _rnd = random 1;
            if (_rnd < _zombieChance) then {
                _iPos = _obj modelToWorld _x;
               
                _nearBy = {alive _x} count nearestObjects [_iPos , ["zZombie_Base"],3] > 0;
                _nearByPlayer = ({isPlayer _x} count (_iPos  nearEntities ["CAManBase",30])) > 0;
                //diag_log ("BUILDING: " + _type + " / " + str(_nearBy) + " / " + str(_nearByPlayer));
               
                if (!_nearByPlayer and !_nearBy) then {
                    [_iPos,_unitTypes] call zombie_generate;
                };
            };
        } forEach _positions;
    };
 
    dayz_buildingMonitor set [count dayz_buildingMonitor,_obj];
};

It's pretty convoluted inside this thing... What should I change?
 
try adding my 2 lines after _originalPos = getPosATL _obj;, this will stop zombie spawn script if local zombies or nearby zombies count is higher than numbers given
 
Copy your variables.sqf from dayz_code, and put it in your mission pbo called from init with an ovverride.

Inside is a value maxLocalZombies that you need to change to whatever you want.
 
Not entirely sure it works. I'm sitting in the middle of Calamar (Lingor) and I'm getting 25 something zombies. I set it to maximum 20. It's a big city so there could be more, but I'm not sure...
 
Do you have a debug monitor installed to monitor the number of zeds?

from my init
variables = compile preprocessFileLineNumbers "fixes\variables.sqf";
in my mission pbo I have a fixes folder with variables.sqf in it. This is how you call an overrride.
I'm using a completely custom player_spawnCheck and building_spawnZombies so I'm not sure if there are other checks in there, but from your building_spawnZombie I dont think so. You may have to changes maxGlobalZombies and maxZombies in variables.sqf too, if you have those values.
Check through your player_spawnCheck and maybe player_zombieCheck, I'm not sure where exactly but you're looking for a conditional limit.
 
I'm using a monitor yes, so I get precise numbers.

I'll check through the other files you mentioned, some of which I had already looked through. the building_spawnZombies I have has already been linked a few posts above. Though the suggestion made by Maciej did not work for me, made it so no zombies at all. I do understand how it works though, it takes the min and max values from teh config.cpp on the DayZ_Code.pbo of the mod.

Isn't there a way to change this:
Code:
    _min =            getNumber (_config >> "minRoaming");
    _max =            getNumber (_config >> "maxRoaming");

And add after each line something like "*0.66 mod 1" so the total number gets reduced by 33 percent and rounded up to 1?
 
Code:
if (_canLoot) then {
//Get zombie class
    _unitTypes =    getArray (_config >> "zombieClass");
    _min =            getNumber (_config >> "minRoaming");
    _max =            getNumber (_config >> "maxRoaming");
//Walking Zombies
    _num = round(random _max) min _min;
    _config =        configFile >> "CfgBuildingLoot" >> _type;
//Get zombie class
    _zombieChance =    getNumber (_config >> "zombieChance");
    _rnd = random 0.5;
    _chance =    round(random 20);
 
    //if (_rnd < _zombieChance) then {
    if ((_chance % 2) == 0) then {
       
        _noPlayerNear = (count ((getPosATL _obj) nearEntities ["CAManBase",30])) == 0;
       
        if (_noPlayerNear) then {
       
            _position = _obj buildingExit 0;
            if ((_position select 0) == 0) then {
                _position = getPosATL _obj;
            };
       
        //diag_log ("Class: " + _type + " / Zombies: " + str(_unitTypes) + " / Walking: " + str(_num));
            for "_i" from 1 to _num do
            {
                [_position,_unitTypes] call zombie_generate;
            };
           
        };
    };
This here is what is calling zombie_generate to spawn zombies by buildings

Those maxRoaming numbers are not for regular zombie spawning I don't think, but for roaming zombies (like the random ones you see in the woods/fields) not those that come from buildings. Don't worry about the roamers

Post/look through your player_spawnCheck and look through your zombie_generate. The limit is in one of those two files I believe. And you definitely have to change it in variables.sqf.

I think, before I mangled my code - that my zeds were spawning only if the total zed count was lower that maxZombies, maxGlobalZombies, and maxLocalZombies. You need to find where these logic checks are, at least for maxLocalZombies - and see what they boolean checks are - just if total zeds < maxLocaal, or something more complicated?

It might take a little longer for zeds to come in, and you might have to be in a city to get a higher number. There are limits on the number that town/city/whatever can spawn as well.

You won't always have exactly the number you set maxLocalZombies to though - because it will be constantly changing as zeds spawn in and are deleted by server_cleanup - so to test maybe put the number higher than it was in vanilla and see what that does.
 
I don't know if this topic is relevant anymore, but I'm still trying to figure out how to adjust zombie spawns or just remove them completely. I'm new to scripting so a detailed description would be great. If anyone would be willing to help or needs more information please let me know. This is for cherno 1.8.0.3 vanilla dayz.
 
I am also still looking for this like HospitalChair is. I have a Chernarus 1.8.03 private server and I would like to decrease the spawn rate or completely remove the zombies. Please help! Thanks!
 
Back
Top