Jump to content

Spawn Zombies via SQF?


PetuniaEpoch

Recommended Posts

Hey all :)

I've been banging my head against a wall for hours with this one, if anyone can help... many beans to them :D

So, I'm trying to spawn zombies via an SQF file that I can call via execvm - I know the method I want to use to call the file, so that's all good... However I just CAN'T get Zombies to spawn :(

I hunted around and found this script, which is supposed to work, however nothing happens :(:

private ["_zombletypes","_zomblesposition","_zombleselectedpos","_agent","_genzombles"];

_zombletypes = ["zZombie_Base", "z_worker3", "z_worker2", "z_worker1", "z_villager1", "z_villager2", "z_villager3", "z_worker3", "z_worker2",

"z_worker1", "z_villager1", "z_villager2", "z_villager3", "z_worker3", "z_worker2", "z_worker1", "z_villager1", "z_villager2", "z_villager3"];

_zomblesposition = [12217.315, 6804.6929, 0.079474516];

_i = 1;

for "_i" from 1 to 30 do

{

_genzombles = _zombletypes call BIS_fnc_selectRandom;

_agent = createAgent [_genzombles, _zomblesposition, [], 40, "NONE"];

_zombleselectedpos = getPosATL _agent;

[_zombleselectedpos,_agent] execFSM "\z\AddOns\dayz_code\system\zombie_agent.fsm";

};

I wonder if perhaps the script is old? I checked the client side PBO for \z\AddOns\dayz_code\system\zombie_agent.fsm, and that file appears to be there - so is this correct?

Anyone spot any errors with this file?

Note: I got this file from an opendayz thread, and it used a sensor entry in mission.sqm - BUT I don't want to call the file that way - could it be my method of execution (trying to just execvm the above file, rather than using a sensor that execVMs it??? Surely not!)

Any help would be seriously appreciated :D

BTW - I'm running 1.0.2.5 still at the moment, upgrading to 1.0.3.1 later next week - not sure if that effects anything? (e.g. zombie spawn file).

Link to comment
Share on other sites

modified the spawn wild zombies script a tiny bit

private ["_position","_doLoiter","_unitTypes","_loot","_array","_agent","_type","_radius","_method","_myDest","_newDest","_lootType","_isAlive","_rnd","_id"];
_unitTypes = ["z_worker3", "z_worker2", "z_worker1", "z_villager1", "z_villager2", "z_villager3", "z_worker3", "z_worker2", "z_worker1", "z_villager1", "z_villager2", "z_villager3", "z_worker3", "z_worker2", "z_worker1", "z_villager1", "z_villager2", "z_villager3"];
_doLoiter = 	true;

_loot = 	"";
_array = 	[];
_agent = 	objNull;

_type = _unitTypes call BIS_fnc_selectRandom;

_radius = 40;
_method = "NONE";

_position = position player;

_agent = createAgent [_type, _position, [], _radius, _method];

if (_doLoiter) then {
	_agent setDir round(random 180);
};

dayz_spawnZombies = dayz_spawnZombies + 1;

if (random 1 > 0.7) then {
	_agent setUnitPos "Middle";
};

if (isNull _agent) exitWith {
	dayz_spawnZombies = dayz_spawnZombies - 1;
};

_isAlive = alive _agent;

_myDest = getPosATL _agent;
_newDest = getPosATL _agent;
_agent setVariable ["myDest",_myDest];
_agent setVariable ["newDest",_newDest];

//Add some loot
_rnd = random 1;
if (_rnd > 0.3) then {
	_lootType = 		configFile >> "CfgVehicles" >> _type >> "zombieLoot";
	if (isText _lootType) then {
		_array = []+ getArray (configFile >> "cfgLoot" >> getText(_lootType));
		if (count _array > 0) then {
			_loot = _array call BIS_fnc_selectRandomWeighted;
			if(!isNil "_array") then {
				_agent addMagazine _loot;
			};
		};
	};
};

_id = [_position,_agent] execFSM "\z\AddOns\dayz_code\system\zombie_agent.fsm";
Link to comment
Share on other sites

That looks cool!

 

I'll give that a bash shortly - I guess I can trim out the loot bit if I don't want that - but how would I spawn a shed-load of Z's? I guess I could add something like:

 

for "_i" from 1 to 30 do
{
(code here)
}

to spawn say, 30 zombies - but I'm not sure what bit of wrap that around - or even if it's the right way to do it :S

 

 

modified the spawn wild zombies script a tiny bit

private ["_position","_doLoiter","_unitTypes","_loot","_array","_agent","_type","_radius","_method","_myDest","_newDest","_lootType","_isAlive","_rnd","_id"];
_unitTypes = ["z_worker3", "z_worker2", "z_worker1", "z_villager1", "z_villager2", "z_villager3", "z_worker3", "z_worker2", "z_worker1", "z_villager1", "z_villager2", "z_villager3", "z_worker3", "z_worker2", "z_worker1", "z_villager1", "z_villager2", "z_villager3"];
_doLoiter = 	true;

_loot = 	"";
_array = 	[];
_agent = 	objNull;

_type = _unitTypes call BIS_fnc_selectRandom;

_radius = 40;
_method = "NONE";

_position = position player;

_agent = createAgent [_type, _position, [], _radius, _method];

if (_doLoiter) then {
	_agent setDir round(random 180);
};

dayz_spawnZombies = dayz_spawnZombies + 1;

if (random 1 > 0.7) then {
	_agent setUnitPos "Middle";
};

if (isNull _agent) exitWith {
	dayz_spawnZombies = dayz_spawnZombies - 1;
};

_isAlive = alive _agent;

_myDest = getPosATL _agent;
_newDest = getPosATL _agent;
_agent setVariable ["myDest",_myDest];
_agent setVariable ["newDest",_newDest];

//Add some loot
_rnd = random 1;
if (_rnd > 0.3) then {
	_lootType = 		configFile >> "CfgVehicles" >> _type >> "zombieLoot";
	if (isText _lootType) then {
		_array = []+ getArray (configFile >> "cfgLoot" >> getText(_lootType));
		if (count _array > 0) then {
			_loot = _array call BIS_fnc_selectRandomWeighted;
			if(!isNil "_array") then {
				_agent addMagazine _loot;
			};
		};
	};
};

_id = [_position,_agent] execFSM "\z\AddOns\dayz_code\system\zombie_agent.fsm";
Link to comment
Share on other sites

That looks cool!

 

I'll give that a bash shortly - I guess I can trim out the loot bit if I don't want that - but how would I spawn a shed-load of Z's? I guess I could add something like:

for "_i" from 1 to 30 do
{
(code here)
}

to spawn say, 30 zombies - but I'm not sure what bit of wrap that around - or even if it's the right way to do it :S

pretty much yea

zombieSpawner = compile preprocessFileLineNumbers "path\to\zedspawnscript.sqf";

_i = 0; for "_i" from 0 to 30 do {[] spawn zombieSpawner;};

something like that probably a better way to do that but worth a shot

Link to comment
Share on other sites

Cool beans!

 

I'm testing now - if it works, I may change:

 

_position = position player; 

 

To be a worldspace - to get them to spawn at a set location. Should be okay I think?

 

 

pretty much yea

zombieSpawner = compile preprocessFileLineNumbers "path\to\zedspawnscript.sqf";

_i = 0; for "_i" from 0 to 30 do {[] spawn zombieSpawner;};

something like that probably a better way to do that but worth a shot

Link to comment
Share on other sites

Nope :( No joy - didn't work :(

 

Not sure why! I just can't get the Z's to spawn! Grrr... lol

 

pretty much yea

zombieSpawner = compile preprocessFileLineNumbers "path\to\zedspawnscript.sqf";

_i = 0; for "_i" from 0 to 30 do {[] spawn zombieSpawner;};

something like that probably a better way to do that but worth a shot

Link to comment
Share on other sites

I even tried without the i= stuff - just using the sqf file, compiling it, and calling the compile using the script you provided in your first post - no joy :(

 

I'm not getting what's wrong here :S

 

 

pretty much yea

zombieSpawner = compile preprocessFileLineNumbers "path\to\zedspawnscript.sqf";

_i = 0; for "_i" from 0 to 30 do {[] spawn zombieSpawner;};

something like that probably a better way to do that but worth a shot

Link to comment
Share on other sites

Not sure if this rpt message is related?

 

 
17:56:58   bin\config.bin/CfgMovesZombie/States/AinvPknlMstpSnonWnonDnon_medic.ConnectTo: Bad move AinvPknlMstpSnonWnonDnon_medic3
17:56:58   bin\config.bin/CfgMovesZombie/States/AinvPknlMstpSnonWnonDnon_medic.ConnectTo: Bad move AinvPknlMstpSnonWnonDr_medic3

 

 

you get any errors in the RPT ?

Link to comment
Share on other sites

 

Not sure if this rpt message is related?

 
17:56:58   bin\config.bin/CfgMovesZombie/States/AinvPknlMstpSnonWnonDnon_medic.ConnectTo: Bad move AinvPknlMstpSnonWnonDnon_medic3
17:56:58   bin\config.bin/CfgMovesZombie/States/AinvPknlMstpSnonWnonDnon_medic.ConnectTo: Bad move AinvPknlMstpSnonWnonDr_medic3

that doesnt have anything to do with it

Link to comment
Share on other sites

Cant remember who it was that helped me with this. This is not my work.

 

 

save this as a .sqf file

_zombletypes = [
"zZombie_Base",
"z_worker1",
"z_worker2",
"z_worker3",
"z_villager1",
"z_villager2",
"z_villager3",
"z_suit1",
"z_suit2",
"z_soldier",
"z_soldier_heavy",
"z_soldier_pilot",
"z_policeman",
"z_teacher",
"z_doctor",
"z_hunter",
"z_priest"
];
_zomblesposition =    [13616.088,3153.3975,5.3405762e-005];
_i = 1;
    for "_i" from 1 to 30 do
    {
        _genzombles = _zombletypes call BIS_fnc_selectRandom;
        _agent = createAgent [_genzombles, _zomblesposition, [], 10, "NONE"];
        _zombleselectedpos = getPosATL _agent;
        [_zombleselectedpos,_agent] execFSM "\z\addons\dayz_code\system\zombie_agent.fsm";
    };

change coordinates and the amount of zombies to spawn in the above file.

 

 

 

 

 

add this to the mission.sqm file where the markers go

		class Item16
		{
            position[]={11787.4,0.001,12674.5};
            a=14;
            b=14;
            activationBy="ANY";
            repeating=1;
            interruptable=1;
            age="UNKNOWN";
            name="ZombleSpawnTrigger";
            expCond="(vehicle player) in thislist;";
            expActiv="zomblespawnt = [] execVM ""map_addons\zombies\1.sqf"";";
            expDesactiv="terminate zomblespawnt;";
            class Effects
            {
            };
        };

change the file location to where ever you save the file.

 

 

I dont know if this works with 1.0.3.1 but it did work ok with 1.0.2.5

 

Link to comment
Share on other sites

Hey :)

 

This looks similar to the code in my spoiler in the OP I think - Thing is, I'm wanting to use this with a epoch mission - so not always using the same location.

 

What I tried was within a server-side mission file using something like this:

 

waitUntil{{isPlayer _x && _x distance _crate < 20  } count playableunits > 0};
execVM "debug\spawnz.sqf";

 

The contents of spawnz.sqf was what was in my OP - Not sure if it's exactly the same. I'm wondering if for some reason I can't do the execVM from serverside to client side - strange if that's the case, as I do that with the mission system to add-remove the markers via an execVM to files in the same client side /debug/ folder :S

 

Any ideas?

 

Cant remember who it was that helped me with this. This is not my work.

 

 

save this as a .sqf file

_zombletypes = [
"zZombie_Base",
"z_worker1",
"z_worker2",
"z_worker3",
"z_villager1",
"z_villager2",
"z_villager3",
"z_suit1",
"z_suit2",
"z_soldier",
"z_soldier_heavy",
"z_soldier_pilot",
"z_policeman",
"z_teacher",
"z_doctor",
"z_hunter",
"z_priest"
];
_zomblesposition =    [13616.088,3153.3975,5.3405762e-005];
_i = 1;
    for "_i" from 1 to 30 do
    {
        _genzombles = _zombletypes call BIS_fnc_selectRandom;
        _agent = createAgent [_genzombles, _zomblesposition, [], 10, "NONE"];
        _zombleselectedpos = getPosATL _agent;
        [_zombleselectedpos,_agent] execFSM "\z\addons\dayz_code\system\zombie_agent.fsm";
    };

change coordinates and the amount of zombies to spawn in the above file.

 

 

 

 

 

add this to the mission.sqm file where the markers go

		class Item16
		{
            position[]={11787.4,0.001,12674.5};
            a=14;
            b=14;
            activationBy="ANY";
            repeating=1;
            interruptable=1;
            age="UNKNOWN";
            name="ZombleSpawnTrigger";
            expCond="(vehicle player) in thislist;";
            expActiv="zomblespawnt = [] execVM ""map_addons\zombies\1.sqf"";";
            expDesactiv="terminate zomblespawnt;";
            class Effects
            {
            };
        };

change the file location to where ever you save the file.

 

 

I dont know if this works with 1.0.3.1 but it did work ok with 1.0.2.5

Link to comment
Share on other sites

If that actual SQF would work you would be able to exec that in your mission module, without having to add it to the mission file.

I am wondering what the server will do with spawned zeds when there are no players nearby though.

 

It's triggered when a player is nearby, otherwise it shouldn't do anything.

 

I never got this to work though :P Anyone did?

Link to comment
Share on other sites

  • 4 weeks later...

Try this, Its exactly the same as your code, but it spawns zombies next to the player that does the command

 

Replace the "INSERT NUMBER TO SPAWN HERE" including quotes to the number you wish to spawn

 

for example

 

for "_i" from 1 to 10 do

 

Will spawn 10 zeds around the player

 

 

Tested on Epoch 1.0.3.1

 

private ["_zombletypes","_zomblesposition","_zombleselectedpos","_agent","_genzombles"];
 
_zombletypes = ["zZombie_Base", "z_worker3", "z_worker2", "z_worker1", "z_villager1", "z_villager2", "z_villager3", "z_worker3", "z_worker2",
"z_worker1", "z_villager1", "z_villager2", "z_villager3", "z_worker3", "z_worker2", "z_worker1", "z_villager1", "z_villager2", "z_villager3"];
_zomblesposition = [((getPos player) select 0) + 2, ((getPos player) select 1) + 2, 0];
_i = 1;
for "_i" from 1 to 'INSERT NUMBER TO SPAWN HERE' do
{
_genzombles = _zombletypes call BIS_fnc_selectRandom;
_agent = createAgent [_genzombles, _zomblesposition, [], 40, "NONE"];
_zombleselectedpos = getPosATL _agent;
[_zombleselectedpos,_agent] execFSM "\z\AddOns\dayz_code\system\zombie_agent.fsm";
};

 

 

 

 

 

Also @Randomness

I am wondering what the server will do with spawned zeds when there are no players nearby though.

 

 

To that question if nobody is around, they will just despawn slowly 

Link to comment
Share on other sites

So basicly, it is not possible to infest an area with zombies before the players arrive , because most of the zombies would have disappeared already?

I'm going to look into this as well later, maybe there is some workaround for events somehow :) Anyone tried that yet, to delay despawning at least?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Discord

×
×
  • Create New...