Skip to content

Commit a4216a7

Browse files
committed
Vectorless
1 parent 7b7235e commit a4216a7

File tree

17 files changed

+266
-91
lines changed

17 files changed

+266
-91
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ jobs:
2626
- name: Create Directories
2727
run: |
2828
mkdir -p plugin/plugins/${{ github.event.repository.name }}
29+
mkdir -p plugin/gamedata
2930
3031
- name: Move Files
3132
run: |
3233
mv ./src/bin/Release/net8.0/* ./plugin/plugins/${{ github.event.repository.name }}
34+
mv ./gamedata/* ./plugin/gamedata
3335
3436
- name: Zip
3537
run: |

.github/workflows/release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,12 @@ jobs:
5151
- name: Create Directories
5252
run: |
5353
mkdir -p plugin/plugins/${{ github.event.repository.name }}
54+
mkdir -p plugin/gamedata
5455
5556
- name: Move Files
5657
run: |
5758
mv ./src/bin/Release/net8.0/* ./plugin/plugins/${{ github.event.repository.name }}
59+
mv ./gamedata/* ./plugin/gamedata
5860
5961
- name: Zip
6062
run: |

FixVectorLeak

Menu

Submodule Menu updated from 9f8bc03 to bfd12bd

gamedata/AntiRush.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"RunCommand": {
3+
"signatures": {
4+
"library": "server",
5+
"windows": "\\x48\\x89\\x5C\\x24\\x18\\x48\\x89\\x6C\\x24\\x20\\x57\\x48\\x83\\xEC\\x20\\x48\\x8B\\xDA",
6+
"linux": "\\x55\\x48\\x89\\xE5\\x41\\x55\\x49\\x89\\xF5\\x41\\x54\\x49\\x89\\xFC\\xE8\\x2A\\x2A\\x2A\\x2A\\x48\\x85\\xC0\\x74\\x30"
7+
}
8+
}
9+
}

src/AntiRush.cs

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using CounterStrikeSharp.API;
1+
using Microsoft.Extensions.Logging;
2+
using System.Runtime.InteropServices;
3+
using CounterStrikeSharp.API;
24
using CounterStrikeSharp.API.Core;
35
using CounterStrikeSharp.API.Modules.Utils;
46
using AntiRush.Classes;
@@ -46,17 +48,30 @@ public override void Load(bool isReload)
4648
if (Config.RestartOnLoad)
4749
Server.ExecuteCommand("mp_restartgame 1");
4850
});
51+
52+
_isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
53+
54+
Logger.LogInformation("{ModuleName} loaded successfully!", ModuleName);
55+
_ProcessMovement = new(GameData.GetSignature("RunCommand"));
56+
_ProcessMovement!.Hook(OnProcessMovement, HookMode.Pre);
57+
}
58+
59+
public override void Unload(bool isReload)
60+
{
61+
Logger.LogInformation("{ModuleName} unloaded successfully!", ModuleName);
62+
_ProcessMovement!.Unhook(OnProcessMovement, HookMode.Pre);
4963
}
5064

5165
private void SaveZone(CCSPlayerController player)
5266
{
5367
var menu = _playerData[player].AddZoneMenu;
68+
_playerData[player].AddZone?.Clear();
5469

5570
CsTeam[] teams = menu!.Items[1].Option switch
5671
{
57-
0 => [CsTeam.Terrorist],
58-
1 => [CsTeam.CounterTerrorist],
59-
2 => [CsTeam.Terrorist, CsTeam.CounterTerrorist],
72+
0 => [CsTeam.Terrorist, CsTeam.CounterTerrorist],
73+
1 => [CsTeam.Terrorist],
74+
2 => [CsTeam.CounterTerrorist],
6075
_ => []
6176
};
6277

@@ -91,14 +106,17 @@ private void SaveZone(CCSPlayerController player)
91106

92107
if (Config.DrawZones)
93108
zone.Draw();
109+
110+
if (_playerData.TryGetValue(player, out var playerData))
111+
playerData.AddZone?.Clear();
94112
}
95113

96114
private bool PrintAction(CCSPlayerController player, Zone zone)
97115
{
98116
if (!player.IsValid(true) || !(Server.CurrentTime - _playerData[player].LastMessage >= 1))
99117
return false;
100118

101-
if (zone.Type == ZoneType.Hurt && Server.CurrentTime % 1 != 0)
119+
if (zone.Type is ZoneType.Hurt && Server.CurrentTime % 1 != 0)
102120
return false;
103121

104122
switch (Config.Messages)
@@ -108,7 +126,7 @@ private bool PrintAction(CCSPlayerController player, Zone zone)
108126
return true;
109127

110128
case "detailed":
111-
if (zone.Type is (ZoneType.Bounce or ZoneType.Teleport))
129+
if (zone.Type is (ZoneType.Bounce or ZoneType.Teleport or ZoneType.Wall))
112130
{
113131
player.PrintToChat(Config.NoRushTime != 0
114132
? $"{Prefix}{Localizer["rushDelayRemaining", zone.ToString(Localizer), (_roundStart + Config.NoRushTime - Server.CurrentTime).ToString("0")]}"
@@ -117,7 +135,7 @@ private bool PrintAction(CCSPlayerController player, Zone zone)
117135
return true;
118136
}
119137

120-
if (zone.Type == ZoneType.Hurt)
138+
if (zone.Type is ZoneType.Hurt)
121139
{
122140
player.PrintToChat($"{Prefix}{Localizer["hurtDamage", zone.ToString(Localizer), zone.Damage]}");
123141
return true;
@@ -138,10 +156,12 @@ private void DoAction(CCSPlayerController player, Zone zone)
138156
if (PrintAction(player, zone))
139157
_playerData[player].LastMessage = Server.CurrentTime;
140158

159+
if (zone.Type is (ZoneType.Bounce or ZoneType.Wall))
160+
_playerData[player].BlockButtons = Server.TickedTime + 0.3;
161+
141162
switch (zone.Type)
142163
{
143164
case ZoneType.Bounce:
144-
_playerData[player].BlockButtons = (float)Server.TickedTime + 1;
145165
player.Bounce(_playerData[player].LastPos, _playerData[player].LastVel);
146166

147167
return;

src/Classes/PlayerData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ public class PlayerData
1313
public Vector_t? SpawnPos { get; set; } = null;
1414
public float[] LastPos { get; set; } = [];
1515
public float[] LastVel { get; set; } = [];
16-
public float BlockButtons { get; set; } = 0;
16+
public double BlockButtons { get; set; } = 0;
1717
}

src/Commands.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ public partial class AntiRush
1010
{
1111
public void CommandAntiRush(CCSPlayerController? player, CommandInfo info)
1212
{
13-
if (player == null || !player.IsValid(true) || player.HasPermission("@css/generic"))
13+
if (player == null || !player.IsValid(true) || !player.HasPermission("@css/generic"))
1414
return;
1515

1616
BuildMenu(player);
1717
}
1818

1919
public void CommandAddZone(CCSPlayerController? player, CommandInfo info)
2020
{
21-
if (player == null || !player.IsValid(true) || player.HasPermission("@css/root"))
21+
if (player == null || !player.IsValid(true) || !player.HasPermission("@css/root"))
2222
return;
2323

2424
BuildMenu(player);
@@ -27,7 +27,7 @@ public void CommandAddZone(CCSPlayerController? player, CommandInfo info)
2727

2828
public void CommandViewZones(CCSPlayerController? player, CommandInfo info)
2929
{
30-
if (player == null || !player.IsValid(true) || player.HasPermission("@css/generic"))
30+
if (player == null || !player.IsValid(true) || !player.HasPermission("@css/generic"))
3131
return;
3232

3333
BuildMenu(player);

src/Events.cs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
using CounterStrikeSharp.API;
22
using CounterStrikeSharp.API.Core;
33
using CounterStrikeSharp.API.Modules.Utils;
4-
using CSSharpUtils.Utils;
5-
using FixVectorLeak.src.Structs;
64
using AntiRush.Extensions;
5+
using CSSharpUtils.Utils;
76
using FixVectorLeak.src;
7+
using FixVectorLeak.src.Structs;
88

99
namespace AntiRush;
1010

@@ -16,7 +16,7 @@ private HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info)
1616
_gameRules = GameUtils.GetGameRules();
1717
_roundStart = Server.CurrentTime;
1818

19-
var count = Utilities.GetPlayers().Where(p => p.Team is CsTeam.CounterTerrorist or CsTeam.Terrorist).ToList().Count;
19+
var count = Utilities.GetPlayers().Where(p => p.Team is (CsTeam.CounterTerrorist or CsTeam.Terrorist)).ToList().Count;
2020
_minPlayers = count >= Config.MinPlayers;
2121
_maxPlayers = count < Config.MaxPlayers;
2222

@@ -33,7 +33,7 @@ private HookResult OnRoundStart(EventRoundStart @event, GameEventInfo info)
3333

3434
private HookResult OnBombPlanted(EventBombPlanted @event, GameEventInfo info)
3535
{
36-
if (!Config.DisableOnBombPlant || !_minPlayers)
36+
if (!Config.DisableOnBombPlant || !_minPlayers || !_maxPlayers)
3737
return HookResult.Continue;
3838

3939
_bombPlanted = true;
@@ -46,7 +46,7 @@ private HookResult OnPlayerSpawn(EventPlayerSpawn @event, GameEventInfo info)
4646
{
4747
var player = @event.Userid;
4848

49-
if (player == null || !player.IsValid() || player.PlayerPawn.Value == null || player.PlayerPawn.Value.AbsOrigin == null)
49+
if (player == null || !player.IsValid() || player.PlayerPawn.Value?.AbsOrigin == null)
5050
return HookResult.Continue;
5151

5252
var origin = player.PlayerPawn.Value.AbsOrigin.ToVector_t();
@@ -64,7 +64,7 @@ private HookResult OnBulletImpact(EventBulletImpact @event, GameEventInfo info)
6464
if (player == null || !player.IsValid() || !_playerData.TryGetValue(player, out var playerData) || playerData.AddZoneMenu == null || !Menu.IsCurrentMenu(player, playerData.AddZoneMenu))
6565
return HookResult.Continue;
6666

67-
if (playerData.AddZoneMenu is null || playerData.AddZoneMenu.Points[0] is not null && playerData.AddZoneMenu.Points[1] is not null)
67+
if (playerData.AddZoneMenu.Points[0] is not null && playerData.AddZoneMenu.Points[1] is not null)
6868
return HookResult.Continue;
6969

7070
if (Server.CurrentTime - playerData.AddZoneMenu.LastShot < 0.1)
@@ -100,12 +100,14 @@ private HookResult OnBulletImpact(EventBulletImpact @event, GameEventInfo info)
100100
if (diffZ < 200)
101101
{
102102
if (playerData.AddZoneMenu.Points[0]!.Value.Z >= playerData.AddZoneMenu.Points[1]!.Value.Z)
103-
playerData.AddZoneMenu.Points[0] = new Vector_t(playerData.AddZoneMenu.Points[0]!.Value.X, playerData.AddZoneMenu.Points[0]!.Value.Y, playerData.AddZoneMenu.Points[0]!.Value.Z + ((playerData.AddZoneMenu.Points[0]!.Value.Z >= playerData.AddZoneMenu.Points[1]!.Value.Z ? 1 : -1) * ((200 - diffZ) / 2)));
103+
playerData.AddZoneMenu.Points[0] = new Vector_t(playerData.AddZoneMenu.Points[0]!.Value.X, playerData.AddZoneMenu.Points[0]!.Value.Y, playerData.AddZoneMenu.Points[0]!.Value.Z + 200 - diffZ);
104104
else
105-
playerData.AddZoneMenu.Points[1] = new Vector_t(playerData.AddZoneMenu.Points[1]!.Value.X, playerData.AddZoneMenu.Points[1]!.Value.Y, playerData.AddZoneMenu.Points[1]!.Value.Z + ((playerData.AddZoneMenu.Points[0]!.Value.Z > playerData.AddZoneMenu.Points[1]!.Value.Z ? -1 : 1) * ((200 - diffZ) / 2)));
105+
playerData.AddZoneMenu.Points[1] = new Vector_t(playerData.AddZoneMenu.Points[1]!.Value.X, playerData.AddZoneMenu.Points[1]!.Value.Y, playerData.AddZoneMenu.Points[1]!.Value.Z + 200 - diffZ);
106106
}
107107

108-
playerData.AddZone = new Zone([playerData.AddZoneMenu.Points[0]!.Value.X, playerData.AddZoneMenu.Points[0]!.Value.Y, playerData.AddZoneMenu.Points[0]!.Value.Z], [playerData.AddZoneMenu.Points[1]!.Value.X, playerData.AddZoneMenu.Points[1]!.Value.Y, playerData.AddZoneMenu.Points[1]!.Value.Z]);
108+
playerData.AddZone ??= new Zone([0, 0, 0], [0, 0, 0]);
109+
playerData.AddZone.MinPoint = [playerData.AddZoneMenu.Points[0]!.Value.X, playerData.AddZoneMenu.Points[0]!.Value.Y, playerData.AddZoneMenu.Points[0]!.Value.Z];
110+
playerData.AddZone.MaxPoint = [playerData.AddZoneMenu.Points[1]!.Value.X, playerData.AddZoneMenu.Points[1]!.Value.Y, playerData.AddZoneMenu.Points[1]!.Value.Z];
109111
playerData.AddZone.Draw();
110112
}
111113

0 commit comments

Comments
 (0)