TacoServer/Classic/scripts/autoexec/VoteOverTime.cs

98 lines
2.6 KiB
C#
Raw Normal View History

2019-09-13 19:34:03 +00:00
// Vote OverTime Script
//
// Dont allow the match to end if a time vote is pending
2019-12-09 05:34:16 +00:00
// 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
2019-09-13 19:34:03 +00:00
2019-12-09 05:34:16 +00:00
$VOStatus = "Normal";
2019-09-13 19:34:03 +00:00
2018-11-18 23:29:37 +00:00
package VoteOverTime
{
2018-08-07 06:50:49 +00:00
2018-08-09 20:55:08 +00:00
function DefaultGame::checkTimeLimit(%game, %forced)
2018-08-07 06:50:49 +00:00
{
2018-08-09 20:55:08 +00:00
// Don't add extra checks:
if ( %forced )
cancel( %game.timeCheck );
2018-08-07 06:50:49 +00:00
2018-08-09 20:55:08 +00:00
// 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();
2018-08-07 06:50:49 +00:00
2018-08-09 20:55:08 +00:00
if (%curTimeLeftMS <= 0)
{
2019-12-09 05:34:16 +00:00
//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)
2018-11-11 04:10:39 +00:00
{
2019-12-09 05:34:16 +00:00
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();
2018-08-09 20:55:08 +00:00
}
}
else
{
if(%curTimeLeftMS >= 20000)
%game.timeCheck = %game.schedule(20000, "checkTimeLimit");
else
%game.timeCheck = %game.schedule(%curTimeLeftMS + 1, "checkTimeLimit");
2018-08-07 06:50:49 +00:00
2018-08-09 20:55:08 +00:00
//now synchronize everyone's clock
messageAll('MsgSystemClock', "", $Host::TimeLimit, %curTimeLeftMS);
}
2018-08-07 06:50:49 +00:00
}
function DefaultGame::gameOver(%game)
{
Parent::gameOver(%game);
//Reset everything to do with Vote Overtime
ResetVOall(%game);
}
2018-08-14 19:28:16 +00:00
};
2019-12-09 05:34:16 +00:00
// Various Flags for the different situations
// Starting a TimeVote - Sets flags so the game wont end during this vote
2018-08-14 19:28:16 +00:00
function StartVOTimeVote(%game)
{
2019-12-09 05:34:16 +00:00
$VOStatus = "Starting";
2018-08-14 19:28:16 +00:00
}
2019-12-09 05:34:16 +00:00
// 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.
2018-08-14 19:28:16 +00:00
function ResetVOTimeChanged(%game)
{
2019-12-09 05:34:16 +00:00
$VOStatus = "TimeChanged";
2018-08-14 19:28:16 +00:00
}
2019-12-09 05:34:16 +00:00
// Reset everything. So everything functions normally after a map change.
2018-08-14 19:28:16 +00:00
function ResetVOall(%game)
{
2019-12-09 05:34:16 +00:00
$VOStatus = "Normal";
2018-08-14 19:28:16 +00:00
}
2018-08-07 06:50:49 +00:00
// Prevent package from being activated if it is already
if (!isActivePackage(VoteOverTime))
activatePackage(VoteOverTime);