More work on round manager.

This commit is contained in:
JezuzLizard 2024-02-28 09:46:33 -08:00
parent 410ffad065
commit 0f53f2beed
8 changed files with 450 additions and 64 deletions

View File

@ -249,8 +249,23 @@ dog_init()
if ( getdvar( #"scr_dog_health_walk_multiplier" ) != "" ) if ( getdvar( #"scr_dog_health_walk_multiplier" ) != "" )
health_multiplier = getdvarfloat( #"scr_dog_health_walk_multiplier" ); health_multiplier = getdvarfloat( #"scr_dog_health_walk_multiplier" );
self.maxhealth = int( level.dog_health * health_multiplier ); if ( isdefined( self.custom_starting_health ) )
self.health = int( level.dog_health * health_multiplier ); {
if ( isdefined( self.use_dog_health_walk_multiplier ) )
{
self.maxhealth = int( self.custom_starting_health * health_multiplier );
}
else
{
self.maxhealth = self.custom_starting_health;
}
}
else
{
self.maxhealth = int( level.dog_health * health_multiplier );
}
self.health = self.maxhealth;
self.freezegun_damage = 0; self.freezegun_damage = 0;
self.zombie_move_speed = "sprint"; self.zombie_move_speed = "sprint";
self thread dog_run_think(); self thread dog_run_think();
@ -268,7 +283,15 @@ dog_init()
self clearenemy(); self clearenemy();
self cleargoalvolume(); self cleargoalvolume();
self.flame_damage_time = 0; self.flame_damage_time = 0;
self.meleedamage = 40; if ( isdefined( self.custom_melee_damage ) )
{
self.meleedamage = self.custom_melee_damage;
}
else
{
self.meleedamage = 40;
}
self.thundergun_knockdown_func = ::dog_thundergun_knockdown; self.thundergun_knockdown_func = ::dog_thundergun_knockdown;
self maps\mp\zombies\_zm_spawner::zombie_history( "zombie_dog_spawn_init -> Spawned = " + self.origin ); self maps\mp\zombies\_zm_spawner::zombie_history( "zombie_dog_spawn_init -> Spawned = " + self.origin );
@ -473,11 +496,22 @@ dog_run_think()
self endon( "death" ); self endon( "death" );
self waittill( "visible" ); self waittill( "visible" );
if ( self.health > level.dog_health ) if ( isdefined( self.custom_starting_health ) )
{ {
self.maxhealth = level.dog_health; if ( self.health > self.custom_starting_health )
self.health = level.dog_health; {
self.maxhealth = self.custom_starting_health;
}
} }
else
{
if ( self.health > level.dog_health )
{
self.maxhealth = level.dog_health;
}
}
self.health = self.maxhealth;
assert( isdefined( self.fx_dog_eye ) ); assert( isdefined( self.fx_dog_eye ) );
maps\mp\zombies\_zm_net::network_safe_play_fx_on_tag( "dog_fx", 2, level._effect["dog_eye_glow"], self.fx_dog_eye, "tag_origin" ); maps\mp\zombies\_zm_net::network_safe_play_fx_on_tag( "dog_fx", 2, level._effect["dog_eye_glow"], self.fx_dog_eye, "tag_origin" );

View File

@ -446,7 +446,15 @@ mechz_attach_objects()
mechz_set_starting_health() mechz_set_starting_health()
{ {
self.maxhealth = level.mechz_health; if ( isdefined( self.custom_starting_health ) )
{
self.maxhealth = self.custom_starting_health;
}
else
{
self.maxhealth = level.mechz_health;
}
self.helmet_dmg = 0; self.helmet_dmg = 0;
self.helmet_dmg_for_removal = self.maxhealth * level.mechz_helmet_health_percentage; self.helmet_dmg_for_removal = self.maxhealth * level.mechz_helmet_health_percentage;
self.powerplant_cover_dmg = 0; self.powerplant_cover_dmg = 0;
@ -463,7 +471,7 @@ mechz_set_starting_health()
println( "\\nMZ: MechZ Required Powerplant Dmg: " + self.powerplant_dmg_for_destroy ); println( "\\nMZ: MechZ Required Powerplant Dmg: " + self.powerplant_dmg_for_destroy );
} }
#/ #/
self.health = level.mechz_health; self.health = self.maxhealth;
self.non_attacker_func = ::mechz_non_attacker_damage_override; self.non_attacker_func = ::mechz_non_attacker_damage_override;
self.non_attack_func_takes_attacker = 1; self.non_attack_func_takes_attacker = 1;
self.actor_damage_func = ::mechz_damage_override; self.actor_damage_func = ::mechz_damage_override;

View File

@ -11,11 +11,16 @@ main()
set_dvar_if_unset( "rm_special_round_chance", 33 ); 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_allow_same_round_as_last_round", 1 );
set_dvar_if_unset( "rm_allowed_special_rounds", "normal zombie_dog mechz" ); set_dvar_if_unset( "rm_allowed_special_rounds", "normal zombie_dog mechz mixed" );
set_dvar_if_unset( "rm_allowed_special_round_variants", "default" ); 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_round", "" );
set_dvar_if_unset( "rm_forced_special_variant", "" ); set_dvar_if_unset( "rm_forced_special_variant", "" );
set_dvar_if_unset( "rm_allowed_mixed_rounds_presets", "default" );
set_dvar_if_unset( "rm_allowed_mixed_rounds_variants", "random" );
set_dvar_if_unset( "rm_forced_mixed_rounds_preset", "" );
set_dvar_if_unset( "rm_forced_mixed_rounds_variant", "" );
level.special_round = sys::spawnstruct(); level.special_round = sys::spawnstruct();
level.special_round.current_data = sys::spawnstruct(); level.special_round.current_data = sys::spawnstruct();
level.special_round.current_data.round_type = ""; level.special_round.current_data.round_type = "";
@ -78,6 +83,23 @@ main()
scripts\zm\zm_ai_pack\rounds\_normal::round_chance, scripts\zm\zm_ai_pack\rounds\_normal::round_chance,
scripts\zm\zm_ai_pack\rounds\_normal::round_next ); scripts\zm\zm_ai_pack\rounds\_normal::round_next );
register_special_round( "mixed", "default",
scripts\zm\zm_ai_pack\rounds\_mixed::round_spawning,
scripts\zm\zm_ai_pack\rounds\_mixed::round_wait,
scripts\zm\zm_ai_pack\rounds\_mixed::round_max,
scripts\zm\zm_ai_pack\rounds\_mixed::round_start,
scripts\zm\zm_ai_pack\rounds\_mixed::round_over,
scripts\zm\zm_ai_pack\rounds\_mixed::round_chance,
scripts\zm\zm_ai_pack\rounds\_mixed::round_next );
register_mixed_round_preset( "default",
scripts\zm\zm_ai_pack\rounds\mixed_presets\_default::preset_chance );
register_mixed_round_preset_variant( "default", "random",
scripts\zm\zm_ai_pack\rounds\mixed_variants\_random::spawning_random,
scripts\zm\zm_ai_pack\rounds\mixed_variants\_random::spawning_chance,
scripts\zm\zm_ai_pack\rounds\mixed_variants\_random::spawning_limit,
scripts\zm\zm_ai_pack\rounds\mixed_variants\_random::spawning_cooldown );
//Future variants //Future variants
// random - random ais, true_random - random ais + random behavior and stats // random - random ais, true_random - random ais + random behavior and stats
// elemental? // elemental?
@ -110,24 +132,32 @@ register_special_round( round_type, variant_type, round_spawning_func, round_wai
level.round_manager_special_rounds[ round_type ][ variant_type ] = s; level.round_manager_special_rounds[ round_type ][ variant_type ] = s;
} }
register_mixed_round_spawning_behavior( spawning_type, variant_type, spawning_func, spawning_portion_of_zombie_total_func, spawning_chance_func, spawning_limit_per_round_func, spawning_cooldown_func ) register_mixed_round_preset( preset_type, preset_chance_func )
{ {
if ( !isDefined( level.round_manager_normal_round_spawning_behaviors ) ) if ( !isDefined( level.round_manager_mixed_round_presets ) )
{ {
level.round_manager_normal_round_spawning_behaviors = []; level.round_manager_mixed_round_presets = [];
} }
if ( !isDefined( level.round_manager_normal_round_spawning_behaviors[ spawning_type ] ) ) if ( !isDefined( level.round_manager_mixed_round_presets[ preset_type ] ) )
{ {
level.round_manager_normal_round_spawning_behaviors[ spawning_type ] = []; level.round_manager_mixed_round_presets[ preset_type ] = sys::spawnstruct();
level.round_manager_mixed_round_presets[ preset_type ].variants = [];
} }
level.round_manager_mixed_round_presets[ preset_type ].chance_func = preset_chance_func;
}
register_mixed_round_preset_variant( preset_type, variant_type, spawning_func, spawning_chance_func, spawning_limit_per_round_func, spawning_cooldown_func )
{
assert( isdefined( level.round_manager_mixed_round_presets[ preset_type ] ) );
s = sys::spawnstruct(); s = sys::spawnstruct();
s.spawning_func = spawning_func; s.spawning_func = spawning_func;
s.portion_of_zombie_total_func = spawning_portion_of_zombie_total_func;
s.chance_func = spawning_chance_func; s.chance_func = spawning_chance_func;
s.limit_per_round_func = spawning_limit_per_round_func; s.limit_per_round_func = spawning_limit_per_round_func;
s.cooldown_func = spawning_cooldown_func; s.cooldown_func = spawning_cooldown_func;
level.round_manager_normal_round_spawning_behaviors[ spawning_type ][ variant_type ] = s; level.round_manager_mixed_round_presets[ preset_type ].variants[ variant_type ] = s;
} }
should_do_special_round() should_do_special_round()
@ -233,6 +263,10 @@ determine_current_round_type()
current_iterations = 0; current_iterations = 0;
allow_repeats = getDvarInt( "rm_allow_same_round_as_last_round" ) != 0; allow_repeats = getDvarInt( "rm_allow_same_round_as_last_round" ) != 0;
allowed_mixed_presets_string = getdvar( "rm_allowed_mixed_rounds_presets" );
can_pick_mixed_round_type = allowed_mixed_presets_string != "";
for (;;) for (;;)
{ {
possible_round_types = array_randomize( possible_round_types_keys ); possible_round_types = array_randomize( possible_round_types_keys );
@ -246,6 +280,11 @@ determine_current_round_type()
continue; continue;
} }
if ( !can_pick_mixed_round_type && possible_round_types[ i ] == "mixed" )
{
continue;
}
assert( possible_variants.size > 0 ); assert( possible_variants.size > 0 );
for ( j = 0; j < possible_variants.size; j++ ) for ( j = 0; j < possible_variants.size; j++ )
@ -461,4 +500,106 @@ round_think_override( restart )
level [[ round_manager_inst.between_round_over_func ]](); level [[ round_manager_inst.between_round_over_func ]]();
restart = 0; restart = 0;
} }
}
determine_mixed_round_preset()
{
forced_preset = getdvar( "rm_forced_mixed_rounds_preset" );
if ( forced_preset != "" )
{
if ( !isDefined( level.round_manager_mixed_round_presets[ forced_preset ] ) )
{
print( "Round Manager ERROR: Can't set preset to " + forced_preset + " because it wasn't registered" );
assert( false );
}
else
{
return level.round_manager_mixed_round_presets[ forced_preset ];
}
}
allowed_presets_string = getDvar( "rm_allowed_mixed_rounds_presets" );
allowed_presets_keys = strok( allowed_presets_string, " " );
max_iterations = 50;
current_iterations = 0;
for (;;)
{
possible_presets = array_randomize( allowed_presets_keys );
for ( i = 0; i < possible_presets.size; i++ )
{
assert( isDefined( level.round_manager_mixed_round_presets[ possible_presets[ i ] ] ) );
if ( possible_presets.size <= 1 || [[ level.round_manager_mixed_round_presets[ possible_presets[ i ] ].chance_func ]]() )
{
return level.round_manager_mixed_round_presets[ possible_presets[ i ] ];
}
}
current_iterations++;
if ( current_iterations >= max_iterations )
{
return level.round_manager_mixed_round_presets[ possible_presets[ 0 ] ];
}
}
}
pick_mixed_round_preset_variant( variants )
{
forced_variant = getdvar( "rm_forced_mixed_rounds_variant" );
if ( forced_preset != "" )
{
if ( !isDefined( variants[ forced_variant ] ) )
{
print( "Round Manager ERROR: Can't set preset to " + forced_preset + " because it wasn't registered" );
assert( false );
}
else
{
return variants[ forced_variant ];
}
}
allowed_variants_string = getdvar( "rm_allowed_mixed_rounds_variants" );
pick_from_allowed_variants_pool = allowed_variants_string != "";
if ( !pick_from_allowed_variants_pool )
{
return random( variants );
}
allowed_variants_keys = strtok( allowed_variants_string, " " );
if ( allowed_variants_keys.size <= 1 )
{
return variants[ allowed_variants_keys[ 0 ] ];
}
max_iterations = 50;
current_iterations = 0;
for (;;)
{
possible_variants = array_randomize( allowed_variants_keys );
for ( i = 0; i < possible_variants.size; i++ )
{
if ( [[ variants[ possible_variants[ i ] ].chance_func ]]() )
{
return variants[ possible_variants[ i ] ];
}
}
current_iterations++;
if ( current_iterations >= max_iterations )
{
return variants[ possible_variants[ 0 ] ];
}
}
} }

View File

@ -19,6 +19,7 @@ main()
set_dvar_if_unset( "rm_mechz_rush_max_spawn_wait", 2.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_alive", 24 );
set_dvar_if_unset( "rm_mechz_rush_max_mechz_round", 24 ); set_dvar_if_unset( "rm_mechz_rush_max_mechz_round", 24 );
set_dvar_if_unset( "rm_mechz_rush_max_health_multiplier", 0.5 );
} }
round_spawning_common() round_spawning_common()
@ -67,9 +68,7 @@ round_spawning()
while ( level.zombie_mechz_locations.size < 1 ) while ( level.zombie_mechz_locations.size < 1 )
wait( randomfloatrange( 5.0, 10.0 ) ); wait( randomfloatrange( 5.0, 10.0 ) );
ai = spawn_zombie( level.mechz_spawners[0] ); ai = spawn_single_mechz();
ai thread maps\mp\zombies\_zm_ai_mechz::mechz_spawn();
level.mechz_left_to_spawn--;
if ( level.mechz_left_to_spawn == 0 ) if ( level.mechz_left_to_spawn == 0 )
level thread maps\mp\zombies\_zm_ai_mechz::response_to_air_raid_siren_vo(); level thread maps\mp\zombies\_zm_ai_mechz::response_to_air_raid_siren_vo();
@ -189,10 +188,7 @@ round_spawning_rush()
while ( level.zombie_mechz_locations.size < 1 ) while ( level.zombie_mechz_locations.size < 1 )
wait( randomfloatrange( 5.0, 10.0 ) ); wait( randomfloatrange( 5.0, 10.0 ) );
ai = spawn_zombie( level.mechz_spawners[0] ); ai = spawn_single_mechz( int( level.mechz_health * getdvarfloat( "rm_mechz_rush_max_health_multiplier" ) ) );
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 ) if ( level.mechz_left_to_spawn == 0 )
level thread maps\mp\zombies\_zm_ai_mechz::response_to_air_raid_siren_vo(); level thread maps\mp\zombies\_zm_ai_mechz::response_to_air_raid_siren_vo();
@ -235,4 +231,22 @@ round_next_rush()
{ {
return level.special_round.last_data.round_number + randomintrange( min, max ); return level.special_round.last_data.round_number + randomintrange( min, max );
} }
}
spawn_single_mechz( starting_health )
{
ai = spawn_zombie( level.mechz_spawners[0] );
if ( isdefined( starting_health ) )
{
ai.custom_starting_health = starting_health;
}
ai thread maps\mp\zombies\_zm_ai_mechz::mechz_spawn();
if ( isdefined( ai ) )
{
level.mechz_left_to_spawn--;
level.zombie_total--;
}
return ai;
} }

View File

@ -1,3 +1,154 @@
#include maps\mp\zombies\_zm_utility;
#include common_scripts\utility;
#include maps\mp\_utility;
#include maps\mp\zombies\_zm;
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 );
if ( level.round_number < 10 || level.speed_change_max > 0 )
level thread zombie_speed_up();
mixed_spawns = 0;
old_spawn = undefined;
spawning_preset = scripts\zm\zm_ai_pack\_round_manager::determine_mixed_round_preset();
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();
ai = scripts\zm\zm_ai_pack\rounds\_normal::spawn_single_normal_zombie();
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;
}
special_dog_spawn( spawners, num_to_spawn ) special_dog_spawn( spawners, num_to_spawn )
{ {
dogs = getaispeciesarray( "all", "zombie_dog" ); dogs = getaispeciesarray( "all", "zombie_dog" );

View File

@ -54,48 +54,8 @@ round_spawning()
wait 0.1; wait 0.1;
run_custom_ai_spawn_checks(); run_custom_ai_spawn_checks();
spawn_point = level.zombie_spawn_locations[randomint( level.zombie_spawn_locations.size )];
if ( !isdefined( old_spawn ) ) ai = spawn_single_normal_zombie();
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.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();
}
wait( level.zombie_vars["zombie_spawn_delay"] ); wait( level.zombie_vars["zombie_spawn_delay"] );
wait_network_frame(); wait_network_frame();
@ -209,4 +169,54 @@ default_max_zombie_func( max_num )
max = int( max_num * 0.9 ); max = int( max_num * 0.9 );
return max; return max;
}
spawn_single_normal_zombie()
{
ai = undefined;
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.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();
}
return ai;
} }

View File

@ -0,0 +1,9 @@
main()
{
}
preset_chance()
{
return true;
}

View File

@ -0,0 +1,19 @@
spawning_random()
{
}
spawning_chance()
{
}
spawning_limit()
{
}
spawning_cooldown()
{
}