Compare commits
No commits in common. "057800e99233805aa729c260f0c9feaa93b19b64" and "9b9fd4596d4fdae714545591ce6950b822776e97" have entirely different histories.
057800e992
...
9b9fd4596d
@ -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 "2023-07-12"
|
#Const Version "2023-07-10"
|
||||||
#Const ScriptName "Modes/TM2020-Gamemodes/LastManStanding.Script.txt"
|
#Const ScriptName "Modes/TM2020-Gamemodes/LastManStanding.Script.txt"
|
||||||
|
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
|
||||||
@ -28,7 +28,7 @@
|
|||||||
#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 120000 as "Time before being an AFK player will be kicked"
|
#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"
|
||||||
@ -164,12 +164,12 @@ UsePvECollisions = True;
|
|||||||
StateMgr::ForcePlayersStates([StateMgr::C_State_Waiting]);
|
StateMgr::ForcePlayersStates([StateMgr::C_State_Waiting]);
|
||||||
WarmUp::SetAvailability(True);
|
WarmUp::SetAvailability(True);
|
||||||
CarRank::Reset();
|
CarRank::Reset();
|
||||||
ResetNetworkVariables();
|
|
||||||
***
|
***
|
||||||
|
|
||||||
***Match_InitMap***
|
***Match_InitMap***
|
||||||
***
|
***
|
||||||
declare Integer Map_ValidRoundsNb;
|
declare Integer Map_ValidRoundsNb;
|
||||||
|
declare Boolean RankInitialized = False;
|
||||||
|
|
||||||
declare Integer Map_TimeBeforeMalus;
|
declare Integer Map_TimeBeforeMalus;
|
||||||
declare Integer Map_TimeBeforeNightmare;
|
declare Integer Map_TimeBeforeNightmare;
|
||||||
@ -189,7 +189,6 @@ declare Integer NextStepMalusTime = 0;
|
|||||||
declare Integer MalusIndex;
|
declare Integer MalusIndex;
|
||||||
declare Integer MalusTime;
|
declare Integer MalusTime;
|
||||||
|
|
||||||
declare netwrite Boolean Net_DisplayUI for Teams[0] = False;
|
|
||||||
declare netwrite Integer Net_NBPlayers for Teams[0] = 0;
|
declare netwrite Integer Net_NBPlayers for Teams[0] = 0;
|
||||||
declare netwrite Integer Net_PlayersNbAlive 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_NextMalus for Teams[0] = -1;
|
||||||
@ -197,8 +196,6 @@ declare netwrite Integer Net_TimeBeforeMalus for Teams[0] = -1;
|
|||||||
declare netwrite Integer Net_RoundsPerMap for Teams[0] = 0;
|
declare netwrite Integer Net_RoundsPerMap for Teams[0] = 0;
|
||||||
declare netwrite Integer Net_CurrentRoundNb for Teams[0] = 0;
|
declare netwrite Integer Net_CurrentRoundNb for Teams[0] = 0;
|
||||||
|
|
||||||
ResetNetworkVariables();
|
|
||||||
|
|
||||||
// Map Intro
|
// Map Intro
|
||||||
declare Boolean MapIsCompatible;
|
declare Boolean MapIsCompatible;
|
||||||
declare CMapLandmark[] Landmarks = Map::GetFinishesAndMultilaps();
|
declare CMapLandmark[] Landmarks = Map::GetFinishesAndMultilaps();
|
||||||
@ -213,7 +210,7 @@ if (!MapIsCompatible) {
|
|||||||
MB_Sleep(3000);
|
MB_Sleep(3000);
|
||||||
MB_StopMap();
|
MB_StopMap();
|
||||||
} else if (S_IntroTime > 0) {
|
} else if (S_IntroTime > 0) {
|
||||||
declare netwrite Boolean Net_LMS_IsIntro for Teams[0] = False;
|
declare netwrite Boolean Net_LMS_IsIntro for Teams[0];
|
||||||
Net_LMS_IsIntro = True;
|
Net_LMS_IsIntro = True;
|
||||||
StateMgr::ForcePlayersStates([StateMgr::C_State_Waiting]);
|
StateMgr::ForcePlayersStates([StateMgr::C_State_Waiting]);
|
||||||
if (Map.HasCustomIntro) {
|
if (Map.HasCustomIntro) {
|
||||||
@ -242,20 +239,12 @@ Race::SetRespawnBehaviour(Race::C_RespawnBehaviour_AlwaysGiveUp);
|
|||||||
CarRank::Reset();
|
CarRank::Reset();
|
||||||
***
|
***
|
||||||
|
|
||||||
***Match_InitRound***
|
|
||||||
***
|
|
||||||
declare Boolean ThrottleUpdate;
|
|
||||||
***
|
|
||||||
|
|
||||||
***Match_StartRound***
|
***Match_StartRound***
|
||||||
***
|
***
|
||||||
Scores::Clear();
|
Scores::Clear();
|
||||||
|
|
||||||
declare netwrite Integer Net_LMS_AFKIdleTime for Teams[0] = 120000;
|
|
||||||
Net_LMS_AFKIdleTime = S_AFKIdleTime;
|
|
||||||
|
|
||||||
// WorkAround for longloading
|
// WorkAround for longloading
|
||||||
declare Integer StartMapTime = Now;
|
declare StartMapTime = Now;
|
||||||
while (Players.count < 2 && Now < (StartMapTime + 3000)) {
|
while (Players.count < 2 && Now < (StartMapTime + 3000)) {
|
||||||
MB_Yield();
|
MB_Yield();
|
||||||
}
|
}
|
||||||
@ -270,7 +259,6 @@ Map_MalusDuration = S_MalusDuration;
|
|||||||
Map_RoundsPerMap = S_RoundsPerMap;
|
Map_RoundsPerMap = S_RoundsPerMap;
|
||||||
UpdateScoresTableFooter();
|
UpdateScoresTableFooter();
|
||||||
MalusTime = GetTimeBeforeMalus(StartTime, S_TimeBeforeMalus, S_TimeBeforeNightmare);
|
MalusTime = GetTimeBeforeMalus(StartTime, S_TimeBeforeMalus, S_TimeBeforeNightmare);
|
||||||
Net_DisplayUI = True;
|
|
||||||
Net_TimeBeforeMalus = MalusTime;
|
Net_TimeBeforeMalus = MalusTime;
|
||||||
Net_NextMalus = -1;
|
Net_NextMalus = -1;
|
||||||
Net_RoundsPerMap = Map_RoundsPerMap;
|
Net_RoundsPerMap = Map_RoundsPerMap;
|
||||||
@ -287,23 +275,22 @@ declare Integer LandmarkIndex for This = 0;
|
|||||||
AccountIdsOfPlayers = [];
|
AccountIdsOfPlayers = [];
|
||||||
|
|
||||||
// Suffle Players list to randomise spawn
|
// Suffle Players list to randomise spawn
|
||||||
declare CSmPlayer[Integer] ShuffledPlayers;
|
declare CSmPlayer[] ShuffledPlayers = Players;
|
||||||
|
declare Integer i=0;
|
||||||
|
while(i<ShuffledPlayers.count) { // this should be enough, you can use arbitrary values, should the need arise
|
||||||
|
// find a pair (a,b) of valid indices to swap
|
||||||
|
declare a=ML::Rand(0, ShuffledPlayers.count-1);
|
||||||
|
declare b=ML::Rand(0, ShuffledPlayers.count-1);
|
||||||
|
|
||||||
foreach (Player in Players) {
|
// now swap them
|
||||||
declare Integer RandomIndex = 0;
|
declare tmp=ShuffledPlayers[b];
|
||||||
while (RandomIndex == 0 || ShuffledPlayers.existskey(RandomIndex)) {
|
ShuffledPlayers[b]=ShuffledPlayers[a];
|
||||||
RandomIndex = ML::Rand(1, 10000);
|
ShuffledPlayers[a]=tmp;
|
||||||
|
|
||||||
|
i=i+1;
|
||||||
}
|
}
|
||||||
ShuffledPlayers[RandomIndex] = Player;
|
|
||||||
}
|
|
||||||
|
|
||||||
ShuffledPlayers = ShuffledPlayers.sortkey();
|
|
||||||
|
|
||||||
Net_NBPlayers = ShuffledPlayers.count;
|
|
||||||
Net_PlayersNbAlive = Net_NBPlayers;
|
|
||||||
|
|
||||||
foreach (Player in ShuffledPlayers) {
|
foreach (Player in ShuffledPlayers) {
|
||||||
if (Player == Null) continue;
|
|
||||||
PlayerLM = Null;
|
PlayerLM = Null;
|
||||||
while (PlayerLM == Null) {
|
while (PlayerLM == Null) {
|
||||||
if (LandmarkIndex > Landmarks.count - 1 ) {
|
if (LandmarkIndex > Landmarks.count - 1 ) {
|
||||||
@ -315,45 +302,102 @@ foreach (Player in ShuffledPlayers) {
|
|||||||
LandmarkIndex = LandmarkIndex + 1 ;
|
LandmarkIndex = LandmarkIndex + 1 ;
|
||||||
}
|
}
|
||||||
Race::Start(Player, PlayerLM , StartTime);
|
Race::Start(Player, PlayerLM , StartTime);
|
||||||
CarRank::SetRank(Player, Net_NBPlayers);
|
|
||||||
AccountIdsOfPlayers.add(Player.User.WebServicesUserId);
|
AccountIdsOfPlayers.add(Player.User.WebServicesUserId);
|
||||||
MalusQueue[Player.User.Login] = GetNewMalus(C_Malus_Reset, 1500);
|
MalusQueue[Player.User.Login] = GetNewMalus(C_Malus_Reset, 1500);
|
||||||
}
|
}
|
||||||
|
|
||||||
UIModules_ScoresTable::DisplayOnly(AccountIdsOfPlayers);
|
Net_NBPlayers = AccountIdsOfPlayers.count;
|
||||||
|
|
||||||
|
UpdateCustomRanking(Null, -1);
|
||||||
StateMgr::ForcePlayersStates([StateMgr::C_State_Playing]);
|
StateMgr::ForcePlayersStates([StateMgr::C_State_Playing]);
|
||||||
|
CarRank::Update(CarRank::C_SortCriteria_BestRace);
|
||||||
Race::EnableIntroDuringMatch(False);
|
Race::EnableIntroDuringMatch(False);
|
||||||
UIManager.UIAll.SendChat("$<$ff3$> Stay the most time on the structure. $<$ff9GL HF!$>");
|
UIManager.UIAll.SendChat("$<$ff3$> Stay the most time on the structure. $<$ff9GL HF!$>");
|
||||||
|
|
||||||
***
|
***
|
||||||
|
|
||||||
|
/***Match_InitPlayLoop***
|
||||||
|
***
|
||||||
|
MalusQueue = [];
|
||||||
|
***/
|
||||||
|
|
||||||
***Match_PlayLoop***
|
***Match_PlayLoop***
|
||||||
***
|
***
|
||||||
|
// Update CarRank & UI Interface
|
||||||
|
if (!RankInitialized) {
|
||||||
|
RankInitialized = True;
|
||||||
|
Net_PlayersNbAlive = PlayersNbAlive;
|
||||||
|
Net_NBPlayers = AccountIdsOfPlayers.count;
|
||||||
|
foreach (Player in Players) {
|
||||||
|
CarRank::SetRank(Player, PlayersNbAlive);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Spawn players who have longloading
|
||||||
|
if (Now < StartTime + 3000) {
|
||||||
|
declare Boolean PlayerSpawned = False;
|
||||||
|
declare CMapLandmark[] Landmarks = Map::GetFinishesAndMultilaps();
|
||||||
|
declare CMapLandmark PlayerLM = Null;
|
||||||
|
if (PlayersNbDead >= 1) {
|
||||||
|
foreach (Player in Players) {
|
||||||
|
if (Player.SpawnStatus == CSmPlayer::ESpawnStatus::NotSpawned && !AccountIdsOfPlayers.exists(Player.User.WebServicesUserId)) {
|
||||||
|
PlayerSpawned = True;
|
||||||
|
PlayerLM = Null;
|
||||||
|
while (PlayerLM == Null) {
|
||||||
|
if (LandmarkIndex > Landmarks.count - 1 ) {
|
||||||
|
LandmarkIndex = 0;
|
||||||
|
}
|
||||||
|
if (Map::IsMultilap(Landmarks[LandmarkIndex])) {
|
||||||
|
PlayerLM = Landmarks[LandmarkIndex];
|
||||||
|
}
|
||||||
|
LandmarkIndex = LandmarkIndex + 1 ;
|
||||||
|
}
|
||||||
|
Race::Start(Player, PlayerLM , StartTime);
|
||||||
|
AccountIdsOfPlayers.add(Player.User.WebServicesUserId);
|
||||||
|
|
||||||
|
MalusQueue[Player.User.Login] = GetNewMalus(C_Malus_Reset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (PlayerSpawned) {
|
||||||
|
PlayerSpawned = False;
|
||||||
|
Net_NBPlayers = AccountIdsOfPlayers.count;
|
||||||
|
Net_PlayersNbAlive = PlayersNbAlive;
|
||||||
|
UpdateCustomRanking(Null, -1);
|
||||||
|
foreach (Player in Players) {
|
||||||
|
CarRank::SetRank(Player, PlayersNbAlive);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Manage race events
|
// Manage race events
|
||||||
declare Events::K_RaceEvent[] RacePendingEvents = Race::GetPendingEvents();
|
declare RacePendingEvents = Race::GetPendingEvents();
|
||||||
foreach (Event in RacePendingEvents) {
|
foreach (Event in RacePendingEvents) {
|
||||||
Race::ValidEvent(Event);
|
Race::ValidEvent(Event);
|
||||||
|
|
||||||
if (Event.Player == Null) continue;
|
|
||||||
|
|
||||||
// Waypoint
|
// Waypoint
|
||||||
switch (Event.Type) {
|
if (Event.Type == Events::C_Type_Waypoint) {
|
||||||
case Events::C_Type_Waypoint: {
|
if (Event.IsEndLap) {
|
||||||
ThrottleUpdate = True;
|
|
||||||
|
|
||||||
Scores::UpdatePlayerBestRaceIfBetter(Event.Player);
|
|
||||||
Race::StopSkipOutro(Event.Player);
|
Race::StopSkipOutro(Event.Player);
|
||||||
UpdateCustomRanking(Event.Player.User, False);
|
foreach (Player in Players) {
|
||||||
|
CarRank::SetRank(Player, PlayersNbAlive);
|
||||||
|
Net_PlayersNbAlive = PlayersNbAlive;
|
||||||
}
|
}
|
||||||
case Events::C_Type_GiveUp: {
|
UpdateCustomRanking(Event.Player, Event.Type);
|
||||||
ThrottleUpdate = True;
|
|
||||||
UpdateCustomRanking(Event.Player.User, True);
|
|
||||||
}
|
}
|
||||||
case Events::C_Type_Eliminated: {
|
} else if (Event.Type == Events::C_Type_GiveUp) {
|
||||||
ThrottleUpdate = True;
|
foreach (Player in Players) {
|
||||||
UpdateCustomRanking(Event.Player.User, True);
|
CarRank::SetRank(Player, PlayersNbAlive);
|
||||||
|
Net_PlayersNbAlive = PlayersNbAlive;
|
||||||
}
|
}
|
||||||
|
UpdateCustomRanking(Event.Player, Event.Type);
|
||||||
|
} else if (Event.Type == Events::C_Type_Eliminated) {
|
||||||
|
Race::StopSkipOutro(Event.Player);
|
||||||
|
foreach (Player in Players) {
|
||||||
|
CarRank::SetRank(Player, PlayersNbAlive);
|
||||||
|
Net_PlayersNbAlive = PlayersNbAlive;
|
||||||
|
}
|
||||||
|
UpdateCustomRanking(Event.Player, Event.Type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -361,13 +405,6 @@ foreach (Event in RacePendingEvents) {
|
|||||||
foreach (Event in PendingEvents) {
|
foreach (Event in PendingEvents) {
|
||||||
if (Event.HasBeenPassed || Event.HasBeenDiscarded) continue;
|
if (Event.HasBeenPassed || Event.HasBeenDiscarded) continue;
|
||||||
Events::Invalid(Event);
|
Events::Invalid(Event);
|
||||||
|
|
||||||
if (Event.Type == CSmModeEvent::EType::OnPlayerRemoved) {
|
|
||||||
if (Event.User == Null ) continue;
|
|
||||||
if (!AccountIdsOfPlayers.exists(Event.User.WebServicesUserId)) continue;
|
|
||||||
ThrottleUpdate = True;
|
|
||||||
UpdateCustomRanking(Event.User, True);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PlayersNbAlive <= 1 && AccountIdsOfPlayers.count >= 2) { //TODO just respawn in case of 1 player
|
if (PlayersNbAlive <= 1 && AccountIdsOfPlayers.count >= 2) { //TODO just respawn in case of 1 player
|
||||||
@ -375,18 +412,6 @@ if (PlayersNbAlive <= 1 && AccountIdsOfPlayers.count >= 2) { //TODO just respawn
|
|||||||
MB_StopRound();
|
MB_StopRound();
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Update the map duration setting
|
// 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) {
|
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) {
|
||||||
@ -451,12 +476,7 @@ if (Players.count > 0 && S_MalusDuration > 0 && MalusTime != -1 && Now > MalusTi
|
|||||||
Net_NextMalus = 0;
|
Net_NextMalus = 0;
|
||||||
Net_TimeBeforeMalus = NextStepMalusTime;
|
Net_TimeBeforeMalus = NextStepMalusTime;
|
||||||
} else if (!PendingMalus && ActiveMalus) {
|
} else if (!PendingMalus && ActiveMalus) {
|
||||||
if (MalusIndex == 99) {
|
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) {
|
foreach (Player in Players) {
|
||||||
MalusQueue[Player.User.Login] = GetNewMalus(C_Malus_Reset);
|
MalusQueue[Player.User.Login] = GetNewMalus(C_Malus_Reset);
|
||||||
}
|
}
|
||||||
@ -471,6 +491,11 @@ if (Players.count > 0 && S_MalusDuration > 0 && MalusTime != -1 && Now > MalusTi
|
|||||||
// Players UI update
|
// Players UI update
|
||||||
Net_NextMalus = -1;
|
Net_NextMalus = -1;
|
||||||
Net_TimeBeforeMalus = NextStepMalusTime;
|
Net_TimeBeforeMalus = NextStepMalusTime;
|
||||||
|
} else {
|
||||||
|
foreach (Player in Players) {
|
||||||
|
MalusQueue[Player.User.Login] = GetNewMalus(C_Malus_Nightmare);
|
||||||
|
}
|
||||||
|
NextStepMalusTime = Now + (S_MalusDuration*1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -493,9 +518,9 @@ foreach (Login => Malus in MalusQueue) {
|
|||||||
***
|
***
|
||||||
PendingMalus = False;
|
PendingMalus = False;
|
||||||
ActiveMalus = False;
|
ActiveMalus = False;
|
||||||
Net_DisplayUI = False;
|
|
||||||
Net_TimeBeforeMalus = -1;
|
Net_TimeBeforeMalus = -1;
|
||||||
Net_NextMalus = -1;
|
Net_NextMalus = -1;
|
||||||
|
RankInitialized = False;
|
||||||
CustomTimes.clear();
|
CustomTimes.clear();
|
||||||
|
|
||||||
Race::StopSkipOutroAll();
|
Race::StopSkipOutroAll();
|
||||||
@ -530,10 +555,11 @@ if (Round_ForceEndRound || Round_SkipPauseRound) {
|
|||||||
UIManager.UIAll.BigMessageSound = CUIConfig::EUISound::EndRound;
|
UIManager.UIAll.BigMessageSound = CUIConfig::EUISound::EndRound;
|
||||||
UIManager.UIAll.BigMessageSoundVariant = 0;
|
UIManager.UIAll.BigMessageSoundVariant = 0;
|
||||||
|
|
||||||
if (WinnerScore == Null) {
|
declare Text Message = _("|Match|Draw");
|
||||||
UIModules_BigMessage::SetMessage(_("|Match|Draw"));
|
if (WinnerScore != Null) {
|
||||||
|
UIModules_BigMessage::SetMessage("$<%1$> wins the match!", WinnerScore.User.WebServicesUserId);
|
||||||
} else {
|
} else {
|
||||||
UIModules_BigMessage::SetMessage(_("$<%1$> wins the match!"), WinnerScore.User.WebServicesUserId);
|
UIModules_BigMessage::SetMessage(_("|Match|Draw"));
|
||||||
}
|
}
|
||||||
|
|
||||||
Scores::EndRound();
|
Scores::EndRound();
|
||||||
@ -555,23 +581,6 @@ if (Round_ForceEndRound || Round_SkipPauseRound) {
|
|||||||
// Functions
|
// Functions
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get the Time Before the first Malus or NightMare Mode
|
/** Get the Time Before the first Malus or NightMare Mode
|
||||||
*
|
*
|
||||||
* @param _StartTime The starting time of the map
|
* @param _StartTime The starting time of the map
|
||||||
@ -595,18 +604,31 @@ Void ResetNetworkVariables() {
|
|||||||
|
|
||||||
/** Update the Scores Table with hidden custom points
|
/** Update the Scores Table with hidden custom points
|
||||||
*
|
*
|
||||||
* @param _User The User who is eliminated
|
* @param _EliminatedPlayer The Player who is eliminated
|
||||||
* @param _OverrideTime Compute time because it not ended the Map
|
* @param _EventType Type of event that led to the update (EndRace or GiveUp)
|
||||||
*/
|
*/
|
||||||
Void UpdateCustomRanking(CUser _User, Boolean _OverrideTime) {
|
Void UpdateCustomRanking(CSmPlayer _EliminatedPlayer, Integer _EventType) {
|
||||||
if (_User == Null) return;
|
declare Integer[Text] CustomTimes for This;
|
||||||
|
declare Text[] AccountIdsOfPlayers for This;
|
||||||
|
foreach (Score in Scores) {
|
||||||
|
if (Score == Null) continue;
|
||||||
|
declare CSmPlayer Player = GetPlayer(Score.User.Login);
|
||||||
|
if (Player == Null) continue;
|
||||||
|
if (Player.SpawnStatus == CSmPlayer::ESpawnStatus::NotSpawned) {
|
||||||
|
|
||||||
if (_OverrideTime) {
|
Scores::UpdatePlayerBestRaceIfBetter(Player);
|
||||||
declare Integer[Text] CustomTimes for This = [];
|
if (_EliminatedPlayer != Null && _EliminatedPlayer == Player) {
|
||||||
CustomTimes[_User.WebServicesUserId] = Now - StartTime;
|
if (_EventType == Events::C_Type_GiveUp || _EventType == Events::C_Type_Eliminated) {
|
||||||
UIModules_ScoresTable::SetCustomTimes(CustomTimes);
|
CustomTimes[Score.User.WebServicesUserId] = Now - StartTime;
|
||||||
}
|
}
|
||||||
UIManager.UIAll.SendChat("""$<$ff3$> Player $<$ff9{{{_User.Name}}}$> is eliminated""");
|
UIManager.UIAll.SendChat("""$<$ff3$> Player $<$ff9{{{Player.User.Name}}}$> is eliminated""");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Scores::SetPlayerRoundPoints(Score,PlayersNbDead);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
UIModules_ScoresTable::DisplayOnly(AccountIdsOfPlayers);
|
||||||
|
UIModules_ScoresTable::SetCustomTimes(CustomTimes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Update the scores table footer text
|
/** Update the scores table footer text
|
||||||
@ -618,7 +640,7 @@ Void ResetNetworkVariables() {
|
|||||||
Footer ^= "Malus disabled";
|
Footer ^= "Malus disabled";
|
||||||
} else {
|
} else {
|
||||||
declare Text[] Parts;
|
declare Text[] Parts;
|
||||||
declare Text Message = "";
|
declare Message = "";
|
||||||
if (S_TimeBeforeMalus >= 0) {
|
if (S_TimeBeforeMalus >= 0) {
|
||||||
if (Parts.count > 0) Message ^= "\n";
|
if (Parts.count > 0) Message ^= "\n";
|
||||||
Message ^= """%{{{Parts.count + 1}}}{{{TL::TimeToText(S_TimeBeforeMalus*1000)}}}""";
|
Message ^= """%{{{Parts.count + 1}}}{{{TL::TimeToText(S_TimeBeforeMalus*1000)}}}""";
|
||||||
@ -732,7 +754,7 @@ Boolean SetMalus(CSmPlayer _Player, Integer _Type) {
|
|||||||
* @param _Player Malus Index
|
* @param _Player Malus Index
|
||||||
*/
|
*/
|
||||||
Void SetML() {
|
Void SetML() {
|
||||||
declare Real TotalWidth = 44.5;
|
declare TotalWidth = 44.5;
|
||||||
|
|
||||||
declare Text MLText = """
|
declare Text MLText = """
|
||||||
<manialink name="LMS_InfoPanel" version="3">
|
<manialink name="LMS_InfoPanel" version="3">
|
||||||
@ -766,7 +788,6 @@ Void SetML() {
|
|||||||
{{{C_Malus_GravityCoef25}}} => "25% Gravity", {{{C_Malus_Nightmare}}} => "NightMare"]
|
{{{C_Malus_GravityCoef25}}} => "25% Gravity", {{{C_Malus_Nightmare}}} => "NightMare"]
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
declare netread Boolean Net_DisplayUI for Teams[0];
|
|
||||||
declare netread Integer Net_NBPlayers for Teams[0];
|
declare netread Integer Net_NBPlayers for Teams[0];
|
||||||
declare netread Integer Net_PlayersNbAlive for Teams[0];
|
declare netread Integer Net_PlayersNbAlive for Teams[0];
|
||||||
declare netread Integer Net_NextMalus for Teams[0];
|
declare netread Integer Net_NextMalus for Teams[0];
|
||||||
@ -774,7 +795,6 @@ Void SetML() {
|
|||||||
declare netread Integer Net_RoundsPerMap for Teams[0];
|
declare netread Integer Net_RoundsPerMap for Teams[0];
|
||||||
declare netread Integer Net_CurrentRoundNb for Teams[0];
|
declare netread Integer Net_CurrentRoundNb for Teams[0];
|
||||||
|
|
||||||
declare Boolean Last_DisplayUI;
|
|
||||||
declare Integer Last_PlayersNbAlive;
|
declare Integer Last_PlayersNbAlive;
|
||||||
declare Integer Last_NextMalus;
|
declare Integer Last_NextMalus;
|
||||||
declare Integer Last_TimeBeforeMalus;
|
declare Integer Last_TimeBeforeMalus;
|
||||||
@ -783,28 +803,15 @@ Void SetML() {
|
|||||||
|
|
||||||
declare Boolean NeedUpdateChrono = False;
|
declare Boolean NeedUpdateChrono = False;
|
||||||
|
|
||||||
declare CMlFrame Frame_Global <=> (Page.GetFirstChild("frame-global") as CMlFrame);
|
declare Label_PlayersAlive <=> (Page.GetFirstChild("label-playersalive") as CMlLabel);
|
||||||
declare CMlLabel Label_PlayersAlive <=> (Frame_Global.GetFirstChild("label-playersalive") as CMlLabel);
|
declare Label_NextMalus <=> (Page.GetFirstChild("label-nextmalus") as CMlLabel);
|
||||||
declare CMlLabel Label_NextMalus <=> (Frame_Global.GetFirstChild("label-nextmalus") as CMlLabel);
|
declare Label_TimeBeforeMalus <=> (Page.GetFirstChild("label-timebeforemalus") as CMlLabel);
|
||||||
declare CMlLabel Label_TimeBeforeMalus <=> (Frame_Global.GetFirstChild("label-timebeforemalus") as CMlLabel);
|
declare Label_Info_RoundsPerMap <=> (Page.GetFirstChild("label-info-roundspermap") as CMlLabel);
|
||||||
declare CMlLabel Label_Info_RoundsPerMap <=> (Frame_Global.GetFirstChild("label-info-roundspermap") as CMlLabel);
|
declare Label_RoundsPerMap <=> (Page.GetFirstChild("label-roundspermap") as CMlLabel);
|
||||||
declare CMlLabel Label_RoundsPerMap <=> (Frame_Global.GetFirstChild("label-roundspermap") as CMlLabel);
|
|
||||||
|
|
||||||
while(True) {
|
while(True) {
|
||||||
yield;
|
yield;
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Last_CurrentRoundNb != Net_CurrentRoundNb) {
|
if (Last_CurrentRoundNb != Net_CurrentRoundNb) {
|
||||||
Last_CurrentRoundNb = Net_CurrentRoundNb;
|
Last_CurrentRoundNb = Net_CurrentRoundNb;
|
||||||
if (Last_RoundsPerMap > 0) {
|
if (Last_RoundsPerMap > 0) {
|
||||||
@ -856,7 +863,7 @@ Void SetML() {
|
|||||||
<style class="text-ingame-number" textfont="GameFontBlack" textcolor="ffffff" textsize="1.25" valign="center2" textprefix="$i"/>
|
<style class="text-ingame-number" textfont="GameFontBlack" textcolor="ffffff" textsize="1.25" valign="center2" textprefix="$i"/>
|
||||||
</stylesheet>
|
</stylesheet>
|
||||||
|
|
||||||
<frame z-index="-2" id="frame-global" size="{{{TotalWidth + 20}}} 180" pos="-225 0" valign="center" hidden=1>
|
<frame z-index="-2" id="frame-global" size="{{{TotalWidth + 20}}} 180" pos="-160 0" valign="center">
|
||||||
<quad id="quad-info-bg" pos="0 7.75" size="{{{TotalWidth + 4}}} 21" valign="center" z-index="-3" bgcolor="000" opacity="0.5"/>
|
<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 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 10" size="{{{TotalWidth/1.75}}} 10" class="text-ingame-text" text="Players Alive" halign="left" />
|
||||||
@ -922,62 +929,6 @@ Void SetML() {
|
|||||||
Layers::Create("LMS_MapInfo", MLText);
|
Layers::Create("LMS_MapInfo", MLText);
|
||||||
Layers::SetType("LMS_MapInfo", CUILayer::EUILayerType::Normal);
|
Layers::SetType("LMS_MapInfo", CUILayer::EUILayerType::Normal);
|
||||||
Layers::Attach("LMS_MapInfo");
|
Layers::Attach("LMS_MapInfo");
|
||||||
|
|
||||||
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) {
|
|
||||||
log("Player is AFK");
|
|
||||||
Playground.QuitServer(False);
|
|
||||||
} else if (Last_AFKIdleTime > 0 && Input.TimeSinceLatestActivity > Last_AFKDisplayTime) {
|
|
||||||
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");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user