jRandomSkills/jRandomSkills - SRC Files/src/player/skills/DemonEye.cs
Juzlus 8038a4d646 v1.2.3.b2 - Part 2
## GENERAL
- Added a css_entity admin command to check whether an entity with a given index/handle exists (prints the designer name to chat or console).
- Added a TakeDamage post-hook (OnTakeDamagePost) alongside the existing pre-hook, so skills can now react after damage has actually been applied, not just before.
- Added CreateMolotovProjectile (new CMolotovProjectile_CreateFunc signature) and CreateTrackedChicken entity helpers.
- Added a weapon_mp7 → weapon_mp5sd fallback mapping.
- Added class for KillfeedIcons

## SKILL IMPROVEMENTS
- Aimbot:
  -- Only forces a headshot hitgroup once (skips if it's already a head or an invalid hitgroup), and now restores the original hitgroup value in the new post-damage hook instead of leaving it overwritten.
- Tripwire:
  -- Reduced the default wire width from 1.5 to 0.7.

## NEW SKILLS:
- Berserker: You deal more damage and move faster as your health gets lower.
- Blast Shot: Press Attack2 with the MP5 to fire an HE grenade.
- Demon Eye: You deal damage to every enemy you are looking at.
- Fire Rain: Throw a decoy to call down a rain of Molotovs.
- Flashlight: Click [css_useSkill] to turn the flashlight on or off; its light can blind enemies.
- Healing Chicken: Your chickens heal you while you are nearby.
- Jetkick: Select a player to jetkick - every shot they fire knocks them backwards until disabled.
- Last Gasp: After you die, you deal damage to the enemy who killed you.
- Take Ammo: Click [css_useSkill] to take the active weapon's magazine from a random enemy.
- Team Teleport: Press [css_useSkill] to teleport to the teammate you're looking at.
2026-07-31 20:28:02 +02:00

80 lines
No EOL
3.4 KiB
C#

using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.utils;
using src.utils;
using static src.jRandomSkills;
namespace src.player.skills
{
public class DemonEye : ISkill
{
private const Skills skillName = Skills.DemonEye;
private static readonly Skills[] hidingSkills = [Skills.Ghost, Skills.Ninja, Skills.C4Camouflage];
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, SkillsInfo.GetValue<string>(skillName, "color"));
}
public static void OnTick()
{
int tickCooldown = (int)(64 * SkillsInfo.GetValue<float>(skillName, "SecondCooldown"));
if (Server.TickCount % tickCooldown != 0) return;
int damage = SkillsInfo.GetValue<int>(skillName, "damage");
foreach (var player in PlayerManager.GetTickPlayers())
{
var playerEvent = PlayerManager.GetPlayerEvent(player);
if (!Instance.IsPlayerValid(playerEvent)) continue;
var playerInfo = PlayerManager.GetPlayerByIndex(playerEvent!.Index);
if (playerInfo?.Skill == skillName)
HitEnemies(playerEvent, damage);
}
}
private static void HitEnemies(CCSPlayerController player, int damage)
{
if (player == null || !player.IsValid || player.PlayerPawn?.Value == null) return;
int playerSlot = player.Slot;
int playerBit = playerSlot % 32;
if (playerSlot < 0)
return;
foreach (var enemy in PlayerManager.GetTickPlayers().FindAll(p => p != null && p.IsValid && p.Team != player.Team))
{
var enemyEvent = PlayerManager.GetPlayerEvent(enemy);
if (enemyEvent == null || !enemyEvent.IsValid) continue;
var enemyPawn = enemyEvent.PlayerPawn?.Value;
if (enemyPawn == null || !enemyPawn.IsValid || enemyPawn.Health <= 0) continue;
int enemySlot = enemy.Slot;
if (enemySlot < 0)
return;
int enemyBit = enemySlot % 32;
uint playerMask = 1u << playerBit;
uint enemyMask = 1u << enemyBit;
bool playerSeesEnemy = (enemyPawn.EntitySpottedState.SpottedByMask[0] & playerMask) != 0;
if (playerSeesEnemy)
{
SkillUtils.TakeHealth(enemyPawn, damage, player, KillfeedIcons.Fist);
enemyEvent.EmitSound("Player.DamageBody.Onlooker");
}
}
}
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#c91243", CsTeam onlyTeam = CsTeam.None, bool disableOnFreezeTime = false, bool needsTeammates = false, string requiredPermission = "", float? hudDuration = null, float? descriptionHudDuration = null, int maxPerServer = -1, Rarity rarity = Rarity.Common, float secondCooldown = 1f, int damage = 5) : SkillsInfo.DefaultSkillInfo(skill, active, color, onlyTeam, disableOnFreezeTime, needsTeammates, requiredPermission, hudDuration, descriptionHudDuration, maxPerServer, rarity)
{
public float SecondCooldown { get; set; } = secondCooldown;
public int Damage { get; set; } = damage;
}
}
}