diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f2b230..00ed606 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +-- 2024.06.02 - 1.4.4 + +- feat: Experimental setting for arena math override (for wierd maps) +- fix: Team assignment glitches +- fix: Warmup stuck glitches +- fix: Warmup not always respawn people + -- 2024.05.11 - 1.4.3 - feat: Added log and stop to find arena if no spawns on the map at all (crash causer) diff --git a/src-plugin/Plugin/Models/ArenaFinder.cs b/src-plugin/Plugin/Models/ArenaFinder.cs index 693e954..94bd71b 100644 --- a/src-plugin/Plugin/Models/ArenaFinder.cs +++ b/src-plugin/Plugin/Models/ArenaFinder.cs @@ -56,9 +56,12 @@ public List, List>> GetSpawnPairs() if (closestTSpawn != null) { + if (Plugin.Config.ArenaMathOverrides > 0 && closestTSpawn.Distance > Plugin.Config.ArenaMathOverrides) + continue; + Tuple, List>? existingPair = null; - if (minTeamDistance < minEnemyDistance && minEnemyDistance < maxTeamDistance) + if ((minTeamDistance < minEnemyDistance && minEnemyDistance < maxTeamDistance) || Plugin.Config.ArenaMathOverrides > 0) { existingPair = FindExistingPairForSpawn(spawnPairs, ctSpawn, closestTSpawn.TSpawn); } @@ -119,17 +122,23 @@ public List, List>> GetSpawnPairs() { var ctDistance = DistanceTo(pair.Item1[0].AbsOrigin!, spawnToCheck.AbsOrigin!); - if (ctDistance < minEnemyDistance) + if (Plugin.Config.ArenaMathOverrides > 0) { - return (pair.Item1, pair.Item2, true); + if (ctDistance < Plugin.Config.ArenaMathOverrides) + return (pair.Item1, pair.Item2, true); } + else if (ctDistance < minEnemyDistance) + return (pair.Item1, pair.Item2, true); var tDistance = DistanceTo(pair.Item2[0].AbsOrigin!, spawnToCheck.AbsOrigin!); - if (tDistance < minEnemyDistance) + if (Plugin.Config.ArenaMathOverrides > 0) { - return (pair.Item1, pair.Item2, false); + if (tDistance < Plugin.Config.ArenaMathOverrides) + return (pair.Item1, pair.Item2, false); } + else if (tDistance < minEnemyDistance) + return (pair.Item1, pair.Item2, false); } return null; @@ -142,10 +151,13 @@ public List, List>> GetSpawnPairs() var ctDistance = DistanceTo(pair.Item1[0].AbsOrigin!, ctSpawn.AbsOrigin!); var tDistance = DistanceTo(pair.Item2[0].AbsOrigin!, tSpawn.AbsOrigin!); - if (ctDistance < minEnemyDistance && tDistance < minEnemyDistance) + if (Plugin.Config.ArenaMathOverrides > 0) { - return pair; + if (ctDistance < Plugin.Config.ArenaMathOverrides && tDistance < Plugin.Config.ArenaMathOverrides) + return pair; } + else if (ctDistance < minEnemyDistance && tDistance < minEnemyDistance) + return pair; } return null; diff --git a/src-plugin/Plugin/Models/ArenaModel.cs b/src-plugin/Plugin/Models/ArenaModel.cs index b725bbb..0680bdd 100644 --- a/src-plugin/Plugin/Models/ArenaModel.cs +++ b/src-plugin/Plugin/Models/ArenaModel.cs @@ -166,10 +166,14 @@ public void SetPlayerDetails(List? team, List spawns, C player.Controller.Clan = Plugin.GetRequiredTag(ArenaID); Utilities.SetStateChanged(player.Controller, "CCSPlayerController", "m_szClan"); - string arenaName = ArenaID == -1 ? Localizer["k4.general.warmup"] : Localizer["k4.general.arena", ArenaID]; - player.Controller.SwitchTeam(switchTo); + Plugin.AddTimer(1.0f, () => + { + if (player.IsValid && player.Controller.PlayerPawn.Value?.LifeState != (byte)LifeState_t.LIFE_ALIVE) + player.Controller.Respawn(); + }); + if (ArenaID != -1) { player.Controller.PrintToChat($" {Localizer["k4.general.prefix"]} {Localizer["k4.chat.arena_roundstart", Plugin.GetRequiredArenaName(ArenaID), Plugin.GetOpponentNames(opponents) ?? "Unknown", Localizer[RoundType.Name ?? "Missing"]]}"); diff --git a/src-plugin/Plugin/Models/ArenaPlayerModel.cs b/src-plugin/Plugin/Models/ArenaPlayerModel.cs index 4924e5e..75e1205 100644 --- a/src-plugin/Plugin/Models/ArenaPlayerModel.cs +++ b/src-plugin/Plugin/Models/ArenaPlayerModel.cs @@ -114,7 +114,6 @@ public void SetupWeapons(RoundType roundType) playerPawn.ArmorValue = roundType.Armor ? 100 : 0; Utilities.SetStateChanged(playerPawn, "CCSPlayerPawn", "m_ArmorValue"); - CCSPlayer_ItemServices itemServive = new CCSPlayer_ItemServices(playerPawn.ItemServices!.Handle) { HasHelmet = roundType.Helmet diff --git a/src-plugin/Plugin/PluginConfig.cs b/src-plugin/Plugin/PluginConfig.cs index b39469c..e40fe40 100644 --- a/src-plugin/Plugin/PluginConfig.cs +++ b/src-plugin/Plugin/PluginConfig.cs @@ -127,8 +127,11 @@ public sealed class PluginConfig : BasePluginConfig [JsonPropertyName("default-weapon-settings")] public DefaultWeaponSettings DefaultWeaponSettings { get; set; } = new DefaultWeaponSettings(); + [JsonPropertyName("arena-math-overrides")] + public int ArenaMathOverrides { get; set; } = 0; + [JsonPropertyName("ConfigVersion")] - public override int Version { get; set; } = 3; + public override int Version { get; set; } = 4; } public sealed class CompatibilitySettings diff --git a/src-plugin/Plugin/PluginEvents.cs b/src-plugin/Plugin/PluginEvents.cs index 17c1786..bdf2470 100644 --- a/src-plugin/Plugin/PluginEvents.cs +++ b/src-plugin/Plugin/PluginEvents.cs @@ -68,6 +68,12 @@ public void Initialize_Events() SetupPlayer(playerController); + /*if (Utilities.GetPlayers().Count(p => p.IsValid && !p.IsBot && !p.IsHLTV && p.Connected == PlayerConnectedState.PlayerConnected) <= 1) + { + Server.ExecuteCommand("mp_restartgame 1"); + return HookResult.Continue; + }*/ + if (gameRules?.WarmupPeriod == false) { if (playerController.IsBot) diff --git a/src-plugin/Plugin/PluginListeners.cs b/src-plugin/Plugin/PluginListeners.cs index ca1f3c0..9608753 100644 --- a/src-plugin/Plugin/PluginListeners.cs +++ b/src-plugin/Plugin/PluginListeners.cs @@ -16,7 +16,7 @@ public void Initialize_Listeners() public HookResult ListenerJoinTeam(CCSPlayerController? player, CommandInfo info) { - if (player?.IsValid == true && player.PlayerPawn?.IsValid == true && info.ArgByIndex(1) != "0") + if (player?.IsValid == true && player.PlayerPawn?.IsValid == true) { ArenaPlayer? arenaPlayer = Arenas?.FindPlayer(player); if (arenaPlayer != null) @@ -50,6 +50,12 @@ public HookResult ListenerJoinTeam(CCSPlayerController? player, CommandInfo info player.ExecuteClientCommand("play sounds/ui/weapon_cant_buy.vsnd_c"); return HookResult.Stop; } + else + { + player.ChangeTeam(CsTeam.Spectator); + return HookResult.Stop; + + } } return HookResult.Continue; diff --git a/src-plugin/Plugin/PluginManifest.cs b/src-plugin/Plugin/PluginManifest.cs index 9514102..5f5a138 100644 --- a/src-plugin/Plugin/PluginManifest.cs +++ b/src-plugin/Plugin/PluginManifest.cs @@ -10,7 +10,7 @@ public sealed partial class Plugin : BasePlugin public override string ModuleAuthor => "K4ryuu"; - public override string ModuleVersion => "1.4.3 " + + public override string ModuleVersion => "1.4.4 " + #if RELEASE "(release)"; #else diff --git a/src-plugin/Plugin/PluginStock.cs b/src-plugin/Plugin/PluginStock.cs index 3f53cc7..6b164fa 100644 --- a/src-plugin/Plugin/PluginStock.cs +++ b/src-plugin/Plugin/PluginStock.cs @@ -62,9 +62,6 @@ public void TerminateRoundIfPossible(CsTeam? team = null) public ArenaPlayer? SetupPlayer(CCSPlayerController playerController) { - if (gameRules?.WarmupPeriod == false) - playerController.ChangeTeam(CsTeam.Spectator); - playerController.Clan = $"{Localizer[gameRules?.WarmupPeriod == true ? "k4.general.warmup" : "k4.general.waiting"]} |"; Utilities.SetStateChanged(playerController, "CCSPlayerController", "m_szClan"); diff --git a/src-shared/K4-ArenaSharedApi.dll b/src-shared/K4-ArenaSharedApi.dll index b87bf4b..a7f1ca7 100644 Binary files a/src-shared/K4-ArenaSharedApi.dll and b/src-shared/K4-ArenaSharedApi.dll differ