jRandomSkills/jRandomSkills - SRC Files/src/player/skills/Jackal.cs
Juzlus 91761f7376 v1.2.2.b2
## GENERAL
- Updated CSS to version 1.0.369.
- Upgraded the project from .NET 8.0 to .NET 10.0.
- Updated Turkish language translation by @ByDexterTR.
- Added Russian language translation by @213sdfsdgf.
- Fixed an issue with incorrect display of Arabic nicknames.
- Used ForceFullUpdate to resolve the "FATAL ERROR: CopyExistingEntity" crash.
- Disabled stale HandleCommandDrop hook to avoid crashes when a player joins a team (thanks to @vladimir214sd).
- Added new signatures to gamedata.
- Added the ability to configure the number of grenades for every skill that uses grenades as part of its ability (e.g., Miner, AntyFlash, MagneticDecoy, etc.).

## SKILL IMPROVEMENTS
- Re-Zombie:
  -- Fixed weapon switching issues when a player is holding a Zeus and a knife.
  -- Weapons are now removed for bots in zombie mode.
- Ghost:
  -- Blocked the ability to use the Zeus.
- Thorns:
  -- Added a configurable maximum health limit (37 HP) for the damage that can be reflected.
- Second Life / Phoenix / Re-Zombie:
  -- Fixed an issue where players would occasionally fail to respawn if they took too much damage too quickly.
- Ghost / Chicken:
  -- Blocked the ability to use the SG556 (`weapon_sg556`).
- Wallhack:
  -- Fixed a bug that caused temporary enemy highlighting right after death.
- Cypher:
  -- Added camera position persistence.
- God Mode:
  -- Fixed an issue with permanent immortality triggering after reaching exactly 0 HP.
- Weapons Swap:
  -- The ammo count is now also transferred when weapons are swapped.
- Muhammed:
  -- Renamed the skill to "DeathBomb".
- Spectator:
  -- Fixed a bug where a player with the Chicken skill would still display as a ragdoll after death when spectated.
- Friendly Fire:
  -- The skill now works even when the server's mp_friendlyfire setting is set to 0.
- Baseball:
  -- Disabled teammate killing.
2026-06-10 13:47:34 +02:00

175 lines
No EOL
7 KiB
C#

using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Attributes;
using CounterStrikeSharp.API.Modules.Entities;
using CounterStrikeSharp.API.Modules.Utils;
using src.utils;
using System.Collections.Concurrent;
using static src.jRandomSkills;
using Timer = CounterStrikeSharp.API.Modules.Timers.Timer;
namespace src.player.skills
{
public class Jackal : ISkill
{
private const Skills skillName = Skills.Jackal;
private static Timer? mainSkillTimer = null;
private static readonly ConcurrentDictionary<uint, uint?> activeTrails = [];
private static readonly ConcurrentDictionary<uint, byte> playersInAction = [];
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, SkillsInfo.GetValue<string>(skillName, "color"));
Instance.AddToManifest(SkillsInfo.GetValue<string>(skillName, "particleName"));
}
public static void NewRound()
{
if (mainSkillTimer != null)
{
mainSkillTimer.Kill();
mainSkillTimer = null;
}
foreach (var index in activeTrails.Keys)
EntityManager.DestroyPlayerEntities(index);
activeTrails.Clear();
playersInAction.Clear();
}
public static void CheckTransmit([CastFrom(typeof(nint))] CCheckTransmitInfoList infoList)
{
var snapshot = activeTrails.ToArray();
foreach (var (info, player) in infoList)
{
if (player == null || !player.IsValid) continue;
var playerInfo = PlayerManager.GetPlayerByIndex(PlayerManager.GetPlayerEvent(player)!.Index);
bool isJackalOwner = playerInfo?.Skill == skillName;
if (!isJackalOwner)
{
var targetHandle = player.Pawn.Value?.ObserverServices?.ObserverTarget.Value?.Handle ?? nint.Zero;
if (targetHandle != nint.Zero)
{
var observed = Utilities.GetPlayers()
.FirstOrDefault(p => p?.Pawn?.Value?.Handle == targetHandle);
if (observed != null && observed.IsValid)
{
var observedInfo = PlayerManager.GetPlayerByIndex(observed.Index);
if (observedInfo?.Skill == skillName)
isJackalOwner = true;
}
}
}
foreach (var (trackedPlayerIndex, relayIndex) in snapshot)
{
if (relayIndex == null) continue;
var trailOwner = Utilities.GetPlayerFromIndex((int)trackedPlayerIndex);
if (trailOwner == null || !trailOwner.IsValid) continue;
var relayEntity = Utilities.GetEntityFromIndex<CBaseEntity>((int)relayIndex);
if (relayEntity == null || !relayEntity.IsValid) continue;
if (player.Team == trailOwner.Team || !isJackalOwner)
if (info.TransmitEntities.Contains(relayEntity.Index))
info.TransmitEntities.Remove(relayEntity.Index);
}
}
}
public static void CreatePlayerTrail(CCSPlayerController? player)
{
if (player == null || !player.IsValid) return;
var playerPawn = player.PlayerPawn.Value;
if (playerPawn == null || !playerPawn.IsValid || playerPawn.AbsOrigin == null
|| playerPawn.LifeState != (byte)LifeState_t.LIFE_ALIVE || playerPawn.Health <= 0) return; ;
var relay = EntityManager.CreateTrackedPhysicsProp(player.Index);
if (relay == null || !relay.IsValid) return;
CBaseEntity target = playerPawn;
var entities = EntityManager.GetPlayerEntities(player.Index, "empty_prop");
if (entities.Count > 0)
{
var entity = Utilities.GetEntityFromIndex<CDynamicProp>((int)entities[0]);
if (entity != null && entity.IsValid)
target = entity;
}
relay.AcceptInput("SetParent", target, relay, "!activator");
var particle = EntityManager.CreateTrackedParticleSystem(
player.Index,
SkillsInfo.GetValue<string>(skillName, "particleName"));
if (particle != null && particle.IsValid && target.AbsOrigin != null)
{
Vector pos = new(target.AbsOrigin.X, target.AbsOrigin.Y, target.AbsOrigin.Z);
if (entities.Count > 0) pos.Z -= 30;
particle.Teleport(pos);
particle.AcceptInput("SetParent", relay, particle, "!activator");
particle.AcceptInput("Start");
}
activeTrails[player.Index] = relay.Index;
}
public static void EnableSkill(CCSPlayerController player)
{
if (player == null || !player.IsValid) return;
Event.EnableTransmit();
playersInAction.TryAdd(player.Index, 0);
var opponents = Utilities.GetPlayers()
.Where(p => p != null
&& p.IsValid
&& p.Team != player.Team
&& p.PawnIsAlive
&& (p.Team is CsTeam.CounterTerrorist or CsTeam.Terrorist))
.ToArray();
mainSkillTimer ??= Instance.AddTimer(2.5f, () => UpdateAllTrails(),
CounterStrikeSharp.API.Modules.Timers.TimerFlags.REPEAT | CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
SkillUtils.ForceFullUpdateToAll();
}
private static void UpdateAllTrails()
{
foreach (var player in Utilities.GetPlayers())
CreatePlayerTrail(player);
}
public static void DisableSkill(CCSPlayerController player)
{
if (player == null || !player.IsValid) return;
uint playerIndex = player.Index;
playersInAction.TryRemove(playerIndex, out _);
EntityManager.DestroyPlayerEntities(playerIndex);
activeTrails.TryRemove(playerIndex, out _);
if (playersInAction.IsEmpty && mainSkillTimer != null)
{
mainSkillTimer.Kill();
mainSkillTimer = null;
}
SkillUtils.ForceFullUpdateToAll();
}
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#f542ef", CsTeam onlyTeam = CsTeam.None, bool disableOnFreezeTime = false, bool needsTeammates = false, string requiredPermission = "", int maxPerServer = 1, Rarity rarity = Rarity.Common, string particleName = "particles/ui/hud/ui_map_def_utility_trail.vpcf") : SkillsInfo.DefaultSkillInfo(skill, active, color, onlyTeam, disableOnFreezeTime, needsTeammates, requiredPermission, maxPerServer, rarity)
{
public string ParticleName { get; set; } = particleName;
}
}
}