Adapt the script to the recent changes of PhysicsController script

This commit is contained in:
Beu 2021-12-24 10:46:32 +01:00
parent dca873cb18
commit 73a0978161

View File

@ -24,47 +24,9 @@ declare Integer[Text] ApplyResetAtRespawn_Queue for This;
ApplyResetAtRespawn_Queue = []; ApplyResetAtRespawn_Queue = [];
*** ***
***PhysicsController_Yield*** // force a reset at respawn to prevent abuse
***PhysicsController_PhysicsAtRespawn***
*** ***
declare RacePendingEvents = Race::GetPendingEvents();
foreach (Event in RacePendingEvents) {
Log::Log("[RacePendingEvents][Yield] Event.Type: " ^ Event.Type);
if (Event.Type == Events::C_Type_StartLine || Event.Type == Events::C_Type_GiveUp || Event.Type == Events::C_Type_SkipOutro || Event.Type == Events::C_Type_Respawn) {
if (Event.Player != Null) {
declare netwrite Integer Net_CoolDownForEffects for Event.Player;
declare netwrite Integer Net_CoolDownBeforeReset for Event.Player;
Net_CoolDownForEffects = 0;
Net_CoolDownBeforeReset = 0;
declare Integer[Text] ApplyResetAtRespawn_Queue for This;
ApplyResetAtRespawn_Queue[Event.Player.User.WebServicesUserId] = Now;
}
}
}
MB_Yield();
***
// I force a reset at respawn to prevent abuse
***PhysicsController_ApplyPhysicsAtRespawn***
***
if (Now % 100 == 0 && ApplyResetAtRespawn_Queue.count > 0) {
foreach (AccountId => Time in ApplyResetAtRespawn_Queue) {
declare CSmPlayer Player = ModeUtils::GetPlayerFromAccountId(AccountId);
if (Player != Null && (Player.SpawnStatus == CSmPlayer::ESpawnStatus::Spawned || Player.SpawnStatus == CSmPlayer::ESpawnStatus::Spawning)) {
Log::Log("[ApplyPhysicsAtRespawn] Player: " ^ Player.User.Name);
SetPhysicsChange("Reset", "", Player);
declare netwrite Net_PlayerPhysics for Player = InitPlayerPhysicsVariable();
Net_PlayerPhysics = InitPlayerPhysicsVariable();
ApplyResetAtRespawn_Queue.removekey(AccountId);
} else if (Time > Now || Time + 10000 < Now ) { // Clear ApplyResetAtRespawn_Queue array if player is DC
Log::Log("[ApplyPhysicsAtRespawn] Clear from array after 10s: " ^ AccountId);
if (Player != Null) {
declare netwrite Net_PlayerPhysics for Player = InitPlayerPhysicsVariable();
Net_PlayerPhysics = InitPlayerPhysicsVariable();
}
ApplyResetAtRespawn_Queue.removekey(AccountId);
}
}
}
foreach (Event in RacePendingEvents) { foreach (Event in RacePendingEvents) {
Log::Log("[RacePendingEvents][MainLoop] Event.Type: " ^ Event.Type); Log::Log("[RacePendingEvents][MainLoop] Event.Type: " ^ Event.Type);
if (Event.Type == Events::C_Type_StartLine || Event.Type == Events::C_Type_GiveUp || Event.Type == Events::C_Type_SkipOutro || Event.Type == Events::C_Type_Respawn) { if (Event.Type == Events::C_Type_StartLine || Event.Type == Events::C_Type_GiveUp || Event.Type == Events::C_Type_SkipOutro || Event.Type == Events::C_Type_Respawn) {
@ -73,14 +35,10 @@ foreach (Event in RacePendingEvents) {
declare netwrite Integer Net_CoolDownBeforeReset for Event.Player; declare netwrite Integer Net_CoolDownBeforeReset for Event.Player;
Net_CoolDownForEffects = 0; Net_CoolDownForEffects = 0;
Net_CoolDownBeforeReset = 0; Net_CoolDownBeforeReset = 0;
if (Event.Player.SpawnStatus == CSmPlayer::ESpawnStatus::Spawned || Event.Player.SpawnStatus == CSmPlayer::ESpawnStatus::Spawning) { declare netwrite Net_PlayerPhysics for Event.Player = InitPlayerPhysicsVariable();
SetPhysicsChange("Reset", "", Event.Player); Net_PlayerPhysics = InitPlayerPhysicsVariable();
declare netwrite Net_PlayerPhysics for Event.Player = InitPlayerPhysicsVariable(); if (!ApplyPhysics_Queue.existskey(Event.Player.User.WebServicesUserId)) ApplyPhysics_Queue[Event.Player.User.WebServicesUserId] = [];
Net_PlayerPhysics = InitPlayerPhysicsVariable(); ApplyPhysics_Queue[Event.Player.User.WebServicesUserId] = DiffPhysics(Event.Player, True);
} else {
declare Integer[Text] ApplyResetAtRespawn_Queue for This;
ApplyResetAtRespawn_Queue[Event.Player.User.WebServicesUserId] = Now;
}
} }
} }
} }
@ -109,11 +67,17 @@ if (_EventName == "Reset") {
***Match_InitMap*** ***Match_InitMap***
*** ***
declare Integer WaitNextUpdate = 0; declare Integer WaitNextUpdate = 0;
declare netwrite Text Net_FloorsInfo for Teams[0] = S_ScriptEnvironment; declare netwrite Text Net_FloorsInfo for Teams[0] = S_FloorsInfo;
declare netwrite K_PlayerInfo[] Net_HolidayShowdown_Ranking for Teams[0]; declare netwrite K_PlayerInfo[] Net_HolidayShowdown_Ranking for Teams[0];
declare netwrite Integer Net_HolidayShowdown_RankingSerial for Teams[0]; declare netwrite Integer Net_HolidayShowdown_RankingSerial for Teams[0];
*** ***
***Match_InitPlayLoop***
***
WaitNextUpdate = 0;
Net_HolidayShowdown_RankingSerial = 0;
***
***Match_PlayLoop*** ***Match_PlayLoop***
*** ***
if (Now > WaitNextUpdate) { if (Now > WaitNextUpdate) {
@ -610,7 +574,7 @@ Void SetHolidayShowdownControlML() {
ToggleUI(); ToggleUI();
Last_IsBindingMode = False; Last_IsBindingMode = False;
Last_EffectToBind = ""; Last_EffectToBind = "";
} else if (Event.ControlId == "BindKey_SettingButton") { } else if (Event.ControlId == "BindKey_SettingButton" && Quad_AntiClicks_Fg.Visible == False && Frame_Warning.Visible == False) {
Last_IsBindingMode = !Last_IsBindingMode; Last_IsBindingMode = !Last_IsBindingMode;
if (Last_EffectToBind != "") { if (Last_EffectToBind != "") {
switch (Last_EffectToBind) { switch (Last_EffectToBind) {