Optimize a bit how to pick Malus

This commit is contained in:
Beu 2023-07-13 10:08:33 +02:00
parent ee5d4c12a9
commit 7fcde52a04

View File

@ -346,7 +346,6 @@ foreach (Event in RacePendingEvents) {
if (Event.Player == Null) continue; if (Event.Player == Null) continue;
// Waypoint
switch (Event.Type) { switch (Event.Type) {
case Events::C_Type_Waypoint: { case Events::C_Type_Waypoint: {
ThrottleUpdate = True; ThrottleUpdate = True;
@ -437,20 +436,11 @@ if (Players.count > 0 && S_MalusDuration > 0 && MalusTime != -1 && Now > MalusTi
if (!ActiveMalus && !PendingMalus) { if (!ActiveMalus && !PendingMalus) {
if (S_TimeBeforeNightmare >= 0 && Now > (StartTime + (S_TimeBeforeNightmare * 1000))) { if (S_TimeBeforeNightmare >= 0 && Now > (StartTime + (S_TimeBeforeNightmare * 1000))) {
MalusIndex = C_Malus_Nightmare; MalusIndex = C_Malus_Nightmare;
} else if (AllPlayersAreInTurtle()) {
log("All players are in turtle");
MalusIndex = ML::Rand(7, 10); // Boost if all players in Turtle
} else { } else {
declare Boolean AllPlayersInTurtle = True; MalusIndex = ML::Rand(1, 15);
foreach (Player in Players) {
if (Player.WheelsContactCount > 1 || Player.Speed > 1) {
AllPlayersInTurtle = False;
break;
}
}
if (AllPlayersInTurtle) {
log("All players are in turtle");
MalusIndex = ML::Rand(7, 10); // Boost if all players in Turtle
} else {
MalusIndex = ML::Rand(1, 15);
}
} }
PendingMalus = True; PendingMalus = True;
ActiveMalus = False; ActiveMalus = False;
@ -574,6 +564,7 @@ if (Round_ForceEndRound || Round_SkipPauseRound) {
// Functions // Functions
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
// Reset Network Variables
Void ResetNetworkVariables() { Void ResetNetworkVariables() {
declare netwrite Boolean Net_DisplayUI for Teams[0] = False; declare netwrite Boolean Net_DisplayUI for Teams[0] = False;
Net_DisplayUI = False; Net_DisplayUI = False;
@ -617,6 +608,19 @@ Boolean IsEliminated(CUser _User, CSmScore _Score) {
return False; return False;
} }
/** 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;
}
/** 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