Skip to content

Commit

Permalink
Patch v1.4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
K4ryuu committed Jun 2, 2024
1 parent 21593b5 commit 1fb015c
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 16 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
26 changes: 19 additions & 7 deletions src-plugin/Plugin/Models/ArenaFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,12 @@ public List<Tuple<List<SpawnPoint>, List<SpawnPoint>>> GetSpawnPairs()

if (closestTSpawn != null)
{
if (Plugin.Config.ArenaMathOverrides > 0 && closestTSpawn.Distance > Plugin.Config.ArenaMathOverrides)
continue;

Tuple<List<SpawnPoint>, List<SpawnPoint>>? existingPair = null;

if (minTeamDistance < minEnemyDistance && minEnemyDistance < maxTeamDistance)
if ((minTeamDistance < minEnemyDistance && minEnemyDistance < maxTeamDistance) || Plugin.Config.ArenaMathOverrides > 0)
{
existingPair = FindExistingPairForSpawn(spawnPairs, ctSpawn, closestTSpawn.TSpawn);
}
Expand Down Expand Up @@ -119,17 +122,23 @@ public List<Tuple<List<SpawnPoint>, List<SpawnPoint>>> 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;
Expand All @@ -142,10 +151,13 @@ public List<Tuple<List<SpawnPoint>, List<SpawnPoint>>> 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;
Expand Down
8 changes: 6 additions & 2 deletions src-plugin/Plugin/Models/ArenaModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,14 @@ public void SetPlayerDetails(List<ArenaPlayer>? team, List<SpawnPoint> 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"]]}");
Expand Down
1 change: 0 additions & 1 deletion src-plugin/Plugin/Models/ArenaPlayerModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src-plugin/Plugin/PluginConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src-plugin/Plugin/PluginEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 7 additions & 1 deletion src-plugin/Plugin/PluginListeners.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src-plugin/Plugin/PluginManifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions src-plugin/Plugin/PluginStock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
Binary file modified src-shared/K4-ArenaSharedApi.dll
Binary file not shown.

0 comments on commit 1fb015c

Please sign in to comment.