Compare commits

..

No commits in common. "e78d7f411ae3ad1e78207776c9ca4677f9c64db1" and "cea0b402f996adc5cae85239b26b37f26957c5d7" have entirely different histories.

View File

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