From 8204aba4ff4105da62203bf3f397a61df2743fdd Mon Sep 17 00:00:00 2001 From: Beu Date: Sun, 29 Aug 2021 18:04:36 +0200 Subject: [PATCH] * Add support of CustomTimes to sort player & interface * Change how the points are distributed * Add a copy of the Rounds SmallScoresTable UI patched to support CustomTimes --- TM_RoyalRounds_Online.Script.txt | 327 ++++++++++++++++++++++++++++--- 1 file changed, 303 insertions(+), 24 deletions(-) diff --git a/TM_RoyalRounds_Online.Script.txt b/TM_RoyalRounds_Online.Script.txt index fbd3d6a..5aa2a65 100644 --- a/TM_RoyalRounds_Online.Script.txt +++ b/TM_RoyalRounds_Online.Script.txt @@ -22,13 +22,15 @@ #Include "Libs/Nadeo/ModeLibs/Common/Utils.Script.txt" as ModeUtils #Include "Libs/Nadeo/TMNext/TrackMania/Menu/Constants.Script.txt" as MenuConsts -#Include "Libs/Nadeo/TMNext/TrackMania/Modes/Rounds/StateManager.Script.txt" as StateMgr +#Include "Libs/Nadeo/TMxSM/Race/StateManager.Script.txt" as StateMgr #Include "ManiaApps/Nadeo/TMxSM/Race/UIModules/ScoresTable_Server.Script.txt" as UIModules_ScoresTable #Include "ManiaApps/Nadeo/TMxSM/Race/UIModules/PauseMenuOnline_Server.Script.txt" as UIModules_PauseMenu_Online #Include "ManiaApps/Nadeo/TMxSM/Race/UIModules/Checkpoint_Server.Script.txt" as UIModules_Checkpoint #Include "ManiaApps/Nadeo/TMxSM/Race/UIModules/BigMessage_Server.Script.txt" as UIModules_BigMessage #Include "ManiaApps/Nadeo/TMxSM/Race/UIModules/Chrono_Server.Script.txt" as UIModules_Chrono +// For the ML +#Include "Libs/Nadeo/ModeLibs/TrackMania/MV_Utils.Script.txt" as MV_Utils // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // Settings @@ -54,7 +56,7 @@ #Const Description _("$zIn $<$t$6F9RoyalRounds$z$z$> mode, the goal is to win a maximum number of $<$t$6F9points.\n\n$z$>The rounds mode consists of $<$t$6F9a series of races$z$>.\nWhen you finish a race in a good $<$t$6F9position$z$>, you get $<$t$6F9points$z$>, added to your total.\n\nThe $<$t$6F9winner$z$> is the first player whose total reaches the $<$t$6F9point limit$z$> (30 for example).") #Const C_HudModulePath "" //< Path to the hud module -#Const C_ManiaAppUrl "file://Media/ManiaApps/Nadeo/TMNext/TrackMania/Rounds/Rounds.Script.txt" //< Url of the mania app +#Const C_ManiaAppUrl "file://Media/ManiaApps/Nadeo/TMNext/TrackMania/TimeAttack/TimeAttack.Script.txt" //< Url of the mania app #Const C_FakeUsersNb 0 @@ -158,6 +160,8 @@ UIManager.UIAll.OverlayHideSpectatorControllers = True; UIManager.UIAll.OverlayHideSpectatorInfos = True; UIManager.UIAll.OverlayHideChrono = True; UIManager.UIAll.OverlayHideCountdown = True; + +SetML(Null); *** ***Match_Yield*** @@ -276,7 +280,8 @@ if (Map_Starts.count > 0) { // the first step without the second. declare Integer WaitingScreenDuration = S_RoundWaitingScreenDuration; if (WaitingScreenDuration >= 0) { - ModeUtils::PushAndApplyUISequence(UIManager.UIAll, CUIConfig::EUISequence::RollingBackgroundIntro); + //ModeUtils::PushAndApplyUISequence(UIManager.UIAll, CUIConfig::EUISequence::RollingBackgroundIntro); <-- Block Cam 7 during the waiting + ModeUtils::PushAndApplyUISequence(UIManager.UIAll, CUIConfig::EUISequence::Playing); // <-- Allow Cam 7 during the waiting // Wait for the connection of the first valid player to start the countdown while (MB_MapIsRunning() && AllPlayers.count <= 0) { @@ -325,6 +330,8 @@ MB_WarmUp(S_WarmUpNb, S_WarmUpDuration * 1000, S_WarmUpTimeout * 1000); declare Boolean Round_ForceEndRound = False; declare Boolean Round_SkipPauseRound = False; //< Skip the current round after the pause declare Boolean Round_Skipped = True; //< Round skipped for another reason + +declare Integer[Text] CustomTimes for This = []; *** ***Match_StartRound*** @@ -370,6 +377,8 @@ StateMgr::ForcePlayersStates([StateMgr::C_State_Playing]); foreach (Player in Players) { declare Integer CurrentSegment for Player.Score = 1; CurrentSegment = 1; + declare Integer RealTime for Player.Score = 0; + RealTime = 0; Player.LandmarkOrderSelector_Race = CurrentSegment; declare Boolean ModeRounds_CanSpawn for Player.Score = Rounds_Settings_CanSpawnDefault; ModeRounds_CanSpawn = False; @@ -432,9 +441,10 @@ foreach (Event in RacePendingEvents) { declare Boolean ModeRounds_CanSpawn for Event.Player.Score = Rounds_Settings_CanSpawnDefault; ModeRounds_CanSpawn = True; } else { - Scores::UpdatePlayerBestRaceIfBetter(Event.Player); + declare Integer RealTime for Event.Player.Score = 0; + RealTime = Event.Player.StartTime - StartTime + Event.RaceTime; Scores::UpdatePlayerPrevRace(Event.Player); - ComputeLatestRaceScores(); + UpdateCustomRanking(Event.Player); Race::SortScores(Race::C_Sort_TotalPoints); if (EndTime <= 0) { EndTime = GetFinishTimeout(S_FinishTimeout); @@ -523,7 +533,7 @@ if (Round_ForceEndRound || Round_SkipPauseRound || Round_Skipped) { } else { Map_ValidRoundsNb += 1; // Get the last round points - ComputeLatestRaceScores(); + UpdateCustomRanking(Null); Race::SortScores(Race::C_Sort_TotalPoints); UIManager.UIAll.ScoreTableVisibility = CUIConfig::EVisibility::ForcedVisible; UIManager.UIAll.UISequence = CUIConfig::EUISequence::EndRound; @@ -540,6 +550,7 @@ if (Round_ForceEndRound || Round_SkipPauseRound || Round_Skipped) { MB_StopMap(); } } +CustomTimes.clear(); *** ***Match_EndMap*** @@ -617,30 +628,43 @@ Integer GetFinishTimeout(Integer _FinishTimeout) { return Now + FinishTimeout; } -// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // -/// Compute the latest race scores -Void ComputeLatestRaceScores() { - Race::SortScores(Race::C_Sort_PrevRaceTime); - - // Points distributed between all players - declare Integer I = 0; +Void SetCustomTimes(Integer[Text] _CustomTimes) { + declare netwrite Integer[Text] Net_Rounds_SmallScoresTable_CustomTimes for Teams[0]; + declare netwrite Integer Net_Rounds_SmallScoresTable_CustomTimesUpdate for Teams[0]; + Net_Rounds_SmallScoresTable_CustomTimes = _CustomTimes; + Net_Rounds_SmallScoresTable_CustomTimesUpdate = Now; +} + +/** Update the Scores Table with Real Time + * + * @param _Player The Player who end the round + */ + Void UpdateCustomRanking(CSmPlayer _Player) { + declare Integer[Text] CustomTimes for This; declare Integer[] PointsRepartition = PointsRepartition::GetPointsRepartition(); - foreach (Score in Scores) { - if (Scores::GetPlayerPrevRaceTime(Score) > 0) { + + if (_Player != Null) { + declare Integer RealTime for _Player.Score; + CustomTimes[_Player.User.WebServicesUserId] = RealTime; + } + + if (PointsRepartition.count > 0) { + CustomTimes = CustomTimes.sort(); + declare Integer I = 0; + foreach (ID => Time in CustomTimes) { + declare CSmPlayer Player = ModeUtils::GetPlayerFromAccountId(ID); + if (Player == Null) continue; declare Integer Points = 0; - if (PointsRepartition.count > 0) { - if (PointsRepartition.existskey(I)) { - Points = PointsRepartition[I]; - } else { - Points = PointsRepartition[PointsRepartition.count - 1]; - } + if (PointsRepartition.existskey(I)) { + Points = PointsRepartition[I]; + } else { + Points = PointsRepartition[PointsRepartition.count - 1]; } - Scores::SetPlayerRoundPoints(Score, Points); + Scores::SetPlayerRoundPoints(Player.Score, Points); I += 1; - } else { - Scores::SetPlayerRoundPoints(Score, 0); } } + SetCustomTimes(CustomTimes); } // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // @@ -750,4 +774,259 @@ Void ForcedEndRoundSequence() { UIManager.UIAll.BigMessageSound = PrevBigMessageSound; UIManager.UIAll.BigMessage = PrevBigMessage; UIManager.UIAll.UISequence = PrevUISequence; +} + +/** Set the UI + * + * @param _Player Malus Index + */ + Void SetML(CSmPlayer _Player) { + declare TotalWidth = 44.5; + + declare Text MLText = """ + + + + +