mirror of
https://github.com/JezuzLizard/BO2-Reimagined.git
synced 2025-06-10 07:08:06 -05:00
Encounter: end game on no enemy players
Optimize game won code
This commit is contained in:
@ -17,8 +17,6 @@ wait_for_team_death_and_round_end()
|
||||
level.isresetting_grief = 0;
|
||||
while ( 1 )
|
||||
{
|
||||
cdc_total = 0;
|
||||
cia_total = 0;
|
||||
cdc_alive = 0;
|
||||
cia_alive = 0;
|
||||
players = get_players();
|
||||
@ -32,7 +30,6 @@ wait_for_team_death_and_round_end()
|
||||
}
|
||||
if ( players[ i ]._encounters_team == "A" )
|
||||
{
|
||||
cia_total++;
|
||||
if ( is_player_valid( players[ i ] ) )
|
||||
{
|
||||
cia_alive++;
|
||||
@ -40,7 +37,6 @@ wait_for_team_death_and_round_end()
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
cdc_total++;
|
||||
if ( is_player_valid( players[ i ] ) )
|
||||
{
|
||||
cdc_alive++;
|
||||
@ -48,19 +44,6 @@ wait_for_team_death_and_round_end()
|
||||
i++;
|
||||
}
|
||||
|
||||
if ( cia_total == 0 )
|
||||
{
|
||||
level notify( "stop_round_end_check" );
|
||||
level thread round_end( "B", true );
|
||||
checking_for_round_end = 1;
|
||||
}
|
||||
else if ( cdc_total == 0 )
|
||||
{
|
||||
level notify( "stop_round_end_check" );
|
||||
level thread round_end( "A", true );
|
||||
checking_for_round_end = 1;
|
||||
}
|
||||
|
||||
if ( !checking_for_round_tie )
|
||||
{
|
||||
if(cia_alive == 0 && cdc_alive == 0)
|
||||
@ -100,6 +83,7 @@ wait_for_team_death_and_round_end()
|
||||
check_for_round_end(winner)
|
||||
{
|
||||
level endon( "stop_round_end_check" );
|
||||
level endon( "end_game" );
|
||||
|
||||
if(isDefined(winner))
|
||||
{
|
||||
@ -113,13 +97,8 @@ check_for_round_end(winner)
|
||||
level thread round_end(winner);
|
||||
}
|
||||
|
||||
round_end(winner, force_win)
|
||||
round_end(winner)
|
||||
{
|
||||
if(!isDefined(force_win))
|
||||
{
|
||||
force_win = false;
|
||||
}
|
||||
|
||||
team = undefined;
|
||||
if(isDefined(winner))
|
||||
{
|
||||
@ -140,28 +119,9 @@ round_end(winner, force_win)
|
||||
level.grief_hud.team["allies"].score[team] setValue(level.grief_score[winner]);
|
||||
setteamscore(team, level.grief_score[winner]);
|
||||
|
||||
if(level.grief_score[winner] == level.grief_winning_score || force_win)
|
||||
if(level.grief_score[winner] == level.grief_winning_score)
|
||||
{
|
||||
level.gamemodulewinningteam = winner;
|
||||
level.zombie_vars[ "spectators_respawn" ] = 0;
|
||||
players = get_players();
|
||||
i = 0;
|
||||
while ( i < players.size )
|
||||
{
|
||||
players[ i ] freezecontrols( 1 );
|
||||
if ( players[ i ]._encounters_team == winner )
|
||||
{
|
||||
players[ i ] thread maps/mp/zombies/_zm_audio_announcer::leaderdialogonplayer( "grief_won" );
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
players[ i ] thread maps/mp/zombies/_zm_audio_announcer::leaderdialogonplayer( "grief_lost" );
|
||||
i++;
|
||||
}
|
||||
level notify( "game_module_ended", winner );
|
||||
level._game_module_game_end_check = undefined;
|
||||
maps/mp/gametypes_zm/_zm_gametype::track_encounters_win_stats( level.gamemodulewinningteam );
|
||||
level notify( "end_game" );
|
||||
game_won(winner);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -217,6 +177,30 @@ round_end(winner, force_win)
|
||||
level thread maps/mp/zombies/_zm::round_think( 1 );
|
||||
}
|
||||
|
||||
game_won(winner)
|
||||
{
|
||||
level.gamemodulewinningteam = winner;
|
||||
level.zombie_vars[ "spectators_respawn" ] = 0;
|
||||
players = get_players();
|
||||
i = 0;
|
||||
while ( i < players.size )
|
||||
{
|
||||
players[ i ] freezecontrols( 1 );
|
||||
if ( players[ i ]._encounters_team == winner )
|
||||
{
|
||||
players[ i ] thread maps/mp/zombies/_zm_audio_announcer::leaderdialogonplayer( "grief_won" );
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
players[ i ] thread maps/mp/zombies/_zm_audio_announcer::leaderdialogonplayer( "grief_lost" );
|
||||
i++;
|
||||
}
|
||||
level notify( "game_module_ended", winner );
|
||||
level._game_module_game_end_check = undefined;
|
||||
maps/mp/gametypes_zm/_zm_gametype::track_encounters_win_stats( level.gamemodulewinningteam );
|
||||
level notify( "end_game" );
|
||||
}
|
||||
|
||||
zombie_goto_round(target_round)
|
||||
{
|
||||
level endon( "end_game" );
|
||||
|
@ -682,6 +682,29 @@ grief_onplayerconnect()
|
||||
|
||||
grief_onplayerdisconnect(disconnecting_player)
|
||||
{
|
||||
players = get_players();
|
||||
count = 0;
|
||||
foreach(player in players)
|
||||
{
|
||||
if(player != disconnecting_player && player.team == disconnecting_player.team)
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
if(count == 0)
|
||||
{
|
||||
encounters_team = "A";
|
||||
if(getOtherTeam(disconnecting_player.team) == "allies")
|
||||
{
|
||||
encounters_team = "B";
|
||||
}
|
||||
|
||||
scripts/zm/replaced/_zm_game_module::game_won(encounters_team);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
level thread update_players_on_disconnect(disconnecting_player);
|
||||
}
|
||||
|
||||
@ -2494,29 +2517,9 @@ increment_score(team)
|
||||
level.grief_hud.team["allies"].score[team] setValue(level.grief_score[encounters_team]);
|
||||
setteamscore(team, level.grief_score[encounters_team]);
|
||||
|
||||
if(level.grief_score[encounters_team] == level.grief_winning_score)
|
||||
if(level.grief_score[encounters_team] >= level.grief_winning_score)
|
||||
{
|
||||
level.gamemodulewinningteam = encounters_team;
|
||||
level.zombie_vars[ "spectators_respawn" ] = 0;
|
||||
players = get_players();
|
||||
i = 0;
|
||||
while ( i < players.size )
|
||||
{
|
||||
players[ i ] freezecontrols( 1 );
|
||||
if ( players[ i ]._encounters_team == encounters_team )
|
||||
{
|
||||
players[ i ] thread maps/mp/zombies/_zm_audio_announcer::leaderdialogonplayer( "grief_won" );
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
players[ i ] thread maps/mp/zombies/_zm_audio_announcer::leaderdialogonplayer( "grief_lost" );
|
||||
i++;
|
||||
}
|
||||
level notify( "game_module_ended", encounters_team );
|
||||
level._game_module_game_end_check = undefined;
|
||||
maps/mp/gametypes_zm/_zm_gametype::track_encounters_win_stats( level.gamemodulewinningteam );
|
||||
level notify( "end_game" );
|
||||
return;
|
||||
scripts/zm/replaced/_zm_game_module::game_won(encounters_team);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user