From 410ffad06505523ac10a297ada822c200ba80066 Mon Sep 17 00:00:00 2001 From: JezuzLizard Date: Tue, 27 Feb 2024 01:49:13 -0800 Subject: [PATCH] Fix round manager. Add rush variants for dogs and mechz. --- zm_ai_pack/maps/mp/zombies/_zm_ai_mechz.gsc | 136 +--------- .../scripts/zm/zm_ai_pack/_round_manager.gsc | 108 ++++++-- .../scripts/zm/zm_ai_pack/rounds/_mechz.gsc | 238 ++++++++++++++++++ .../scripts/zm/zm_ai_pack/rounds/_normal.gsc | 210 ++++++++-------- .../zm/zm_ai_pack/rounds/_zombie_dog.gsc | 233 +++++++++++++---- zm_ai_pack/scripts/zm/zm_ai_pack_mod_main.gsc | 3 +- zm_ai_pack/zone_source/mod.zone | 11 + 7 files changed, 625 insertions(+), 314 deletions(-) diff --git a/zm_ai_pack/maps/mp/zombies/_zm_ai_mechz.gsc b/zm_ai_pack/maps/mp/zombies/_zm_ai_mechz.gsc index 4337a0d..467e259 100644 --- a/zm_ai_pack/maps/mp/zombies/_zm_ai_mechz.gsc +++ b/zm_ai_pack/maps/mp/zombies/_zm_ai_mechz.gsc @@ -171,11 +171,6 @@ init() level thread init_flamethrower_triggers(); - if ( isdefined( level.mechz_spawning_logic_override_func ) ) - level thread [[ level.mechz_spawning_logic_override_func ]](); - else - level thread mechz_spawning_logic(); - if ( level.script != "zm_tomb" ) { scriptmodelsuseanimtree( #animtree ); @@ -389,133 +384,6 @@ play_ambient_mechz_vocals() } } -enable_mechz_rounds() -{ -/# - if ( getdvarint( #"_id_FA81816F" ) >= 2 ) - return; -#/ - level.mechz_rounds_enabled = 1; - flag_init( "mechz_round" ); - level thread mechz_round_tracker(); -} - -mechz_round_tracker() -{ - maps\mp\zombies\_zm_ai_mechz_ffotd::mechz_round_tracker_start(); - level.num_mechz_spawned = 0; - old_spawn_func = level.round_spawn_func; - old_wait_func = level.round_wait_func; - - while ( !isdefined( level.zombie_mechz_locations ) ) - wait 0.05; - - if ( getDvar( "mapname" ) == "zm_tomb" ) - { - flag_wait( "activate_zone_nml" ); - } - - mech_start_round_num = 8; - - if ( isdefined( level.is_forever_solo_game ) && level.is_forever_solo_game ) - mech_start_round_num = 8; - - while ( level.round_number < mech_start_round_num ) - level waittill( "between_round_over" ); - - level.next_mechz_round = level.round_number; - level thread debug_print_mechz_round(); - - while ( true ) - { - maps\mp\zombies\_zm_ai_mechz_ffotd::mechz_round_tracker_loop_start(); - - if ( level.num_mechz_spawned > 0 ) - level.mechz_should_drop_powerup = 1; - - if ( level.next_mechz_round <= level.round_number ) - { - a_zombies = getaispeciesarray( level.zombie_team, "all" ); - - foreach ( zombie in a_zombies ) - { - if ( isdefined( zombie.is_mechz ) && zombie.is_mechz && isalive( zombie ) ) - { - level.next_mechz_round++; - break; - } - } - } - - if ( level.mechz_left_to_spawn == 0 && level.next_mechz_round <= level.round_number ) - { - mechz_health_increases(); - - if ( isdefined( level.is_forever_solo_game ) && level.is_forever_solo_game ) - level.mechz_zombie_per_round = 1; - else if ( level.mechz_round_count < 2 ) - level.mechz_zombie_per_round = 1; - else if ( level.mechz_round_count < 5 ) - level.mechz_zombie_per_round = 2; - else - level.mechz_zombie_per_round = 3; - - level.mechz_left_to_spawn = level.mechz_zombie_per_round; - mechz_spawning = level.mechz_left_to_spawn; - wait( randomfloatrange( 10.0, 15.0 ) ); - level notify( "spawn_mechz" ); - - if ( isdefined( level.is_forever_solo_game ) && level.is_forever_solo_game ) - n_round_gap = randomintrange( level.mechz_min_round_fq_solo, level.mechz_max_round_fq_solo ); - else - n_round_gap = randomintrange( level.mechz_min_round_fq, level.mechz_max_round_fq ); - - level.next_mechz_round = level.round_number + n_round_gap; - level.mechz_round_count++; - level thread debug_print_mechz_round(); - level.num_mechz_spawned = level.num_mechz_spawned + mechz_spawning; - } - - maps\mp\zombies\_zm_ai_mechz_ffotd::mechz_round_tracker_loop_end(); - level waittill( "between_round_over" ); - mechz_clear_spawns(); - } -} - -debug_print_mechz_round() -{ - flag_wait( "start_zombie_round_logic" ); -/# - iprintln( "Next mechz Round = " + level.next_mechz_round ); -#/ -} - -mechz_spawning_logic() -{ - level thread enable_mechz_rounds(); - - while ( true ) - { - level waittill( "spawn_mechz" ); - - while ( level.mechz_left_to_spawn ) - { - while ( level.zombie_mechz_locations.size < 1 ) - wait( randomfloatrange( 5.0, 10.0 ) ); - - ai = spawn_zombie( level.mechz_spawners[0] ); - ai thread mechz_spawn(); - level.mechz_left_to_spawn--; - - if ( level.mechz_left_to_spawn == 0 ) - level thread response_to_air_raid_siren_vo(); - - ai thread mechz_hint_vo(); - wait( randomfloatrange( 3.0, 6.0 ) ); - } - } -} - mechz_prespawn() { @@ -736,10 +604,10 @@ get_best_mechz_spawn_pos( ignore_used_positions ) for ( i = 0; i < level.zombie_mechz_locations.size; i++ ) { - if ( level.script == "zm_tomb" && !ignore_used_positions && ( isdefined( level.zombie_mechz_locations[i].has_been_used ) && level.zombie_mechz_locations[i].has_been_used ) ) + if ( !ignore_used_positions && ( isdefined( level.zombie_mechz_locations[i].has_been_used ) && level.zombie_mechz_locations[i].has_been_used ) ) continue; - if ( level.script == "zm_tomb" && ignore_used_positions == 1 && ( isdefined( level.zombie_mechz_locations[i].used_cooldown ) && level.zombie_mechz_locations[i].used_cooldown ) ) + if ( ignore_used_positions == 1 && ( isdefined( level.zombie_mechz_locations[i].used_cooldown ) && level.zombie_mechz_locations[i].used_cooldown ) ) continue; for ( j = 0; j < players.size; j++ ) diff --git a/zm_ai_pack/scripts/zm/zm_ai_pack/_round_manager.gsc b/zm_ai_pack/scripts/zm/zm_ai_pack/_round_manager.gsc index f5f92b4..423cdad 100644 --- a/zm_ai_pack/scripts/zm/zm_ai_pack/_round_manager.gsc +++ b/zm_ai_pack/scripts/zm/zm_ai_pack/_round_manager.gsc @@ -7,11 +7,11 @@ main() { set_dvar_if_unset( "rm_min_rounds_before_special_round", 3 ); - set_dvar_if_unset( "rm_max_rounds_before_special_round", 7 ); + set_dvar_if_unset( "rm_max_rounds_before_special_round", 5 ); set_dvar_if_unset( "rm_special_round_chance", 33 ); set_dvar_if_unset( "rm_allow_same_round_as_last_round", 1 ); - set_dvar_if_unset( "rm_allowed_special_rounds", "normal zombie_dog mechz brutus leaper ghost avogadro mixed" ); + set_dvar_if_unset( "rm_allowed_special_rounds", "normal zombie_dog mechz" ); set_dvar_if_unset( "rm_allowed_special_round_variants", "default" ); set_dvar_if_unset( "rm_forced_special_round", "" ); set_dvar_if_unset( "rm_forced_special_variant", "" ); @@ -31,24 +31,62 @@ main() level.normal_round.current_data.variant = ""; scripts\zm\zm_ai_pack\rounds\_zombie_dog::main(); + scripts\zm\zm_ai_pack\rounds\_mechz::main(); + register_special_round( "zombie_dog", "default", scripts\zm\zm_ai_pack\rounds\_zombie_dog::round_spawning, scripts\zm\zm_ai_pack\rounds\_zombie_dog::round_wait, scripts\zm\zm_ai_pack\rounds\_zombie_dog::round_max, + scripts\zm\zm_ai_pack\rounds\_zombie_dog::round_start, scripts\zm\zm_ai_pack\rounds\_zombie_dog::round_over, scripts\zm\zm_ai_pack\rounds\_zombie_dog::round_chance, scripts\zm\zm_ai_pack\rounds\_zombie_dog::round_next ); + register_special_round( "zombie_dog", "rush", + scripts\zm\zm_ai_pack\rounds\_zombie_dog::round_spawning_rush, + scripts\zm\zm_ai_pack\rounds\_zombie_dog::round_wait, + scripts\zm\zm_ai_pack\rounds\_zombie_dog::round_max_rush, + scripts\zm\zm_ai_pack\rounds\_zombie_dog::round_start, + scripts\zm\zm_ai_pack\rounds\_zombie_dog::round_over, + scripts\zm\zm_ai_pack\rounds\_zombie_dog::round_chance_rush, + scripts\zm\zm_ai_pack\rounds\_zombie_dog::round_next_rush ); + + register_special_round( "mechz", "default", + scripts\zm\zm_ai_pack\rounds\_mechz::round_spawning, + scripts\zm\zm_ai_pack\rounds\_mechz::round_wait, + scripts\zm\zm_ai_pack\rounds\_mechz::round_max, + scripts\zm\zm_ai_pack\rounds\_mechz::round_start, + scripts\zm\zm_ai_pack\rounds\_mechz::round_over, + scripts\zm\zm_ai_pack\rounds\_mechz::round_chance, + scripts\zm\zm_ai_pack\rounds\_mechz::round_next ); + + register_special_round( "mechz", "rush", + scripts\zm\zm_ai_pack\rounds\_mechz::round_spawning_rush, + scripts\zm\zm_ai_pack\rounds\_mechz::round_wait, + scripts\zm\zm_ai_pack\rounds\_mechz::round_max_rush, + scripts\zm\zm_ai_pack\rounds\_mechz::round_start, + scripts\zm\zm_ai_pack\rounds\_mechz::round_over, + scripts\zm\zm_ai_pack\rounds\_mechz::round_chance_rush, + scripts\zm\zm_ai_pack\rounds\_mechz::round_next_rush ); + register_special_round( "normal", "default", - scripts\zm\zm_ai_pack\rounds\_zombie::round_spawning, - scripts\zm\zm_ai_pack\rounds\_zombie::round_wait, - scripts\zm\zm_ai_pack\rounds\_zombie::round_max, - scripts\zm\zm_ai_pack\rounds\_zombie::round_over, - scripts\zm\zm_ai_pack\rounds\_zombie::round_chance, - scripts\zm\zm_ai_pack\rounds\_zombie::round_next ); + scripts\zm\zm_ai_pack\rounds\_normal::round_spawning, + scripts\zm\zm_ai_pack\rounds\_normal::round_wait, + scripts\zm\zm_ai_pack\rounds\_normal::round_max, + scripts\zm\zm_ai_pack\rounds\_normal::round_start, + scripts\zm\zm_ai_pack\rounds\_normal::round_over, + scripts\zm\zm_ai_pack\rounds\_normal::round_chance, + scripts\zm\zm_ai_pack\rounds\_normal::round_next ); + + //Future variants + // random - random ais, true_random - random ais + random behavior and stats + // elemental? + // durable + // waves for mixed round_type + // several default presets to cycle through } -register_special_round( round_type, variant_type, round_spawning_func, round_wait_func, round_max_func, between_round_over_func, round_chance_func, next_instance_func ) +register_special_round( round_type, variant_type, round_spawning_func, round_wait_func, round_max_func, round_start_func, between_round_over_func, round_chance_func, next_instance_func ) { if ( !isDefined( level.round_manager_special_rounds ) ) { @@ -64,6 +102,7 @@ register_special_round( round_type, variant_type, round_spawning_func, round_wai s.spawning_func = round_spawning_func; s.wait_func = round_wait_func; s.max_func = round_max_func; + s.start_func = round_start_func; s.between_round_over_func = between_round_over_func; s.chance_func = round_chance_func; s.next_instance_func = next_instance_func; @@ -125,7 +164,7 @@ should_do_special_round() chance = getDvarInt( "rm_special_round_chance" ); - special_round_diff = level.round_number - level.special_round.last_round; + special_round_diff = level.round_number - level.special_round.last_data.round_number; if ( special_round_diff >= max_round ) { @@ -145,16 +184,6 @@ determine_current_round_type() return_value = sys::spawnstruct(); return_value.round_number = level.round_number; - should_do_special_round = should_do_special_round(); - - if ( !should_do_special_round || !isDefined( level.round_manager_special_rounds ) || level.round_manager_special_rounds.size <= 0 ) - { - return_value.round_type = "normal"; - return_value.variant = "default"; - level.normal_round.current_data = return_value; - return level.normal_round.current_data; - } - level.special_round.last_data = level.special_round.current_data; forced_special_round = getdvar( "rm_forced_special_round" ); @@ -175,6 +204,16 @@ determine_current_round_type() } } + should_do_special_round = should_do_special_round(); + + if ( !should_do_special_round || !isDefined( level.round_manager_special_rounds ) || level.round_manager_special_rounds.size <= 0 ) + { + return_value.round_type = "normal"; + return_value.variant = "default"; + level.normal_round.current_data = return_value; + return level.normal_round.current_data; + } + allowed_round_string = getDvar( "rm_allowed_special_rounds" ); variant_string = getdvar( "rm_allowed_special_round_variants" ); @@ -247,6 +286,26 @@ get_zombie_dog_count() return get_zombie_dog_array().size; } +get_mechz_array() +{ + zombies = getaiarray( level.zombie_team ); + mechz = []; + for ( i = 0; i < zombies.size; i++ ) + { + if ( isdefined( zombies[ i ].animname ) && zombies[ i ].animname == "mechz_zombie" ) + { + mechz[ mechz.size ] = zombies[ i ]; + } + } + + return mechz; +} + +get_mechz_count() +{ + return get_mechz_array().size; +} + round_think_override( restart ) { if ( !isdefined( restart ) ) @@ -285,6 +344,12 @@ round_think_override( restart ) for (;;) { + current_round_data = determine_current_round_type(); + + round_manager_inst = level.round_manager_special_rounds[ current_round_data.round_type ][ current_round_data.variant ]; + + level [[ round_manager_inst.start_func ]](); + maxreward = 50 * level.round_number; if ( maxreward > 500 ) @@ -318,9 +383,6 @@ round_think_override( restart ) while ( level.zombie_spawn_locations.size <= 0 ) wait 0.1; - current_round_data = determine_current_round_type(); - - round_manager_inst = level.round_manager_special_rounds[ current_round_data.round_type ][ current_round_data.variant ]; level.round_manager_special_rounds[ current_round_data.round_type ][ current_round_data.variant ].active = true; level [[ round_manager_inst.max_func ]](); level thread [[ round_manager_inst.spawning_func ]](); diff --git a/zm_ai_pack/scripts/zm/zm_ai_pack/rounds/_mechz.gsc b/zm_ai_pack/scripts/zm/zm_ai_pack/rounds/_mechz.gsc index e69de29..58747db 100644 --- a/zm_ai_pack/scripts/zm/zm_ai_pack/rounds/_mechz.gsc +++ b/zm_ai_pack/scripts/zm/zm_ai_pack/rounds/_mechz.gsc @@ -0,0 +1,238 @@ +#include maps\mp\zombies\_zm_utility; +#include common_scripts\utility; +#include maps\mp\_utility; + +#include maps\mp\zombies\_zm_ai_mechz; + +#include scripts\zm\zm_ai_pack\_round_manager; + +main() +{ + set_dvar_if_unset( "rm_mechz_round_chance", 10 ); + set_dvar_if_unset( "rm_mechz_min_round", 8 ); + set_dvar_if_unset( "rm_mechz_initial_round_wait", 5.0 ); + set_dvar_if_unset( "rm_mechz_max_mechz_alive", 3 ); + + set_dvar_if_unset( "rm_mechz_rush_round_chance", 6 ); + set_dvar_if_unset( "rm_mechz_rush_min_round", 45 ); + set_dvar_if_unset( "rm_mechz_rush_min_spawn_wait", 1.5 ); + set_dvar_if_unset( "rm_mechz_rush_max_spawn_wait", 2.5 ); + set_dvar_if_unset( "rm_mechz_rush_max_mechz_alive", 24 ); + set_dvar_if_unset( "rm_mechz_rush_max_mechz_round", 24 ); +} + +round_spawning_common() +{ + + while ( !isdefined( level.zombie_mechz_locations ) ) + wait 0.05; + + initial_wait = getdvarint( "rm_mechz_initial_round_wait" ); + wait( randomfloatrange( initial_wait, initial_wait + 5.0 ) ); + + level.mechz_should_drop_powerup = true; +} + +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; +#/ + round_spawning_common(); + + for (;;) + { + while ( get_mechz_count() >= level.zombie_ai_limit || get_mechz_count() >= getdvarint( "rm_mechz_max_mechz_alive" ) || 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_mechz_locations.size < 1 ) + wait( randomfloatrange( 5.0, 10.0 ) ); + + ai = spawn_zombie( level.mechz_spawners[0] ); + ai thread maps\mp\zombies\_zm_ai_mechz::mechz_spawn(); + level.mechz_left_to_spawn--; + + if ( level.mechz_left_to_spawn == 0 ) + level thread maps\mp\zombies\_zm_ai_mechz::response_to_air_raid_siren_vo(); + + ai thread maps\mp\zombies\_zm_ai_mechz::mechz_hint_vo(); + wait( randomfloatrange( 3.0, 6.0 ) ); + } +} + +round_wait() +{ + level endon( "restart_round" ); +/# + while ( getdvarint( #"zombie_cheat" ) == 2 || getdvarint( #"zombie_cheat" ) >= 4 ) + wait 1; +#/ + wait 1; + + while ( true ) + { + should_wait = get_mechz_count() > 0 || level.zombie_total > 0 || level.intermission; + + if ( !should_wait ) + return; + + wait 1.0; + } +} + +round_max() +{ + if ( isdefined( level.is_forever_solo_game ) && level.is_forever_solo_game ) + level.mechz_zombie_per_round = 1; + else if ( level.mechz_round_count < 2 ) + level.mechz_zombie_per_round = 1; + else if ( level.mechz_round_count < 5 ) + level.mechz_zombie_per_round = 2; + else + level.mechz_zombie_per_round = 3; + + level.zombie_total = level.mechz_zombie_per_round; + level.mechz_left_to_spawn = level.zombie_total; +} + +round_start() +{ + +} + +round_over() +{ + maps\mp\zombies\_zm_ai_mechz::mechz_health_increases(); + level.mechz_round_count++; + maps\mp\zombies\_zm_ai_mechz::mechz_clear_spawns(); +} + +round_chance() +{ + if ( flag_exists( "activate_zone_nml" ) && !flag( "activate_zone_nml" ) ) + { + return false; + } + + if ( level.round_number < getdvarint( "rm_mechz_min_round" ) ) + { + return false; + } + + return randomint( 100 ) <= getdvarint( "rm_mechz_round_chance" ); +} + +round_next() +{ + min = getDvarInt( "rm_min_rounds_before_special_round" ); + max = getDvarInt( "rm_max_rounds_before_special_round" ); + if ( min >= max ) + { + return level.special_round.last_data.round_number + 1; + } + else + { + return level.special_round.last_data.round_number + randomintrange( min, max ); + } +} + +round_spawning_rush() +{ + 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; +#/ + round_spawning_common(); + + for (;;) + { + while ( get_mechz_count() >= level.zombie_ai_limit || get_mechz_count() >= getdvarint( "rm_mechz_rush_max_mechz_alive" ) || 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_mechz_locations.size < 1 ) + wait( randomfloatrange( 5.0, 10.0 ) ); + + ai = spawn_zombie( level.mechz_spawners[0] ); + ai thread maps\mp\zombies\_zm_ai_mechz::mechz_spawn(); + level.mechz_left_to_spawn--; + level.zombie_total--; + + if ( level.mechz_left_to_spawn == 0 ) + level thread maps\mp\zombies\_zm_ai_mechz::response_to_air_raid_siren_vo(); + + ai thread maps\mp\zombies\_zm_ai_mechz::mechz_hint_vo(); + wait( randomfloatrange( getdvarfloat( "rm_mechz_rush_min_spawn_wait" ), getdvarfloat( "rm_mechz_rush_min_spawn_wait" ) + 0.05 ) ); + } +} + +round_max_rush() +{ + level.zombie_total = getdvarint( "rm_mechz_rush_max_mechz_round" ); + level.mechz_left_to_spawn = level.zombie_total; +} + +round_chance_rush() +{ + if ( flag_exists( "activate_zone_nml" ) && !flag( "activate_zone_nml" ) ) + { + return false; + } + + if ( level.round_number < getdvarint( "rm_mechz_rush_min_round" ) ) + { + return false; + } + + return randomint( 100 ) <= getdvarint( "rm_mechz_rush_round_chance" ); +} + +round_next_rush() +{ + min = getDvarInt( "rm_min_rounds_before_special_round" ); + max = getDvarInt( "rm_max_rounds_before_special_round" ); + if ( min >= max ) + { + return level.special_round.last_data.round_number + 1; + } + else + { + return level.special_round.last_data.round_number + randomintrange( min, max ); + } +} \ No newline at end of file diff --git a/zm_ai_pack/scripts/zm/zm_ai_pack/rounds/_normal.gsc b/zm_ai_pack/scripts/zm/zm_ai_pack/rounds/_normal.gsc index e4815a8..f16d9c1 100644 --- a/zm_ai_pack/scripts/zm/zm_ai_pack/rounds/_normal.gsc +++ b/zm_ai_pack/scripts/zm/zm_ai_pack/rounds/_normal.gsc @@ -4,105 +4,6 @@ #include maps\mp\zombies\_zm; -default_max_zombie_func( max_num ) -{ -/# - count = getdvarint( #"zombie_default_max" ); - - if ( count > -1 ) - return count; -#/ - max = max_num; - - if ( level.round_number < 2 ) - max = int( max_num * 0.25 ); - else if ( level.round_number < 3 ) - max = int( max_num * 0.3 ); - else if ( level.round_number < 4 ) - max = int( max_num * 0.5 ); - else if ( level.round_number < 5 ) - max = int( max_num * 0.7 ); - else if ( level.round_number < 6 ) - max = int( max_num * 0.9 ); - - return max; -} - -round_max() -{ - players = sys::getplayers(); - - 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 ); - - if ( !isdefined( level.max_zombie_func ) ) - level.max_zombie_func = ::default_max_zombie_func; - - 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 ]](); -} - -round_chance() -{ - return false; -} - -round_next() -{ - return level.round_number + 1; -} - -round_wait() -{ - level endon( "restart_round" ); -/# - if ( getdvarint( #"zombie_rise_test" ) ) - level waittill( "forever" ); -#/ -/# - while ( getdvarint( #"zombie_cheat" ) == 2 || getdvarint( #"zombie_cheat" ) >= 4 ) - wait 1; -#/ - wait 1; - - while ( true ) - { - should_wait = 0; - - if ( isdefined( level.is_ghost_round_started ) && [[ level.is_ghost_round_started ]]() ) - should_wait = 1; - else - should_wait = get_current_zombie_count() > 0 || level.zombie_total > 0 || level.intermission; - - if ( !should_wait ) - return; - - if ( flag( "end_round_wait" ) ) - return; - - wait 1.0; - } -} - round_spawning() { level endon( "intermission" ); @@ -129,7 +30,6 @@ round_spawning() } ai_calculate_health( level.round_number ); - count = 0; if ( level.round_number < 10 || level.speed_change_max > 0 ) level thread zombie_speed_up(); @@ -195,10 +95,118 @@ round_spawning() { level.zombie_total--; ai thread round_spawn_failsafe(); - count++; } wait( level.zombie_vars["zombie_spawn_delay"] ); wait_network_frame(); } +} + +round_wait() +{ + level endon( "restart_round" ); +/# + if ( getdvarint( #"zombie_rise_test" ) ) + level waittill( "forever" ); +#/ +/# + while ( getdvarint( #"zombie_cheat" ) == 2 || getdvarint( #"zombie_cheat" ) >= 4 ) + wait 1; +#/ + wait 1; + + while ( true ) + { + should_wait = 0; + + if ( isdefined( level.is_ghost_round_started ) && [[ level.is_ghost_round_started ]]() ) + should_wait = 1; + else + should_wait = get_current_zombie_count() > 0 || level.zombie_total > 0 || level.intermission; + + if ( !should_wait ) + return; + + if ( flag( "end_round_wait" ) ) + return; + + wait 1.0; + } +} + +round_max() +{ + players = sys::getplayers(); + + 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 ); + + if ( !isdefined( level.max_zombie_func ) ) + level.max_zombie_func = ::default_max_zombie_func; + + 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 ]](); +} + +round_start() +{ + +} + +round_over() +{ + +} + +round_chance() +{ + return false; +} + +round_next() +{ + return level.round_number + 1; +} + +default_max_zombie_func( max_num ) +{ +/# + count = getdvarint( #"zombie_default_max" ); + + if ( count > -1 ) + return count; +#/ + max = max_num; + + if ( level.round_number < 2 ) + max = int( max_num * 0.25 ); + else if ( level.round_number < 3 ) + max = int( max_num * 0.3 ); + else if ( level.round_number < 4 ) + max = int( max_num * 0.5 ); + else if ( level.round_number < 5 ) + max = int( max_num * 0.7 ); + else if ( level.round_number < 6 ) + max = int( max_num * 0.9 ); + + return max; } \ No newline at end of file diff --git a/zm_ai_pack/scripts/zm/zm_ai_pack/rounds/_zombie_dog.gsc b/zm_ai_pack/scripts/zm/zm_ai_pack/rounds/_zombie_dog.gsc index 63eb074..86213fb 100644 --- a/zm_ai_pack/scripts/zm/zm_ai_pack/rounds/_zombie_dog.gsc +++ b/zm_ai_pack/scripts/zm/zm_ai_pack/rounds/_zombie_dog.gsc @@ -9,6 +9,16 @@ main() { set_dvar_if_unset( "rm_dog_round_chance", 40 ); + + set_dvar_if_unset( "rm_dog_rush_min_round", 20 ); + set_dvar_if_unset( "rm_dog_rush_round_chance", 10 ); + set_dvar_if_unset( "rm_dog_rush_max_dogs_alive", 24 ); + set_dvar_if_unset( "rm_dog_rush_max_dogs_round", 128 ); + set_dvar_if_unset( "rm_dog_rush_max_dogs_round_per_player", 8 ); + set_dvar_if_unset( "rm_dog_rush_max_dogs_round_base", 24 ); + set_dvar_if_unset( "rm_dog_rush_max_dogs_round_number_multiplier", 0.1 ); + set_dvar_if_unset( "rm_dog_rush_max_spawn_wait", 0.5 ); + set_dvar_if_unset( "rm_dog_rush_min_spawn_wait", 0.1 ); } round_spawning() @@ -30,58 +40,17 @@ round_spawning() if ( level.intermission ) return; - level.music_round_override = 1; - maps\mp\zombies\_zm_ai_dogs::dog_round_start(); - - level.dog_intermission = 1; - level thread maps\mp\zombies\_zm_ai_dogs::dog_round_aftermath(); - players = sys::getplayers(); - array_thread( players, maps\mp\zombies\_zm_ai_dogs::play_dog_round ); - wait 1; - playsoundatposition( game["zmbdialog"]["prefix"] + "_event_dogstart_0", ( 0, 0, 0 ) ); - wait 6; - - dog_health_increase(); count = 0; + max = level.zombie_total; while ( true ) { - while ( get_current_zombie_count() >= level.zombie_ai_limit || level.zombie_total <= 0 ) + while ( get_zombie_dog_count() >= level.zombie_ai_limit || level.zombie_total <= 0 ) wait 0.1; for ( num_player_valid = get_number_of_valid_players(); get_zombie_dog_count() >= num_player_valid * 2; num_player_valid = get_number_of_valid_players() ) wait 2; - - players = sys::getplayers(); - favorite_enemy = maps\mp\zombies\_zm_ai_dogs::get_favorite_enemy(); - - if ( isdefined( level.dog_spawn_func ) ) - { - spawn_loc = [[ level.dog_spawn_func ]]( level.dog_spawners, favorite_enemy ); - ai = spawn_zombie( level.dog_spawners[0] ); - - if ( isdefined( ai ) ) - { - ai.favoriteenemy = favorite_enemy; - spawn_loc thread maps\mp\zombies\_zm_ai_dogs::dog_spawn_fx( ai, spawn_loc ); - level.zombie_total--; - count++; - } - } - else - { - spawn_point = dog_spawn_factory_logic( level.enemy_dog_spawns, favorite_enemy ); - ai = spawn_zombie( level.dog_spawners[0] ); - - if ( isdefined( ai ) ) - { - ai.favoriteenemy = favorite_enemy; - spawn_point thread maps\mp\zombies\_zm_ai_dogs::dog_spawn_fx( ai, spawn_point ); - level.zombie_total--; - count++; - flag_set( "dog_clips" ); - } - } - + + count = spawn_zombie_dog( count ); waiting_for_next_dog_spawn( count, max ); } } @@ -95,7 +64,9 @@ round_wait() wait 0.5; } - increment_dog_round_stat( "finished" ); + maps\mp\zombies\_zm::increment_dog_round_stat( "finished" ); + + wait 8; } round_max() @@ -113,6 +84,35 @@ round_max() level.zombie_total = max; } +round_start() +{ + level.music_round_override = 1; + maps\mp\zombies\_zm_ai_dogs::dog_round_start(); + + level.dog_intermission = 1; + level thread maps\mp\zombies\_zm_ai_dogs::dog_round_aftermath(); + players = sys::getplayers(); + array_thread( players, maps\mp\zombies\_zm_ai_dogs::play_dog_round ); + wait 1; + playsoundatposition( game["zmbdialog"]["prefix"] + "_event_dogstart_0", ( 0, 0, 0 ) ); + wait 6; +} + +round_over() +{ + if ( !isDefined( level.dog_round_count ) ) + { + level.dog_round_count = 1; + } + + maps\mp\zombies\_zm_ai_dogs::dog_health_increase(); + + maps\mp\zombies\_zm_ai_dogs::dog_round_stop(); + level.music_round_override = 0; + level.dog_round_count = level.dog_round_count + 1; + flag_clear( "dog_round" ); +} + round_chance() { @@ -123,7 +123,92 @@ round_chance() round_next() { - return level.special_round.last_data.round_number + randomintrange( getDvarInt( "rm_min_rounds_before_special_round" ), getDvarInt( "rm_max_rounds_before_special_round" ) ); + min = getDvarInt( "rm_min_rounds_before_special_round" ); + max = getDvarInt( "rm_max_rounds_before_special_round" ); + if ( min >= max ) + { + return level.special_round.last_data.round_number + 1; + } + else + { + return level.special_round.last_data.round_number + randomintrange( min, max ); + } +} + +round_spawning_rush() +{ + level endon( "end_of_round" ); + level endon( "intermission" ); + level.dog_targets = sys::getplayers(); + + for ( i = 0; i < level.dog_targets.size; i++ ) + level.dog_targets[i].hunted_by = 0; + +/# + level endon( "kill_round" ); + + if ( getdvarint( #"zombie_cheat" ) == 2 || getdvarint( #"zombie_cheat" ) >= 4 ) + return; +#/ + + if ( level.intermission ) + return; + + count = 0; + max = level.zombie_total; + while ( true ) + { + while ( get_zombie_dog_count() >= level.zombie_ai_limit || get_zombie_dog_count() >= getdvarint( "rm_dog_rush_max_dogs_alive" ) || level.zombie_total <= 0 ) + wait 0.1; + + count = spawn_zombie_dog( count ); + + waiting_for_next_dog_spawn_rush( count, max ); + } +} + +round_max_rush() +{ + players = sys::getplayers(); + + dog_max = getdvarint( "rm_dog_rush_max_dogs_round_base" ); + + dog_max += players.size * getdvarint( "rm_dog_rush_max_dogs_round_per_player" ); + + dog_max *= int( level.round_number * getdvarfloat( "rm_dog_rush_max_dogs_round_number_multiplier" ) ); + + max = getdvarint( "rm_dog_rush_max_dogs_round" ); + if ( dog_max > max ) + { + dog_max = max; + } + + dog_max = int( dog_max ); + level.zombie_total = dog_max; +} + +round_chance_rush() +{ + if ( level.round_number < getdvarint( "rm_dog_rush_min_round" ) ) + { + return false; + } + + return randomint( 100 ) <= getdvarint( "rm_dog_rush_round_chance" ); +} + +round_next_rush() +{ + min = getDvarInt( "rm_min_rounds_before_special_round" ); + max = getDvarInt( "rm_max_rounds_before_special_round" ); + if ( min >= max ) + { + return level.special_round.last_data.round_number + 1; + } + else + { + return level.special_round.last_data.round_number + randomintrange( min, max ); + } } waiting_for_next_dog_spawn( count, max ) @@ -143,17 +228,57 @@ waiting_for_next_dog_spawn( count, max ) wait( default_wait ); } -round_over() +waiting_for_next_dog_spawn_rush( count, max ) { - if ( !isDefined( level.dog_round_count ) ) + default_wait = getdvarfloat( "rm_dog_rush_max_spawn_wait" ); + + default_wait = default_wait - ( ( count / max ) * 2 ); + min_wait = getdvarfloat( "rm_dog_rush_min_spawn_wait" ); + if ( default_wait <= min_wait ) { - level.dog_round_count = 1; + default_wait = min_wait; + } + if ( default_wait < 0.05 ) + { + default_wait = 0.05; + } + wait( default_wait ); +} + +spawn_zombie_dog( count ) +{ + players = sys::getplayers(); + favorite_enemy = maps\mp\zombies\_zm_ai_dogs::get_favorite_enemy(); + + if ( isdefined( level.dog_spawn_func ) ) + { + spawn_loc = [[ level.dog_spawn_func ]]( level.dog_spawners, favorite_enemy ); + ai = spawn_zombie( level.dog_spawners[0] ); + + if ( isdefined( ai ) ) + { + ai.favoriteenemy = favorite_enemy; + spawn_loc thread maps\mp\zombies\_zm_ai_dogs::dog_spawn_fx( ai, spawn_loc ); + level.zombie_total--; + count++; + } + } + else + { + spawn_point = dog_spawn_factory_logic( level.enemy_dog_spawns, favorite_enemy ); + ai = spawn_zombie( level.dog_spawners[0] ); + + if ( isdefined( ai ) ) + { + ai.favoriteenemy = favorite_enemy; + spawn_point thread maps\mp\zombies\_zm_ai_dogs::dog_spawn_fx( ai, spawn_point ); + level.zombie_total--; + count++; + flag_set( "dog_clips" ); + } } - maps\mp\zombies\_zm_ai_dogs::dog_round_stop(); - level.music_round_override = 0; - level.dog_round_count = level.dog_round_count + 1; - flag_clear( "dog_round" ); + return count; } dog_spawn_sumpf_logic( dog_array, favorite_enemy ) diff --git a/zm_ai_pack/scripts/zm/zm_ai_pack_mod_main.gsc b/zm_ai_pack/scripts/zm/zm_ai_pack_mod_main.gsc index acd6d92..ef475e8 100644 --- a/zm_ai_pack/scripts/zm/zm_ai_pack_mod_main.gsc +++ b/zm_ai_pack/scripts/zm/zm_ai_pack_mod_main.gsc @@ -52,8 +52,7 @@ main() level.ai_data[ "mechz" ].should_execute = level.script != "zm_tomb"; level.ai_data[ "zombie_dog" ] = sys::spawnstruct(); level.ai_data[ "zombie_dog" ].main = maps\mp\zombies\_zm_ai_dogs::init; - level.ai_data[ "zombie_dog" ].init = maps\mp\zombies\_zm_ai_dogs::enable_dog_rounds; - level.ai_data[ "zombie_dog" ].should_execute = !( level.gametype == "zstandard" && getGametypeSetting( "allowDogs" ) == 1 ); + level.ai_data[ "zombie_dog" ].should_execute = level.gametype != "zstandard" ; keys = getArrayKeys( level.ai_data ); for ( i = 0; i < keys.size; i++ ) diff --git a/zm_ai_pack/zone_source/mod.zone b/zm_ai_pack/zone_source/mod.zone index f1d9979..8db8c54 100644 --- a/zm_ai_pack/zone_source/mod.zone +++ b/zm_ai_pack/zone_source/mod.zone @@ -68,6 +68,17 @@ script,scripts/zm/zm_ai_pack_mod_main.gsc script,scripts/zm/clientfield_alt_sys.csc script,scripts/zm/clientfield_alt_sys.gsc +script,scripts/zm/zm_ai_pack/_utility.gsc +script,scripts/zm/zm_ai_pack/_round_manager.gsc +script,scripts/zm/zm_ai_pack/rounds/_avogadro.gsc +script,scripts/zm/zm_ai_pack/rounds/_brutus.gsc +script,scripts/zm/zm_ai_pack/rounds/_ghost.gsc +script,scripts/zm/zm_ai_pack/rounds/_leaper.gsc +script,scripts/zm/zm_ai_pack/rounds/_mechz.gsc +script,scripts/zm/zm_ai_pack/rounds/_mixed.gsc +script,scripts/zm/zm_ai_pack/rounds/_normal.gsc +script,scripts/zm/zm_ai_pack/rounds/_zombie_dog.gsc + script,sys.gsc script,pluto_sys.gsc