Compare commits
	
		
			3 Commits
		
	
	
		
			cea0b402f9
			...
			e78d7f411a
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| e78d7f411a | |||
| 3cabb3bce9 | |||
| bd358b7acb | 
@@ -4,7 +4,7 @@
 | 
				
			|||||||
#Extends "Libs/Nadeo/TMNext/TrackMania/Modes/TMNextRoundsBase.Script.txt"
 | 
					#Extends "Libs/Nadeo/TMNext/TrackMania/Modes/TMNextRoundsBase.Script.txt"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#Const	CompatibleMapTypes	"TrackMania\\TM_Race,TM_Race"
 | 
					#Const	CompatibleMapTypes	"TrackMania\\TM_Race,TM_Race"
 | 
				
			||||||
#Const	Version							"2022-03-08"
 | 
					#Const	Version							"2023-07-10"
 | 
				
			||||||
#Const	ScriptName					"Modes/TM2020-Gamemodes/LastManStanding.Script.txt"
 | 
					#Const	ScriptName					"Modes/TM2020-Gamemodes/LastManStanding.Script.txt"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
 | 
					// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
 | 
				
			||||||
@@ -12,6 +12,7 @@
 | 
				
			|||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
 | 
					// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
 | 
				
			||||||
#Include "TextLib" as TL
 | 
					#Include "TextLib" as TL
 | 
				
			||||||
#Include "MathLib" as ML
 | 
					#Include "MathLib" as ML
 | 
				
			||||||
 | 
					#Include "Libs/Nadeo/ModeLibs/Common/AFK_Server.Script.txt" as AFK
 | 
				
			||||||
#Include "Libs/Nadeo/TMNext/TrackMania/Modes/Rounds/StateManager.Script.txt" as StateMgr
 | 
					#Include "Libs/Nadeo/TMNext/TrackMania/Modes/Rounds/StateManager.Script.txt" as StateMgr
 | 
				
			||||||
#Include "Libs/Nadeo/TMNext/TrackMania/Menu/Constants.Script.txt" as MenuConsts
 | 
					#Include "Libs/Nadeo/TMNext/TrackMania/Menu/Constants.Script.txt" as MenuConsts
 | 
				
			||||||
#Include "Libs/Nadeo/ModeLibs/Common/Utils.Script.txt" as ModeUtils
 | 
					#Include "Libs/Nadeo/ModeLibs/Common/Utils.Script.txt" as ModeUtils
 | 
				
			||||||
@@ -27,6 +28,9 @@
 | 
				
			|||||||
#Setting S_ForceLapsNb 1
 | 
					#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
 | 
					#Setting S_RoundsPerMap 1 as _("Number of rounds per map") ///< Number of round to play on one map before going to the next one
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#Setting S_AFKIdleTime 10000 as "Time before being an AFK player will be kicked"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#Setting S_IntroTime 5 as "Time of the map intro"
 | 
					#Setting S_IntroTime 5 as "Time of the map intro"
 | 
				
			||||||
#Setting S_TimeBeforeMalus 10 as "Time Before Malus"
 | 
					#Setting S_TimeBeforeMalus 10 as "Time Before Malus"
 | 
				
			||||||
#Setting S_TimeBeforeNightmare 150 as "Time Before Nightmare"
 | 
					#Setting S_TimeBeforeNightmare 150 as "Time Before Nightmare"
 | 
				
			||||||
@@ -88,11 +92,17 @@ Log::RegisterScript(StateMgr::ScriptName, StateMgr::Version);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
***Match_LoadLibraries***
 | 
					***Match_LoadLibraries***
 | 
				
			||||||
***
 | 
					***
 | 
				
			||||||
 | 
					AFK::Load();
 | 
				
			||||||
 | 
					AFK::SetCheckCP(False); // No CP in LMS
 | 
				
			||||||
 | 
					AFK::SetIdleTimeLimit(S_AFKIdleTime);
 | 
				
			||||||
 | 
					AFK::SetSpawnTimeLimit(3000);
 | 
				
			||||||
 | 
					AFK::SetCheckInterval(3000);
 | 
				
			||||||
StateMgr::Load();
 | 
					StateMgr::Load();
 | 
				
			||||||
***
 | 
					***
 | 
				
			||||||
 | 
					
 | 
				
			||||||
***Match_UnloadLibraries***
 | 
					***Match_UnloadLibraries***
 | 
				
			||||||
***
 | 
					***
 | 
				
			||||||
 | 
					AFK::Unload();
 | 
				
			||||||
StateMgr::Unload();
 | 
					StateMgr::Unload();
 | 
				
			||||||
***
 | 
					***
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -149,6 +159,7 @@ foreach (Event in PendingEvents) {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					AFK::Yield();
 | 
				
			||||||
StateMgr::Yield();
 | 
					StateMgr::Yield();
 | 
				
			||||||
***
 | 
					***
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -175,7 +186,7 @@ declare Integer Map_NextMalusPreparationTime;
 | 
				
			|||||||
declare Integer Map_MalusDuration;
 | 
					declare Integer Map_MalusDuration;
 | 
				
			||||||
declare Integer Map_RoundsPerMap;
 | 
					declare Integer Map_RoundsPerMap;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
declare Text[] AccountIdsOfPlayers for This = [];
 | 
					declare Text[] LoginsOfPlayers for This = [];
 | 
				
			||||||
declare Integer LandmarkIndex for This = 0;
 | 
					declare Integer LandmarkIndex for This = 0;
 | 
				
			||||||
declare Integer[Text] CustomTimes for This = [];
 | 
					declare Integer[Text] CustomTimes for This = [];
 | 
				
			||||||
declare K_Malus[Text] MalusQueue;
 | 
					declare K_Malus[Text] MalusQueue;
 | 
				
			||||||
@@ -265,11 +276,11 @@ MalusQueue = [];
 | 
				
			|||||||
// Spawn players for the race
 | 
					// Spawn players for the race
 | 
				
			||||||
---Rounds_CanSpawn---
 | 
					---Rounds_CanSpawn---
 | 
				
			||||||
 | 
					
 | 
				
			||||||
declare Text[] AccountIdsOfPlayers for This = [];
 | 
					declare Text[] LoginsOfPlayers for This = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
declare CMapLandmark PlayerLM;
 | 
					declare CMapLandmark PlayerLM;
 | 
				
			||||||
declare Integer LandmarkIndex for This = 0;
 | 
					declare Integer LandmarkIndex for This = 0;
 | 
				
			||||||
AccountIdsOfPlayers = [];
 | 
					LoginsOfPlayers = [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Suffle Players list to randomise spawn
 | 
					// Suffle Players list to randomise spawn
 | 
				
			||||||
declare CSmPlayer[] ShuffledPlayers = Players;
 | 
					declare CSmPlayer[] ShuffledPlayers = Players;
 | 
				
			||||||
@@ -299,11 +310,11 @@ foreach (Player in ShuffledPlayers) {
 | 
				
			|||||||
		LandmarkIndex = LandmarkIndex + 1 ;
 | 
							LandmarkIndex = LandmarkIndex + 1 ;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	Race::Start(Player, PlayerLM , StartTime);
 | 
						Race::Start(Player, PlayerLM , StartTime);
 | 
				
			||||||
	AccountIdsOfPlayers.add(Player.User.WebServicesUserId);
 | 
						LoginsOfPlayers.add(Player.User.Login);
 | 
				
			||||||
	MalusQueue[Player.User.WebServicesUserId] = GetNewMalus(C_Malus_Reset, 1500);
 | 
						MalusQueue[Player.User.Login] = GetNewMalus(C_Malus_Reset, 1500);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Net_NBPlayers = AccountIdsOfPlayers.count;
 | 
					Net_NBPlayers = LoginsOfPlayers.count;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
UpdateCustomRanking(Null, -1);
 | 
					UpdateCustomRanking(Null, -1);
 | 
				
			||||||
StateMgr::ForcePlayersStates([StateMgr::C_State_Playing]);
 | 
					StateMgr::ForcePlayersStates([StateMgr::C_State_Playing]);
 | 
				
			||||||
@@ -324,7 +335,7 @@ MalusQueue = [];
 | 
				
			|||||||
if (!RankInitialized) {
 | 
					if (!RankInitialized) {
 | 
				
			||||||
	RankInitialized = True;
 | 
						RankInitialized = True;
 | 
				
			||||||
	Net_PlayersNbAlive = PlayersNbAlive;
 | 
						Net_PlayersNbAlive = PlayersNbAlive;
 | 
				
			||||||
	Net_NBPlayers = AccountIdsOfPlayers.count;
 | 
						Net_NBPlayers = LoginsOfPlayers.count;
 | 
				
			||||||
	foreach (Player in Players) {
 | 
						foreach (Player in Players) {
 | 
				
			||||||
		CarRank::SetRank(Player, PlayersNbAlive);
 | 
							CarRank::SetRank(Player, PlayersNbAlive);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -337,7 +348,7 @@ if (Now < StartTime + 3000) {
 | 
				
			|||||||
	declare CMapLandmark PlayerLM = Null;
 | 
						declare CMapLandmark PlayerLM = Null;
 | 
				
			||||||
	if (PlayersNbDead >= 1) {
 | 
						if (PlayersNbDead >= 1) {
 | 
				
			||||||
		foreach (Player in Players) {
 | 
							foreach (Player in Players) {
 | 
				
			||||||
			if (Player.SpawnStatus == CSmPlayer::ESpawnStatus::NotSpawned && !AccountIdsOfPlayers.exists(Player.User.WebServicesUserId)) {
 | 
								if (Player.SpawnStatus == CSmPlayer::ESpawnStatus::NotSpawned && !LoginsOfPlayers.exists(Player.User.Login)) {
 | 
				
			||||||
				PlayerSpawned = True;
 | 
									PlayerSpawned = True;
 | 
				
			||||||
				PlayerLM = Null;
 | 
									PlayerLM = Null;
 | 
				
			||||||
				while (PlayerLM == Null) {
 | 
									while (PlayerLM == Null) {
 | 
				
			||||||
@@ -350,15 +361,15 @@ if (Now < StartTime + 3000) {
 | 
				
			|||||||
					LandmarkIndex = LandmarkIndex + 1 ;
 | 
										LandmarkIndex = LandmarkIndex + 1 ;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				Race::Start(Player, PlayerLM , StartTime);
 | 
									Race::Start(Player, PlayerLM , StartTime);
 | 
				
			||||||
				AccountIdsOfPlayers.add(Player.User.WebServicesUserId);
 | 
									LoginsOfPlayers.add(Player.User.Login);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				MalusQueue[Player.User.WebServicesUserId] = GetNewMalus(C_Malus_Reset);
 | 
									MalusQueue[Player.User.Login] = GetNewMalus(C_Malus_Reset);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (PlayerSpawned) {
 | 
						if (PlayerSpawned) {
 | 
				
			||||||
		PlayerSpawned = False;
 | 
							PlayerSpawned = False;
 | 
				
			||||||
		Net_NBPlayers = AccountIdsOfPlayers.count;
 | 
							Net_NBPlayers = LoginsOfPlayers.count;
 | 
				
			||||||
		Net_PlayersNbAlive = PlayersNbAlive;
 | 
							Net_PlayersNbAlive = PlayersNbAlive;
 | 
				
			||||||
		UpdateCustomRanking(Null, -1);
 | 
							UpdateCustomRanking(Null, -1);
 | 
				
			||||||
		foreach (Player in Players) {
 | 
							foreach (Player in Players) {
 | 
				
			||||||
@@ -404,7 +415,7 @@ foreach (Event in PendingEvents) {
 | 
				
			|||||||
	Events::Invalid(Event);
 | 
						Events::Invalid(Event);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if (PlayersNbAlive <= 1 && AccountIdsOfPlayers.count >= 2) { //TODO just respawn in case of 1 player
 | 
					if (PlayersNbAlive <= 1 && LoginsOfPlayers.count >= 2) { //TODO just respawn in case of 1 player
 | 
				
			||||||
	Net_TimeBeforeMalus = -1;
 | 
						Net_TimeBeforeMalus = -1;
 | 
				
			||||||
	MB_StopRound();
 | 
						MB_StopRound();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -460,7 +471,7 @@ if (Players.count > 0 && S_MalusDuration > 0 && MalusTime != -1 && Now > MalusTi
 | 
				
			|||||||
			Net_TimeBeforeMalus = NextStepMalusTime;
 | 
								Net_TimeBeforeMalus = NextStepMalusTime;
 | 
				
			||||||
		} else if (PendingMalus && !ActiveMalus) {
 | 
							} else if (PendingMalus && !ActiveMalus) {
 | 
				
			||||||
			foreach (Player in Players) {
 | 
								foreach (Player in Players) {
 | 
				
			||||||
				MalusQueue[Player.User.WebServicesUserId] = GetNewMalus(MalusIndex);
 | 
									MalusQueue[Player.User.Login] = GetNewMalus(MalusIndex);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			PendingMalus = False;
 | 
								PendingMalus = False;
 | 
				
			||||||
			ActiveMalus = True;
 | 
								ActiveMalus = True;
 | 
				
			||||||
@@ -475,7 +486,7 @@ if (Players.count > 0 && S_MalusDuration > 0 && MalusTime != -1 && Now > MalusTi
 | 
				
			|||||||
		} else if (!PendingMalus && ActiveMalus) {
 | 
							} else if (!PendingMalus && ActiveMalus) {
 | 
				
			||||||
			if (MalusIndex != 99) {
 | 
								if (MalusIndex != 99) {
 | 
				
			||||||
				foreach (Player in Players) {
 | 
									foreach (Player in Players) {
 | 
				
			||||||
					MalusQueue[Player.User.WebServicesUserId] = GetNewMalus(C_Malus_Reset);
 | 
										MalusQueue[Player.User.Login] = GetNewMalus(C_Malus_Reset);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				PendingMalus = False;
 | 
									PendingMalus = False;
 | 
				
			||||||
				ActiveMalus = False;
 | 
									ActiveMalus = False;
 | 
				
			||||||
@@ -490,7 +501,7 @@ if (Players.count > 0 && S_MalusDuration > 0 && MalusTime != -1 && Now > MalusTi
 | 
				
			|||||||
				Net_TimeBeforeMalus = NextStepMalusTime;
 | 
									Net_TimeBeforeMalus = NextStepMalusTime;
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
				foreach (Player in Players) {
 | 
									foreach (Player in Players) {
 | 
				
			||||||
					MalusQueue[Player.User.WebServicesUserId] = GetNewMalus(C_Malus_Nightmare);
 | 
										MalusQueue[Player.User.Login] = GetNewMalus(C_Malus_Nightmare);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				NextStepMalusTime = Now + (S_MalusDuration*1000);
 | 
									NextStepMalusTime = Now + (S_MalusDuration*1000);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
@@ -498,14 +509,14 @@ if (Players.count > 0 && S_MalusDuration > 0 && MalusTime != -1 && Now > MalusTi
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
foreach (AccountId => Malus in MalusQueue) {
 | 
					foreach (Login => Malus in MalusQueue) {
 | 
				
			||||||
	declare CSmPlayer Player = ModeUtils::GetPlayerFromAccountId(AccountId);
 | 
						declare CSmPlayer Player = GetPlayer(Login);
 | 
				
			||||||
	if (Malus.Time + 1000 < Now) { // Clear old entry
 | 
						if (Malus.Time + 1000 < Now) { // Clear old entry
 | 
				
			||||||
		MalusQueue.removekey(AccountId);
 | 
							MalusQueue.removekey(Login);
 | 
				
			||||||
	} else if (Player != Null && Malus.Time <= Now && (Player.SpawnStatus == CSmPlayer::ESpawnStatus::Spawned || Player.SpawnStatus == CSmPlayer::ESpawnStatus::Spawning)) {
 | 
						} 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);
 | 
							Log::Log("[ApplyPhysics] Trying to set Event " ^ C_Malus_Name[Malus.MalusIndex] ^ " for " ^ Player.User.Name);
 | 
				
			||||||
		if (SetMalus(Player, Malus.MalusIndex)) {
 | 
							if (SetMalus(Player, Malus.MalusIndex)) {
 | 
				
			||||||
			MalusQueue.removekey(AccountId);
 | 
								MalusQueue.removekey(Login);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -538,7 +549,7 @@ if (Round_ForceEndRound || Round_SkipPauseRound) {
 | 
				
			|||||||
	declare CSmScore WinnerScore <=> Scores::GetBestPlayer(Scores::C_Sort_RoundPoints);
 | 
						declare CSmScore WinnerScore <=> Scores::GetBestPlayer(Scores::C_Sort_RoundPoints);
 | 
				
			||||||
	if (WinnerScore == Null) {
 | 
						if (WinnerScore == Null) {
 | 
				
			||||||
		foreach (Score in Scores) {
 | 
							foreach (Score in Scores) {
 | 
				
			||||||
			if (Score.BestRaceTimes.count <= 0 && Score.User != Null && AccountIdsOfPlayers.exists(Score.User.WebServicesUserId)) {
 | 
								if (Score.BestRaceTimes.count <= 0 && Score.User != Null && LoginsOfPlayers.exists(Score.User.Login)) {
 | 
				
			||||||
				declare CSmPlayer Player = GetPlayer(Score.User.Login);
 | 
									declare CSmPlayer Player = GetPlayer(Score.User.Login);
 | 
				
			||||||
				if (Player != Null && !Player.RequestsSpectate) {
 | 
									if (Player != Null && !Player.RequestsSpectate) {
 | 
				
			||||||
					WinnerScore <=> Score;
 | 
										WinnerScore <=> Score;
 | 
				
			||||||
@@ -606,8 +617,8 @@ if (Round_ForceEndRound || Round_SkipPauseRound) {
 | 
				
			|||||||
 */
 | 
					 */
 | 
				
			||||||
 Void UpdateCustomRanking(CSmPlayer _EliminatedPlayer, Integer _EventType) {
 | 
					 Void UpdateCustomRanking(CSmPlayer _EliminatedPlayer, Integer _EventType) {
 | 
				
			||||||
	declare Integer[Text] CustomTimes for This;
 | 
						declare Integer[Text] CustomTimes for This;
 | 
				
			||||||
	declare Text[] AccountIdsOfPlayers for This;
 | 
						declare Text[] LoginsOfPlayers for This;
 | 
				
			||||||
	foreach (Index => Score in Scores) {
 | 
						foreach (Score in Scores) {
 | 
				
			||||||
		if (Score == Null) continue;
 | 
							if (Score == Null) continue;
 | 
				
			||||||
		declare CSmPlayer Player = GetPlayer(Score.User.Login);
 | 
							declare CSmPlayer Player = GetPlayer(Score.User.Login);
 | 
				
			||||||
		if (Player == Null) continue;
 | 
							if (Player == Null) continue;
 | 
				
			||||||
@@ -624,7 +635,7 @@ if (Round_ForceEndRound || Round_SkipPauseRound) {
 | 
				
			|||||||
			Scores::SetPlayerRoundPoints(Score,PlayersNbDead);
 | 
								Scores::SetPlayerRoundPoints(Score,PlayersNbDead);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	UIModules_ScoresTable::DisplayOnly(AccountIdsOfPlayers);
 | 
						UIModules_ScoresTable::DisplayOnly(LoginsOfPlayers);
 | 
				
			||||||
	UIModules_ScoresTable::SetCustomTimes(CustomTimes);
 | 
						UIModules_ScoresTable::SetCustomTimes(CustomTimes);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user