Modme Forums
Menu:

How to pause zombie spawning / kill all zombies

Game Modding | Call of Duty: Black Ops 3 | Scripting


ModmeBot:

Thread By: mathfag
TUTORIAL:
How to make zombies stop spawning.
You can use this for an easter egg step like in Gorod Krovi, where there are no zombies when Sophia talks

to pause spawning:

SetDvar("ai_DisableSpawn",1);


to continue spawning:
SetDvar("ai_DisableSpawn",0);


to kill all of the zombies (1/2):
zombies = zombie_utility::get_round_enemy_array();
    if ( isdefined( zombies ) )
    {
    array::run_all( zombies, &Kill );
    }
you can put this in a while(1)


to kill all of the zombies (2/2):
#using scripts\shared\ai\zombie_utility;
#using scripts\shared\array_shared;
add this to the top of the gsc


note:
this will stop all ai including NSZ brutus


ModmeBot:

Reply By: Abnormal202
Useful stuff. I also found you can use:

level flag::clear( "spawn_zombies" );
to stop them from spawning, and use:
level flag::set( "spawn_zombies" );
to make them start spawning again.


ModmeBot:

Reply By: XxRaPiDK3LLERxX
But what if you want the zombies to die when using let's say, a teleporter to teleport far away? Since my map involves a lot of teleportation.


ModmeBot:

Reply By: Abnormal202

XxRaPiDK3LLERxX
But what if you want the zombies to die when using let's say, a teleporter to teleport far away? Since my map involves a lot of teleportation.

Find the script for teleporting and inject the line that kills all the zombies right after the teleporter is triggered. Don't know if you want to kill ALL the zombies though.


ModmeBot:

Reply By: Zombeast250
so i am just wanting to clear all the zombies (not kill) and start them spawning again/respawn them again after teleport is complete what lines of code will make this happen?


this is the code:

function player_teleporter_init()
{
player_tp = GetEntArray( "teleport_player", "targetname" );
for( i = 0; i < player_tp.size; i++ )
{
player_tpthread player_teleport();
}
}
function player_teleport()
{
destination = GetEnt( self.target, "targetname" );
while(1)
{
self waittill( "trigger", player );

player SetOrigin( destination.origin );
player SetPlayerAngles( destination.angles );

wait(0.05);

PlaySoundAtPosition( "beast_teleplayer1", player.origin ); // sound made when teleporting
//self PlaySound("beast_teleplayer1"); // not working
//player PlayLocalSound("beast_teleplayer1"); //works
}
}


ModmeBot:

Reply By: Abnormal202

Zombeast250
so i am just wanting to clear all the zombies (not kill) and start them spawning again/respawn them again after teleport is complete what lines of code will make this happen? this is the code: function player_teleporter_init(){ player_tp = GetEntArray( "teleport_player", "targetname" ); for( i = 0; i < player_tp.size; i++ ) { player_tpthread player_teleport(); }} function player_teleport(){ destination = GetEnt( self.target, "targetname" ); while(1) { self waittill( "trigger", player ); player SetOrigin( destination.origin ); player SetPlayerAngles( destination.angles ); wait(0.05); PlaySoundAtPosition( "beast_teleplayer1", player.origin ); // sound made when teleporting //self PlaySound("beast_teleplayer1"); // not working //player PlayLocalSound("beast_teleplayer1"); //works }}
what do you mean by clear the zombies (not kill)? You can either kill them, or stop spawning. Now, zombies will respawn if they can't find a path to the player within a certain time, so you could just keep the script how it is and just put spawns where the players teleport to, and they would start respawning there. If you wanted, you could teleport the zombies to there, that would get them there faster. If that's the case put this:
zombies = GetAiSpeciesArray( "axis", "all" );
zombie_destinations = struct::get_array("zombie_destination","targetname");
for(i=0;i&lt;zombies.size;i++) {="" rand="RandomIntRange(" 0,="" zombie_destinations.size="" );="" zombies[i]="" setorigin(="" zombie_destinations[rand].origin="" );="" zombies[i]="" setplayerangles(="" zombie_destinations[rand].angles="" );="" wait(0.25);="" time="" between="" zombie="" teleportation.="" don&#39;t="" put="" 0,="" as="" i&#39;m="" worried="" it="" could="" cause="" errors.=""&gt;&lt;/zombies.size;i++)&gt;
under:
player SetPlayerAngles( destination.angles );
You will have to make a bunch of script_structs in radiant and give them the targetname: "zombie_destination". Put them where zombies can respawn. Make a good amount of them too, like 10.

also can you use the insert code tags next time? it's a lot harder to look at code when it's just pasted into a forum without the code tags.


ModmeBot:

Reply By: Zombeast250
does this look right?

function player_teleport()
{
	destination = GetEnt( self.target, "targetname" );
	while(1)
	{
		self waittill( "trigger", player );
		
		player SetOrigin( destination.origin );
		player SetPlayerAngles( destination.angles );
		
    zombies = GetAiSpeciesArray( "axis", "all" );
    zombie_destinations = struct::get_array("zombie_destination","targetname");
    for(i=0;i&lt;zombies.size;i++) {="" rand="RandomIntRange(" 0,="" zombie_destinations.size="" );="" zombies[i]="" setorigin(="" zombie_destinations[rand].origin="" );="" zombies[i]="" setplayerangles(="" zombie_destinations[rand].angles="" );="" wait(0.25);="" time="" between="" zombie="" teleportation.="" don&#39;t="" put="" 0,="" as="" i&#39;m="" worried="" it="" could="" cause="" errors.="" }="" wait(0.05);="" playsoundatposition(="" "beast_teleplayer1",="" player.origin="" );="" sound="" made="" when="" teleporting="" self="" playsound("beast_teleplayer1");="" not="" working="" player="" playlocalsound("beast_teleplayer1");="" works="" }=""&gt;&lt;/zombies.size;i++)&gt;


ModmeBot:

Reply By: Abnormal202
tab { and } forward once


ModmeBot:

Reply By: Zombeast250

Abnormal202
tab { and } forward once

not sure what you mean sorry


ModmeBot:

Reply By: Zombeast250
also does the trigger need to be linked (w) to the struct?


ModmeBot:

Reply By: Abnormal202

Zombeast250
also does the trigger need to be linked (w) to the struct?

make this:
{
	rand = RandomIntRange( 0, zombie_destinations.size );
	zombies[i] SetOrigin( zombie_destinations[rand].origin );
	zombies[i] SetPlayerAngles( zombie_destinations[rand].angles );
	wait(0.25); //Time between zombie teleportation. Don&#39;t put 0, as I&#39;m worried it could cause errors.
}
this:
{
	rand = RandomIntRange( 0, zombie_destinations.size );
	zombies[i] SetOrigin( zombie_destinations[rand].origin );
	zombies[i] SetPlayerAngles( zombie_destinations[rand].angles );
	wait(0.25); //Time between zombie teleportation. Don&#39;t put 0, as I&#39;m worried it could cause errors.
	}
and no the trigger doesn't need to target anything else.


ModmeBot:

Reply By: Zombeast250
sorry this is the code:



function player_teleporter_init()
{
	player_tp = GetEntArray( "teleport_player", "targetname" );
	for( i = 0; i &lt; player_tp.size; i++ )
	{
		player_tp[i] thread player_teleport();
	}
}

function player_teleport()
{
	destination = GetEnt( self.target, "targetname" );
	while(1)
	{
		self waittill( "trigger", player );
		
		player SetOrigin( destination.origin );
		player SetPlayerAngles( destination.angles );
		
        zombies = GetAiSpeciesArray( "axis", "all" );
        zombie_destinations = struct::get_array("zombie_destination","targetname");
        for(i=0;i&lt;zombies.size;i++) {="" rand="RandomIntRange(" 0,="" zombie_destinations.size="" );="" zombies[i]="" setorigin(="" zombie_destinations[rand].origin="" );="" zombies[i]="" setplayerangles(="" zombie_destinations[rand].angles="" );="" wait(0.25);="" time="" between="" zombie="" teleportation.="" don&#39;t="" put="" 0,="" as="" i&#39;m="" worried="" it="" could="" cause="" errors.="" }="" wait(0.05);="" playsoundatposition(="" "beast_teleplayer1",="" player.origin="" );="" sound="" made="" when="" teleporting="" self="" playsound("beast_teleplayer1");="" not="" working="" player="" playlocalsound("beast_teleplayer1");="" works="" }=""&gt;&lt;/zombies.size;i++)&gt;