Vote Overtime Redo

This commit is contained in:
ChocoTaco1 2025-10-29 15:31:04 -04:00
parent 3e858b5649
commit 3bd4577832
5 changed files with 95 additions and 127 deletions

View file

@ -1266,7 +1266,13 @@ function CTFGame::checkTimeLimit(%game, %forced)
{
%teamOneCaps = mFloor($TeamScore[1] / %game.SCORE_PER_TEAM_FLAG_CAP);
%teamTwoCaps = mFloor($TeamScore[2] / %game.SCORE_PER_TEAM_FLAG_CAP);
if(%teamOneCaps == %teamTwoCaps && $CTF::Overtime && (($TeamRank[1, count] + $TeamRank[2, count]) > 6)){
if(%game.scheduleVote !$= "" && !%game.voteOT && !$Host::TournamentMode)
{
messageAll('MsgOvertime', '\c2Vote Overtime Initiated.~wfx/powered/turret_heavy_activate.wav');
%game.voteOT = 1;
}
else if(%teamOneCaps == %teamTwoCaps && $CTF::Overtime && (($TeamRank[1, count] + $TeamRank[2, count]) > 6))
{
if(!%game.overtime)
{
%game.overtime = 1;
@ -1276,19 +1282,30 @@ function CTFGame::checkTimeLimit(%game, %forced)
UpdateClientTimes($CTF::Overtime * 60 * 1000);
EndCountdown($CTF::Overtime * 60 * 1000);
%game.timeCheck = %game.schedule($CTF::Overtime * 60 * 1000, "timeLimitReached");
//Cancel vote if any
if(%game.scheduleVote !$= "")
{
messageAll('closeVoteHud', "");
cancel(Game.scheduleVote);
Game.scheduleVote = "";
Game.kickClient = "";
clearVotes();
//Stop vote chimes
for(%i = 0; %i < $Host::EnableVoteSoundReminders; %i++)
{
if(isEventPending(Game.voteReminder[%i]))
cancel(Game.voteReminder[%i]);
Game.voteReminder[%i] = "";
}
messageAll('MsgOvertime', "\c2Vote has been cancelled due to Sudden-Death Overtime.");
}
}
}
else
{
if(%game.scheduleVote !$= "" && !%game.voteOT)
{
messageAll('MsgOvertime', '\c2Vote Overtime Initiated.~wfx/powered/turret_heavy_activate.wav');
%game.voteOT = 1;
}
else
{
%game.timeLimitReached();
}
%game.timeLimitReached();
}
}
else

View file

@ -1566,7 +1566,13 @@ function LCTFGame::checkTimeLimit(%game, %forced)
{
%teamOneCaps = mFloor($TeamScore[1] / %game.SCORE_PER_TEAM_FLAG_CAP);
%teamTwoCaps = mFloor($TeamScore[2] / %game.SCORE_PER_TEAM_FLAG_CAP);
if(%teamOneCaps == %teamTwoCaps && $LCTF::Overtime && (($TeamRank[1, count] + $TeamRank[2, count]) > 6)){
if(%game.scheduleVote !$= "" && !%game.voteOT && !$Host::TournamentMode)
{
messageAll('MsgOvertime', '\c2Vote Overtime Initiated.~wfx/powered/turret_heavy_activate.wav');
%game.voteOT = 1;
}
else if(%teamOneCaps == %teamTwoCaps && $LCTF::Overtime && (($TeamRank[1, count] + $TeamRank[2, count]) > 6))
{
if(!%game.overtime)
{
%game.overtime = 1;
@ -1576,19 +1582,30 @@ function LCTFGame::checkTimeLimit(%game, %forced)
UpdateClientTimes($LCTF::Overtime * 60 * 1000);
EndCountdown($LCTF::Overtime * 60 * 1000);
%game.timeCheck = %game.schedule($LCTF::Overtime * 60 * 1000, "timeLimitReached");
//Cancel vote if any
if(%game.scheduleVote !$= "")
{
messageAll('closeVoteHud', "");
cancel(Game.scheduleVote);
Game.scheduleVote = "";
Game.kickClient = "";
clearVotes();
//Stop vote chimes
for(%i = 0; %i < $Host::EnableVoteSoundReminders; %i++)
{
if(isEventPending(Game.voteReminder[%i]))
cancel(Game.voteReminder[%i]);
Game.voteReminder[%i] = "";
}
messageAll('MsgOvertime', "\c2Vote has been cancelled due to Sudden-Death Overtime.");
}
}
}
else
{
if(%game.scheduleVote !$= "" && !%game.voteOT)
{
messageAll('MsgOvertime', '\c2Vote Overtime Initiated.~wfx/powered/turret_heavy_activate.wav');
%game.voteOT = 1;
}
else
{
%game.timeLimitReached();
}
%game.timeLimitReached();
}
}
else

View file

@ -2017,6 +2017,45 @@ function LakRabbitGame::resetFlag(%game, %flag)
cancel(%game.updateFlagThread[%flag]); // z0dd - ZOD, 8/4/02. Cancel this flag's thread to KineticPoet's flag updater
}
function LakRabbitGame::checkTimeLimit(%game, %forced)
{
// Don't add extra checks:
if ( %forced )
cancel( %game.timeCheck );
// if there is no time limit, check back in a minute to see if it's been set
if(($Host::TimeLimit $= "") || $Host::TimeLimit == 0)
{
%game.timeCheck = %game.schedule(20000, "checkTimeLimit");
return;
}
%curTimeLeftMS = ($Host::TimeLimit * 60 * 1000) + $missionStartTime - getSimTime();
if (%curTimeLeftMS <= 0)
{
if(%game.scheduleVote !$= "" && !%game.voteOT && !$Host::TournamentMode)
{
messageAll('MsgOvertime', '\c2Vote Overtime Initiated.~wfx/powered/turret_heavy_activate.wav');
%game.voteOT = 1;
}
else
{
%game.timeLimitReached();
}
}
else
{
if(%curTimeLeftMS >= 20000)
%game.timeCheck = %game.schedule(20000, "checkTimeLimit");
else
%game.timeCheck = %game.schedule(%curTimeLeftMS + 1, "checkTimeLimit");
//now synchronize everyone's clock
messageAll('MsgSystemClock', "", $Host::TimeLimit, %curTimeLeftMS);
}
}
// ----- These functions are native to Rabbit
function LakRabbitGame::timeLimitReached(%game)

View file

@ -502,8 +502,6 @@ function serverCmdStartNewVote(%client, %typeName, %arg1, %arg2, %arg3, %arg4, %
{
if(%arg1 $= "999") %time = "unlimited"; else %time = %arg1;
%msg = %client.nameBase @ " initiated a vote to change the time limit to " @ %time SPC "minutes.";
// VoteOvertime
StartVOTimeVote(%game);
$CMHasVoted[%client.guid]++;
}
@ -583,7 +581,8 @@ function serverCmdStartNewVote(%client, %typeName, %arg1, %arg2, %arg3, %arg4, %
case "stopRunningVote":
if(%client.isSuperAdmin || (%client.isAdmin && $Host::AllowAdminStopVote))
{
if($VOStatus $="InProgress") //Dont allow a stop vote after time has expired, then no new time is set - VoteOverTime
%curTimeLeftMS = ($Host::TimeLimit * 60 * 1000) + $missionStartTime - getSimTime();
if(%curTimeLeftMS <= 0) //Dont allow a stop vote after time has expired, then no new time is set - VoteOverTime
{
messageClient(%client, "", "\c2Can't stop time vote after time has expired.");
return;
@ -1223,8 +1222,6 @@ function DefaultGame::voteChangeTimeLimit( %game, %admin, %newLimit )
{
messageAll('MsgVotePassed', '\c2The mission time limit was set to %1 minutes by vote.', %display);
$Host::TimeLimit = %newLimit;
// VoteOvertime
ResetVOTimeChanged(%game);
// Reset the voted time limit when changing mission
$TimeLimitChanged = 1;
@ -1243,9 +1240,6 @@ function DefaultGame::voteChangeTimeLimit( %game, %admin, %newLimit )
votePercentLog(%newLimit, %typeName, %key, %game.totalVotesFor, %game.totalVotesAgainst, %totalVotes, %game.totalVotesNone);
//Show Vote %
messageAll('', '\c1Vote %6: \c0Yea: %1 Nay: %2 Abstain: %7 Total: %3 [%4%5]', %game.totalVotesFor, %game.totalVotesAgainst, %totalVotes, mfloor((%game.totalVotesFor/(ClientGroup.getCount() - %game.totalVotesNone)) * 100), "%", %key, %game.totalVotesNone);
// VoteOvertime
ResetVOall(%game);
}
}

View file

@ -1,99 +0,0 @@
// Vote OverTime Script
//
// Dont allow the match to end if a time vote is pending
// Or if the timelimit has changed
//
// Changes were also made in how time votes are handled in scripts/autoexec/VoteMenu.cs
// DefaultGame::voteChangeMission, DefaultGame::voteChangeTimeLimit, serverCmdStartNewVote
//
// The VoteChangeTimeLimit functions in evo dictate VOStatus conditions
$VOStatus = "Normal";
package VoteOverTime
{
function DefaultGame::checkTimeLimit(%game, %forced)
{
// Don't add extra checks:
if ( %forced )
cancel( %game.timeCheck );
// if there is no time limit, check back in a minute to see if it's been set
if(($Host::TimeLimit $= "") || $Host::TimeLimit == 0)
{
%game.timeCheck = %game.schedule(20000, "checkTimeLimit");
return;
}
%curTimeLeftMS = ($Host::TimeLimit * 60 * 1000) + $missionStartTime - getSimTime();
if (%curTimeLeftMS <= 0)
{
//Vote Overtime
//Check if Time Vote is starting or active or if the timelimit has changed.
//If the timelimit has changed, don't end the game.
switch$($VOStatus)
{
case Starting:
if($missionRunning)
{
messageAll('', '\c2Vote Overtime Initiated.~wfx/powered/turret_heavy_activate.wav', %display);
$VOStatus = "InProgress";
}
case InProgress:
//Do Nothing
case TimeChanged:
//Do Nothing
case Normal:
// time's up, put down your pencils
%game.timeLimitReached();
}
}
else
{
if(%curTimeLeftMS >= 20000)
%game.timeCheck = %game.schedule(20000, "checkTimeLimit");
else
%game.timeCheck = %game.schedule(%curTimeLeftMS + 1, "checkTimeLimit");
//now synchronize everyone's clock
messageAll('MsgSystemClock', "", $Host::TimeLimit, %curTimeLeftMS);
}
}
function DefaultGame::gameOver(%game)
{
Parent::gameOver(%game);
//Reset everything to do with Vote Overtime
ResetVOall(%game);
}
};
// Various Flags for the different situations
// Starting a TimeVote - Sets flags so the game wont end during this vote
function StartVOTimeVote(%game)
{
if(!$Host::TournamentMode)
$VOStatus = "Starting";
}
// 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)
{
$VOStatus = "TimeChanged";
}
// Reset everything. So everything functions normally after a map change.
function ResetVOall(%game)
{
$VOStatus = "Normal";
}
// Prevent package from being activated if it is already
if (!isActivePackage(VoteOverTime))
activatePackage(VoteOverTime);