Make zombies respawn when player walks to far away?

broken avatar :(
Created 2271 days ago
by NaviLlicious
0 Members and 1 Guest are viewing this topic.
8,555 views
broken avatar :(
×
broken avatar :(
Location: usconverse tx
Date Registered: 20 June 2013
Last active: 139 days ago
Posts
84
Respect
Forum Rank
Rotting Walker
Primary Group
Member
My Contact & Social Links
More
×
NaviLlicious's Groups
NaviLlicious's Contact & Social LinksTheHubbyNaviLlusShore
search self thread zombie_damage_failsafe(); in zombiemodespawner and add
self thread check_distance();

then add this to the bottom of the file
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
	level.max_dist_for_respawn = 2000;

under this
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
broken avatar :(
×
broken avatar :(
drago
Location: mx
Date Registered: 5 July 2013
Last active: 252 days ago
Posts
947
Respect
Forum Rank
The Decider
Primary Group
Member
My Contact & Social Links
More
×
jjbradman's Groups
jjbradman's Contact & Social Linksjjbradmanjjbradmanjjbradman
ye i mentioned that that still needs to be done :P i might have time to add it in a few hours
broken avatar :(
×
broken avatar :(
Location: usconverse tx
Date Registered: 20 June 2013
Last active: 139 days ago
Posts
84
Respect
Forum Rank
Rotting Walker
Primary Group
Member
My Contact & Social Links
More
×
NaviLlicious's Groups
NaviLlicious's Contact & Social LinksTheHubbyNaviLlusShore
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
broken avatar :(
×
broken avatar :(
drago
Location: mx
Date Registered: 5 July 2013
Last active: 252 days ago
Posts
947
Respect
Forum Rank
The Decider
Primary Group
Member
My Contact & Social Links
More
×
jjbradman's Groups
jjbradman's Contact & Social Linksjjbradmanjjbradmanjjbradman
ok i modified my topic whi the code. it just needs to get your spawner to trigger the closer one to the player
broken avatar :(
×
broken avatar :(
Location: usconverse tx
Date Registered: 20 June 2013
Last active: 139 days ago
Posts
84
Respect
Forum Rank
Rotting Walker
Primary Group
Member
My Contact & Social Links
More
×
NaviLlicious's Groups
NaviLlicious's Contact & Social LinksTheHubbyNaviLlusShore
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?
broken avatar :(
×
broken avatar :(
drago
Location: mx
Date Registered: 5 July 2013
Last active: 252 days ago
Posts
947
Respect
Forum Rank
The Decider
Primary Group
Member
My Contact & Social Links
More
×
jjbradman's Groups
jjbradman's Contact & Social Linksjjbradmanjjbradmanjjbradman
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 28, 2014, 05:44:25 am
lol i should make a tut on how to do this after it gets finished xD
Last Edit: May 28, 2014, 05:44:25 am by jjbradman
broken avatar :(
×
broken avatar :(
Location: usconverse tx
Date Registered: 20 June 2013
Last active: 139 days ago
Posts
84
Respect
Forum Rank
Rotting Walker
Primary Group
Member
My Contact & Social Links
More
×
NaviLlicious's Groups
NaviLlicious's Contact & Social LinksTheHubbyNaviLlusShore
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
broken avatar :(
×
broken avatar :(
Location: gbComing up in the world
Date Registered: 26 November 2013
Last active: 1806 days ago
Posts
325
Respect
Forum Rank
Perk Hacker
Primary Group
Community Scripter Elite
My Groups
More
My Contact & Social Links
More
Personal Quote
I own the hat!
×
DuaLVII's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
DuaLVII's Contact & Social Linksthomas.gascoigne.7DuaLVIIDuaLVIITheProlonger
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, 10:16:04 am by DuaLVII
broken avatar :(
×
broken avatar :(
Location: usconverse tx
Date Registered: 20 June 2013
Last active: 139 days ago
Posts
84
Respect
Forum Rank
Rotting Walker
Primary Group
Member
My Contact & Social Links
More
×
NaviLlicious's Groups
NaviLlicious's Contact & Social LinksTheHubbyNaviLlusShore
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
broken avatar :(
×
broken avatar :(
Location: gbComing up in the world
Date Registered: 26 November 2013
Last active: 1806 days ago
Posts
325
Respect
Forum Rank
Perk Hacker
Primary Group
Community Scripter Elite
My Groups
More
My Contact & Social Links
More
Personal Quote
I own the hat!
×
DuaLVII's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
DuaLVII's Contact & Social Linksthomas.gascoigne.7DuaLVIIDuaLVIITheProlonger
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.
broken avatar :(
×
broken avatar :(
Location: usconverse tx
Date Registered: 20 June 2013
Last active: 139 days ago
Posts
84
Respect
Forum Rank
Rotting Walker
Primary Group
Member
My Contact & Social Links
More
×
NaviLlicious's Groups
NaviLlicious's Contact & Social LinksTheHubbyNaviLlusShore
Not that there were no nodes there was just no exterior goal for them to go to, but it works.
Gotcha
broken avatar :(
×
broken avatar :(
Location: gbComing up in the world
Date Registered: 26 November 2013
Last active: 1806 days ago
Posts
325
Respect
Forum Rank
Perk Hacker
Primary Group
Community Scripter Elite
My Groups
More
My Contact & Social Links
More
Personal Quote
I own the hat!
×
DuaLVII's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
DuaLVII's Contact & Social Linksthomas.gascoigne.7DuaLVIIDuaLVIITheProlonger
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]
broken avatar :(
×
broken avatar :(
Location: usconverse tx
Date Registered: 20 June 2013
Last active: 139 days ago
Posts
84
Respect
Forum Rank
Rotting Walker
Primary Group
Member
My Contact & Social Links
More
×
NaviLlicious's Groups
NaviLlicious's Contact & Social LinksTheHubbyNaviLlusShore
Very nice can't wait I appreciate It dude
broken avatar :(
×
broken avatar :(
Location: gbComing up in the world
Date Registered: 26 November 2013
Last active: 1806 days ago
Posts
325
Respect
Forum Rank
Perk Hacker
Primary Group
Community Scripter Elite
My Groups
More
My Contact & Social Links
More
Personal Quote
I own the hat!
×
DuaLVII's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
DuaLVII's Contact & Social Linksthomas.gascoigne.7DuaLVIIDuaLVIITheProlonger
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;
level.zombies_to_add = 0;

Next find `round_spawning()` around line 1435.
Replace the whole round_spawning() function with this;
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;

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;

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;
}
broken avatar :(
×
broken avatar :(
Location: usconverse tx
Date Registered: 20 June 2013
Last active: 139 days ago
Posts
84
Respect
Forum Rank
Rotting Walker
Primary Group
Member
My Contact & Social Links
More
×
NaviLlicious's Groups
NaviLlicious's Contact & Social LinksTheHubbyNaviLlusShore
Seems to work perfectly thanks a bunch!
Last Edit: June 01, 2014, 02:27:10 pm by NaviLlicious

 

Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch
Loading ...