Modme Forums

Need Help Making Dogs Spawn with zombies at high rounds

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


ModmeBot:

Thread By: MyNameIsNobody
Is there a way to make it like on Der Riese where Dogs start spawning with zombies at the high rounds? I wanted to add dogs starting around level 30, but can't find anywhere anyone has discussed this. TIA!


ModmeBot:

Reply By: WECoyote99

MyNameIsNobody
Is there a way to make it like on Der Riese where Dogs start spawning with zombies at the high rounds? I wanted to add dogs starting around level 30, but can't find anywhere anyone has discussed this. TIA!

i have a function for it


ModmeBot:

Reply By: steviewonder87

WECoyote99
i have a function for it

How does telling him that help him?


ModmeBot:

Reply By: Kabe
I hope this helps you

#using scripts\zm\_zm_ai_dogs;

//add in your main:
level.dognon_stop = true;
level thread dog_non_stop();

//paste function:

function dog_non_stop()
{
    level endon( "intermission" );
    while(1)
    {
        level waittill( "between_round_over" );
        if( isDefined( level.dognon_stop ) && level.dognon_stop )
        {            
            while( level.round_number >= 30 )
            {
                wait( RandomIntRange( 2, 3 ) );
            
                if( level.zombie_total >= 3 )
                {
                    zm_ai_dogs::special_dog_spawn(1);
                }
            }
        }
    }
}


ModmeBot:

Reply By: MyNameIsNobody

WECoyote99
MyNameIsNobody Is there a way to make it like on Der Riese where Dogs start spawning with zombies at the high rounds? I wanted to add dogs starting around level 30, but can't find anywhere anyone has discussed this. TIA! i have a function for it


I'll credit you if you share it with me!


ModmeBot:

Reply By: MyNameIsNobody

Kabe
I hope this helps you #using scripts\zm\_zm_ai_dogs; add in your main: level.dognon_stop = true; level thread dog_non_stop(); paste function: function dog_non_stop(){ level endon( "intermission" ); while(1) { level waittill( "between_round_over" ); if( isDefined( level.dognon_stop ) && level.dognon_stop ) { while( level.round_number >= 30 ) { wait( RandomIntRange( 2, 3 ) ); if( level.zombie_total >= 3 ) { zm_ai_dogs::special_dog_spawn(1); } } } }}


This seems to make my game crash in the middle of the round right before when the dogs should be spawning. Have you or anyone else tested this? Curious for anyones input. I will try it again on a blank test map and let everyone know.

EDIT: REMOVED FROM MAP, MAP STILL CRASHED. So issue might no have been kabe's code he put on here, instead I must have another issue...


ModmeBot:

Reply By: Harry Bo21
lol whys everyone suddenly want this

anyway i cleaned up that code a bit ( Devnotes at the bottom ), i don't see any reason it should cause a crash, unless maybe you haven't placed dog spawners / spawn points in the map

// Add to top of the script

#using scripts\zm\_zm_ai_dogs;

// Add directly after zm_usermap::main();:

level thread dog_non_stop();

// Paste function way down the bottom, not inside any other functions :

function dog_non_stop()
{
	level endon( "intermission" );
	
	n_start_spawning_from_round 			= 30; 		// Round number
	n_minimum_zombie_total_for_spawn 		= 3;		// Minimum zombies remaining either "now" or "left to spawn" - if less the do spawning will pause till the next round
	n_minimum_delay_between_spawns 			= 2;		// Minimum wait in seconds between spawning dogs
	n_maximum_delay_between_spawns 			= 3;		// Maximum wait in seconds between spawning dogs
	
	while ( 1 )
	{
		level waittill( "between_round_over" ); // Wait till the end of a round
		
		if ( !isDefined( level.round_number ) || level.round_number < n_start_spawning_from_round ) // If round number is less that decided above, loop back to start
			continue;
		
		while ( isDefined( level.zombie_total ) && level.zombie_total >= n_minimum_zombie_total_for_spawn ) // Loop this block of code "only" while there is a high enough zombie total either spawned or spawning
		{
			wait randomIntRange( n_minimum_delay_between_spawns, n_maximum_delay_between_spawns ); // Use the random delay
			
			zm_ai_dogs::special_dog_spawn( 1 ); // Force spawn a dog           
		}
	}
}

// DEV NOTES : 

// Changed values to be easily changed and understandable to nooblets, better if you ever need to debug anyway

// Removed the level variable and the check, no need for it as this function doesn't support toggling the loop "back off" as you throw straight into a loop which never breaks. Also if your threading this function "at all" obviously they are not going to set the variable to false lol

// Added some isDefined checks to some of the values being passed, odds are these should never really be undefined, but you never know, and these are things that may potentially only error in Developer mode - which may seem irrelevant, but means when you really "do" need Developer mode to track down a problem, this error will block it first

// Advised to thread "after" zm_usermap::main(); - This is safer for things that rely on stock code / functions / variables as it is all set up inside that function

// Added a check to the second conditional loop to break when zombie count falls below the minimum - this will cause the first loop to repeat, up to the waittill on round over before running the second loop again

// HarryBo21

This is definitely not how this should be done, people are constantly asking for this lately however so I will take a look through the code and post a proper way in a while

Ill post to the wiki probably

EDIT : Ill see what i can do about the power switch lag too, I had already started a while back for Stevie, wrote out code, then got called away by modders and completely forgot about the code I wrote as usual lol.


ModmeBot:

Reply By: Kabe
Thanks for optimizing the code ;)
I updated it a little.
Now start when the round starts.
Now can detect if it is round of dogs and back to start.
Added level.dognon_stop to start / stop the spawn of dogs, if we are going to create some EE that requires it or simply use a cinematic while it is being played, simply add " level.dognon_stop = true " or " level.dognon_stop = false " of your code.
Now the zombie counter still has also the zombies that are alive and in turn can wake up zombie_ai_limit preventing the spawn of dogs.

// Add to top of the script

#using scripts\shared\flag_shared; //add this if it is not already
#using scripts\shared\ai\zombie_utility; //add this if it is not already
#using scripts\zm\_zm_ai_dogs;

// Add directly after zm_usermap::main();

level.dognon_stop = true;
level thread dog_non_stop();

// Paste function way down the bottom, not inside any other functions :

function dog_non_stop()
{
	level endon( "intermission" );
	
	n_start_spawning_from_round 			= 30; 		// Round number
	n_minimum_zombie_total_for_spawn 		= 3;		// Minimum zombies remaining either "now" or "left to spawn" - if less the do spawning will pause till the next round
	n_minimum_delay_between_spawns 			= 2;		// Minimum wait in seconds between spawning dogs
	n_maximum_delay_between_spawns 			= 3;		// Maximum wait in seconds between spawning dogs
	
	while ( 1 )
	{
		level waittill( "start_of_round" ); // Wait till the start round
		
		if ( !isDefined( level.round_number ) || level.round_number < n_start_spawning_from_round || level flag::exists( "dog_round" ) && level flag::get("dog_round" ) || !isDefined( level.zombie_total )) // If round number is less that decided above, loop back to start
			continue;
		
		n_count_total_zombie = level.zombie_total;
		while ( n_count_total_zombie >= n_minimum_zombie_total_for_spawn ) // Loop this block of code "only" while there is a high enough zombie total either spawned or spawning and level.dognon_stop = true
		{
			wait randomIntRange( n_minimum_delay_between_spawns, n_maximum_delay_between_spawns ); // Use the random delay
			n_count_zombies_spawn = zombie_utility::get_current_zombie_count(); //Count zombies spawned
			n_count_total_zombie = n_count_zombies_spawn + level.zombie_total; //Count zombies spawned + zombies spawning
			
			if( n_count_zombies_spawn < level.zombie_ai_limit && isDefined( level.dognon_stop ) && level.dognon_stop ){ zm_ai_dogs::special_dog_spawn(1); }	 // Force spawn a dog if it does not reach the zombie_ai_limit
		}
	}
}

// DEV NOTES : 

// Changed values to be easily changed and understandable to nooblets, better if you ever need to debug anyway

// Removed the level variable and the check, no need for it as this function doesn't support toggling the loop "back off" as you throw straight into a loop which never breaks. Also if your threading this function "at all" obviously they are not going to set the variable to false lol

// Added some isDefined checks to some of the values being passed, odds are these should never really be undefined, but you never know, and these are things that may potentially only error in Developer mode - which may seem irrelevant, but means when you really "do" need Developer mode to track down a problem, this error will block it first

// Advised to thread "after" zm_usermap::main(); - This is safer for things that rely on stock code / functions / variables as it is all set up inside that function

// Added a check to the second conditional loop to break when zombie count falls below the minimum - this will cause the first loop to repeat, up to the waittill on round over before running the second loop again

// HarryBo21

//Changed level waittill( "between_round_over" ); for level waittill( "start_of_round" );

//Added  level flag::exists( "dog_round" ) && level flag::get("dog_round" ) so that it is not used in this round

//Added level.dognon_stop to start / stop the spawn of dogs

//Now the zombie counter still has also the zombies that are alive and in turn can wake up zombie_ai_limit preventing the spawn of dogs.

//Kabe




MyNameIsNobody
This seems to make my game crash in the middle of the round right before when the dogs should be spawning. Have you or anyone else tested this? Curious for anyones input. I will try it again on a blank test map and let everyone know. EDIT: REMOVED FROM MAP, MAP STILL CRASHED. So issue might no have been kabe's code he put on here, instead I must have another issue...

I always check it before I share it ;)
Did you check it on a clean map? remember to put the dog spawn points and the dog actor


ModmeBot:

Reply By: Harry Bo21

if ( !isDefined( level.round_number ) || level.round_number < n_start_spawning_from_round || level flag::exists( "dog_round" ) && level flag::get("dog_round" ) || !isDefined( level.zombie_total ))

this is not the correct way to do this. You have to structure it differently because you are using "or" and "and" ( || && )


if ( !isDefined( level.round_number ) || level.round_number < n_start_spawning_from_round || ( level flag::exists( "dog_round" ) && level flag::get("dog_round" ) ) || !isDefined( level.zombie_total ) )

need to force these two checks in to a single condition ->

( level flag::exists( "dog_round" ) && level flag::get("dog_round" ) )

otherwise you can potentially get either false positives or false negatives

<hr>
n_count_total_zombie = level.zombie_total;

this is also a bad idea, your storing the value, not the reference "to" the value. if zombie total was say 10, even if zombies die, n_count_total_zombie will still be 10

just use level.zombie_total

while ( isDefined( level.zombie_total ) &amp;&amp; level.zombie_total &gt;= n_minimum_zombie_total_for_spawn )

<hr>


isDefined( level.dognon_stop ) &amp;&amp; level.dognon_stop


you can simplify this

IS_TRUE( level.dognon_stop )


if you wanted to check if its instead "false - or - undefined" then :

!IS_TRUE( level.dognon_stop )


ModmeBot:

Reply By: Kabe
Thanks for helping me and teaching me :)

I use it to get level.zombie_total and add it later with n_count_zombies_spawn preventing having up to some enemies and not spawn dogs, sorry for not commenting before

n_count_total_zombie = level.zombie_total; // level.zombie_total by default, this number is updated while (n_count_total_zombie &gt;= n_minimum_zombie_total_for_spawn) using "n_count_total_zombie = n_count_zombies_spawn + level.zombie_total;"

Update 2
// Add to top of the script

#using scripts\shared\flag_shared; //add this if it is not already
#using scripts\shared\ai\zombie_utility; //add this if it is not already
#using scripts\zm\_zm_ai_dogs;

// Add directly after zm_usermap::main();

level.dognon_stop = true;
level thread dog_non_stop();

// Paste function way down the bottom, not inside any other functions :

function dog_non_stop()
{
	level endon( "intermission" );
	
	n_start_spawning_from_round 			= 30; 		// Round number
	n_minimum_zombie_total_for_spawn 		= 3;		// Minimum zombies remaining either "now" or "left to spawn" - if less the do spawning will pause till the next round
	n_minimum_delay_between_spawns 			= 2;		// Minimum wait in seconds between spawning dogs
	n_maximum_delay_between_spawns 			= 3;		// Maximum wait in seconds between spawning dogs
	
	while ( 1 )
	{
		level waittill( "start_of_round" ); // Wait till the start round
		
		if ( !isDefined( level.round_number ) || level.round_number &lt; n_start_spawning_from_round || ( level flag::exists( "dog_round" ) &amp;&amp; level flag::get( "dog_round" ) ) || !isDefined( level.zombie_total )) // If round number is less that decided above, loop back to start
			continue;
		
		n_count_total_zombie = level.zombie_total;  // level.zombie_total by default, this number is updated while (n_count_total_zombie &gt;= n_minimum_zombie_total_for_spawn) using "n_count_total_zombie = n_count_zombies_spawn + level.zombie_total;"
		while ( n_count_total_zombie &gt;= n_minimum_zombie_total_for_spawn ) // Loop this block of code "only" while there is a high enough zombie total either spawned or spawning
		{
			wait randomIntRange( n_minimum_delay_between_spawns, n_maximum_delay_between_spawns ); // Use the random delay
			n_count_zombies_spawn = zombie_utility::get_current_zombie_count(); //Get enemies spawned
			n_count_total_zombie = n_count_zombies_spawn + level.zombie_total; //Update n_count_total_zombie = enemies spawned + zombies spawning
			
			if( n_count_zombies_spawn &lt; level.zombie_ai_limit &amp;&amp; IS_TRUE( level.dognon_stop ) ){ zm_ai_dogs::special_dog_spawn(1); } // Force spawn a dog if it does not reach the zombie_ai_limit and level.dognon_stop = true
		}
	}
}

// DEV NOTES : 

// Changed values to be easily changed and understandable to nooblets, better if you ever need to debug anyway

// Removed the level variable and the check, no need for it as this function doesn&#39;t support toggling the loop "back off" as you throw straight into a loop which never breaks. Also if your threading this function "at all" obviously they are not going to set the variable to false lol

// Added some isDefined checks to some of the values being passed, odds are these should never really be undefined, but you never know, and these are things that may potentially only error in Developer mode - which may seem irrelevant, but means when you really "do" need Developer mode to track down a problem, this error will block it first

// Advised to thread "after" zm_usermap::main(); - This is safer for things that rely on stock code / functions / variables as it is all set up inside that function

// Added a check to the second conditional loop to break when zombie count falls below the minimum - this will cause the first loop to repeat, up to the waittill on round over before running the second loop again

// HarryBo21

//Changed level waittill( "between_round_over" ); for level waittill( "start_of_round" );

//Added  ( level flag::exists( "dog_round" ) &amp;&amp; level flag::get("dog_round" ) ) so that it is not used in this round

//Added level.dognon_stop to start / stop the spawn of dogs

//Now the zombie counter still has also the zombies that are alive + level.zombie_total Preventing having up to some enemies and not spawn dogs

//Added n_count_zombies_spawn  &lt; zombie_ai_limit preventing the spawn of dogs.

//Simplified IS_TRUE( level.dognon_stop )

//Kabe


I tried it and it worked perfectly
I think it's finished, what do you think?
I would like you to try it.
Thanks again :)


ModmeBot:

Reply By: MyNameIsNobody
Thanks Kabe & Harry both. I have been extremely ill and unable to test this until now. Thanks! P.s. the issue I had with the game crashing was unrelated and I fixed it.