Skip to content

Commit

Permalink
Small tidy up :>
Browse files Browse the repository at this point in the history
  • Loading branch information
B3none committed Apr 14, 2024
1 parent efa1b8e commit ba1c474
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 36 deletions.
7 changes: 2 additions & 5 deletions ChaseMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,11 @@ public override void Unload(bool hotReload)
[GameEventHandler]
public HookResult OnEventRoundFreezeEnd(EventRoundFreezeEnd @event, GameEventInfo info)
{
Server.NextFrame(() =>
{
TriggerWorkaround.DisableWorkaroundTriggers();
});
Server.NextFrame(TriggerWorkaround.DisableWorkaroundTriggers);
return HookResult.Continue;
}

public void OnTick()
private void OnTick()
{
foreach (var controller in ChaseModUtils.GetAllRealPlayers())
{
Expand Down
1 change: 1 addition & 0 deletions ChaseModConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Text.Json.Serialization;

namespace ChaseMod;

public sealed class ChaseModConfig : BasePluginConfig
{
[JsonPropertyName("Version")]
Expand Down
16 changes: 10 additions & 6 deletions Commands/MiscCommands.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
using System.Runtime.InteropServices;
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core;

namespace ChaseMod.Commands;

public static class MiscCommands
{

public static void AddCommands(BasePlugin plugin)
{
plugin.AddCommand("css_hns", "Shows the current version of the plugin", (client, args) =>
{
if (client == null || !client.IsValid)
{
return;
}

client.PrintToChat($"HnS ChaseMod v{plugin.ModuleVersion}");
});
}

}

2 changes: 1 addition & 1 deletion KnifeCooldownManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using CounterStrikeSharp.API.Modules.Utils;

namespace ChaseMod;

internal class KnifeCooldownManager
{
private readonly ChaseMod _plugin;
Expand Down Expand Up @@ -40,7 +41,6 @@ private HookResult CBaseEntity_TakeDamageOldFuncHook(DynamicHook hook)
}

var attacker = info.Attacker.Value!.As<CCSPlayerPawn>();
var attackerController = attacker.Controller.Value!;

var pawn = entity.As<CCSPlayerPawn>();
var controller = pawn.OriginalController.Value!;
Expand Down
2 changes: 1 addition & 1 deletion NadeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using CounterStrikeSharp.API;

namespace ChaseMod;

internal class NadeManager
{
private readonly ChaseMod _plugin;
Expand Down Expand Up @@ -124,5 +125,4 @@ private void FreezeGrenadeExplode(CSmokeGrenadeProjectile smoke)

smoke.Remove();
}

}
9 changes: 3 additions & 6 deletions PlayerFreezeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void Freeze(CCSPlayerController controller, float time, bool showEffect,
}
}

public void Unfreeze(CCSPlayerController controller, bool sendMessage)
private void Unfreeze(CCSPlayerController controller, bool sendMessage)
{
if (!ChaseModUtils.IsRealPlayer(controller)) return;
var pawn = controller.PlayerPawn.Value!;
Expand Down Expand Up @@ -110,10 +110,7 @@ public void Unfreeze(CCSPlayerController controller, bool sendMessage)
var timeRemaining = freezeState.Time - freezeTime;
return timeRemaining;
}
else
{
return null;
}

return null;
}

}
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# ChaseMod
CS2 HNS ChaseMod (freezetime, freezenade, antiflash, knife dmg, winstreak team switch)
CS2 HNS ChaseMod (freezetime, freezenade, antiflash, knife dmg, winstreak team switch)

## Installation
Download the .zip from the [releases](https://github.com/ipsvn/ChaseMod/releases) and extract the contents into `counterstrikesharp/plugins/ChaseMod` on your server.
11 changes: 3 additions & 8 deletions RoundStartFreezeTimeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,10 @@ public void Start()

SwitchFallDamage(false);

foreach (var player in ChaseModUtils.GetAllRealPlayers())
foreach (var player in ChaseModUtils.GetAllRealPlayers().Where(p => p.Team == CsTeam.CounterTerrorist))
{
var pawn = player.PlayerPawn.Value!;

if (player.Team == CsTeam.CounterTerrorist)
{
_playerFreezeManager.Freeze(player, _plugin.Config.RoundStartFreezeTime,
true, false, true);
}
_playerFreezeManager.Freeze(player, _plugin.Config.RoundStartFreezeTime,
true, false, true);
}

if (_countdownTimer != null)
Expand Down
1 change: 1 addition & 0 deletions TeamSwitchManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using ChaseMod.Utils.Memory;

namespace ChaseMod;

internal class TeamSwitchManager
{
private bool _switchingTeams;
Expand Down
3 changes: 1 addition & 2 deletions Utils/ChaseModUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,4 @@ public static void ChatAllPrefixed(string message)
{
Server.PrintToChatAll($" {ChatColors.Magenta}HNS {ChatColors.Grey}| {message}");
}

}
}
3 changes: 2 additions & 1 deletion Utils/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Vector = CounterStrikeSharp.API.Modules.Utils.Vector;

namespace ChaseMod.Utils;

public static class Extensions
{
public static float Distance(this Vector thisVector, Vector vector2)
Expand Down Expand Up @@ -59,7 +60,7 @@ public static void DisableAllWeaponsUntil(this CPlayer_WeaponServices weaponServ
}
}

public static void SetMoveType(this CCSPlayerPawn pawn, MoveType_t moveType)
private static void SetMoveType(this CCSPlayerPawn pawn, MoveType_t moveType)
{
pawn.MoveType = moveType;
Utilities.SetStateChanged(pawn, "CBaseEntity", "m_MoveType");
Expand Down
3 changes: 2 additions & 1 deletion Utils/Memory/CCSMatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Runtime.InteropServices;

namespace ChaseMod.Utils.Memory;

public class CCSMatch
{
private static nint MATCH_OFFSET = 0xF3C;
Expand Down Expand Up @@ -41,7 +42,7 @@ public static void SwapTeamScores(CCSGameRules gameRules)

var marshallMatch = Marshal.PtrToStructure<MCCSMatch>(structOffset);

short temp = marshallMatch.m_terroristScoreFirstHalf;
var temp = marshallMatch.m_terroristScoreFirstHalf;
marshallMatch.m_terroristScoreFirstHalf = marshallMatch.m_ctScoreFirstHalf;
marshallMatch.m_ctScoreFirstHalf = temp;

Expand Down
5 changes: 1 addition & 4 deletions Utils/Memory/GrenadeFunctions.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions;

namespace ChaseMod.Utils.Memory;

public static class GrenadeFunctions
{
// search 'decoy_projectile', xref to function string used at top
public static MemoryFunctionWithReturn<nint, nint, nint, nint, nint, nint, nint, nint> CDecoyProjectile_CreateFunc =
new(@"\x55\x4C\x89\xC1\x48\x89\xE5\x41\x57\x45\x89\xCF\x41\x56\x49\x89\xFE\x41\x55\x49\x89\xD5\x48\x89\xF2\x48\x89\xFE\x41\x54\x48\x8D\x3D\x2A\x2A\x2A\x2A\x53\x4C\x89\xC3\x48\x83\xEC\x18");

// search 'smokegrenade_projectile', xref to function string used at top
public static MemoryFunctionWithReturn<IntPtr, IntPtr, IntPtr, IntPtr, IntPtr, IntPtr, float, IntPtr> CSmokeGrenadeProjectile_CreateFunc =
new(
Expand Down

0 comments on commit ba1c474

Please sign in to comment.