Skip to content

Commit

Permalink
Release
Browse files Browse the repository at this point in the history
Fixed tags and condition of aimbot detection
Adding a proper take items through walls (soon)
  • Loading branch information
TH3AL3X committed Aug 15, 2024
1 parent 665fd03 commit 6119879
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 17 deletions.
6 changes: 5 additions & 1 deletion DAC/components/player_component.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
using Rocket.Unturned.Player;
using DAC;
using Rocket.Unturned.Chat;
using Rocket.Unturned.Player;
using SDG.Unturned;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

namespace Darkness_Anti_Cheat.components
{
Expand Down
33 changes: 20 additions & 13 deletions DAC/events/events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.Linq;
using System.Threading;
using UnityEngine;
using static SDG.Provider.SteamGetInventoryResponse;

namespace DAC
{
Expand Down Expand Up @@ -80,7 +81,7 @@ public static void event_aimbot(Player player, EDeathCause cause, ELimb limb, CS
if (Physics.Raycast(Killer.Player.look.aim.position, Killer.Player.look.aim.forward, out hit, gunAsset.range, RayMasks.BARRICADE | RayMasks.STRUCTURE | RayMasks.VEHICLE | RayMasks.RESOURCE | RayMasks.PLAYER))
{
// Test it with real anti cheat, if player is not visible or not targeting him and shooting through walls, detect it as silent-aim
if (hit.transform == null || !hit.transform.CompareTag("Enemy"))
if (hit.transform != null && hit.transform.tag != "Player")
{
Killer.GetComponent<PlayerComponent>().RateAim++;

Expand All @@ -107,7 +108,6 @@ public static void event_aimbot(Player player, EDeathCause cause, ELimb limb, CS
}
}

// Cannot detect Melee, i'm do lazy do it xd
// Range changer hack detection, max of punch distance is 2, but i put more cause the lag compensation can fail
if (Darkness_Anti_Cheat.Instance.Configuration.Instance.punch_override_distance_detection)
{
Expand Down Expand Up @@ -183,7 +183,7 @@ public static IEnumerator get_players_detection()
while (true)
{
// Don't rape the CPU server
yield return new WaitForSeconds(1f);
yield return new WaitForSeconds(3f);

foreach (SteamPlayer list in Provider.clients)
{
Expand Down Expand Up @@ -269,6 +269,22 @@ public static IEnumerator get_players_detection()
}
}


/*List<InteractableItem> itemsInRadius;
Darkness_Anti_Cheat_Functions.GetItemsInRadius(unturnedPlayer, out itemsInRadius, 8, 395f);
if (!(itemsInRadius.Count < 1))
{
foreach (InteractableItem i in itemsInRadius)
{
float dst = Vector3.Distance(i.transform.position, unturnedPlayer.Player.transform.position);
if (dst < 2)
continue;
UnturnedChat.Say($"{i.asset.name}");
}
}*/

// Just doing some test with vehicle no-clip, getting distance to detect if is insane of a wall
/*if (Physics.Raycast(unturnedPlayer.Position, unturnedPlayer.Player.look.aim.forward, out hit, 100, RayMasks.BARRICADE | RayMasks.LARGE | RayMasks.MEDIUM | RayMasks.SMALL | RayMasks.STRUCTURE | RayMasks.RESOURCE))
{
Expand All @@ -293,16 +309,7 @@ public static void take_items_through_walls(UnturnedPlayer player, InventoryGrou
{
RocketPlayer rocketPlayer = new RocketPlayer(player.Id);

if (!player.IsAdmin && !rocketPlayer.HasPermission("*") && !rocketPlayer.HasPermission("dac_bypass"))
{
RaycastHit hit;

// I'm working on it
/*if (Physics.Raycast(player.Player.look.aim.position, player.Player.look.aim.forward, out hit, 2.5f, RayMasks.ITEM | RayMasks.PLAYER_INTERACT))
{
}*/
}
UnturnedChat.Say($"{P.interactableItem.transform.position}");
}

public static void chat_log(UnturnedPlayer player, string message)
Expand Down
24 changes: 24 additions & 0 deletions DAC/helpers/helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,30 @@ public UnturnedPlayer FindClosestPlayer(UnturnedPlayer targetPlayer)

return closestPlayer;
}

// Reverse from random cheat
public static void GetItemsInRadius(UnturnedPlayer player, out List<InteractableItem> items, int RegionReach, float MaxMagnitude)
{
items = new List<InteractableItem>();

List<ItemRegion> regionsInRadius = new List<ItemRegion>();

for (int x = 0; x < 64; x++)
for (int y = 0; y < 64; y++)
if (ItemManager.regions[x, y] != null)
if (ItemManager.regions[x, y].drops.Count > 0)
if ((x <= player.Player.movement.region_x && y <= player.Player.movement.region_y && (player.Player.movement.region_x - x) <= RegionReach && (player.Player.movement.region_y - y) <= RegionReach) ||
(x >= player.Player.movement.region_x && y >= player.Player.movement.region_y && (x - player.Player.movement.region_x) <= RegionReach && (y - player.Player.movement.region_y) <= RegionReach))
regionsInRadius.Add(ItemManager.regions[x, y]);

foreach (ItemRegion x in regionsInRadius)
foreach (ItemDrop y in x.drops)
if (!y.interactableItem.checkInteractable() || !y.interactableItem.checkUseable())
continue;
else if ((y.interactableItem.transform.position - player.Player.transform.position).sqrMagnitude < MaxMagnitude)
items.Add(y.interactableItem);
}

public static byte[] ByteArray(string imagePath)
{
byte[] imageByteArray = null;
Expand Down
6 changes: 3 additions & 3 deletions DAC/main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected override void Load()
UnturnedPlayerEvents.OnPlayerChatted += OnPlayerChatted; Darkness_Anti_Cheat_Functions.Log("OnPlayerChatted event loaded", ConsoleColor.DarkCyan);
DamageTool.playerDamaged += OnPlayerDamage; Darkness_Anti_Cheat_Functions.Log("OnPlayerDamage event loaded", ConsoleColor.DarkCyan);

Check warning on line 52 in DAC/main.cs

View workflow job for this annotation

GitHub Actions / build

'DamageTool.playerDamaged' is obsolete: 'Use damagePlayerRequested'

Check warning on line 52 in DAC/main.cs

View workflow job for this annotation

GitHub Actions / build

'DamageTool.playerDamaged' is obsolete: 'Use damagePlayerRequested'
U.Events.OnPlayerConnected += OnPlayerConnect; Darkness_Anti_Cheat_Functions.Log("OnPlayerConnect event loaded", ConsoleColor.DarkCyan);
UnturnedPlayerEvents.OnPlayerInventoryAdded += OnPlayerInventoryAdded; Darkness_Anti_Cheat_Functions.Log("OnPlayerInventoryAdded event loaded", ConsoleColor.DarkCyan);
//UnturnedPlayerEvents.OnPlayerInventoryAdded += OnPlayerInventoryAdded; Darkness_Anti_Cheat_Functions.Log("OnPlayerInventoryAdded event loaded", ConsoleColor.DarkCyan);

Level.onPostLevelLoaded += OnPostLevelLoaded;
if (Level.isLoaded)
Expand All @@ -74,7 +74,7 @@ protected override void Unload()
}

DamageTool.playerDamaged -= OnPlayerDamage; Darkness_Anti_Cheat_Functions.Log("OnPlayerDamage event unloaded", ConsoleColor.DarkCyan);

Check warning on line 76 in DAC/main.cs

View workflow job for this annotation

GitHub Actions / build

'DamageTool.playerDamaged' is obsolete: 'Use damagePlayerRequested'

Check warning on line 76 in DAC/main.cs

View workflow job for this annotation

GitHub Actions / build

'DamageTool.playerDamaged' is obsolete: 'Use damagePlayerRequested'
UnturnedPlayerEvents.OnPlayerInventoryAdded -= OnPlayerInventoryAdded; Darkness_Anti_Cheat_Functions.Log("OnPlayerInventoryAdded event unloaded", ConsoleColor.DarkCyan);
//UnturnedPlayerEvents.OnPlayerInventoryAdded -= OnPlayerInventoryAdded; Darkness_Anti_Cheat_Functions.Log("OnPlayerInventoryAdded event unloaded", ConsoleColor.DarkCyan);
Level.onPostLevelLoaded -= OnPostLevelLoaded;
CancelInvoke("AutoAnnouncement");

Expand All @@ -86,7 +86,7 @@ public void OnPostLevelLoaded(int level)
Darkness_Anti_Cheat_Functions.Log("Let's destroy the game breakers...", ConsoleColor.Green);
}

private void OnPlayerInventoryAdded(UnturnedPlayer player, InventoryGroup inventoryGroup, byte inventoryIndex, ItemJar P) => Darkness_Anti_Cheat_Events.take_items_through_walls(player, inventoryGroup, inventoryIndex, P);
//private void OnPlayerInventoryAdded(UnturnedPlayer player, InventoryGroup inventoryGroup, byte inventoryIndex, ItemJar P) => Darkness_Anti_Cheat_Events.take_items_through_walls(player, inventoryGroup, inventoryIndex, P);
private void OnPlayerChatted(UnturnedPlayer player, ref Color color, string message, SDG.Unturned.EChatMode chatMode, ref bool cancel) => Darkness_Anti_Cheat_Events.chat_log(player, message);
private void OnPlayerConnect(UnturnedPlayer player) { player.Player.GetComponent<PlayerComponent>().Kills = 0; player.Player.GetComponent<PlayerComponent>().Deaths = 0; player.Player.GetComponent<PlayerComponent>().Headshots = 0; }
private void OnPlayerDeath(UnturnedPlayer player, EDeathCause cause, ELimb limb, CSteamID killer) => Darkness_Anti_Cheat_Events.auto_report(killer, player, limb);
Expand Down

0 comments on commit 6119879

Please sign in to comment.