Cap the Number of Zombies in the Round to 1 Player
-
Hello,
This is a simple script using replace function to cap the zombies numbers in a round to 1 player.
Now instead of 389 zombies for 4 players on round 26, it's now 84You can also make it a X number of zombies for X number of players, all from the simple function, 8 players in game but only spawns zombies up to 6 players.
Or change how much zombies get added per player for better
calculating, example on round 40 for normal calculations:
1 Player: 168 Zombies
2 Players: 312 Zombies, 1.85 Worth of zombies
3 Players: 600 Zombies, 3.57 Worth of zombies
4 Players: 888 Zombies, 5.28 Worth of zombiesIt's also possible to change the formula, you can have any number of zombies you want.
the change is simple:
From --->if ( player_num == 1 ) max = max + int( 0.5 * level.zombie_vars["zombie_ai_per_player"] * multiplier ); else max = max + int( ( player_num - 1 ) * level.zombie_vars["zombie_ai_per_player"] * multiplier );
To --->
if ( player_num == 1 ) max = max + int( 0.5 * level.zombie_vars["zombie_ai_per_player"] * multiplier ); else max = max + int( 0.5 * level.zombie_vars["zombie_ai_per_player"] * multiplier );
Here is the script:
#include common_scripts\utility; #include maps\mp\_utility; #include maps\mp\zombies\_zm_utility; #include maps\mp\zombies\_zm_ffotd; #include maps\mp\zombies\_zm; #include maps\mp\_visionset_mgr; #include maps\mp\zombies\_zm_devgui; #include maps\mp\zombies\_zm_zonemgr; #include maps\mp\zombies\_zm_unitrigger; #include maps\mp\zombies\_zm_audio; #include maps\mp\zombies\_zm_blockers; #include maps\mp\zombies\_zm_bot; #include maps\mp\zombies\_zm_clone; #include maps\mp\zombies\_zm_buildables; #include maps\mp\zombies\_zm_equipment; #include maps\mp\zombies\_zm_laststand; #include maps\mp\zombies\_zm_magicbox; #include maps\mp\zombies\_zm_perks; #include maps\mp\zombies\_zm_playerhealth; #include maps\mp\zombies\_zm_power; #include maps\mp\zombies\_zm_powerups; #include maps\mp\zombies\_zm_score; #include maps\mp\zombies\_zm_spawner; #include maps\mp\zombies\_zm_gump; #include maps\mp\zombies\_zm_timer; #include maps\mp\zombies\_zm_traps; #include maps\mp\zombies\_zm_weapons; #include maps\mp\zombies\_zm_tombstone; #include maps\mp\zombies\_zm_stats; #include maps\mp\zombies\_zm_pers_upgrades; #include maps\mp\gametypes_zm\_zm_gametype; #include maps\mp\zombies\_zm_pers_upgrades_functions; #include maps\mp\_demo; #include maps\mp\gametypes_zm\_hud_util; #include maps\mp\zombies\_zm_melee_weapon; #include maps\mp\zombies\_zm_ai_dogs; #include maps\mp\zombies\_zm_pers_upgrades_system; #include maps\mp\gametypes_zm\_weapons; #include maps\mp\zombies\_zm_ai_basic; #include maps\mp\zombies\_zm_game_module; main() { replaceFunc(maps\mp\zombies\_zm::round_spawning, ::round_spawning); } round_spawning() { level endon( "intermission" ); level endon( "end_of_round" ); level endon( "restart_round" ); /# level endon( "kill_round" ); #/ if ( level.intermission ) return; /# if ( getdvarint( #"zombie_cheat" ) == 2 || getdvarint( #"zombie_cheat" ) >= 4 ) return; #/ if ( level.zombie_spawn_locations.size < 1 ) { /# assertmsg( "No active spawners in the map. Check to see if the zone is active and if it's pointing to spawners." ); #/ return; } ai_calculate_health( level.round_number ); count = 0; 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; if ( level.round_number >= 10 ) multiplier = multiplier * ( level.round_number * 0.15 ); player_num = get_players().size; if ( player_num == 1 ) max = max + int( 0.5 * level.zombie_vars["zombie_ai_per_player"] * multiplier ); else { //max = max + int( ( player_num - 1 ) * level.zombie_vars["zombie_ai_per_player"] * multiplier ); max = max + int( 0.5 * level.zombie_vars["zombie_ai_per_player"] * multiplier ); iPrintLn("^8Zombies count set to 1 Player :D"); } if ( !isdefined( level.max_zombie_func ) ) level.max_zombie_func = ::default_max_zombie_func; if ( !( isdefined( level.kill_counter_hud ) && level.zombie_total > 0 ) ) { level.zombie_total = [[ level.max_zombie_func ]]( max ); level notify( "zombie_total_set" ); } if ( isdefined( level.zombie_total_set_func ) ) level thread [[ level.zombie_total_set_func ]](); if ( level.round_number < 10 || level.speed_change_max > 0 ) level thread zombie_speed_up(); mixed_spawns = 0; old_spawn = undefined; while ( true ) { while ( get_current_zombie_count() >= level.zombie_ai_limit || level.zombie_total <= 0 ) wait 0.1; while ( get_current_actor_count() >= level.zombie_actor_limit ) { clear_all_corpses(); wait 0.1; } flag_wait( "spawn_zombies" ); while ( level.zombie_spawn_locations.size <= 0 ) wait 0.1; run_custom_ai_spawn_checks(); spawn_point = level.zombie_spawn_locations[randomint( level.zombie_spawn_locations.size )]; if ( !isdefined( old_spawn ) ) old_spawn = spawn_point; else if ( spawn_point == old_spawn ) spawn_point = level.zombie_spawn_locations[randomint( level.zombie_spawn_locations.size )]; old_spawn = spawn_point; if ( isdefined( level.mixed_rounds_enabled ) && level.mixed_rounds_enabled == 1 ) { spawn_dog = 0; if ( level.round_number > 30 ) { if ( randomint( 100 ) < 3 ) spawn_dog = 1; } else if ( level.round_number > 25 && mixed_spawns < 3 ) { if ( randomint( 100 ) < 2 ) spawn_dog = 1; } else if ( level.round_number > 20 && mixed_spawns < 2 ) { if ( randomint( 100 ) < 2 ) spawn_dog = 1; } else if ( level.round_number > 15 && mixed_spawns < 1 ) { if ( randomint( 100 ) < 1 ) spawn_dog = 1; } 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\mp\zombies\_zm_ai_dogs::special_dog_spawn( undefined, 1 ); level.zombie_total--; wait_network_frame(); } } } } } } if ( isdefined( level.zombie_spawners ) ) { if ( isdefined( level.use_multiple_spawns ) && level.use_multiple_spawns ) { if ( isdefined( spawn_point.script_int ) ) { if ( isdefined( level.zombie_spawn[spawn_point.script_int] ) && level.zombie_spawn[spawn_point.script_int].size ) spawner = random( level.zombie_spawn[spawn_point.script_int] ); else { /# assertmsg( "Wanting to spawn from zombie group " + spawn_point.script_int + "but it doens't exist" ); #/ } } else if ( isdefined( level.zones[spawn_point.zone_name].script_int ) && level.zones[spawn_point.zone_name].script_int ) spawner = random( level.zombie_spawn[level.zones[spawn_point.zone_name].script_int] ); else if ( isdefined( level.spawner_int ) && ( isdefined( level.zombie_spawn[level.spawner_int].size ) && level.zombie_spawn[level.spawner_int].size ) ) spawner = random( level.zombie_spawn[level.spawner_int] ); else spawner = random( level.zombie_spawners ); } else spawner = random( level.zombie_spawners ); ai = spawn_zombie( spawner, spawner.targetname, spawn_point ); } if ( isdefined( ai ) ) { level.zombie_total--; ai thread round_spawn_failsafe(); count++; } wait( level.zombie_vars["zombie_spawn_delay"] ); wait_network_frame(); } }
-
How do I add this to my game?
-
Kyber66 save the content of the last code block as a .gsc file using notepad then read our doc to place the file in the right directory
-
Ivobardolf why don't you remove the now useless if?
You had if x then a else b
Now you got if x then a else a
You can rewrite to to just a. -
Resxt Thanks for the help
-
On the final line of the script you need to remove ''' else it crashes to menu every time
-
Xerxes which one
-
Kyber66 Fixed