Author Topic: [SOLVED] Make zombies respawn when player walks to far away?  (Read 3558 times)

0 Members and 1 Guest are viewing this topic.

Offline NaviLlicious

  • - Original Poster (OP) -
  • Rotting Walker
  • Posts: 84
  • Country: us
  • Respect: 11
    • NaviLlusShore's YouTube Channel
    • View Profile
  • WaW: TheHubby

Re: Make zombies respawn when player walks to far away?

« Reply #15 on: May 27, 2014, 02:12:31 pm »
search self thread zombie_damage_failsafe(); in zombiemodespawner and add
Code: [Select]
self thread check_distance();

then add this to the bottom of the file
Code: [Select]
check_distance()
{
while(1)
{
all_players = GetPlayers();
for(i = 0; i < all_players.size; i++)
{
zombie_distance = Distance(all_players[i].origin, self.origin);
if( zombie_distance >= level.max_dist_for_respawn)
{
self.too_far_away = true;
}
else
{
self.too_far_away = false;
break;
}
}

if(self.too_far_away == true)
{
self dodamage((self.health * 100), self.origin);
//level.zombie_total++; //May not work when the round_spawning function in zombiemode.gsc has finished it's while flow
//Could try making a seperate spawn script to spawn a zombie before killing this one which would keep the wave alive.
}

wait 1;
}
}
and add this
Code: [Select]
	level.max_dist_for_respawn = 2000;

under this
Code: [Select]
init()
{
just need to spawn the other zombie closer to the player good luck dual :P
This does kill the zombies when you get far enough away but doesn't spawn the zombies In the current zone the player Is In

Offline jjbradman

  • drago
  • The Decider
  • Posts: 949
  • Country: mx
  • Respect: 142
    • jjbradman
    • View Profile
  • Skype: jjbradman
  • WaW: jjbradman

Re: Make zombies respawn when player walks to far away?

« Reply #16 on: May 27, 2014, 02:18:33 pm »
ye i mentioned that that still needs to be done :P i might have time to add it in a few hours

Offline NaviLlicious

  • - Original Poster (OP) -
  • Rotting Walker
  • Posts: 84
  • Country: us
  • Respect: 11
    • NaviLlusShore's YouTube Channel
    • View Profile
  • WaW: TheHubby

Re: Make zombies respawn when player walks to far away?

« Reply #17 on: May 27, 2014, 02:19:18 pm »
ye i mentioned that that still needs to be done :P i might have time to add it in a few hours
Oh xD sorry didn't see that alright man like I said I appreciate It and no rush

Offline jjbradman

  • drago
  • The Decider
  • Posts: 949
  • Country: mx
  • Respect: 142
    • jjbradman
    • View Profile
  • Skype: jjbradman
  • WaW: jjbradman

Re: Make zombies respawn when player walks to far away?

« Reply #18 on: May 27, 2014, 06:42:01 pm »
ok i modified my topic whi the code. it just needs to get your spawner to trigger the closer one to the player

Offline NaviLlicious

  • - Original Poster (OP) -
  • Rotting Walker
  • Posts: 84
  • Country: us
  • Respect: 11
    • NaviLlusShore's YouTube Channel
    • View Profile
  • WaW: TheHubby

Re: Make zombies respawn when player walks to far away?

« Reply #19 on: May 27, 2014, 06:58:40 pm »
ok i modified my topic whi the code. it just needs to get your spawner to trigger the closer one to the player
The zombies die and the round doesn't end but the zombies also don't respawn even when standing In a zone how would I make the spawners trigger when a player gets close to them?

Offline jjbradman

  • drago
  • The Decider
  • Posts: 949
  • Country: mx
  • Respect: 142
    • jjbradman
    • View Profile
  • Skype: jjbradman
  • WaW: jjbradman

Re: Make zombies respawn when player walks to far away?

« Reply #20 on: May 27, 2014, 08:27:03 pm »
if you look in the script theres a part in which i mentioned you somehow have to acquiare the spawners and then check distance :l emm can you show me your spawners kvps?

Post Merge: May 27, 2014, 08:44:25 pm
lol i should make a tut on how to do this after it gets finished xD
« Last Edit: May 27, 2014, 08:44:25 pm by jjbradman »

Offline NaviLlicious

  • - Original Poster (OP) -
  • Rotting Walker
  • Posts: 84
  • Country: us
  • Respect: 11
    • NaviLlusShore's YouTube Channel
    • View Profile
  • WaW: TheHubby

Re: Make zombies respawn when player walks to far away?

« Reply #21 on: May 28, 2014, 12:46:03 am »
The KVP's are the normal zombie KVP's here are the targetnames for them "targetname" "initial_zone_spawner" "targetname" "zone1_spawner" "targetname" "zone2_spawner" the number goes up from there

Offline DuaLVII

  • *
  • Perk Hacker
  • Posts: 325
  • Country: gb
  • Respect: 86
  • I own the hat!
    • DuaLVII
    • dualvii's Xfire Profile
    • TheProlonger's YouTube Channel
    • View Profile
  • Skype: thomas.gascoigne.7
  • WaW: DuaLVII

Re: Make zombies respawn when player walks to far away?

« Reply #22 on: May 28, 2014, 12:57:01 am »
Here's my progress on my version of the respawn which I've coded into the round_spawning under zombiemode think with additional functions to making this work.

For testing I set the distance to 1000 and so far there seems to be no glitches in the process however I did this without playable_area also so I need to also make sure zombie deaths by distance don't spawn powerups.

[You are not allowed to view external links. Register or Login to see them]



Edit: This will run with zones so they will respawn to a zone a player is in, I'm just using one zone on this at the moment.
« Last Edit: May 28, 2014, 01:16:04 am by DuaLVII »

Offline NaviLlicious

  • - Original Poster (OP) -
  • Rotting Walker
  • Posts: 84
  • Country: us
  • Respect: 11
    • NaviLlusShore's YouTube Channel
    • View Profile
  • WaW: TheHubby

Re: Make zombies respawn when player walks to far away?

« Reply #23 on: May 28, 2014, 01:54:52 am »
Here's my progress on my version of the respawn which I've coded into the round_spawning under zombiemode think with additional functions to making this work.

For testing I set the distance to 1000 and so far there seems to be no glitches in the process however I did this without playable_area also so I need to also make sure zombie deaths by distance don't spawn powerups.

[You are not allowed to view external links. Register or Login to see them]



Edit: This will run with zones so they will respawn to a zone a player is in, I'm just using one zone on this at the moment.
Some zombies that respawned weren't following the player Is that because there were no nodes? Looks good

Offline DuaLVII

  • *
  • Perk Hacker
  • Posts: 325
  • Country: gb
  • Respect: 86
  • I own the hat!
    • DuaLVII
    • dualvii's Xfire Profile
    • TheProlonger's YouTube Channel
    • View Profile
  • Skype: thomas.gascoigne.7
  • WaW: DuaLVII

Re: Make zombies respawn when player walks to far away?

« Reply #24 on: May 28, 2014, 02:29:50 am »
Some zombies that respawned weren't following the player Is that because there were no nodes? Looks good

Not that there were no nodes there was just no exterior goal for them to go to, but it works.

Offline NaviLlicious

  • - Original Poster (OP) -
  • Rotting Walker
  • Posts: 84
  • Country: us
  • Respect: 11
    • NaviLlusShore's YouTube Channel
    • View Profile
  • WaW: TheHubby

Re: Make zombies respawn when player walks to far away?

« Reply #25 on: May 28, 2014, 05:43:50 am »
Not that there were no nodes there was just no exterior goal for them to go to, but it works.
Gotcha

Offline DuaLVII

  • *
  • Perk Hacker
  • Posts: 325
  • Country: gb
  • Respect: 86
  • I own the hat!
    • DuaLVII
    • dualvii's Xfire Profile
    • TheProlonger's YouTube Channel
    • View Profile
  • Skype: thomas.gascoigne.7
  • WaW: DuaLVII

Re: Make zombies respawn when player walks to far away?

« Reply #26 on: May 29, 2014, 12:38:04 am »
Update, All issues I was having before are fixed and powerups don't spawn on zombie deaths from distance.
Just going to do a hard test on it before sending it out.

[You are not allowed to view external links. Register or Login to see them]

Offline NaviLlicious

  • - Original Poster (OP) -
  • Rotting Walker
  • Posts: 84
  • Country: us
  • Respect: 11
    • NaviLlusShore's YouTube Channel
    • View Profile
  • WaW: TheHubby

Re: Make zombies respawn when player walks to far away?

« Reply #27 on: May 29, 2014, 01:19:42 am »
Very nice can't wait I appreciate It dude

Offline DuaLVII

  • *
  • Perk Hacker
  • Posts: 325
  • Country: gb
  • Respect: 86
  • I own the hat!
    • DuaLVII
    • dualvii's Xfire Profile
    • TheProlonger's YouTube Channel
    • View Profile
  • Skype: thomas.gascoigne.7
  • WaW: DuaLVII

Re: Make zombies respawn when player walks to far away?

« Reply #28 on: May 31, 2014, 11:49:50 pm »
I've done a hard test on this script with zombie spawn delays of 0.1 and wait between rounds as 5 seconds and all worked really well.

I've harshly modified the round_spawning feature which delayed me putting this out for a little while because if round_spawning was to bug out in higher waves it could go terribly wrong so it shouldn't do this.

I won't put this up as a tutorial for now until it's properly tested so consider it as a beta.



Open up _zombiemode.gsc and search for `level.overridePlayerDamage = ::player_damage_override;` around line 103.
Below add the following;
Code: [Select]
level.zombies_to_add = 0;

Next find `round_spawning()` around line 1435.
Replace the whole round_spawning() function with this;
Code: [Select]
round_spawning()
{
level endon( "intermission" );
/#
level endon( "kill_round" );
#/

if( level.intermission )
{
return;
}

if( level.enemy_spawns.size < 1 )
{
ASSERTMSG( "No spawners with targetname zombie_spawner in map." );
return;
}

/#
if ( GetDVarInt( "zombie_cheat" ) == 2 || GetDVarInt( "zombie_cheat" ) >= 4 )
{
return;
}
#/

ai_calculate_health();

count = 0;

//CODER MOD: TOMMY K
players = get_players();
for( i = 0; i < players.size; i++ )
{
players[i].zombification_time = 0;
}

max = level.zombie_vars["zombie_max_ai"];

multiplier = level.round_number / 5;
if( multiplier < 1 )
{
multiplier = 1;
}

// After round 10, exponentially have more AI attack the player
if( level.round_number >= 10 )
{
multiplier *= level.round_number * 0.15;
}

player_num = get_players().size;

if( player_num == 1 )
{
max += int( ( 0.5 * level.zombie_vars["zombie_ai_per_player"] ) * multiplier );
}
else
{
max += int( ( ( player_num - 1 ) * level.zombie_vars["zombie_ai_per_player"] ) * multiplier );
}



if(level.round_number < 3 && level.script == "nazi_zombie_asylum")
{
if(get_players().size > 1)
{

max = get_players().size * 3 + level.round_number;

}
else
{

max = 6;

}
}
else if ( level.first_round )
{
max = int( max * 0.2 );
}
else if (level.round_number < 3)
{
max = int( max * 0.4 );
}
else if (level.round_number < 4)
{
max = int( max * 0.6 );
}
else if (level.round_number < 5)
{
max = int( max * 0.8 );
}


level.zombie_total = max;
mixed_spawns = 0; // Number of mixed spawns this round.  Currently means number of dogs in a mixed round

// DEBUG HACK:
//max = 1;
old_spawn = undefined;
while(1) //while( count < max )
{

spawn_point = level.enemy_spawns[RandomInt( level.enemy_spawns.size )];

if( !IsDefined( old_spawn ) )
{
old_spawn = spawn_point;
}
else if( Spawn_point == old_spawn )
{
spawn_point = level.enemy_spawns[RandomInt( level.enemy_spawns.size )];
}
old_spawn = spawn_point;

// iPrintLn(spawn_point.targetname + " " + level.zombie_vars["zombie_spawn_delay"]);
while( get_enemy_count() > 31 )
{
wait( 0.05 );
}

// MM Mix in dog spawns...
if ( IsDefined( level.mixed_rounds_enabled ) && level.mixed_rounds_enabled == 1 )
{
spawn_dog = false;
if ( level.round_number > 30 )
{
if ( RandomInt(100) < 3 )
{
spawn_dog = true;
}
}
else if ( level.round_number > 25 && mixed_spawns < 3 )
{
if ( RandomInt(100) < 2 )
{
spawn_dog = true;
}
}
else if ( level.round_number > 20 && mixed_spawns < 2 )
{
if ( RandomInt(100) < 2 )
{
spawn_dog = true;
}
}
else if ( level.round_number > 15 && mixed_spawns < 1 )
{
if ( RandomInt(100) < 1 )
{
spawn_dog = true;
}
}

if ( spawn_dog )
{
keys = GetArrayKeys( level.zones );
for ( i=0; i<keys.size; i++ )
{
if ( level.zones[ keys[i] ].is_occupied )
{
akeys = GetArrayKeys( level.zones[ keys[i] ].adjacent_zones );
for ( k=0; k<akeys.size; k++ )
{
if ( level.zones[ akeys[k] ].is_active &&
!level.zones[ akeys[k] ].is_occupied &&
level.zones[ akeys[k] ].dog_locations.size > 0 )
{
maps\_zombiemode_dogs::special_dog_spawn( undefined, 1 );
level.zombie_total--;
wait_network_frame();
}
}
}
}
}
}

ai = spawn_zombie( spawn_point );
if( IsDefined( ai ) )
{
level.zombie_total--;
ai thread dist_check();
ai thread round_spawn_failsafe();
count++;
}
if(count >= max)
{
while(get_enemy_count() + level.zombie_total > 0)
{
kill_and_replace(true);
if(level.zombies_to_add > 0)
break;
wait(0.1);
}
//iPrintLn("zombie_total is set to " + level.zombie_total);
level.zombies_to_add = 0; // fail safe
}
max = run_respawn_check(max);
wait( level.zombie_vars["zombie_spawn_delay"] );
wait_network_frame();
if(count >= max)
{
//iPrintLnBold("round_spawning() has ended");
break;
}
//iPrintLn("zombie_total is set to " + level.zombie_total);
}
thread last_zombie_runner();
}



Below the end of the round_spawning function, Add these 4 functions in;

Code: [Select]
run_respawn_check(max)
{
kill_and_replace(true);
if(level.zombies_to_add > 0)
{
//iPrintLn("zombie_to_add is set to " + level.zombies_to_add);
max += level.zombies_to_add;
level.zombie_total += level.zombies_to_add;
level.zombies_to_add = 0;
kill_and_replace(false);
iPrintLn("zombie_total is set to " + level.zombie_total);
}
return max;
}

last_zombie_runner()
{
if( level.round_number > 3 )
{
while( 1 )
{
zombies = getaiarray( "axis" );
if( zombies.size == 1 && zombies[0].has_legs == true )
{
var = randomintrange(1, 4);
zombies[0] set_run_anim( "sprint" + var );                       
zombies[0].run_combatanim = level.scr_anim[zombies[0].animname]["sprint" + var];
}
else if(zombies.size <= 0)
break;
wait(0.5);

//zombies = getaiarray("axis"); DuaLVII : WTF?
}
}
}

dist_check()
{
self endon("death");
max_dist_for_respawn = 1000;
too_far_away = false;
all_players = GetPlayers();
wait(5); // time to spawn and move around a bit before checking
while(1)
{
for(i = 0; i < all_players.size; i++)
{
zombie_distance = Distance(all_players[i].origin, self.origin);
if( zombie_distance >= max_dist_for_respawn)
{
too_far_away = true;
}
else
{
too_far_away = false;
break;
}
}
if(too_far_away == true)
{
//level.zombies_to_add++;
self.kill_and_replace = true;
//self dodamage((self.health * 100), self.origin); //Killing before round_spawning has a chance to pick up on it could result in round end
break;
}
wait(1);
}
}

kill_and_replace(check)
{
zombies = getaiarray( "axis" );
for(i = 0; i < zombies.size; i++)
{
if(isDefined(zombies[i].kill_and_replace) && zombies[i].kill_and_replace == true)
{
if(check == true)
{
level.zombies_to_add++;
}
else
{
zombies[i] dodamage((zombies[i].health * 100), zombies[i].origin);
}
}
}
}

Save the _zombiemode.gsc and then open up your _zombiemode_spawner.gsc
Search for `zombie_can_drop_powerups( zombie )` and replace the function with this;

Code: [Select]
zombie_can_drop_powerups( zombie )
{
if( zombie.damageweapon == "zombie_cymbal_monkey" || isDefined(zombie.kill_and_replace) && zombie.kill_and_replace == true )
{
return false;
}

return true;
}

Offline NaviLlicious

  • - Original Poster (OP) -
  • Rotting Walker
  • Posts: 84
  • Country: us
  • Respect: 11
    • NaviLlusShore's YouTube Channel
    • View Profile
  • WaW: TheHubby

Re: Make zombies respawn when player walks to far away?

« Reply #29 on: June 01, 2014, 05:22:02 am »
Seems to work perfectly thanks a bunch!
« Last Edit: June 01, 2014, 05:27:10 am by NaviLlicious »