Safer Scheduling/Vote Overtime Rework

This commit is contained in:
ChocoTaco 2019-12-09 00:34:16 -05:00
parent 6a1d1f2913
commit 181646ccbb
3 changed files with 39 additions and 33 deletions

Binary file not shown.

View file

@ -1,10 +1,15 @@
// Vote OverTime Script // Vote OverTime Script
// //
// Dont allow the match to end if a time vote is pending // Dont allow the match to end if a time vote is pending
// Or if the timelimit has changed
//
// Changes were also made in the Evo Admin.ovl and DefaultGame.ovl
// DefaultGame::voteChangeMission, DefaultGame::voteChangeTimeLimit, serverCmdStartNewVote
//
// The VoteChangeTimeLimit functions in evo dictate VOStatus conditions
$VOStatus = "Normal";
//Changes were also made in the Evo Admin.ovl and DefaultGame.ovl
//DefaultGame::voteChangeMission, DefaultGame::voteChangeTimeLimit, serverCmdStartNewVote
package VoteOverTime package VoteOverTime
{ {
@ -25,23 +30,24 @@ function DefaultGame::checkTimeLimit(%game, %forced)
if (%curTimeLeftMS <= 0) if (%curTimeLeftMS <= 0)
{ {
//Vote Overtime //Vote Overtime
//Check if Vote is active or if the timelimit has changed. //Check if Time Vote is starting or active or if the timelimit has changed.
if( !$VoteInProgress && !$TimeLimitChanged ) //If the timelimit has changed, don't end the game.
switch$($VOStatus)
{ {
// time's up, put down your pencils case Starting:
%game.timeLimitReached(); if($missionRunning)
} {
else if( $missionRunning && $VoteInProgress && !$TimeLimitChanged ) messageAll('', '\c2Vote Overtime Initiated.~wfx/powered/turret_heavy_activate.wav', %display);
{ $VOStatus = "InProgress";
//Restart the function so the map can end if the Vote doesnt pass. }
schedule(2000, 0, "RestartcheckTimeLimit", %game, %forced); case InProgress:
//Do Nothing
if( !$VoteInProgressMsg ) case TimeChanged:
{ //Do Nothing
messageAll('', '\c2Vote Overtime Initiated.~wfx/powered/turret_heavy_activate.wav', %display); case Normal:
$VoteInProgressMsg = true; // time's up, put down your pencils
} %game.timeLimitReached();
} }
} }
else else
@ -56,42 +62,39 @@ function DefaultGame::checkTimeLimit(%game, %forced)
} }
} }
// Reset every map change
function DefaultGame::gameOver(%game) function DefaultGame::gameOver(%game)
{ {
Parent::gameOver(%game); Parent::gameOver(%game);
//Reset everything to do with Vote Overtime //Reset everything to do with Vote Overtime
ResetVOall(%game); ResetVOall(%game);
if(isEventPending($VoteSoundSchedule))
cancel($VoteSoundSchedule);
} }
}; };
function RestartcheckTimeLimit(%game, %forced) // Various Flags for the different situations
{ // Starting a TimeVote - Sets flags so the game wont end during this vote
%game.checkTimeLimit(%game, %forced);
}
function StartVOTimeVote(%game) function StartVOTimeVote(%game)
{ {
$VOStatus = "Starting";
$VoteSoundInProgress = true; $VoteSoundInProgress = true;
$VoteInProgress = true;
$TimeLimitChanged = false;
} }
// Tribes wont change the time after its reached zero and you cant change it again afterwards until a gameover/map change.
// But this serves its purpose for extending the game whether it works (technically) or not.
function ResetVOTimeChanged(%game) function ResetVOTimeChanged(%game)
{ {
$VoteInProgress = false; $VOStatus = "TimeChanged";
$TimeLimitChanged = true;
$VoteInProgressMsg = false;
$VoteSoundInProgress = false; $VoteSoundInProgress = false;
} }
// Reset everything. So everything functions normally after a map change.
function ResetVOall(%game) function ResetVOall(%game)
{ {
$VoteInProgress = false; $VOStatus = "Normal";
$TimeLimitChanged = false;
$VoteInProgressMsg = false;
$VoteSoundInProgress = false; $VoteSoundInProgress = false;
} }

View file

@ -52,6 +52,9 @@ function VoteSound( %game, %typename, %arg1, %arg2, %VoteSoundRandom )
messageAll('', '\c1Vote in Progress: \c0To change the mission to Tournament Mode (%1). %3~wgui/objective_notification.wav', %arg1, %arg2, %votemsg ); messageAll('', '\c1Vote in Progress: \c0To change the mission to Tournament Mode (%1). %3~wgui/objective_notification.wav', %arg1, %arg2, %votemsg );
} }
schedule(12000, 0, "VoteSound", %game, %typename, %arg1, %arg2, %VoteSoundRandom); if(isEventPending($VoteSoundSchedule))
cancel($VoteSoundSchedule);
$VoteSoundSchedule = schedule(12000, 0, "VoteSound", %game, %typename, %arg1, %arg2, %VoteSoundRandom);
} }
} }