TM2020-Gamemodes/LastManStanding.Script.txt

1045 lines
34 KiB
Plaintext
Raw Normal View History

2021-08-06 17:27:21 +02:00
/**
* LastManStanding mode
*/
2023-09-25 18:24:25 +02:00
#Extends "Modes/Nadeo/Trackmania/Base/TrackmaniaRoundsBase.Script.txt"
2021-08-06 17:27:21 +02:00
#Const CompatibleMapTypes "TrackMania\\TM_Race,TM_Race"
#Const Version "2023-10-16"
2022-03-08 18:20:57 +01:00
#Const ScriptName "Modes/TM2020-Gamemodes/LastManStanding.Script.txt"
2021-08-06 17:27:21 +02:00
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
// Libraries
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
#Include "TextLib" as TL
#Include "MathLib" as ML
2023-09-25 18:24:25 +02:00
#Include "Libs/Nadeo/Trackmania/Modes/Rounds/StateManager.Script.txt" as StateMgr
#Include "Libs/Nadeo/Trackmania/MainMenu/Constants.Script.txt" as MenuConsts
#Include "Libs/Nadeo/CMGame/Modes/Utils.Script.txt" as ModeUtils
2021-08-06 17:27:21 +02:00
// UI from Race
2023-09-25 18:24:25 +02:00
#Include "Libs/Nadeo/TMGame/Modes/Base/UIModules/ScoresTable_Server.Script.txt" as UIModules_ScoresTable
#Include "Libs/Nadeo/TMGame/Modes/Base/UIModules/PauseMenuOnline_Server.Script.txt" as UIModules_PauseMenu_Online
#Include "Libs/Nadeo/TMGame/Modes/Base/UIModules/BigMessage_Server.Script.txt" as UIModules_BigMessage
2021-08-06 17:27:21 +02:00
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
// Settings
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
#Setting S_ForceLapsNb 1
#Setting S_RoundsPerMap 1 as _("Number of rounds per map") ///< Number of round to play on one map before going to the next one
2023-07-12 12:04:53 +02:00
#Setting S_AFKIdleTime 120000 as "Time before being an AFK player will be kicked"
2022-03-08 19:01:02 +01:00
#Setting S_IntroTime 5 as "Time of the map intro"
2021-08-06 17:27:21 +02:00
#Setting S_TimeBeforeMalus 10 as "Time Before Malus"
#Setting S_TimeBeforeNightmare 150 as "Time Before Nightmare"
#Setting S_MalusEveryNSecs 10 as "Roll a new Malus every N Sec"
#Setting S_NextMalusPreparationTime 10 as "Time given to players to prepare them before a Malus"
#Setting S_MalusDuration 5 as "Malus Duration"
#Setting S_TrustClientSimu False
#Setting S_UseCrudeExtrapolation False
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
// Constants
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
#Const C_ModeName "LastManStanding"
#Const Description "$zIn $<$t$6F9LastManStanding$> mode, The goal is to be the last player not to fall off the structure. Collisions are activated and you can push your opponents to win. From a certain time, malus are sent to all the players of the game to accelerate its end."
#Const C_HudModulePath "" //< Path to the hud module
2023-09-25 18:59:38 +02:00
#Const C_ManiaAppUrl "file://Media/ManiaApps/Nadeo/Trackmania/Modes/Rounds.Script.txt" //< Url of the mania app
2021-08-06 17:27:21 +02:00
#Const C_FakeUsersNb 0
#Const C_Malus_Reset 0
#Const C_Malus_ForceEngine 1
#Const C_Malus_BackwardOnly 2
#Const C_Malus_NoBrakes 3
#Const C_Malus_NoEngine 4
#Const C_Malus_NoSteer 5
#Const C_Malus_SlowMotion 6
#Const C_Malus_BoostDown 7
#Const C_Malus_BoostUp 8
#Const C_Malus_Boost2Down 9
#Const C_Malus_Boost2Up 10
#Const C_Malus_LockPlayer 11
#Const C_Malus_AccelCoef25 12
#Const C_Malus_AdherenceCoef25 13
#Const C_Malus_ControlCoef25 14
#Const C_Malus_GravityCoef25 15
#Const C_Malus_Nightmare 99
#Const C_Malus_Name [0 => "Reset", 1 => "ForceEngine", 2 => "BackwardOnly" , 3 => "NoBrakes", 4 => "NoEngine",
5 => "NoSteer", 6 => "SlowMotion", 7 => "BoostDown", 8 => "BoostUp",
9 => "SuperBoostDown", 10 => "SuperBoostUp", 11 => "LoseControl",
12 => "25% AccelCoef", 13 => "25% Adherence", 14 => "25% Control",
15 => "25% Gravity", 99 => "NightMare"]
#Struct K_Malus {
Integer Time;
Integer MalusIndex;
}
2021-08-06 17:27:21 +02:00
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
// Extends
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
***Match_LogVersions***
***
Log::RegisterScript(ScriptName, Version);
Log::RegisterScript(StateMgr::ScriptName, StateMgr::Version);
***
***Match_LoadLibraries***
***
StateMgr::Load();
***
***Match_UnloadLibraries***
***
StateMgr::Unload();
***
***Match_Settings***
***
MB_Settings_UseDefaultTimer = False;
MB_Settings_UseDefaultHud = (C_HudModulePath == "");
MB_Settings_UseDefaultPodiumSequence = False;
Rounds_Settings_UseDefaultSpawnManagement = False;
2022-03-08 19:01:02 +01:00
MB_Settings_UseDefaultIntroSequence = False;
2021-08-06 17:27:21 +02:00
***
***Match_Rules***
***
ModeInfo::SetName(C_ModeName);
ModeInfo::SetType(ModeInfo::C_Type_FreeForAll);
ModeInfo::SetRules(Description);
ModeInfo::SetStatusMessage(_("TYPE: Free for all\nOBJECTIVE: Be the last player not to fall off the structure."));
***
***Match_LoadHud***
***
if (C_HudModulePath != "") Hud_Load(C_HudModulePath);
***
***Match_AfterLoadHud***
***
UIManager.UIAll.ScoreTableOnlyManialink = True;
ClientManiaAppUrl = C_ManiaAppUrl;
Race::SortScores(Race::C_Sort_TotalPoints);
UIModules_PauseMenu_Online::SetHelp(Description);
UIManager.UIAll.OverlayHideSpectatorInfos = True;
UIManager.UIAll.OverlayHideCountdown = True;
Markers::SetDefaultMarker_HudVisibility(CUIConfigMarker::EHudVisibility::Always);
UIManager.UIAll.LabelsVisibility = CUIConfig::EHudVisibility::Everything ;
2022-03-08 18:30:10 +01:00
UIModules::UnloadModules(["UIModule_Race_LapsCounter"]);
2022-03-08 18:26:37 +01:00
SetML();
2021-08-06 17:27:21 +02:00
***
***Match_Yield***
***
foreach (Event in PendingEvents) {
switch (Event.Type) {
// Initialize players when they join the server
case CSmModeEvent::EType::OnPlayerAdded: {
StateMgr::InitializePlayer(Event.Player);
CarRank::InitializePlayer(Event.Player);
}
}
}
foreach (Event in UIManager.PendingEvents) {
if (Event.CustomEventType == "LMS_NotifyAFK") {
if (Event.CustomEventData.count > 0) {
UIManager.UIAll.SendChat("$ff9" ^ Event.CustomEventData[0] ^ " has been kicked for being AFK");
}
}
}
2021-08-06 17:27:21 +02:00
StateMgr::Yield();
***
***Match_StartServer***
***
// Initialize mode
Clans::SetClansNb(0);
UsePvPCollisions = True;
UsePvECollisions = True;
StateMgr::ForcePlayersStates([StateMgr::C_State_Waiting]);
WarmUp::SetAvailability(True);
CarRank::Reset();
2023-07-12 13:26:50 +02:00
ResetNetworkVariables();
2021-08-06 17:27:21 +02:00
***
***Match_InitMap***
***
declare Integer Map_ValidRoundsNb;
declare Integer Map_TimeBeforeMalus;
declare Integer Map_TimeBeforeNightmare;
declare Integer Map_MalusEveryNSecs;
declare Integer Map_NextMalusPreparationTime;
declare Integer Map_MalusDuration;
declare Integer Map_RoundsPerMap;
2023-07-10 23:16:10 +02:00
declare Text[] AccountIdsOfPlayers for This = [];
2021-08-06 17:27:21 +02:00
declare Integer LandmarkIndex for This = 0;
declare K_Malus[Text] MalusQueue;
2021-08-06 17:27:21 +02:00
declare Boolean ActiveMalus = False;
declare Boolean PendingMalus = False;
declare Integer NextStepMalusTime = 0;
declare Integer MalusIndex;
declare Integer MalusTime;
2023-07-12 13:26:29 +02:00
declare netwrite Boolean Net_DisplayUI for Teams[0] = False;
2021-08-06 17:27:21 +02:00
declare netwrite Integer Net_NBPlayers for Teams[0] = 0;
declare netwrite Integer Net_PlayersNbAlive for Teams[0] = 0;
declare netwrite Integer Net_NextMalus for Teams[0] = -1;
declare netwrite Integer Net_TimeBeforeMalus for Teams[0] = -1;
declare netwrite Integer Net_RoundsPerMap for Teams[0] = 0;
declare netwrite Integer Net_CurrentRoundNb for Teams[0] = 0;
2022-03-08 19:01:02 +01:00
ResetNetworkVariables();
2023-07-12 22:20:27 +02:00
UIModules_ScoresTable::SetCustomTimes([]);
2022-03-08 19:01:02 +01:00
// Map Intro
2022-03-08 19:57:50 +01:00
declare Boolean MapIsCompatible;
declare CMapLandmark[] Landmarks = Map::GetFinishesAndMultilaps();
foreach (Landmark in Landmarks) {
if (Map::IsMultilap(Landmark)) {
MapIsCompatible = True;
break;
}
2022-03-08 19:01:02 +01:00
}
2022-03-08 19:57:50 +01:00
if (!MapIsCompatible) {
UIManager.UIAll.QueueMessage(3000, 1, CUIConfig::EMessageDisplay::Big, _("This map is not valid"));
MB_Sleep(3000);
MB_StopMap();
} else if (S_IntroTime > 0) {
2023-07-12 13:09:43 +02:00
declare netwrite Boolean Net_LMS_IsIntro for Teams[0] = False;
2022-03-08 19:57:50 +01:00
Net_LMS_IsIntro = True;
StateMgr::ForcePlayersStates([StateMgr::C_State_Waiting]);
if (Map.HasCustomIntro) {
ModeUtils::PushAndApplyUISequence(UIManager.UIAll, CUIConfig::EUISequence::RollingBackgroundIntro);
} else {
ModeUtils::PushAndApplyUISequence(UIManager.UIAll, CUIConfig::EUISequence::Playing);
}
if (MB_MapIsRunning() && AllPlayers.count <= 0) MB_Yield();
2022-03-08 19:57:50 +01:00
declare Integer WaitingScreenDuration = 0;
while (MB_MapIsRunning() && S_IntroTime - WaitingScreenDuration > 0) {
WaitingScreenDuration = WaitingScreenDuration + 1;
MB_Sleep(1000);
}
ModeUtils::PopAndApplyUISequence(UIManager.UIAll);
Net_LMS_IsIntro = False;
}
2021-08-06 17:27:21 +02:00
***
***Match_StartMap***
***
Race::SetRespawnBehaviour(Race::C_RespawnBehaviour_AlwaysGiveUp);
CarRank::Reset();
***
***Match_InitRound***
***
declare Boolean ThrottleUpdate;
***
2021-08-06 17:27:21 +02:00
***Match_StartRound***
***
Scores::Clear();
2023-07-12 22:20:27 +02:00
UIModules_ScoresTable::SetCustomTimes([]);
2021-08-06 17:27:21 +02:00
2023-07-12 12:04:53 +02:00
declare netwrite Integer Net_LMS_AFKIdleTime for Teams[0] = 120000;
Net_LMS_AFKIdleTime = S_AFKIdleTime;
2021-08-06 17:27:21 +02:00
// WorkAround for longloading
2023-07-12 13:09:43 +02:00
declare Integer StartMapTime = Now;
2021-08-06 17:27:21 +02:00
while (Players.count < 2 && Now < (StartMapTime + 3000)) {
MB_Yield();
}
// Initialize race
StartTime = Now + Race::C_SpawnDuration;
Map_TimeBeforeMalus = S_TimeBeforeMalus;
Map_TimeBeforeNightmare = S_TimeBeforeNightmare;
Map_MalusEveryNSecs = S_MalusEveryNSecs;
Map_NextMalusPreparationTime = S_NextMalusPreparationTime;
Map_MalusDuration = S_MalusDuration;
Map_RoundsPerMap = S_RoundsPerMap;
UpdateScoresTableFooter();
MalusTime = GetTimeBeforeMalus(StartTime, S_TimeBeforeMalus, S_TimeBeforeNightmare);
2023-07-12 13:26:29 +02:00
Net_DisplayUI = True;
2021-08-06 17:27:21 +02:00
Net_TimeBeforeMalus = MalusTime;
Net_NextMalus = -1;
Net_RoundsPerMap = Map_RoundsPerMap;
Net_CurrentRoundNb = Map_ValidRoundsNb + 1;
MalusQueue = [];
2021-08-06 17:27:21 +02:00
// Spawn players for the race
---Rounds_CanSpawn---
2023-07-10 23:16:10 +02:00
declare Text[] AccountIdsOfPlayers for This = [];
2022-03-08 19:57:50 +01:00
declare CMapLandmark PlayerLM;
declare Integer LandmarkIndex for This = 0;
2023-07-10 23:16:10 +02:00
AccountIdsOfPlayers = [];
2022-03-08 19:57:50 +01:00
// Suffle Players list to randomise spawn
2023-07-12 12:16:23 +02:00
declare CSmPlayer[Integer] ShuffledPlayers;
foreach (Player in Players) {
declare Integer RandomIndex = 0;
while (RandomIndex == 0 || ShuffledPlayers.existskey(RandomIndex)) {
RandomIndex = ML::Rand(1, 10000);
}
ShuffledPlayers[RandomIndex] = Player;
2022-03-08 19:57:50 +01:00
}
2023-07-12 12:16:23 +02:00
ShuffledPlayers = ShuffledPlayers.sortkey();
Net_NBPlayers = ShuffledPlayers.count;
Net_PlayersNbAlive = Net_NBPlayers;
2022-03-08 19:57:50 +01:00
foreach (Player in ShuffledPlayers) {
2023-07-12 12:16:23 +02:00
if (Player == Null) continue;
2022-03-08 19:57:50 +01:00
PlayerLM = Null;
while (PlayerLM == Null) {
if (LandmarkIndex > Landmarks.count - 1 ) {
LandmarkIndex = 0;
}
if (Map::IsMultilap(Landmarks[LandmarkIndex])) {
PlayerLM = Landmarks[LandmarkIndex];
2021-08-06 17:27:21 +02:00
}
2022-03-08 19:57:50 +01:00
LandmarkIndex = LandmarkIndex + 1 ;
2021-08-06 17:27:21 +02:00
}
2022-03-08 19:57:50 +01:00
Race::Start(Player, PlayerLM , StartTime);
CarRank::SetRank(Player, Net_NBPlayers);
2023-07-10 23:16:10 +02:00
AccountIdsOfPlayers.add(Player.User.WebServicesUserId);
MalusQueue[Player.User.Login] = GetNewMalus(C_Malus_Reset, 1500);
2021-08-06 17:27:21 +02:00
}
2022-03-08 19:57:50 +01:00
UIModules_ScoresTable::DisplayOnly(AccountIdsOfPlayers);
2022-03-08 19:57:50 +01:00
StateMgr::ForcePlayersStates([StateMgr::C_State_Playing]);
Race::EnableIntroDuringMatch(False);
UIManager.UIAll.SendChat("$<$ff3$> Stay the most time on the structure. $<$ff9GL HF!$>");
2021-08-06 17:27:21 +02:00
***
2021-08-06 17:27:21 +02:00
***Match_PlayLoop***
***
// Manage race events
declare Events::K_RaceEvent[] RacePendingEvents = Race::GetPendingEvents();
2021-08-06 17:27:21 +02:00
foreach (Event in RacePendingEvents) {
2022-03-08 17:32:13 +01:00
Race::ValidEvent(Event);
2021-08-06 17:27:21 +02:00
if (Event.Player == Null) continue;
2023-07-13 10:08:33 +02:00
switch (Event.Type) {
case Events::C_Type_Waypoint: {
ThrottleUpdate = True;
Scores::UpdatePlayerBestRaceIfBetter(Event.Player);
2021-08-06 17:27:21 +02:00
Race::StopSkipOutro(Event.Player);
UpdateCustomRanking(Event.Player.User, False);
2021-08-06 17:27:21 +02:00
}
case Events::C_Type_GiveUp: {
ThrottleUpdate = True;
UpdateCustomRanking(Event.Player.User, True);
2021-08-06 17:27:21 +02:00
}
case Events::C_Type_Eliminated: {
ThrottleUpdate = True;
2023-07-14 22:54:53 +02:00
Race::StopSkipOutro(Event.Player);
UpdateCustomRanking(Event.Player.User, True);
}
2021-08-06 17:27:21 +02:00
}
}
// Manage mode events
foreach (Event in PendingEvents) {
if (Event.HasBeenPassed || Event.HasBeenDiscarded) continue;
Events::Invalid(Event);
if (Event.Type == CSmModeEvent::EType::OnPlayerRemoved) {
if (Event.User == Null ) continue;
if (!AccountIdsOfPlayers.exists(Event.User.WebServicesUserId)) continue;
if (IsEliminated(Event.User, Null)) continue;
ThrottleUpdate = True;
UpdateCustomRanking(Event.User, True);
}
2021-08-06 17:27:21 +02:00
}
// Detect when a players count changed without having triggered any of Event (when becoming spectator for example)
if (!ThrottleUpdate && Net_PlayersNbAlive != PlayersNbAlive) {
log("Trying to detect why the player count changed");
foreach (Player in AllPlayers) {
if (Player.User == Null || Player.Score == Null) continue;
if (!AccountIdsOfPlayers.exists(Player.User.WebServicesUserId)) continue;
if (Player.SpawnStatus != CSmPlayer::ESpawnStatus::NotSpawned) continue;
if (IsEliminated(Player.User, Player.Score)) continue;
UpdateCustomRanking(Player.User, True);
ThrottleUpdate = True;
}
2021-08-06 17:27:21 +02:00
}
if (ThrottleUpdate) {
ThrottleUpdate = False;
Net_PlayersNbAlive = PlayersNbAlive;
declare Integer Points = Net_NBPlayers - Net_PlayersNbAlive;
foreach (Player in Players) {
CarRank::SetRank(Player, PlayersNbAlive);
if (Player.SpawnStatus == CSmPlayer::ESpawnStatus::Spawned) {
Scores::SetPlayerRoundPoints(Player.Score, Points);
}
}
}
if (PlayersNbAlive <= 1 && AccountIdsOfPlayers.count >= 2) { //TODO just respawn in case of 1 player
Net_TimeBeforeMalus = -1;
MB_StopRound();
}
2021-08-06 17:27:21 +02:00
// Update the map duration setting
if (Map_TimeBeforeMalus != S_TimeBeforeMalus || Map_TimeBeforeMalus != S_TimeBeforeNightmare || Map_MalusEveryNSecs != S_MalusEveryNSecs || Map_NextMalusPreparationTime != S_NextMalusPreparationTime || Map_MalusDuration != S_MalusDuration || Map_RoundsPerMap != S_RoundsPerMap) {
Map_TimeBeforeMalus = S_TimeBeforeMalus;
Map_TimeBeforeNightmare = S_TimeBeforeNightmare;
Map_MalusEveryNSecs = S_MalusEveryNSecs;
Map_NextMalusPreparationTime = S_NextMalusPreparationTime;
Map_MalusDuration = S_MalusDuration;
Map_RoundsPerMap = S_RoundsPerMap;
Net_RoundsPerMap = Map_RoundsPerMap;
UpdateScoresTableFooter();
MalusTime = GetTimeBeforeMalus(StartTime, S_TimeBeforeMalus, S_TimeBeforeNightmare);
if (NextStepMalusTime == 0) {
Net_TimeBeforeMalus = MalusTime;
}
if (Map_MalusDuration <= 0 || (Map_TimeBeforeMalus < 0 && Map_TimeBeforeNightmare < 0)) {
Net_TimeBeforeMalus = -1;
Net_NextMalus = -1;
}
}
// Run Malus
if (Players.count > 0 && S_MalusDuration > 0 && MalusTime != -1 && Now > MalusTime) {
if (Now > NextStepMalusTime) {
if (!ActiveMalus && !PendingMalus) {
if (S_TimeBeforeNightmare >= 0 && Now > (StartTime + (S_TimeBeforeNightmare * 1000))) {
MalusIndex = C_Malus_Nightmare;
2023-07-13 10:08:33 +02:00
} else if (AllPlayersAreInTurtle()) {
log("All players are in turtle");
MalusIndex = ML::Rand(7, 10); // Boost if all players in Turtle
2021-08-06 17:27:21 +02:00
} else {
2023-07-13 10:08:33 +02:00
MalusIndex = ML::Rand(1, 15);
2021-08-06 17:27:21 +02:00
}
PendingMalus = True;
ActiveMalus = False;
NextStepMalusTime = Now + (S_NextMalusPreparationTime*1000);
// Players UI update
Net_NextMalus = MalusIndex;
Net_TimeBeforeMalus = NextStepMalusTime;
} else if (PendingMalus && !ActiveMalus) {
foreach (Player in Players) {
MalusQueue[Player.User.Login] = GetNewMalus(MalusIndex);
}
2021-08-06 17:27:21 +02:00
PendingMalus = False;
ActiveMalus = True;
NextStepMalusTime = Now + (S_MalusDuration*1000);
2022-03-31 22:32:23 +02:00
UIModules_BigMessage::SetMessage("Current Effect: "^C_Malus_Name[MalusIndex]);
2021-08-06 17:27:21 +02:00
// Players UI update
Net_NextMalus = 0;
Net_TimeBeforeMalus = NextStepMalusTime;
} else if (!PendingMalus && ActiveMalus) {
2023-07-12 13:09:43 +02:00
if (MalusIndex == 99) {
foreach (Player in Players) {
MalusQueue[Player.User.Login] = GetNewMalus(C_Malus_Nightmare);
}
NextStepMalusTime = Now + (S_MalusDuration*1000);
} else {
foreach (Player in Players) {
MalusQueue[Player.User.Login] = GetNewMalus(C_Malus_Reset);
}
2021-08-06 17:27:21 +02:00
PendingMalus = False;
ActiveMalus = False;
NextStepMalusTime = Now + (S_MalusEveryNSecs*1000);
2022-03-31 22:32:23 +02:00
UIModules_BigMessage::SetMessage("");
2021-08-06 17:27:21 +02:00
// Players UI update
Net_NextMalus = -1;
Net_TimeBeforeMalus = NextStepMalusTime;
}
}
}
}
foreach (Login => Malus in MalusQueue) {
declare CSmPlayer Player = GetPlayer(Login);
if (Malus.Time + 1000 < Now) { // Clear old entry
MalusQueue.removekey(Login);
} else if (Player != Null && Malus.Time <= Now && (Player.SpawnStatus == CSmPlayer::ESpawnStatus::Spawned || Player.SpawnStatus == CSmPlayer::ESpawnStatus::Spawning)) {
Log::Log("[ApplyPhysics] Trying to set Event " ^ C_Malus_Name[Malus.MalusIndex] ^ " for " ^ Player.User.Name);
if (SetMalus(Player, Malus.MalusIndex)) {
MalusQueue.removekey(Login);
}
}
}
2021-08-06 17:27:21 +02:00
***
***Match_EndRound***
***
PendingMalus = False;
ActiveMalus = False;
2023-07-12 13:26:29 +02:00
Net_DisplayUI = False;
2021-08-06 17:27:21 +02:00
Net_TimeBeforeMalus = -1;
Net_NextMalus = -1;
Race::StopSkipOutroAll();
StateMgr::ForcePlayersStates([StateMgr::C_State_Waiting]);
if (Round_ForceEndRound || Round_SkipPauseRound) {
// Cancel points
foreach (Score in Scores) {
Scores::SetPlayerRoundPoints(Score, 0);
}
// Do not launch the forced end round sequence after a pause
if (!Round_SkipPauseRound) {
ForcedEndRoundSequence();
}
MB_SetValidRound(False);
2021-08-06 17:27:21 +02:00
} else {
Map_ValidRoundsNb += 1;
declare CSmScore WinnerScore <=> Scores::GetBestPlayer(Scores::C_Sort_RoundPoints);
2022-03-08 19:21:28 +01:00
if (WinnerScore == Null) {
foreach (Score in Scores) {
2023-07-10 23:16:10 +02:00
if (Score.BestRaceTimes.count <= 0 && Score.User != Null && AccountIdsOfPlayers.exists(Score.User.WebServicesUserId)) {
2022-03-08 21:52:19 +01:00
declare CSmPlayer Player = GetPlayer(Score.User.Login);
if (Player != Null && !Player.RequestsSpectate) {
WinnerScore <=> Score;
break;
}
2022-03-08 19:21:28 +01:00
}
}
}
Scores::SetPlayerWinner(WinnerScore);
2023-07-13 10:08:02 +02:00
ModeUtils::PlaySound(CUIConfig::EUISound::EndRound, 0);
2022-03-31 22:32:23 +02:00
2023-07-12 13:09:43 +02:00
if (WinnerScore == Null) {
2022-03-31 22:32:23 +02:00
UIModules_BigMessage::SetMessage(_("|Match|Draw"));
2023-07-12 13:09:43 +02:00
} else {
UIModules_BigMessage::SetMessage(_("$<%1$> wins the match!"), WinnerScore.User.WebServicesUserId);
2021-08-06 17:27:21 +02:00
}
2022-03-08 19:21:28 +01:00
Scores::EndRound();
Race::SortScores(Race::C_Sort_TotalPoints);
2021-08-06 17:27:21 +02:00
MB_Sleep(5000);
2022-03-31 22:32:23 +02:00
UIModules_BigMessage::SetMessage("");
2021-08-06 17:27:21 +02:00
UIManager.UIAll.ScoreTableVisibility = CUIConfig::EVisibility::ForcedVisible;
MB_Sleep((S_ChatTime*1000)/2);
UIManager.UIAll.ScoreTableVisibility = CUIConfig::EVisibility::Normal;
UIManager.UIAll.UISequence = CUIConfig::EUISequence::Playing;
if (MapIsOver(Map_ValidRoundsNb)) MB_StopMatch();
}
***
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
// Functions
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
2023-07-13 10:08:33 +02:00
// Reset Network Variables
2023-07-12 13:26:50 +02:00
Void ResetNetworkVariables() {
declare netwrite Boolean Net_DisplayUI for Teams[0] = False;
Net_DisplayUI = False;
declare netwrite Integer Net_NBPlayers for Teams[0] = 0;
Net_NBPlayers = 0;
declare netwrite Integer Net_PlayersNbAlive for Teams[0] = 0;
Net_PlayersNbAlive = 0;
declare netwrite Integer Net_NextMalus for Teams[0] = -1;
Net_NextMalus = 0;
declare netwrite Integer Net_TimeBeforeMalus for Teams[0] = -1;
Net_TimeBeforeMalus = 0;
declare netwrite Integer Net_RoundsPerMap for Teams[0] = 0;
Net_RoundsPerMap = 0;
declare netwrite Integer Net_CurrentRoundNb for Teams[0] = 0;
Net_CurrentRoundNb = 0;
}
2023-07-13 09:59:44 +02:00
/** Check if a Player is already considered eliminated
*
* @param _User The User
* @param _Score The Score, can be Null but it will search the Score in Scores
*
* @return Return True if the player have a time
*/
Boolean IsEliminated(CUser _User, CSmScore _Score) {
if (UIModules_ScoresTable::GetCustomTimes().existskey(_User.WebServicesUserId)) return True;
if (_Score == Null) {
foreach (Score in Scores) {
if (Score.User == Null) continue;
if (Score.User == _User) {
if (Score.PrevRaceTimes.count > 0) return True;
else return False;
break;
}
}
} else if (_Score.PrevRaceTimes.count > 0) {
return True;
}
return False;
}
2023-07-13 10:08:33 +02:00
/** Detect if all players are in Turtle
*
* @return Return False if one player is not in turtle
*/
Boolean AllPlayersAreInTurtle() {
foreach (Player in Players) {
if (Player.WheelsContactCount > 1 || Player.Speed > 1) {
return False;
}
}
return True;
}
2021-08-06 17:27:21 +02:00
/** Get the Time Before the first Malus or NightMare Mode
*
* @param _StartTime The starting time of the map
* @param _TimeBeforeMalus The time before the first Malus
* @param _TimeBeforeNightmare The time before the NightMare mode
*
* @return The Malus Time or -1 in no Malus
*/
Integer GetTimeBeforeMalus(Integer _StartTime, Integer _TimeBeforeMalus, Integer _TimeBeforeNightmare) {
declare Integer MalusTime;
if (_TimeBeforeMalus >= 0 && (_TimeBeforeMalus < _TimeBeforeNightmare || _TimeBeforeNightmare == -1)) {
MalusTime = _StartTime + (_TimeBeforeMalus * 1000);
} else if (_TimeBeforeNightmare >= 0 && (_TimeBeforeNightmare < _TimeBeforeMalus || _TimeBeforeNightmare == _TimeBeforeMalus || _TimeBeforeMalus == -1)) {
MalusTime = _StartTime + (_TimeBeforeNightmare * 1000);
} else {
MalusTime = -1;
}
return MalusTime;
}
/** Update the Scores Table with hidden custom points
*
* @param _User The User who is eliminated
* @param _OverrideTime Compute time because it not ended the Map
2021-08-06 17:27:21 +02:00
*/
Void UpdateCustomRanking(CUser _User, Boolean _OverrideTime) {
if (_User == Null) return;
if (_OverrideTime) {
2023-07-12 22:20:27 +02:00
declare Integer[Text] CustomTimes = UIModules_ScoresTable::GetCustomTimes();
CustomTimes[_User.WebServicesUserId] = Now - StartTime;
UIModules_ScoresTable::SetCustomTimes(CustomTimes);
2021-08-06 17:27:21 +02:00
}
UIManager.UIAll.SendChat("""$<$ff3$> Player $<$ff9{{{_User.Name}}}$> is eliminated""");
2021-08-06 17:27:21 +02:00
}
/** Update the scores table footer text
*
*/
Void UpdateScoresTableFooter() {
declare Text Footer = "";
if (S_MalusDuration <= 0 || (S_TimeBeforeMalus < 0 && S_TimeBeforeNightmare < 0)) {
Footer ^= "Malus disabled";
} else {
declare Text[] Parts;
2023-07-12 13:09:43 +02:00
declare Text Message = "";
2021-08-06 17:27:21 +02:00
if (S_TimeBeforeMalus >= 0) {
if (Parts.count > 0) Message ^= "\n";
Message ^= """%{{{Parts.count + 1}}}{{{TL::TimeToText(S_TimeBeforeMalus*1000)}}}""";
Parts.add("Time Before Malus: ");
}
if (S_TimeBeforeNightmare >= 0) {
if (Parts.count > 0) Message ^= "\n";
Message ^= """%{{{Parts.count + 1}}}{{{TL::TimeToText(S_TimeBeforeNightmare*1000)}}}""";
Parts.add("Time Before NM: ");
}
switch (Parts.count) {
case 0: Footer = Message;
case 1: Footer = TL::Compose(Message, Parts[0]);
case 2: Footer = TL::Compose(Message, Parts[0], Parts[1]);
}
}
UIModules_ScoresTable::SetFooterInfo(Footer);
}
K_Malus GetNewMalus(Integer _MalusIndex, Integer _Time) {
return K_Malus {
Time = Now + _Time,
MalusIndex = _MalusIndex
};
}
K_Malus GetNewMalus(Integer _MalusIndex) {
return GetNewMalus(_MalusIndex, 0);
}
2021-08-06 17:27:21 +02:00
/** Set Malus to a specific Players
*
* @param _Player Player
* @param _Type Malus Index
*/
Boolean SetMalus(CSmPlayer _Player, Integer _Type) {
if (_Player.SpawnStatus == CSmPlayer::ESpawnStatus::Spawned && !SetPlayer_DelayedIsFull(_Player)) {
2021-08-06 17:27:21 +02:00
if (_Type > 0) {
_Player.Dossard_Color = <1., 0., 0.>;
} else {
_Player.Dossard_Color = <1., 1., 1.>;
}
switch (_Type) {
case C_Malus_Reset: {
SetPlayerVehicle_ControlledByMode(_Player, False);
SetPlayerVehicle_ResetControlledModeValues(_Player);
SetPlayer_Delayed_Reset(_Player);
}
case C_Malus_ForceEngine: {
SetPlayer_Delayed_ForceEngine(_Player,True);
}
case C_Malus_NoEngine: {
SetPlayer_Delayed_NoEngine(_Player,True);
}
case C_Malus_BackwardOnly: {
SetPlayer_Delayed_Cruise(_Player,True,-999.);
}
case C_Malus_NoBrakes: {
SetPlayer_Delayed_NoBrakes(_Player,True);
}
case C_Malus_NoSteer: {
SetPlayer_Delayed_NoSteer(_Player,True);
}
case C_Malus_SlowMotion: {
SetPlayer_Delayed_SlowMotion(_Player,True);
}
case C_Malus_BoostDown: {
SetPlayer_Delayed_BoostDown(_Player,True);
}
case C_Malus_BoostUp: {
SetPlayer_Delayed_BoostUp(_Player,True);
}
case C_Malus_Boost2Down: {
SetPlayer_Delayed_Boost2Down(_Player,True);
}
case C_Malus_Boost2Up: {
SetPlayer_Delayed_Boost2Up(_Player,True);
}
case C_Malus_LockPlayer: {
SetPlayerVehicle_ControlledByMode(_Player, True);
}
case C_Malus_AccelCoef25: {
SetPlayer_Delayed_AccelCoef(_Player,0.25);
}
case C_Malus_AdherenceCoef25: {
SetPlayer_Delayed_AdherenceCoef(_Player,0.25);
}
case C_Malus_ControlCoef25: {
SetPlayer_Delayed_ControlCoef(_Player,0.25);
}
case C_Malus_GravityCoef25: {
SetPlayer_Delayed_GravityCoef(_Player,0.25);
}
// The goal is to kill all Players
case C_Malus_Nightmare: {
SetPlayerVehicle_ControlledByMode(_Player, True);
SetPlayerVehicle_TargetSpeedValue(_Player, ML::Rand(-500.,500.));
SetPlayerVehicle_SteerValue(_Player,ML::Rand(-1.,1.));
SetPlayer_Delayed_Boost2Up(_Player,True);
SetPlayer_Delayed_AdherenceCoef(_Player,0.1);
}
}
return True;
}
return False;
}
/** Set the UI
*
* @param _Player Malus Index
*/
2022-03-08 18:26:37 +01:00
Void SetML() {
2023-07-12 13:09:43 +02:00
declare Real TotalWidth = 44.5;
2021-08-06 17:27:21 +02:00
2021-10-31 12:31:48 +01:00
declare Text MLText = """
2022-03-08 19:57:50 +01:00
<manialink name="LMS_InfoPanel" version="3">
2021-10-31 12:31:48 +01:00
<script><!--
#Include "TextLib" as TL
2021-08-06 17:27:21 +02:00
#Const C_Malus_Reset {{{C_Malus_Reset}}}
#Const C_Malus_ForceEngine {{{C_Malus_ForceEngine}}}
#Const C_Malus_BackwardOnly {{{C_Malus_BackwardOnly}}}
#Const C_Malus_NoBrakes {{{C_Malus_NoBrakes}}}
#Const C_Malus_NoEngine {{{C_Malus_NoEngine}}}
#Const C_Malus_NoSteer {{{C_Malus_NoSteer}}}
#Const C_Malus_SlowMotion {{{C_Malus_SlowMotion}}}
#Const C_Malus_BoostDown {{{C_Malus_BoostDown}}}
#Const C_Malus_BoostUp {{{C_Malus_BoostUp}}}
#Const C_Malus_Boost2Down {{{C_Malus_Boost2Down}}}
#Const C_Malus_Boost2Up {{{C_Malus_Boost2Up}}}
#Const C_Malus_LockPlayer {{{C_Malus_LockPlayer}}}
#Const C_Malus_AccelCoef25 {{{C_Malus_AccelCoef25}}}
#Const C_Malus_AdherenceCoef25 {{{C_Malus_AdherenceCoef25}}}
#Const C_Malus_ControlCoef25 {{{C_Malus_ControlCoef25}}}
#Const C_Malus_GravityCoef25 {{{C_Malus_GravityCoef25}}}
#Const C_Malus_Nightmare {{{C_Malus_Nightmare}}}
#Const C_Malus_Name [{{{C_Malus_Reset}}} => "Reset", {{{C_Malus_ForceEngine}}} => "ForceEngine", {{{C_Malus_BackwardOnly}}} => "Backward Only", {{{C_Malus_NoBrakes}}} => "NoBrakes", {{{C_Malus_NoEngine}}} => "NoEngine" , {{{C_Malus_NoSteer}}} => "NoSteer",
{{{C_Malus_SlowMotion}}} => "SlowMotion", {{{C_Malus_BoostDown}}} => "BoostDown", {{{C_Malus_BoostUp}}} => "BoostUp",
{{{C_Malus_Boost2Down}}} => "SuperBoostDown", {{{C_Malus_Boost2Up}}} => "SuperBoostUp", {{{C_Malus_LockPlayer}}} => "LoseControl",
{{{C_Malus_AccelCoef25}}} => "25% AccelCoef", {{{C_Malus_AdherenceCoef25}}} => "25% Adherence", {{{C_Malus_ControlCoef25}}} => "25% Control",
{{{C_Malus_GravityCoef25}}} => "25% Gravity", {{{C_Malus_Nightmare}}} => "NightMare"]
2021-10-31 12:31:48 +01:00
main() {
2023-07-12 13:26:29 +02:00
declare netread Boolean Net_DisplayUI for Teams[0];
2021-08-06 17:27:21 +02:00
declare netread Integer Net_NBPlayers for Teams[0];
declare netread Integer Net_PlayersNbAlive for Teams[0];
declare netread Integer Net_NextMalus for Teams[0];
declare netread Integer Net_TimeBeforeMalus for Teams[0];
declare netread Integer Net_RoundsPerMap for Teams[0];
declare netread Integer Net_CurrentRoundNb for Teams[0];
2023-07-12 13:26:29 +02:00
declare Boolean Last_DisplayUI;
2021-08-06 17:27:21 +02:00
declare Integer Last_PlayersNbAlive;
declare Integer Last_NextMalus;
declare Integer Last_TimeBeforeMalus;
declare Integer Last_RoundsPerMap;
declare Integer Last_CurrentRoundNb;
declare Boolean NeedUpdateChrono = False;
2023-07-12 13:26:29 +02:00
declare CMlFrame Frame_Global <=> (Page.GetFirstChild("frame-global") as CMlFrame);
declare CMlLabel Label_PlayersAlive <=> (Frame_Global.GetFirstChild("label-playersalive") as CMlLabel);
declare CMlLabel Label_NextMalus <=> (Frame_Global.GetFirstChild("label-nextmalus") as CMlLabel);
declare CMlLabel Label_TimeBeforeMalus <=> (Frame_Global.GetFirstChild("label-timebeforemalus") as CMlLabel);
declare CMlLabel Label_Info_RoundsPerMap <=> (Frame_Global.GetFirstChild("label-info-roundspermap") as CMlLabel);
declare CMlLabel Label_RoundsPerMap <=> (Frame_Global.GetFirstChild("label-roundspermap") as CMlLabel);
2021-08-06 17:27:21 +02:00
2021-10-31 12:31:48 +01:00
while(True) {
2021-08-06 17:27:21 +02:00
yield;
2023-07-12 13:26:29 +02:00
if (Last_DisplayUI != Net_DisplayUI) {
Last_DisplayUI = Net_DisplayUI;
AnimMgr.Flush(Frame_Global);
if (Last_DisplayUI) {
Frame_Global.Visible = True;
AnimMgr.Add(Frame_Global, "<a pos=\"-160 0\"/>", 300, CAnimManager::EAnimManagerEasing::Linear);
} else {
AnimMgr.Add(Frame_Global, "<a hidden=1 pos=\"-225 0\"/>", 300, CAnimManager::EAnimManagerEasing::Linear);
}
}
2021-08-06 17:27:21 +02:00
if (Last_CurrentRoundNb != Net_CurrentRoundNb) {
Last_CurrentRoundNb = Net_CurrentRoundNb;
if (Last_RoundsPerMap > 0) {
Label_RoundsPerMap.Value = Last_CurrentRoundNb^"/"^Last_RoundsPerMap;
}
}
if (Last_RoundsPerMap != Net_RoundsPerMap) {
Last_RoundsPerMap = Net_RoundsPerMap;
if (Last_RoundsPerMap > 0) {
Label_RoundsPerMap.Value = Last_CurrentRoundNb^"/"^Last_RoundsPerMap;
} else {
Label_RoundsPerMap.Value = "Unlimited";
}
}
if (Last_PlayersNbAlive != Net_PlayersNbAlive) {
Last_PlayersNbAlive = Net_PlayersNbAlive;
Label_PlayersAlive.Value = Last_PlayersNbAlive^"/"^Net_NBPlayers;
}
if (Last_NextMalus != Net_NextMalus) {
Last_NextMalus = Net_NextMalus;
if (Last_NextMalus == -1) {
Label_NextMalus.Value = "Nothing";
} else {
Label_NextMalus.Value = C_Malus_Name[Last_NextMalus];
}
}
if (Last_TimeBeforeMalus != Net_TimeBeforeMalus) {
NeedUpdateChrono = True;
Last_TimeBeforeMalus = Net_TimeBeforeMalus;
}
if (Last_TimeBeforeMalus < 0) {
NeedUpdateChrono = False;
Label_TimeBeforeMalus.Value = "--:--.--";
} else if (Last_TimeBeforeMalus < ArenaNow) {
NeedUpdateChrono = False;
Label_TimeBeforeMalus.Value = "00:00.00";
} else {
Label_TimeBeforeMalus.Value = TL::TimeToText(Last_TimeBeforeMalus - ArenaNow , True);
}
2021-10-31 12:31:48 +01:00
}
}
--></script>
2021-08-06 17:27:21 +02:00
<stylesheet>
<style class="text-ingame-text" textfont="GameFontBlack" textcolor="ffffff" textsize="1.5" valign="center2" textprefix="$i$t"/>
<style class="text-ingame-time" textfont="GameFontSemiBold" textcolor="ffffff" textsize="1.25" valign="center2" textprefix="$i$t"/>
<style class="text-ingame-number" textfont="GameFontBlack" textcolor="ffffff" textsize="1.25" valign="center2" textprefix="$i"/>
</stylesheet>
2023-07-12 13:26:29 +02:00
<frame z-index="-2" id="frame-global" size="{{{TotalWidth + 20}}} 180" pos="-225 0" valign="center" hidden=1>
2021-08-06 17:27:21 +02:00
<quad id="quad-info-bg" pos="0 7.75" size="{{{TotalWidth + 4}}} 21" valign="center" z-index="-3" bgcolor="000" opacity="0.5"/>
<label id="label-info-roundspermap" pos="1 15" size="{{{TotalWidth/1.75}}} 10" class="text-ingame-text" text="Rounds" halign="left"/>
<label pos="1 10" size="{{{TotalWidth/1.75}}} 10" class="text-ingame-text" text="Players Alive" halign="left" />
<label pos="1 5" size="{{{TotalWidth/1.75}}} 10" class="text-ingame-text" text="Next Malus" halign="left" />
<label pos="1 0" size="{{{TotalWidth/1.75}}} 10" class="text-ingame-text" text="Next Step in" halign="left" />
<label id="label-roundspermap" pos="{{{TotalWidth + 2}}} 15" size="{{{TotalWidth/2.}}} 10" class="text-ingame-number" halign="right" text="Unlimited"/>
<label id="label-playersalive" pos="{{{TotalWidth + 2}}} 10" size="{{{TotalWidth/2.}}} 10" class="text-ingame-number" halign="right"/>
<label id="label-nextmalus" pos="{{{TotalWidth + 2}}} 5" size="{{{TotalWidth/2.}}} 10" class="text-ingame-number" halign="right" text="Nothing"/>
<label id="label-timebeforemalus" pos="{{{TotalWidth + 2}}} 0" size="{{{TotalWidth/2.}}} 10" class="text-ingame-time" halign="right" text="--:--.--"/>
</frame>
2021-10-31 12:31:48 +01:00
</manialink>
2021-08-06 17:27:21 +02:00
""";
2022-03-08 19:57:50 +01:00
Layers::Create("LMS_InfoPanel", MLText);
Layers::SetType("LMS_InfoPanel", CUILayer::EUILayerType::Normal);
Layers::Attach("LMS_InfoPanel");
MLText = """
<manialink name="LMS_MapInfo" version="3">
<script><!--
#Include "TextLib" as TL
main() {
declare netread Boolean Net_LMS_IsIntro for Teams[0];
declare Boolean Last_IsIntro;
declare CMlFrame Frame_Global = (Page.GetFirstChild("frame-global") as CMlFrame);
declare CMlLabel Label_MapInfo_Name = (Page.GetFirstChild("label-mapinfo-name") as CMlLabel);
declare CMlLabel Label_MapInfo_Author = (Page.GetFirstChild("label-mapinfo-author") as CMlLabel);
while(True) {
yield;
if (Last_IsIntro != Net_LMS_IsIntro) {
Last_IsIntro = Net_LMS_IsIntro;
if (Last_IsIntro) {
Label_MapInfo_Name.Value = Map.MapName;
Label_MapInfo_Author.Value = "by " ^ Map.AuthorNickName;
AnimMgr.Flush(Frame_Global);
AnimMgr.Add(Frame_Global, "<anim hidden=\"0\" pos=\"0 60\"/>", 200 , CAnimManager::EAnimManagerEasing::SineInOut);
} else {
AnimMgr.Flush(Frame_Global);
AnimMgr.Add(Frame_Global, "<anim hidden=\"1\" pos=\"0 115\"/>", 200 , CAnimManager::EAnimManagerEasing::SineInOut);
}
}
}
}
--></script>
<stylesheet>
<style class="text" textfont="GameFontBlack" textcolor="ffffffff" textsize="8" valign="center2" halign="center"/>
</stylesheet>
<frame id="frame-global" pos="0 115" hidden="1">
<quad size="150 25" halign="center" z-index="-1" bgcolor="000" opacity="0.7"/>
<label id="label-mapinfo-name" class="text" pos="0 -8" size="140 10"/>
<label id="label-mapinfo-author" class="text" pos="0 -18" size="140 10" textsize="6"/>
</frame>
</manialink>
""";
Layers::Create("LMS_MapInfo", MLText);
Layers::SetType("LMS_MapInfo", CUILayer::EUILayerType::Normal);
Layers::Attach("LMS_MapInfo");
2023-07-12 12:04:53 +02:00
MLText = """
<manialink name="LMS_AFKManager" version="3">
<script><!--
#Include "MathLib" as ML
main() {
declare CMlFrame Frame_Global = (Page.GetFirstChild("frame-global") as CMlFrame);
wait(InputPlayer != Null);
declare netread Integer Net_LMS_AFKIdleTime for Teams[0] = 120000;
declare Integer Last_AFKIdleTime;
declare Integer Last_AFKDisplayTime;
declare Integer Last_NextCheck;
while(True) {
yield;
if (Now > Last_NextCheck) {
Last_NextCheck = Now + 500;
if (Last_AFKIdleTime != Net_LMS_AFKIdleTime) {
Last_AFKIdleTime = Net_LMS_AFKIdleTime;
Last_AFKDisplayTime = Last_AFKIdleTime - ML::Clamp(ML::FloorInteger(Net_LMS_AFKIdleTime * 0.33), 3000, 20000);
}
// Check if player is AFK or not
if (Last_AFKIdleTime > 0 && Input.TimeSinceLatestActivity > Last_AFKIdleTime) {
2023-07-12 12:04:53 +02:00
log("Player is AFK");
SendCustomEvent("LMS_NotifyAFK", [InputPlayer.User.Name]);
sleep(200); // Ensure that the Event is send to the server before leaving
2023-07-12 12:04:53 +02:00
Playground.QuitServer(False);
} else if (Last_AFKIdleTime > 0 && Input.TimeSinceLatestActivity > Last_AFKDisplayTime) {
2023-07-12 12:04:53 +02:00
Frame_Global.Visible = True;
} else {
Frame_Global.Visible = False;
}
}
}
}
--></script>
<stylesheet>
<style class="text" textfont="GameFontBlack" textcolor="ffffffff" textsize="8" valign="center2" halign="center"/>
</stylesheet>
<frame id="frame-global" pos="0 40" hidden="1">
<quad size="150 35" halign="center" z-index="-1" bgcolor="000" opacity="0.7"/>
<label class="text" pos="0 -8" size="140 10" text="AFK Warning"/>
<label class="text" pos="0 -21.5" size="140 20" autonewline=1 textsize="4" text="Move your mouse or press a key on your keyboard or gamepad to prevent to be kicked"/>
</frame>
</manialink>
""";
Layers::Create("LMS_AFKManager", MLText);
Layers::SetType("LMS_AFKManager", CUILayer::EUILayerType::Normal);
Layers::Attach("LMS_AFKManager");
2021-08-06 17:27:21 +02:00
}
/** Check if we should go to the next map
*
* @param _ValidRoundsNb Number of valid rounds played
*
* @return True if it is the case, false otherwise
*/
Boolean MapIsOver(Integer _ValidRoundsNb) {
if (S_RoundsPerMap > 0 && _ValidRoundsNb >= S_RoundsPerMap) return True; //< There is a rounds limit and it is reached
return False;
}