Trying to change zombie spawns from SPAWN to CALL

I was able to install your code from Post #17, joikd on to my Tavi server. It works great and really changes the experience when driving or walking into a town or city. Thank you much.

EDIT: I also installed and tested the three files from Post #18, and personally I prefer the more instantaneous zombie spawn from the two older files; it is a real eye opener to see that many zombies around you.

EDIT #2: I see what you mean, joikd about stuttering when the zombies spawn en masse with your code from post #17. Taviana - in the big cities - can be laggy anyway, but I do not mind it to much. I tested trying to land a helicopter in Lypestock a few blocks from the soccer stadium, and was swarmed by around fifty or so zombies. I love it!

EDIT #3: After extensive testing of your code, joikd - from post #17 - I've discovered that, on Tavi.eu at least - it prevents players from harvesting meat from animals for some reason. That is a darn shame, because with your zombie spawn code running, the server really came to life.
 
Thank you very much, I am definitely interested in that safe zone. I found that I could exec this inside the init like this and it would work properly.


fnc_usec_selfActions = compile preprocessFileLineNumbers "fixes\zombieSpawns.sqf";

For me, this removes all of the other player self actions when running the file like you show here in the init.sqf.

This is driving me bonkers. If I run it one place in the init.sqf, it prevents loot from spawning, if I run it as I imagine you did, then all other self actions are removed.
 
For me, this removes all of the other player self actions when running the file like you show here in the init.sqf.

This is driving me bonkers. If I run it one place in the init.sqf, it prevents loot from spawning, if I run it as I imagine you did, then all other self actions are removed.

Yeah, I removed this a while ago, just change the variable its assigned to.
 
Joikd,

Quick question on your "drip" stuttering zombie issue, I though that when you use call instead of spawn, it requires the script being called to complete as it is being kept in the single processor thread whereas spawn creates a new thread and lets it run in parallel?

So as you call building_spawn then it calls zombie_gen , your player_spawn has to wait for the completion of both calls before continuing, you may want to try spawning, the zombie_gen or both the zombie_gen and the building_spawn, may take more mem but relive stutter etc.
 
Yeah, I removed this a while ago, just change the variable its assigned to.
I'm pretty new to scripting, what would be appropriate?
thevisad, I'm not sure what you mean here. Can I use your earlier player_spawnChecks.sqf here with any variable? myVar1?
fnc_usec_selfActions = compile preprocessFileLineNumbers "fixes\zombieSpawns.sqf";
 
I have tried to run Joikd's zombie code every way that I can come up with - and while it works amazingly well - no matter how I run it, it prevents loot from spawning. I have tried:

Code:
fnc_usec_player_spawnCheck = compile preprocessFileLineNumbers "fixes\player_spawnCheck.sqf";
 
player_spawnCheck = compile preprocessFileLineNumbers "fixes\player_spawnCheck.sqf";

and more.

My conclusion, and I admit that I am very new to ArmaII/DayZ coding, is that the only way to properly use Joikd's code is to replace the relevant .sqf files in the DayZ Code itself, and then distribute the altered package to those who wish to join your server. If anyone else can find a way to run it without consequence, I for one would be very appreciative.
 
I have this working perfectly on my server, but I can't and won't be releasing my scripts. But a hint is if you know how to script. You can re-script his original code with loot. :)
 
How are you calling the script?

That's where I'm stuck - how can I call his script to spawn all loot on server start, to replace the original?
 
Well he removed the loot code. So you would have to rewrite the code for spawning loot. :p That's all I'll give ya.
 
Not near a machine I can actually test this on, but here is a modified player_spawnCheck.sqf that should allow all items to spawn in game a single time per server start, in addition to causing zeds to spawn regardless of player being in vehicle.

Code:
_isAir = vehicle player iskindof "Air";
_inVehicle = vehicle player isKindOf "player";
_fastRun = _this select 0;
_dateNow = (DateToNumber date);
_age = -1;
_handle = [_x,_fastRun] call building_spawnLoot;
waitUntil{scriptDone _handle};
 
    _position = getPosATL player;
    _nearby = _position nearObjects ["building",400];
    _tooManyZs = {alive _x} count (_position nearEntities ["zZombie_Base",400]) > dayz_maxLocalZombies;
    {
        _type = typeOf _x;
        _config =        configFile >> "CfgBuildingLoot" >> _type;
        _canLoot =        isClass (_config);       
        if (_canLoot) then {           
               
            if ((time - dayz_spawnWait) > dayz_spawnDelay) then {
                if (dayz_spawnZombies < dayz_maxLocalZombies) then {
                    if (!_tooManyZs) then {
                        private["_zombied"];
                        _zombied = (_x getVariable ["zombieSpawn",-0.1]);
                        _dateNow = (DateToNumber date);
                        _age = (_dateNow - _zombied) * 525948;
                        if (_age > 5) then {
                            _bPos = getPosATL _x;
                            _zombiesNum = {alive _x} count (_bPos nearEntities ["zZombie_Base",(((sizeOf _type) * 2) + 10)]);
                            if (_zombiesNum == 0) then {
                                _x setVariable ["zombieSpawn",_dateNow,true];
                                _handle = [_x,_fastRun] call building_spawnZombies;
                                waitUntil{scriptDone _handle};
                            };
                        };
                    };
                } else {
                    dayz_spawnWait = time;
                    dayz_spawnZombies = 0;
                };
            };
        };
        if (!_fastRun) then {
            sleep 0.1;
        };
    } forEach _nearby;
I intend to use this code, but I don't know how to call it in my mission to overwrite the default. Is this what you are referring to?

I get that you don't want to share your unique features, I simply want to call this file, surely you are willing to share that?
 
@mmmyum:

To call the code you want to use find the following in your server mission PBO init.sqf:

Code:
call compile preprocessFileLineNumbers "\z\addons\dayz_code\init\compiles.sqf"; //Compile regular functions

put this underneath it:

Code:
player_spawnCheck = compile preprocessFileLineNumbers "fixes\player_spawnCheck.sqf";

Of course, you also need to create a fixes folder in your unpacked server mission PBO, and paste the code you want to use in a new file that you created in the fixes folder with Notepad++. The code I cannot properly call is from post #17, which causes an explosive zombie spawn around players and allows them to kill all of the zombies in a certain radius, then prevents them from spawning again for a certain amount of time.
 
Ahhh perfect, thank you!

Yeah I know how to do the fixes folder/etc - just needed to know how to call it properly. You're the best!

As I understand it, this code will make loot spawn only once per server start, but will it all spawn upon mission load - or will it simply spawn as a player nears a building for the first time after server start?

Anyone know? I'll test it when I get a chance.

My fear is that one player will cause all item spawns as they go through a town, then the cleanup script will delete the loot bags as the player leaves the area, and no loot will remain.
 
@Saethkept

Got it working, thanks to you!

But the code I used is not working - I've seen no zeds or loot at all. Oh well.

Anyone have a solution to spawn all loot once on server start?

@thevisad, did you get this working?
 
Same kind of trouble I had been having, but gave up for the moment.
I'm pretty close to giving up too, maybe eventually I'll just distribute my own mod package, and dive into the code.
Out of curiosity - did you ever have an idea of what the problem might be?
 
Well, the code from post #17 in this thread works really well, but also prevents loot from spawning on my server. My only guess is that it is overriding or suppressing the building_spawnLoot.sqf in the DayZ Code. I suppose one could build new loot spawn code into all of Joikd's code "packets" but that is tough to do when you run a server people wish to play on and you've got to shut it down to tinker with added features like this.

Another possibility - pertaining more to the code you wish to run, authored by theVisad, is that we are running it from the wrong place in the Init.sqf with the wrong code hook. He said to change the variable - which I tried. I had presumed that he was running it inside an if (!isDedicated) then { }; statement, but when I tried running it with fnc_usec_selfActions, rather than as I advised you above, it disabled all other player self actions.

Bottom line I guess ... I am new to all of this and teaching myself as I go. Either I will figure it out or let it go ... it seems.
 
Huh. Could I not just copy building_spawnLoot.sqf to my mission in a similar way as player_spawnCheck.sqf?

I've been reading through the code, trying to understand what's calling what, like _fastrun.

Is anyone else still working on this? Or can someone point me to a resource about overriding through the mission pbo?
Or can someone just tell me what it's called, so I can google it easier?

Bottom line for myself as well, new and trying to learn as I go. But if I want a more realistic approach to loot and zed spawning, gotta keep wading through the code
 
Well, the code from post #17 in this thread works really well, but also prevents loot from spawning on my server. My only guess is that it is overriding or suppressing the building_spawnLoot.sqf in the DayZ Code. I suppose one could build new loot spawn code into all of Joikd's code "packets" but that is tough to do when you run a server people wish to play on and you've got to shut it down to tinker with added features like this.

Another possibility - pertaining more to the code you wish to run, authored by theVisad, is that we are running it from the wrong place in the Init.sqf with the wrong code hook. He said to change the variable - which I tried. I had presumed that he was running it inside an if (!isDedicated) then { }; statement, but when I tried running it with fnc_usec_selfActions, rather than as I advised you above, it disabled all other player self actions.

Bottom line I guess ... I am new to all of this and teaching myself as I go. Either I will figure it out or let it go ... it seems.
So, I've figured out why you're not getting any loot - sky479 is correct, he has removed the loot spawning code from his stuff in post 17 (or whereever that post was that said update, all his code it seems.)
I'm not sure how he's calling loot spawning - but this is what I am interested in so I will be looking into it.
Here's his loot spawning code, that I found -
Code:
spawn_allBuildingLoot = {
    private["_center","_Chernarus","_allBldngs","_fastRun","_type","_config","_canLoot","_handle"];
 
    if (isDedicated) then {
        _center = getArray (configFile >> "CfgWorlds" >> _Chernarus >> "centerPosition";
        _allBldngs = _center nearObjects ["building",20000];
        _fastRun = _this select 0;
        {
            _type = typeOf _x;
            _config = configFile >> "CfgBuildingLoot" >> _type;
            _canLoot = isClass (_config);     
            if (_canLoot) then {             
                _handle = [_x,_fastRun] spawn building_spawnLoot;
                waitUntil{scriptDone _handle};
                _x setVariable ["permaLoot",true];
            };
        } forEach _allBldngs;
    };
};
Maybe he's calling it in the init with execVM and giving it parameters?
I'd like to have it only run once and just spawn all loot on server start - so no loot respawning at all, until reboot.

As sky said, you can also just implement his code into your already existing player_spawnCheck.sqf or whatever file, and simply do not delete the loot spawning code.

Thanks to you I've got it working with the command you gave me
player_spawnCheck = compile preprocessFileLineNumbers "fixes\player_spawnCheck.sqf";
and I'm thinking we can use the same command to override the rest of the files we need to change, including this building spawn loot if we have to.

I'll be away for the next few days, hopefully get something working when I'm back.
 
Back
Top