This commit is contained in:
Juzlus 2025-08-29 02:41:39 +02:00
parent 6b8988ade4
commit 26cb787b57
125 changed files with 9157 additions and 1940 deletions

View file

@ -1,7 +1,7 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Memory;
using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using System.Runtime.InteropServices;
using static jRandomSkills.jRandomSkills;
@ -10,15 +10,12 @@ namespace jRandomSkills
{
public class Aimbot : ISkill
{
private static Skills skillName = Skills.Aimbot;
private const Skills skillName = Skills.Aimbot;
private static Dictionary<nint, int> hitGroups = new Dictionary<nint, int>();
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#ff0000");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
VirtualFunctions.CBaseEntity_TakeDamageOldFunc.Hook(OnTakeDamage, HookMode.Pre);
}
@ -66,5 +63,12 @@ namespace jRandomSkills
return HookResult.Continue;
}
public class SkillConfig : Config.DefaultSkillInfo
{
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#ff0000", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}
}

View file

@ -0,0 +1,163 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using jRandomSkills.src.utils;
using static CounterStrikeSharp.API.Core.Listeners;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class Anomaly : ISkill
{
private const Skills skillName = Skills.Anomaly;
private static int maxSize = Config.GetValue<int>(skillName, "secondsInBack");
private static float tickRate = 64;
private static float timerCooldown = Config.GetValue<float>(skillName, "cooldown");
private static readonly Dictionary<ulong, PlayerSkillInfo> SkillPlayerInfo = new Dictionary<ulong, PlayerSkillInfo>();
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
Instance.AddTimer(0.1f, () =>
{
foreach (var player in Utilities.GetPlayers())
{
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill == skillName)
EnableSkill(player);
}
});
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventRoundEnd>((@event, info) =>
{
SkillPlayerInfo.Clear();
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventPlayerDeath>((@event, info) =>
{
var player = @event.Userid;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill == skillName)
if (SkillPlayerInfo.ContainsKey(player.SteamID))
SkillPlayerInfo.Remove(player.SteamID);
return HookResult.Continue;
});
Instance.RegisterListener<OnTick>(() =>
{
foreach (var player in Utilities.GetPlayers())
{
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill == skillName)
if (SkillPlayerInfo.TryGetValue(player.SteamID, out var skillInfo))
{
UpdateHUD(player, skillInfo);
if (Server.TickCount % tickRate != 0) return;
var pawn = player.PlayerPawn.Value;
if (pawn != null && pawn.IsValid)
{
skillInfo.LastPositions.Add(new Vector(pawn.AbsOrigin.X, pawn.AbsOrigin.Y, pawn.AbsOrigin.Z));
skillInfo.LastRotations.Add(new QAngle(pawn.EyeAngles.X, pawn.EyeAngles.Y, pawn.EyeAngles.Z));
if (skillInfo.LastRotations.Count > maxSize)
{
skillInfo.LastPositions.RemoveAt(0);
skillInfo.LastRotations.RemoveAt(0);
}
}
}
}
});
}
public static void EnableSkill(CCSPlayerController player)
{
SkillPlayerInfo[player.SteamID] = new PlayerSkillInfo
{
SteamID = player.SteamID,
CanUse = true,
Cooldown = DateTime.MinValue,
LastPositions = new List<Vector>(),
LastRotations = new List<QAngle>(),
};
}
public static void DisableSkill(CCSPlayerController player)
{
if (SkillPlayerInfo.ContainsKey(player.SteamID))
SkillPlayerInfo.Remove(player.SteamID);
}
private static void UpdateHUD(CCSPlayerController player, PlayerSkillInfo skillInfo)
{
float cooldown = 0;
if (skillInfo != null)
{
float time = (int)(skillInfo.Cooldown.AddSeconds(timerCooldown) - DateTime.Now).TotalSeconds;
cooldown = Math.Max(time, 0);
if (cooldown == 0 && skillInfo?.CanUse == false)
skillInfo.CanUse = true;
}
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == skillName);
if (skillData == null) return;
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{Localization.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{skillData.Name}</font> <br>";
string remainingLine = cooldown != 0 ? $"<font class='fontSize-m' color='#FFFFFF'>{Localization.GetTranslation("hud_info", $"<font color='#FF0000'>{cooldown}</font>")}</font> <br>" : "";
var hudContent = infoLine + skillLine + remainingLine;
player.PrintToCenterHtml(hudContent);
}
public static void UseSkill(CCSPlayerController player)
{
var playerPawn = player.PlayerPawn.Value;
if (playerPawn?.CBodyComponent == null) return;
if (SkillPlayerInfo.TryGetValue(player.SteamID, out var skillInfo))
{
if (!player.IsValid || !player.PawnIsAlive) return;
if (skillInfo.CanUse)
{
skillInfo.CanUse = false;
skillInfo.Cooldown = DateTime.Now;
Vector lastPosition = skillInfo.LastPositions.FirstOrDefault();
QAngle lastRotation = skillInfo.LastRotations.FirstOrDefault();
if (lastPosition != null && lastRotation != null)
playerPawn.Teleport(lastPosition, lastRotation, null);
}
}
}
public class PlayerSkillInfo
{
public ulong SteamID { get; set; }
public bool CanUse { get; set; }
public DateTime Cooldown { get; set; }
public List<Vector> LastPositions { get; set; }
public List<QAngle> LastRotations { get; set; }
}
public class SkillConfig : Config.DefaultSkillInfo
{
public int SecondsInBack { get; set; }
public float Cooldown { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#a86eff", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int secondsInBack = 5, float cooldown = 15) : base(skill, active, color, onlyTeam, needsTeammates)
{
SecondsInBack = secondsInBack;
Cooldown = cooldown;
}
}
}
}

View file

@ -1,4 +1,7 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Entities.Constants;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static jRandomSkills.jRandomSkills;
@ -6,15 +9,28 @@ namespace jRandomSkills
{
public class AntyFlash : ISkill
{
private static Skills skillName = Skills.AntyFlash;
private const Skills skillName = Skills.AntyFlash;
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
Instance.AddTimer(0.1f, () =>
{
foreach (var player in Utilities.GetPlayers())
{
if (!Instance.IsPlayerValid(player)) continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) continue;
EnableSkill(player);
}
});
return HookResult.Continue;
});
SkillUtils.RegisterSkill(skillName, "#D6E6FF");
Instance.RegisterEventHandler<EventPlayerBlind>((@event, info) =>
{
var player = @event.Userid;
@ -35,5 +51,17 @@ namespace jRandomSkills
return HookResult.Continue;
});
}
public static void EnableSkill(CCSPlayerController player)
{
SkillUtils.TryGiveWeapon(player, CsItem.FlashbangGrenade);
}
public class SkillConfig : Config.DefaultSkillInfo
{
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#D6E6FF", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}
}

View file

@ -1,4 +1,5 @@
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static jRandomSkills.jRandomSkills;
@ -6,15 +7,12 @@ namespace jRandomSkills
{
public class AntyHead : ISkill
{
private static Skills skillName = Skills.AntyHead;
private const Skills skillName = Skills.AntyHead;
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
SkillUtils.RegisterSkill(skillName, "#8B4513");
Instance.RegisterEventHandler<EventPlayerHurt>((@event, info) =>
{
var attacker = @event.Attacker;
@ -45,5 +43,12 @@ namespace jRandomSkills
playerPawn.Health = (int)newHealth;
}
public class SkillConfig : Config.DefaultSkillInfo
{
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#8B4513", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}
}

View file

@ -9,11 +9,11 @@ namespace jRandomSkills
{
public class AreaReaper : ISkill
{
private static Skills skillName = Skills.AreaReaper;
private const Skills skillName = Skills.AreaReaper;
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, "#edf5b5", false);
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
@ -94,5 +94,12 @@ namespace jRandomSkills
foreach (var bombTarget in bombTargets)
bombTarget.AcceptInput("Enable");
}
public class SkillConfig : Config.DefaultSkillInfo
{
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#edf5b5", CsTeam onlyTeam = CsTeam.CounterTerrorist, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}
}

View file

@ -11,14 +11,11 @@ namespace jRandomSkills
{
public class Armored : ISkill
{
private static Skills skillName = Skills.Armored;
private const Skills skillName = Skills.Armored;
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#d1430a", false);
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"), false);
VirtualFunctions.CBaseEntity_TakeDamageOldFunc.Hook(OnTakeDamage, HookMode.Pre);
@ -44,10 +41,7 @@ namespace jRandomSkills
{
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
var skillConfig = Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString());
if (skillConfig == null) return;
float newScale = (float)Instance.Random.NextDouble() * (skillConfig.ChanceTo - skillConfig.ChanceFrom) + skillConfig.ChanceFrom;
float newScale = (float)Instance.Random.NextDouble() * (Config.GetValue<float>(skillName, "ChanceTo") - Config.GetValue<float>(skillName, "ChanceFrom")) + Config.GetValue<float>(skillName, "ChanceFrom");
playerInfo.SkillChance = newScale;
newScale = (float)Math.Round(newScale, 2);
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{Localization.GetTranslation("armored")}{ChatColors.Lime}: " + Localization.GetTranslation("armored_desc2", newScale), false);
@ -73,15 +67,24 @@ namespace jRandomSkills
CCSPlayerController attacker = attackerPawn.Controller.Value.As<CCSPlayerController>();
CCSPlayerController victim = victimPawn.Controller.Value.As<CCSPlayerController>();
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == victim.SteamID);
if (playerInfo == null) return HookResult.Continue;
if (playerInfo.Skill == skillName && attacker.PawnIsAlive)
{
if (playerInfo.Skill == skillName && victim.PawnIsAlive)
param2.Damage *= (float)playerInfo.SkillChance;
}
return HookResult.Continue;
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float ChanceFrom { get; set; }
public float ChanceTo { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#d1430a", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float chanceFrom = .65f, float chanceTo = .85f) : base(skill, active, color, onlyTeam, needsTeammates)
{
ChanceFrom = chanceFrom;
ChanceTo = chanceTo;
}
}
}
}

View file

@ -0,0 +1,78 @@
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class Assassin : ISkill
{
private const Skills skillName = Skills.Assassin;
private static float damageMultiplier = Config.GetValue<float>(skillName, "damageMultiplier");
private static float toleranceDeg = Config.GetValue<float>(skillName, "toleranceDeg");
private static string[] nades = { "inferno", "flashbang", "smokegrenade", "decoy", "hegrenade" };
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventPlayerHurt>((@event, info) =>
{
var damage = @event.DmgHealth;
var victim = @event.Userid;
var attacker = @event.Attacker;
var weapon = @event.Weapon;
HitGroup_t hitgroup = (HitGroup_t)@event.Hitgroup;
if (!Instance.IsPlayerValid(attacker) || !Instance.IsPlayerValid(victim) || attacker == victim) return HookResult.Continue;
if (nades.Contains(weapon)) return HookResult.Continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
if (playerInfo?.Skill != skillName) return HookResult.Continue;
if (IsBehind(attacker, victim))
SkillUtils.TakeHealth(victim.PlayerPawn.Value, (int)(damage * (damageMultiplier - 1f)));
return HookResult.Continue;
});
}
private static bool IsBehind(CCSPlayerController attacker, CCSPlayerController victim)
{
var attackerPawn = attacker.PlayerPawn.Value;
var victimPawn = victim.PlayerPawn.Value;
if (attackerPawn == null || !attackerPawn.IsValid || victimPawn == null || !victimPawn.IsValid) return false;
var angles = GetAngleRange(victimPawn.AbsRotation.Y);
return IsBeetween(angles.Item1, angles.Item2, attackerPawn.AbsRotation.Y);
}
private static (float, float) GetAngleRange(float angle)
{
float min = angle - toleranceDeg;
float max = angle + toleranceDeg;
if (min < -180) min += 360f;
if (max > 180f) max -= 360f;
return (min, max);
}
private static bool IsBeetween(float a, float b, float target)
{
if (a <= b)
return (target >= a && target <= b);
return (target >= a || target <= b);
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float DamageMultiplier { get; set; }
public float ToleranceDeg { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#d9d9d9", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float damageMultiplier = 2f, float toleranceDeg = 45f) : base(skill, active, color, onlyTeam, needsTeammates)
{
DamageMultiplier = damageMultiplier;
ToleranceDeg = toleranceDeg;
}
}
}
}

View file

@ -9,15 +9,12 @@ namespace jRandomSkills
{
public class Astronaut : ISkill
{
private static Skills skillName = Skills.Astronaut;
private const Skills skillName = Skills.Astronaut;
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"), false);
SkillUtils.RegisterSkill(skillName, "#7E10AD", false);
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
Instance.AddTimer(0.1f, () =>
@ -35,6 +32,13 @@ namespace jRandomSkills
});
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
foreach (var player in Utilities.GetPlayers())
DisableSkill(player);
return HookResult.Continue;
});
}
public static void EnableSkill(CCSPlayerController player)
@ -44,17 +48,25 @@ namespace jRandomSkills
public static void DisableSkill(CCSPlayerController player)
{
player.Pawn.Value.GravityScale = 1;
player.Pawn.Value.ActualGravityScale = 1;
}
private static void ApplyGravityModifier(CCSPlayerController player)
{
var skillConfig = Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString());
if (skillConfig == null) return;
float gravityModifier = (float)Math.Round(Instance.Random.NextDouble() * (skillConfig.ChanceTo - skillConfig.ChanceFrom) + skillConfig.ChanceFrom, 1);
float gravityModifier = (float)Math.Round(Instance.Random.NextDouble() * (Config.GetValue<float>(skillName, "ChanceTo") - Config.GetValue<float>(skillName, "chanceFrom")) + Config.GetValue<float>(skillName, "chanceFrom"), 1);
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{Localization.GetTranslation("astronaut")}{ChatColors.Lime}: " + Localization.GetTranslation("astronaut_desc2", gravityModifier), false);
player.Pawn.Value.GravityScale = gravityModifier;
player.Pawn.Value.ActualGravityScale = gravityModifier;
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float ChanceFrom { get; set; }
public float ChanceTo { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#7E10AD", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float chanceFrom = .1f, float chanceTo = .7f) : base(skill, active, color, onlyTeam, needsTeammates)
{
ChanceFrom = chanceFrom;
ChanceTo = chanceTo;
}
}
}
}

View file

@ -0,0 +1,130 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Entities.Constants;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class Baseball : ISkill
{
private const Skills skillName = Skills.Baseball;
private static float speedMultipier = Config.GetValue<float>(skillName, "speedMultipier");
private static float maxSpeed = Config.GetValue<float>(skillName, "maxSpeed");
private static int damageDeal = Config.GetValue<int>(skillName, "damageDeal");
private static HashSet<CDecoyProjectile> decoys = new HashSet<CDecoyProjectile>();
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
Instance.AddTimer(0.1f, () =>
{
foreach (var player in Utilities.GetPlayers())
{
if (!Instance.IsPlayerValid(player)) continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) continue;
EnableSkill(player);
}
});
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventPlayerHurt>((@event, info) =>
{
var victim = @event.Userid;
var attacker = @event.Attacker;
var weapon = @event.Weapon;
if (weapon != "decoy") return HookResult.Continue;
if (!Instance.IsPlayerValid(victim) || !Instance.IsPlayerValid(attacker)) return HookResult.Continue;
var attackerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
if (attackerInfo?.Skill != skillName) return HookResult.Continue;
SkillUtils.TakeHealth(victim.PlayerPawn.Value, damageDeal);
return HookResult.Continue;
});
Instance.RegisterListener<Listeners.OnEntitySpawned>(@event =>
{
var name = @event.DesignerName;
if (name != "decoy_projectile")
return;
var decoy = @event.As<CDecoyProjectile>();
var pawn = decoy.OwnerEntity.Value.As<CCSPlayerPawn>();
var player = pawn.Controller.Value.As<CCSPlayerController>();
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) return;
decoys.Add(decoy);
});
Instance.RegisterEventHandler<EventDecoyStarted>((@event, info) =>
{
var player = @event.Userid;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) return HookResult.Continue;
var decoy = decoys.FirstOrDefault(d => d.Index == @event.Entityid);
if (decoy != null && decoy.IsValid)
decoy.Remove();
return HookResult.Continue;
});
Instance.RegisterListener<Listeners.OnTick>(OnTick);
}
private static void OnTick()
{
foreach (var decoy in decoys)
{
if (decoy == null || !decoy.IsValid)
{
decoys.Remove(decoy);
continue;
}
decoy.Bounces = 0;
if (Server.TickCount % 8 != 0) continue;
var vel = decoy.AbsVelocity;
float speed = vel.Length();
float targetSpeed = Math.Min(speed * speedMultipier, maxSpeed);
if (speed > .01f)
{
var dir = vel / speed;
var newVelocity = dir * targetSpeed;
decoy.AbsVelocity.X = newVelocity.X;
decoy.AbsVelocity.Y = newVelocity.Y;
decoy.AbsVelocity.Z = newVelocity.Z;
}
}
}
public static void EnableSkill(CCSPlayerController player)
{
SkillUtils.TryGiveWeapon(player, CsItem.DecoyGrenade);
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float SpeedMultipier { get; set; }
public float MaxSpeed { get; set; }
public float DamageDeal { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#2effc7", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float speedMultipier = 2f, float maxSpeed = 900f, int damageDeal = 9999) : base(skill, active, color, onlyTeam, needsTeammates)
{
SpeedMultipier = speedMultipier;
MaxSpeed = maxSpeed;
DamageDeal = damageDeal;
}
}
}
}

View file

@ -9,14 +9,11 @@ namespace jRandomSkills
{
public class Behind : ISkill
{
private static Skills skillName = Skills.Behind;
private const Skills skillName = Skills.Behind;
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#00FF00", false);
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"), false);
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
@ -57,11 +54,8 @@ namespace jRandomSkills
public static void EnableSkill(CCSPlayerController player)
{
var skillConfig = Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString());
if (skillConfig == null) return;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
float newChance = (float)Instance.Random.NextDouble() * (skillConfig.ChanceTo - skillConfig.ChanceFrom) + skillConfig.ChanceFrom;
float newChance = (float)Instance.Random.NextDouble() * (Config.GetValue<float>(skillName, "ChanceTo") - Config.GetValue<float>(skillName, "ChanceFrom")) + Config.GetValue<float>(skillName, "ChanceFrom");
playerInfo.SkillChance = newChance;
newChance = (float)Math.Round(newChance, 2) * 100;
newChance = (float)Math.Round(newChance);
@ -84,5 +78,16 @@ namespace jRandomSkills
player.PlayerPawn.Value.Teleport(currentPosition, newAngles, new Vector(0, 0, 0));
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float ChanceFrom { get; set; }
public float ChanceTo { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#00FF00", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float chanceFrom = .2f, float chanceTo = .4f) : base(skill, active, color, onlyTeam, needsTeammates)
{
ChanceFrom = chanceFrom;
ChanceTo = chanceTo;
}
}
}
}

View file

@ -0,0 +1,75 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class BladeMaster : ISkill
{
private const Skills skillName = Skills.BladeMaster;
private static string[] noReflectionWeapon = { "inferno", "flashbang", "smokegrenade", "decoy", "hegrenade", "knife" };
private static float torseReflectionChance = Config.GetValue<float>(skillName, "torseReflectionChance") * 100;
private static float legReflectionChance = Config.GetValue<float>(skillName, "legReflectionChance") * 100;
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventPlayerHurt>((@event, info) =>
{
var victim = @event.Userid;
int damage = @event.DmgHealth;
HitGroup_t hitGroup = (HitGroup_t)@event.Hitgroup;
string weapon = @event.Weapon;
if (noReflectionWeapon.Contains(weapon) || !Instance.IsPlayerValid(victim)) return HookResult.Continue;
var victimInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == victim.SteamID);
if (victimInfo == null || victimInfo.Skill != skillName) return HookResult.Continue;
int chance = Instance.Random.Next(0, 101);
if (hitGroup == HitGroup_t.HITGROUP_LEFTLEG || hitGroup == HitGroup_t.HITGROUP_RIGHTLEG)
{
if (chance > legReflectionChance)
return HookResult.Continue;
}
else
if (chance > torseReflectionChance)
return HookResult.Continue;
var pawn = victim.PlayerPawn.Value;
if (pawn == null || !pawn.IsValid) return HookResult.Continue;
var activeWeapon = pawn.WeaponServices.ActiveWeapon.Value;
if (activeWeapon == null || !activeWeapon.IsValid || activeWeapon.DesignerName != "weapon_knife") return HookResult.Continue;
RestoreHealth(victim, damage);
return HookResult.Stop;
});
}
private static void RestoreHealth(CCSPlayerController victim, float damage)
{
var playerPawn = victim.PlayerPawn.Value;
var newHealth = playerPawn.Health + damage;
if (newHealth > 100)
newHealth = 100;
playerPawn.Health = (int)newHealth;
Utilities.SetStateChanged(playerPawn, "CBaseEntity", "m_iHealth");
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float TorseReflectionChance { get; set; }
public float LegReflectionChance { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#cc7504", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float torseReflectionChance = .95f, float legReflectionChance = .80f) : base(skill, active, color, onlyTeam, needsTeammates)
{
TorseReflectionChance = torseReflectionChance;
LegReflectionChance = legReflectionChance;
}
}
}
}

View file

@ -9,16 +9,14 @@ namespace jRandomSkills
{
public class BunnyHop : ISkill
{
private static Skills skillName = Skills.BunnyHop;
private const float MaxSpeed = 500f;
private const float BunnyHopVelocity = 300f;
private const Skills skillName = Skills.BunnyHop;
private static float maxSpeed = Config.GetValue<float>(skillName, "maxSpeed");
private static float bunnyHopVelocity = Config.GetValue<float>(skillName, "jumpVelocity");
private static float jumpBoost = Config.GetValue<float>(skillName, "jumpBoost");
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#EB4034");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterListener<OnTick>(OnTick);
}
@ -27,40 +25,52 @@ namespace jRandomSkills
foreach (var player in Utilities.GetPlayers())
{
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill == skillName)
{
GiveBunnyHop(player);
}
}
}
private static void GiveBunnyHop(CCSPlayerController player)
{
var playerPawn = player.PlayerPawn.Value;
if (playerPawn != null)
if (playerPawn == null || !playerPawn.IsValid) return;
var flags = (PlayerFlags)playerPawn.Flags;
var buttons = player.Buttons;
if (buttons.HasFlag(PlayerButtons.Jump) && flags.HasFlag(PlayerFlags.FL_ONGROUND) && !playerPawn.MoveType.HasFlag(MoveType_t.MOVETYPE_LADDER))
{
if (Math.Round(playerPawn.AbsVelocity.Length2D()) > MaxSpeed && MaxSpeed != 0)
ChangeVelocity(playerPawn, MaxSpeed);
playerPawn.AbsVelocity.Z = bunnyHopVelocity;
var flags = (PlayerFlags)playerPawn.Flags;
var buttons = player.Buttons;
var vX = playerPawn.AbsVelocity.X;
var vY = playerPawn.AbsVelocity.Y;
var speed2D = Math.Sqrt(vX * vX + vY * vY);
var scale = 1d;
if (buttons.HasFlag(PlayerButtons.Jump) && flags.HasFlag(PlayerFlags.FL_ONGROUND) && !playerPawn.MoveType.HasFlag(MoveType_t.MOVETYPE_LADDER))
playerPawn.AbsVelocity.Z = BunnyHopVelocity;
if (speed2D < maxSpeed)
{
var newSpeed = Math.Min(speed2D * jumpBoost, maxSpeed);
scale = newSpeed / (speed2D == 0 ? 1 : speed2D);
}
else if (speed2D > maxSpeed)
scale = maxSpeed / speed2D;
playerPawn.AbsVelocity.X = (float)(vX * scale);
playerPawn.AbsVelocity.Y = (float)(vY * scale);
}
}
private static void ChangeVelocity(CCSPlayerPawn? pawn, float vel)
public class SkillConfig : Config.DefaultSkillInfo
{
if (pawn == null) return;
var currentVelocity = new Vector(pawn.AbsVelocity.X, pawn.AbsVelocity.Y, pawn.AbsVelocity.Z);
var currentSpeed3D = Math.Sqrt(currentVelocity.X * currentVelocity.X + currentVelocity.Y * currentVelocity.Y + currentVelocity.Z * currentVelocity.Z);
pawn.AbsVelocity.X = (float)(currentVelocity.X / currentSpeed3D) * vel;
pawn.AbsVelocity.Y = (float)(currentVelocity.Y / currentSpeed3D) * vel;
pawn.AbsVelocity.Z = (float)(currentVelocity.Z / currentSpeed3D) * vel;
public float MaxSpeed { get; set; }
public float JumpVelocity { get; set; }
public float JumpBoost { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#d1430a", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float maxSpeed = 500f, float jumpVelocity = 300f, float jumpBoost = 2f) : base(skill, active, color, onlyTeam, needsTeammates)
{
MaxSpeed = maxSpeed;
JumpVelocity = jumpVelocity;
JumpBoost = jumpBoost;
}
}
}
}

View file

@ -1,6 +1,7 @@
using System.Drawing;
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static jRandomSkills.jRandomSkills;
@ -8,14 +9,11 @@ namespace jRandomSkills
{
public class C4Camouflage : ISkill
{
private static Skills skillName = Skills.C4Camouflage;
private const Skills skillName = Skills.C4Camouflage;
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#00911f");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
@ -23,6 +21,7 @@ namespace jRandomSkills
{
foreach (var player in Utilities.GetPlayers())
{
DisableSkill(player);
if (!Instance.IsPlayerValid(player)) continue;
var playerPawn = player.PlayerPawn?.Value;
@ -35,10 +34,15 @@ namespace jRandomSkills
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventRoundEnd>((@event, info) =>
Instance.RegisterEventHandler<EventPlayerDeath>((@event, info) =>
{
foreach (var player in Utilities.GetPlayers())
var player = @event.Userid;
if (!player.IsValid || player.PlayerPawn.Value == null) return HookResult.Continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill == skillName)
DisableSkill(player);
return HookResult.Continue;
});
@ -117,5 +121,12 @@ namespace jRandomSkills
}
}
}
public class SkillConfig : Config.DefaultSkillInfo
{
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#00911f", CsTeam onlyTeam = CsTeam.Terrorist, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}
}

View file

@ -9,14 +9,11 @@ namespace jRandomSkills
{
public class Catapult : ISkill
{
private static Skills skillName = Skills.Catapult;
private const Skills skillName = Skills.Catapult;
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#FF4500", false);
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"), false);
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
@ -40,10 +37,7 @@ namespace jRandomSkills
var attacker = @event.Attacker;
var victim = @event.Userid;
if (attacker == null || !attacker.IsValid || victim == null || !victim.IsValid) return HookResult.Continue;
if (attacker == victim) return HookResult.Continue;
if (!Instance.IsPlayerValid(attacker) || !Instance.IsPlayerValid(victim) || attacker == victim) return HookResult.Continue;
var attackerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
if (attackerInfo?.Skill == skillName && victim.PawnIsAlive)
@ -64,15 +58,23 @@ namespace jRandomSkills
public static void EnableSkill(CCSPlayerController player)
{
var skillConfig = Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString());
if (skillConfig == null) return;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
float newChance = (float)Instance.Random.NextDouble() * (skillConfig.ChanceTo - skillConfig.ChanceFrom) + skillConfig.ChanceFrom;
float newChance = (float)Instance.Random.NextDouble() * (Config.GetValue<float>(skillName, "chanceTo") - Config.GetValue<float>(skillName, "chanceFrom")) + Config.GetValue<float>(skillName, "chanceFrom");
playerInfo.SkillChance = newChance;
newChance = (float)Math.Round(newChance, 2) * 100;
newChance = (float)Math.Round(newChance);
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{Localization.GetTranslation("catapult")}{ChatColors.Lime}: " + Localization.GetTranslation("catapult_desc2", newChance), false);
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float ChanceFrom { get; set; }
public float ChanceTo { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#FF4500", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float chanceFrom = .2f, float chanceTo = .4f) : base(skill, active, color, onlyTeam, needsTeammates)
{
ChanceFrom = chanceFrom;
ChanceTo = chanceTo;
}
}
}
}

View file

@ -11,7 +11,7 @@ namespace jRandomSkills
{
public class Chicken : ISkill
{
private static Skills skillName = Skills.Chicken;
private const Skills skillName = Skills.Chicken;
private static string[] disabledWeapons =
{
"weapon_ak47",
@ -44,10 +44,7 @@ namespace jRandomSkills
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#FF8B42");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
@ -82,7 +79,13 @@ namespace jRandomSkills
Instance.RegisterEventHandler<EventPlayerDeath>((@event, info) =>
{
DisableSkill(@event.Userid);
var player = @event.Userid;
if (!player.IsValid || player.PlayerPawn.Value == null) return HookResult.Continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill == skillName)
DisableSkill(player);
return HookResult.Continue;
});
@ -95,6 +98,13 @@ namespace jRandomSkills
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventRoundStart>((@event, info) =>
{
foreach (var player in Utilities.GetPlayers())
SetWeaponAttack(player, false);
return HookResult.Continue;
});
Instance.RegisterListener<OnTick>(OnTick);
}
@ -104,7 +114,6 @@ namespace jRandomSkills
if (playerPawn != null)
{
playerPawn.VelocityModifier = 1.1f;
Utilities.SetStateChanged(player, "CCSPlayerPawn", "m_flVelocityModifier");
playerPawn.Health = 50;
Utilities.SetStateChanged(playerPawn, "CBaseEntity", "m_iHealth");
@ -127,7 +136,6 @@ namespace jRandomSkills
if (playerPawn != null)
{
playerPawn.VelocityModifier = 1f;
Utilities.SetStateChanged(player, "CCSPlayerPawn", "m_flVelocityModifier");
playerPawn.Health += 50;
Utilities.SetStateChanged(playerPawn, "CBaseEntity", "m_iHealth");
@ -219,5 +227,12 @@ namespace jRandomSkills
var hudContent = infoLine + skillLine + remainingLine;
player.PrintToCenterHtml(hudContent);
}
public class SkillConfig : Config.DefaultSkillInfo
{
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#FF8B42", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}
}

View file

@ -0,0 +1,50 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class ChillOut : ISkill
{
private const Skills skillName = Skills.ChillOut;
private static float bombArmedTime = Config.GetValue<float>(skillName, "bombArmedTime");
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventBombBeginplant>((@event, info) =>
{
var player = @event.Userid;
if (!Instance.IsPlayerValid(player)) return HookResult.Continue;
var anyChillOut = Instance.skillPlayer.FirstOrDefault(p => p.Skill == skillName);
if (anyChillOut != null)
{
var bombEntities = Utilities.FindAllEntitiesByDesignerName<CC4>("weapon_c4").ToList();
if (bombEntities.Any())
{
var bomb = bombEntities.FirstOrDefault();
if (bomb != null)
bomb.ArmedTime = Server.CurrentTime + bombArmedTime;
}
}
return HookResult.Continue;
});
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float BombArmedTime { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#343deb", CsTeam onlyTeam = CsTeam.CounterTerrorist, bool needsTeammates = false, float bombArmedTime = 10f) : base(skill, active, color, onlyTeam, needsTeammates)
{
BombArmedTime = bombArmedTime;
}
}
}
}

View file

@ -0,0 +1,41 @@
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class Cutter : ISkill
{
private const Skills skillName = Skills.Cutter;
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventPlayerHurt>((@event, info) =>
{
var damage = @event.DmgHealth;
var attacker = @event.Attacker;
var victim = @event.Userid;
var weapon = @event.Weapon;
if (!Instance.IsPlayerValid(attacker) || !Instance.IsPlayerValid(victim) || attacker == victim) return HookResult.Continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
if (playerInfo?.Skill != skillName) return HookResult.Continue;
if (weapon == "knife")
SkillUtils.TakeHealth(victim.PlayerPawn.Value, 9999);
return HookResult.Continue;
});
}
public class SkillConfig : Config.DefaultSkillInfo
{
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#88a31a", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}
}

View file

@ -0,0 +1,136 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using jRandomSkills.src.utils;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class Darkness : ISkill
{
private const Skills skillName = Skills.Darkness;
private static float brightness = Config.GetValue<float>(skillName, "brightness");
private static Dictionary<CCSPlayerController, CPostProcessingVolume> deafultPostProcessing = new Dictionary<CCSPlayerController, CPostProcessingVolume>();
private static List<CPostProcessingVolume> newPostProcessing = new List<CPostProcessingVolume>();
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"), false);
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
Instance.AddTimer(0.1f, () =>
{
foreach (var player in Utilities.GetPlayers())
{
if (!Instance.IsPlayerValid(player)) continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) continue;
EnableSkill(player);
}
});
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventRoundEnd>((@event, info) =>
{
foreach (var player in deafultPostProcessing.Keys)
DisableSkill(player);
foreach (var postProcessing in newPostProcessing)
postProcessing.Remove();
newPostProcessing.Clear();
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventPlayerDeath>((@event, info) =>
{
SetUpPostProcessing(@event.Userid, true);
return HookResult.Continue;
});
}
public static void TypeSkill(CCSPlayerController player, string[] commands)
{
if (player == null || !player.IsValid || !player.PawnIsAlive) return;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) return;
if (playerInfo.SkillChance == 1)
{
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("areareaper_used_info")}");
return;
}
string enemyId = commands[0];
var enemy = Utilities.GetPlayers().FirstOrDefault(p => p.Team != player.Team && p.Index.ToString() == enemyId);
if (enemy == null)
{
player.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("selectplayerskill_incorrect_enemy_index"));
return;
}
SetUpPostProcessing(enemy);
playerInfo.SkillChance = 1;
player.PrintToChat($" {ChatColors.Green}" + Localization.GetTranslation("darkness_player_info", enemy.PlayerName));
enemy.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("darkness_enemy_info"));
}
public static void EnableSkill(CCSPlayerController player)
{
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
playerInfo.SkillChance = 0;
SkillUtils.PrintToChat(player, Localization.GetTranslation("darkness") + ":", false);
player.PrintToChat($" {ChatColors.Green}{Localization.GetTranslation("darkness_select_info")}");
var enemies = Utilities.GetPlayers().Where(p => p.Team != player.Team && p.IsValid && !p.IsBot).ToArray();
if (enemies.Length > 0)
{
foreach (var enemy in enemies)
player.PrintToChat($" {ChatColors.Green}⠀⠀⠀[{ChatColors.Red}{enemy.Index}{ChatColors.Green}] {enemy.PlayerName}");
}
else
player.PrintToChat($" {ChatColors.Red}⠀⠀⠀{Localization.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
player.PrintToChat($" {ChatColors.Green}{Localization.GetTranslation("selectplayerskill_command")} {ChatColors.Red}index");
}
public static void DisableSkill(CCSPlayerController player)
{
SetUpPostProcessing(player, true);
}
private static void SetUpPostProcessing(CCSPlayerController player, bool dontCreateNew = false)
{
if (deafultPostProcessing.TryGetValue(player, out var oldPostProcessing))
{
player.PlayerPawn.Value.CameraServices.PostProcessingVolumes.FirstOrDefault().Raw = oldPostProcessing.EntityHandle.Raw;
deafultPostProcessing.Remove(player);
Utilities.SetStateChanged(player.PlayerPawn.Value, "CBasePlayerPawn", "m_pCameraServices");
return;
}
if (dontCreateNew)
return;
var postProcessing = Utilities.CreateEntityByName<CPostProcessingVolume>("post_processing_volume");
postProcessing.ExposureControl = true;
postProcessing.MaxExposure = brightness;
postProcessing.MinExposure = brightness;
deafultPostProcessing.TryAdd(player, player.PlayerPawn.Value.CameraServices.PostProcessingVolumes.FirstOrDefault().Value);
player.PlayerPawn.Value.CameraServices.PostProcessingVolumes.FirstOrDefault().Raw = postProcessing.EntityHandle.Raw;
Utilities.SetStateChanged(player.PlayerPawn.Value, "CBasePlayerPawn", "m_pCameraServices");
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float Brightness { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#383838", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float brightness = .01f) : base(skill, active, color, onlyTeam, needsTeammates)
{
Brightness = brightness;
}
}
}
}

View file

@ -3,21 +3,17 @@ using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using jRandomSkills.src.utils;
using static CounterStrikeSharp.API.Core.Listeners;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class Deactivator : ISkill
{
private static Skills skillName = Skills.Deactivator;
private const Skills skillName = Skills.Deactivator;
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#919191", false);
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"), false);
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
@ -83,7 +79,7 @@ namespace jRandomSkills
var enemyInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == enemy.SteamID);
if (enemyInfo == null) continue;
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == enemyInfo.Skill);
player.PrintToChat($" {ChatColors.Green}⠀⠀⠀{ChatColors.Red}{enemy.Index}{ChatColors.Green}] {enemy.PlayerName}: {ChatColors.Red}{skillData.Name}");
player.PrintToChat($" {ChatColors.Green}⠀⠀⠀[{ChatColors.Red}{enemy.Index}{ChatColors.Green}] {enemy.PlayerName}: {ChatColors.Red}{skillData.Name}");
}
}
else
@ -117,5 +113,12 @@ namespace jRandomSkills
enemy.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("deactivator_enemy_info"));
}
}
public class SkillConfig : Config.DefaultSkillInfo
{
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#919191", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}
}

View file

@ -0,0 +1,119 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using jRandomSkills.src.utils;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class Deaf : ISkill
{
private const Skills skillName = Skills.Deaf;
private static HashSet<CCSPlayerController> deafPlayers = new HashSet<CCSPlayerController>();
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"), false);
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
deafPlayers.Clear();
Instance.AddTimer(0.1f, () =>
{
foreach (var player in Utilities.GetPlayers())
{
if (!Instance.IsPlayerValid(player)) continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) continue;
EnableSkill(player);
}
});
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventPlayerDeath>((@event, info) =>
{
DisableSkill(@event.Userid);
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventRoundEnd>((@event, info) =>
{
foreach (var player in deafPlayers)
DisableSkill(player);
return HookResult.Continue;
});
Instance.HookUserMessage(208, um =>
{
var soundevent = um.ReadUInt("soundevent_hash");
var userIndex = um.ReadUInt("source_entity_index");
foreach (var player in deafPlayers)
um.Recipients.Remove(player);
return HookResult.Continue;
}, HookMode.Pre);
}
public static void TypeSkill(CCSPlayerController player, string[] commands)
{
if (player == null || !player.IsValid || !player.PawnIsAlive) return;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) return;
if (playerInfo.SkillChance == 1)
{
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("areareaper_used_info")}");
return;
}
string enemyId = commands[0];
var enemy = Utilities.GetPlayers().FirstOrDefault(p => p.Team != player.Team && p.Index.ToString() == enemyId);
if (enemy == null)
{
player.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("selectplayerskill_incorrect_enemy_index"));
return;
}
deafPlayers.Add(enemy);
playerInfo.SkillChance = 1;
player.PrintToChat($" {ChatColors.Green}" + Localization.GetTranslation("deaf_player_info", enemy.PlayerName));
enemy.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("deaf_enemy_info"));
}
public static void EnableSkill(CCSPlayerController player)
{
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
playerInfo.SkillChance = 0;
SkillUtils.PrintToChat(player, Localization.GetTranslation("deaf") + ":", false);
player.PrintToChat($" {ChatColors.Green}{Localization.GetTranslation("deaf_select_info")}");
var enemies = Utilities.GetPlayers().Where(p => p.Team != player.Team && p.IsValid && !p.IsBot).ToArray();
if (enemies.Length > 0)
{
foreach (var enemy in enemies)
player.PrintToChat($" {ChatColors.Green}⠀⠀⠀[{ChatColors.Red}{enemy.Index}{ChatColors.Green}] {enemy.PlayerName}");
}
else
player.PrintToChat($" {ChatColors.Red}⠀⠀⠀{Localization.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
player.PrintToChat($" {ChatColors.Green}{Localization.GetTranslation("selectplayerskill_command")} {ChatColors.Red}index");
}
public static void DisableSkill(CCSPlayerController player)
{
deafPlayers.Remove(player);
}
public class SkillConfig : Config.DefaultSkillInfo
{
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#dae01f", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}
}

View file

@ -9,14 +9,11 @@ namespace jRandomSkills
{
public class Disarmament : ISkill
{
private static Skills skillName = Skills.Disarmament;
private const Skills skillName = Skills.Disarmament;
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#FF4500", false);
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"), false);
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
@ -40,10 +37,7 @@ namespace jRandomSkills
var attacker = @event.Attacker;
var victim = @event.Userid;
if (attacker == null || !attacker.IsValid || victim == null || !victim.IsValid) return HookResult.Continue;
if (attacker == victim) return HookResult.Continue;
if (!Instance.IsPlayerValid(attacker) || !Instance.IsPlayerValid(victim) || attacker == victim) return HookResult.Continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
if (playerInfo?.Skill == skillName && victim.PawnIsAlive)
@ -55,7 +49,8 @@ namespace jRandomSkills
var weaponName = weaponServices?.ActiveWeapon?.Value?.DesignerName;
if (weaponName != null && !weaponName.Contains("weapon_knife") && !weaponName.Contains("weapon_c4"))
victim.DropActiveWeapon();
victim.ExecuteClientCommand("slot3");
//victim.DropActiveWeapon();
}
}
return HookResult.Continue;
@ -64,15 +59,23 @@ namespace jRandomSkills
public static void EnableSkill(CCSPlayerController player)
{
var skillConfig = Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString());
if (skillConfig == null) return;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
float newChance = (float)Instance.Random.NextDouble() * (skillConfig.ChanceTo - skillConfig.ChanceFrom) + skillConfig.ChanceFrom;
float newChance = (float)Instance.Random.NextDouble() * (Config.GetValue<float>(skillName, "chanceTo") - Config.GetValue<float>(skillName, "chanceFrom")) + Config.GetValue<float>(skillName, "chanceFrom");
playerInfo.SkillChance = newChance;
newChance = (float)Math.Round(newChance, 2) * 100;
newChance = (float)Math.Round(newChance);
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{Localization.GetTranslation("disarmament")}{ChatColors.Lime}: " + Localization.GetTranslation("disarmament_desc2", newChance), false);
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float ChanceFrom { get; set; }
public float ChanceTo { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#FF4500", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float chanceFrom = .65f, float chanceTo = .85f) : base(skill, active, color, onlyTeam, needsTeammates)
{
ChanceFrom = chanceFrom;
ChanceTo = chanceTo;
}
}
}
}

View file

@ -0,0 +1,98 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using jRandomSkills.src.utils;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class Distancer : ISkill
{
private const Skills skillName = Skills.Distancer;
private static HashSet<CCSPlayerController> distancerPlayers = new HashSet<CCSPlayerController>();
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
Instance.AddTimer(0.1f, () =>
{
foreach (var player in Utilities.GetPlayers())
{
if (!Instance.IsPlayerValid(player)) continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) continue;
EnableSkill(player);
}
});
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventRoundEnd>((@event, info) =>
{
foreach (var player in distancerPlayers)
DisableSkill(player);
return HookResult.Continue;
});
Instance.RegisterListener<Listeners.OnTick>(OnTick);
}
private static void OnTick()
{
foreach (var player in distancerPlayers)
{
var playerPawn = player.PlayerPawn.Value;
if (playerPawn == null || !playerPawn.IsValid) return;
if (playerPawn.LifeState != (byte)LifeState_t.LIFE_ALIVE) return;
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == skillName);
if (skillData == null) return;
string closetEnemy = "Bot";
double closetDistance = double.MaxValue;
foreach (var enemy in Utilities.GetPlayers().Where(p => p.Team != player.Team))
{
var enemyPawn = enemy.PlayerPawn.Value;
if (enemyPawn == null || !enemyPawn.IsValid) continue;
if (enemyPawn.LifeState != (byte)LifeState_t.LIFE_ALIVE) continue;
double distance = (int)SkillUtils.GetDistance(playerPawn.AbsOrigin, enemyPawn.AbsOrigin);
if (distance >= closetDistance) continue;
closetDistance = distance;
closetEnemy = enemy.PlayerName;
}
string distanceColor = closetDistance > 1500 ? "#00FF00" : closetDistance > 600 ? "#FFFF00" : "#FF0000";
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{Localization.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{skillData.Name}</font> <br>";
string remainingLine = $"<font class='fontSize-m' color='#FFFFFF'>{closetEnemy}: <font color='{distanceColor}'>{closetDistance}</font></font> <br>";
var hudContent = infoLine + skillLine + remainingLine;
player.PrintToCenterHtml(hudContent);
}
}
public static void EnableSkill(CCSPlayerController player)
{
distancerPlayers.Add(player);
}
public static void DisableSkill(CCSPlayerController player)
{
distancerPlayers.Remove(player);
}
public class SkillConfig : Config.DefaultSkillInfo
{
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#00f2ff", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}
}

View file

@ -1,5 +1,6 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static jRandomSkills.jRandomSkills;
@ -7,21 +8,19 @@ namespace jRandomSkills
{
public class Dracula : ISkill
{
private static Skills skillName = Skills.Dracula;
private const Skills skillName = Skills.Dracula;
private static float healthRegainScale = Config.GetValue<float>(skillName, "healthRegainScale");
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#FA050D");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventPlayerHurt>((@event, info) =>
{
var attacker = @event.Attacker;
var victim = @event.Userid;
if (!Instance.IsPlayerValid(attacker) || attacker == victim) return HookResult.Continue;
if (!Instance.IsPlayerValid(attacker) || !Instance.IsPlayerValid(victim) || attacker == victim) return HookResult.Continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
@ -38,7 +37,7 @@ namespace jRandomSkills
var attackerPawn = attacker.PlayerPawn.Value;
if (attackerPawn == null) return;
int newHealth = (int)(attackerPawn.Health + (damage * 0.3));
int newHealth = (int)(attackerPawn.Health + (damage * healthRegainScale));
attackerPawn.MaxHealth = Math.Max(newHealth, 100);
Utilities.SetStateChanged(attackerPawn, "CBaseEntity", "m_iMaxHealth");
@ -46,5 +45,14 @@ namespace jRandomSkills
attackerPawn.Health = newHealth;
Utilities.SetStateChanged(attackerPawn, "CBaseEntity", "m_iHealth");
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float HealthRegainScale { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#FA050D", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float healthRegainScale = .3f) : base(skill, active, color, onlyTeam, needsTeammates)
{
HealthRegainScale = healthRegainScale;
}
}
}
}

View file

@ -9,14 +9,11 @@ namespace jRandomSkills
{
public class Duplicator : ISkill
{
private static Skills skillName = Skills.Duplicator;
private const Skills skillName = Skills.Duplicator;
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#ffb73b", false);
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"), false);
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
@ -98,5 +95,12 @@ namespace jRandomSkills
player.PrintToChat($" {ChatColors.Green}" + Localization.GetTranslation("duplicator_player_info", enemy.PlayerName));
}
}
public class SkillConfig : Config.DefaultSkillInfo
{
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#ffb73b", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}
}

View file

@ -9,14 +9,11 @@ namespace jRandomSkills
{
public class Dwarf : ISkill
{
private static Skills skillName = Skills.Dwarf;
private const Skills skillName = Skills.Dwarf;
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#ffff00", false);
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"), false);
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
@ -62,16 +59,12 @@ namespace jRandomSkills
var playerPawn = player.PlayerPawn?.Value;
if (playerPawn != null)
{
var skillConfig = Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString());
if (skillConfig == null) return;
float newSize = (float)Instance.Random.NextDouble() * (skillConfig.ChanceTo - skillConfig.ChanceFrom) + skillConfig.ChanceFrom;
float newSize = (float)Instance.Random.NextDouble() * (Config.GetValue<float>(skillName, "maxScale") - Config.GetValue<float>(skillName, "minScale")) + Config.GetValue<float>(skillName, "minScale");
newSize = (float)Math.Round(newSize, 2);
// playerPawn.CBodyComponent.SceneNode.GetSkeletonInstance().Scale = newSize;
player.PlayerPawn.Value.CBodyComponent.SceneNode.Scale = newSize;
playerPawn.CBodyComponent.SceneNode.Scale = newSize;
Utilities.SetStateChanged(playerPawn, "CBaseEntity", "m_CBodyComponent");
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{Localization.GetTranslation("dwarf")}{ChatColors.Lime}: " + Localization.GetTranslation("dwarf_desc2", newSize), false);
}
}
@ -82,9 +75,21 @@ namespace jRandomSkills
if (playerPawn != null && playerPawn?.CBodyComponent != null)
{
// playerPawn.CBodyComponent.SceneNode.GetSkeletonInstance().Scale = 1;
player.PlayerPawn.Value.CBodyComponent.SceneNode.Scale = 1;
playerPawn.CBodyComponent.SceneNode.Scale = 1;
Utilities.SetStateChanged(playerPawn, "CBaseEntity", "m_CBodyComponent");
}
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float MinScale { get; set; }
public float MaxScale { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#ffff00", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float minScale = .6f, float maxScale = .95f) : base(skill, active, color, onlyTeam, needsTeammates)
{
MinScale = minScale;
MaxScale = maxScale;
}
}
}
}

View file

@ -10,16 +10,13 @@ namespace jRandomSkills
{
public class EnemySpawn : ISkill
{
private static Skills skillName = Skills.EnemySpawn;
private static float timerCooldown = (float)(Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Cooldown);
private const Skills skillName = Skills.EnemySpawn;
private static float timerCooldown = Config.GetValue<float>(skillName, "cooldown");
private static readonly Dictionary<ulong, PlayerSkillInfo> SkillPlayerInfo = new Dictionary<ulong, PlayerSkillInfo>();
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#ff8c92");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
@ -123,14 +120,6 @@ namespace jRandomSkills
player.PrintToCenterHtml(hudContent);
}
private static void ActiveUse(CCSPlayerController player)
{
if (SkillPlayerInfo.TryGetValue(player.SteamID, out var skillInfo))
{
skillInfo.CanUse = true;
}
}
public static void UseSkill(CCSPlayerController player)
{
var playerPawn = player.PlayerPawn.Value;
@ -169,5 +158,14 @@ namespace jRandomSkills
public DateTime Cooldown { get; set; }
public DateTime LastClick { get; set; }
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float Cooldown { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#ff8c92", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float cooldown = 15f) : base(skill, active, color, onlyTeam, needsTeammates)
{
Cooldown = cooldown;
}
}
}
}

View file

@ -0,0 +1,106 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Memory;
using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using jRandomSkills.src.utils;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class ExplosiveShot : ISkill
{
private const Skills skillName = Skills.ExplosiveShot;
private static float damage = Config.GetValue<float>(skillName, "damage");
private static float damageRadius = Config.GetValue<float>(skillName, "damageRadius");
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"), false);
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
Instance.AddTimer(0.1f, () =>
{
foreach (var player in Utilities.GetPlayers())
{
if (!Instance.IsPlayerValid(player)) continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) continue;
EnableSkill(player);
}
});
return HookResult.Continue;
});
VirtualFunctions.CBaseEntity_TakeDamageOldFunc.Hook(OnTakeDamage, HookMode.Pre);
}
public static void EnableSkill(CCSPlayerController player)
{
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
float newChance = (float)Instance.Random.NextDouble() * (Config.GetValue<float>(skillName, "ChanceTo") - Config.GetValue<float>(skillName, "ChanceFrom")) + Config.GetValue<float>(skillName, "ChanceFrom");
playerInfo.SkillChance = newChance;
newChance = (float)Math.Round(newChance, 2) * 100;
newChance = (float)Math.Round(newChance);
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{Localization.GetTranslation("explosiveshot")}{ChatColors.Lime}: " + Localization.GetTranslation("explosiveshot_desc2", newChance), false);
}
private static void SpawnExplosion(Vector vector)
{
var heProjectile = Utilities.CreateEntityByName<CHEGrenadeProjectile>("hegrenade_projectile");
if (heProjectile == null || !heProjectile.IsValid) return;
Vector pos = vector;
heProjectile.TicksAtZeroVelocity = 100;
heProjectile.TeamNum = (byte)CsTeam.None;
heProjectile.Damage = damage;
heProjectile.DmgRadius = damageRadius;
heProjectile.Teleport(pos, null, new Vector(0, 0, -10));
heProjectile.DispatchSpawn();
heProjectile.AcceptInput("InitializeSpawnFromWorld", null, null, "");
heProjectile.DetonateTime = 0;
}
private static HookResult OnTakeDamage(DynamicHook h)
{
CEntityInstance param = h.GetParam<CEntityInstance>(0);
CTakeDamageInfo param2 = h.GetParam<CTakeDamageInfo>(1);
if (param == null || param.Entity == null || param2 == null || param2.Attacker == null || param2.Attacker.Value == null)
return HookResult.Continue;
CCSPlayerPawn attackerPawn = new CCSPlayerPawn(param2.Attacker.Value.Handle);
if (attackerPawn.DesignerName != "player")
return HookResult.Continue;
if (attackerPawn == null || attackerPawn.Controller?.Value == null)
return HookResult.Continue;
CCSPlayerController attacker = attackerPawn.Controller.Value.As<CCSPlayerController>();
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
if (playerInfo == null || playerInfo.Skill != skillName) return HookResult.Continue;
if (Instance.Random.NextDouble() <= playerInfo.SkillChance)
SpawnExplosion(param2.DamagePosition);
return HookResult.Continue;
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float Damage { get; set; }
public float DamageRadius { get; set; }
public float ChanceFrom { get; set; }
public float ChanceTo { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#9c0000", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float damage = 10f, float damageRadius = 190f, float chanceFrom = .15f, float chanceTo = .3f) : base(skill, active, color, onlyTeam, needsTeammates)
{
Damage = damage;
DamageRadius = damageRadius;
ChanceFrom = chanceFrom;
ChanceTo = chanceTo;
}
}
}
}

View file

@ -0,0 +1,147 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using System.Drawing;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class FalconEye : ISkill
{
private const Skills skillName = Skills.FalconEye;
private static bool blocked = false;
private static float distance = Config.GetValue<float>(skillName, "distance");
private static Dictionary<ulong, (uint, CDynamicProp)> cameras = new Dictionary<ulong, (uint, CDynamicProp)>();
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundEnd>((@event, info) =>
{
blocked = true;
foreach (var player in Utilities.GetPlayers())
if (cameras.TryGetValue(player.SteamID, out _))
DisableSkill(player);
foreach (var camera in cameras)
camera.Value.Item2.Remove();
cameras.Clear();
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
blocked = false;
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventItemPickup>((@event, info) =>
{
var player = @event.Userid;
if (!Instance.IsPlayerValid(player)) return HookResult.Continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) return HookResult.Continue;
if (cameras.TryGetValue(player.SteamID, out var cameraInfo) && cameraInfo.Item1 == player.PlayerPawn.Value.CameraServices!.ViewEntity!.Raw)
BlockWeapon(player, true);
return HookResult.Continue;
});
Instance.RegisterListener<Listeners.OnTick>(OnTick);
}
public static void UseSkill(CCSPlayerController player)
{
var playerPawn = player.PlayerPawn.Value;
if (playerPawn?.CBodyComponent == null || blocked) return;
ChangeCamera(player);
}
public static void DisableSkill(CCSPlayerController player)
{
ChangeCamera(player, true);
}
private static void OnTick()
{
foreach (var player in Utilities.GetPlayers())
if (cameras.TryGetValue(player.SteamID, out var cameraInfo) && cameraInfo.Item2.IsValid)
{
var pawn = player.PlayerPawn.Value;
if (pawn.LifeState != (byte)LifeState_t.LIFE_ALIVE)
{
ChangeCamera(player, true);
continue;
}
Vector pos = new Vector(pawn.AbsOrigin.X, pawn.AbsOrigin.Y, pawn.AbsOrigin.Z + 1000);
QAngle angle = new QAngle(90, 0, -pawn.V_angle.Y);
cameraInfo.Item2.Teleport(pos, angle);
}
}
private static void ChangeCamera(CCSPlayerController player, bool forceToDefault = false)
{
uint orginalCameraRaw;
uint newCameraRaw;
var pawn = player.PlayerPawn.Value;
if (cameras.TryGetValue(player.SteamID, out var cameraInfo) && cameraInfo.Item2.IsValid)
{
orginalCameraRaw = cameraInfo.Item1;
newCameraRaw = cameraInfo.Item2.EntityHandle.Raw;
}
else
{
orginalCameraRaw = pawn!.CameraServices!.ViewEntity.Raw;
newCameraRaw = CreateCamera(player);
}
if (newCameraRaw == 0)
return;
bool defaultCam = forceToDefault ? true : (pawn.CameraServices!.ViewEntity!.Raw == orginalCameraRaw ? false : true);
pawn!.CameraServices!.ViewEntity.Raw = defaultCam ? orginalCameraRaw : newCameraRaw;
Utilities.SetStateChanged(pawn, "CBasePlayerPawn", "m_pCameraServices");
BlockWeapon(player, !defaultCam);
}
private static uint CreateCamera(CCSPlayerController player)
{
var camera = Utilities.CreateEntityByName<CDynamicProp>("prop_dynamic");
if (camera == null || !camera.IsValid) return 0;
var pawn = player.PlayerPawn.Value;
Vector pos = new Vector(pawn.AbsOrigin.X, pawn.AbsOrigin.Y, pawn.AbsOrigin.Z + distance);
camera.Render = Color.FromArgb(0, 255, 255, 255);
camera.Teleport(pos, new QAngle(90, 0, 0));
camera.DispatchSpawn();
cameras[player.SteamID] = (pawn.CameraServices!.ViewEntity.Raw, camera);
return camera.EntityHandle.Raw;
}
private static void BlockWeapon(CCSPlayerController player, bool block)
{
foreach (var weapon in player.Pawn.Value.WeaponServices?.MyWeapons)
if (weapon != null && weapon.IsValid && weapon.Value != null && weapon.Value.IsValid)
{
weapon.Value.NextPrimaryAttackTick = block ? int.MaxValue : Server.TickCount;
weapon.Value.NextSecondaryAttackTick = block ? int.MaxValue : Server.TickCount;
Utilities.SetStateChanged(weapon.Value, "CBasePlayerWeapon", "m_nNextPrimaryAttackTick");
Utilities.SetStateChanged(weapon.Value, "CBasePlayerWeapon", "m_nNextSecondaryAttackTick");
}
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float Distance { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#d1f542", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float distance = 1000f) : base(skill, active, color, onlyTeam, needsTeammates)
{
Distance = distance;
}
}
}
}

View file

@ -0,0 +1,46 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class FastReload : ISkill
{
private const Skills skillName = Skills.FastReload;
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
}
public static void UseSkill(CCSPlayerController player)
{
var playerPawn = player.PlayerPawn.Value;
if (playerPawn?.CBodyComponent == null) return;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) return;
if (!player.IsValid || !player.PawnIsAlive) return;
InstaReload(playerPawn);
}
private static void InstaReload(CCSPlayerPawn pawn)
{
var activeWeapon = pawn.WeaponServices.ActiveWeapon.Value;
if (activeWeapon == null || !activeWeapon.IsValid) return;
activeWeapon.Clip1 = activeWeapon.VData.MaxClip1;
Utilities.SetStateChanged(activeWeapon, "CBasePlayerWeapon", "m_iClip1");
}
public class SkillConfig : Config.DefaultSkillInfo
{
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#ffc061", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float distance = 1000f) : base(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}
}

View file

@ -10,14 +10,11 @@ namespace jRandomSkills
{
public class Flash : ISkill
{
private static Skills skillName = Skills.Flash;
private const Skills skillName = Skills.Flash;
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#A31912", false);
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"), false);
Instance.RegisterListener<OnTick>(UpdateSpeed);
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
@ -30,8 +27,6 @@ namespace jRandomSkills
var playerPawn = player.PlayerPawn?.Value;
playerPawn.VelocityModifier = 1;
Utilities.SetStateChanged(playerPawn, "CCSPlayerPawn", "m_flVelocityModifier");
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) continue;
EnableSkill(player);
@ -74,12 +69,11 @@ namespace jRandomSkills
var skillConfig = Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString());
if (skillConfig == null) return;
float newSpeed = (float)Instance.Random.NextDouble() * (skillConfig.ChanceTo - skillConfig.ChanceFrom) + skillConfig.ChanceFrom;
float newSpeed = (float)Instance.Random.NextDouble() * (Config.GetValue<float>(skillName, "ChanceTo") - Config.GetValue<float>(skillName, "ChanceFrom")) + Config.GetValue<float>(skillName, "ChanceFrom");
newSpeed = (float)Math.Round(newSpeed, 2);
playerInfo.SkillChance = newSpeed;
playerPawn.VelocityModifier = newSpeed;
Utilities.SetStateChanged(playerPawn, "CCSPlayerPawn", "m_flVelocityModifier");
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{Localization.GetTranslation("flash")}{ChatColors.Lime}: " + Localization.GetTranslation("flash_desc2", newSpeed), false);
}
@ -88,7 +82,6 @@ namespace jRandomSkills
var playerPawn = player.PlayerPawn.Value;
if (playerPawn == null) return;
playerPawn.VelocityModifier = 1;
Utilities.SetStateChanged(playerPawn, "CCSPlayerPawn", "m_flVelocityModifier");
}
private static void UpdateSpeed()
@ -102,10 +95,18 @@ namespace jRandomSkills
var playerPawn = player.PlayerPawn?.Value;
if (playerPawn != null && playerPawn.VelocityModifier != 0)
{
playerPawn.VelocityModifier = Math.Max((float)playerInfo?.SkillChance, 1);
Utilities.SetStateChanged(playerPawn, "CCSPlayerPawn", "m_flVelocityModifier");
}
}
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float ChanceFrom { get; set; }
public float ChanceTo { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#A31912", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float chanceFrom = 1.2f, float chanceTo = 3.0f) : base(skill, active, color, onlyTeam, needsTeammates)
{
ChanceFrom = chanceFrom;
ChanceTo = chanceTo;
}
}
}

View file

@ -0,0 +1,191 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Memory;
using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using jRandomSkills.src.utils;
using static CounterStrikeSharp.API.Core.Listeners;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class Fortnite : ISkill
{
private const Skills skillName = Skills.Fortnite;
private static float timerCooldown = Config.GetValue<float>(skillName, "Cooldown");
private const string propModel = "models/props/de_aztec/hr_aztec/aztec_scaffolding/aztec_scaffold_wall_support_128.vmdl";
private static readonly Dictionary<ulong, PlayerSkillInfo> SkillPlayerInfo = new Dictionary<ulong, PlayerSkillInfo>();
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
Instance.AddTimer(0.1f, () =>
{
foreach (var player in Utilities.GetPlayers())
{
if (!Instance.IsPlayerValid(player)) return;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill == skillName)
EnableSkill(player);
}
});
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventRoundEnd>((@event, info) =>
{
SkillPlayerInfo.Clear();
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventPlayerDeath>((@event, info) =>
{
var player = @event.Userid;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill == skillName)
if (SkillPlayerInfo.ContainsKey(player.SteamID))
SkillPlayerInfo.Remove(player.SteamID);
return HookResult.Continue;
});
Instance.RegisterListener<OnTick>(() =>
{
foreach (var player in Utilities.GetPlayers())
{
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill == skillName)
if (SkillPlayerInfo.TryGetValue(player.SteamID, out var skillInfo))
UpdateHUD(player, skillInfo);
}
});
Instance.RegisterListener<OnServerPrecacheResources>((ResourceManifest manifest) =>
{
manifest.AddResource(propModel);
});
VirtualFunctions.CBaseEntity_TakeDamageOldFunc.Hook(OnTakeDamage, HookMode.Pre);
}
public static void EnableSkill(CCSPlayerController player)
{
SkillPlayerInfo[player.SteamID] = new PlayerSkillInfo
{
SteamID = player.SteamID,
CanUse = true,
Cooldown = DateTime.MinValue,
LastClick = DateTime.MinValue,
};
}
public static void DisableSkill(CCSPlayerController player)
{
if (SkillPlayerInfo.ContainsKey(player.SteamID))
SkillPlayerInfo.Remove(player.SteamID);
}
private static void UpdateHUD(CCSPlayerController player, PlayerSkillInfo skillInfo)
{
float cooldown = 0;
if (skillInfo != null)
{
float time = (int)(skillInfo.Cooldown.AddSeconds(timerCooldown) - DateTime.Now).TotalSeconds;
cooldown = Math.Max(time, 0);
if (cooldown == 0 && skillInfo?.CanUse == false)
skillInfo.CanUse = true;
}
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == skillName);
if (skillData == null) return;
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{Localization.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{skillData.Name}</font> <br>";
string remainingLine = cooldown != 0 ? $"<font class='fontSize-m' color='#FFFFFF'>{Localization.GetTranslation("hud_info", $"<font color='#FF0000'>{cooldown}</font>")}</font> <br>" : "";
var hudContent = infoLine + skillLine + remainingLine;
player.PrintToCenterHtml(hudContent);
}
public static void UseSkill(CCSPlayerController player)
{
var playerPawn = player.PlayerPawn.Value;
if (playerPawn?.CBodyComponent == null) return;
if (SkillPlayerInfo.TryGetValue(player.SteamID, out var skillInfo))
{
if (!player.IsValid || !player.PawnIsAlive) return;
if (skillInfo.CanUse)
{
skillInfo.CanUse = false;
skillInfo.Cooldown = DateTime.Now;
CreateBox(player);
}
else
skillInfo.LastClick = DateTime.Now;
}
}
private static void CreateBox(CCSPlayerController player)
{
var playerPawn = player.PlayerPawn.Value;
var box = Utilities.CreateEntityByName<CDynamicProp>("prop_dynamic_override");
if (box == null) return;
float distance = 50;
Vector pos = playerPawn.AbsOrigin + SkillUtils.GetForwardVector(playerPawn.AbsRotation) * distance;
QAngle angle = new QAngle(playerPawn.AbsRotation.X, playerPawn.AbsRotation.Y + 90, playerPawn.AbsRotation.Z);
box.Entity.Name = box.Globalname = $"FortniteWall_{Server.TickCount}";
box.Collision.SolidType = SolidType_t.SOLID_VPHYSICS;
box.CBodyComponent!.SceneNode!.Owner!.Entity!.Flags = (uint)(box.CBodyComponent!.SceneNode!.Owner!.Entity!.Flags & ~(1 << 2));
box.DispatchSpawn();
Server.NextFrame(() =>
{
box.SetModel(propModel);
box.Teleport(pos, angle, null);
});
}
private static HookResult OnTakeDamage(DynamicHook h)
{
CEntityInstance param = h.GetParam<CEntityInstance>(0);
CTakeDamageInfo param2 = h.GetParam<CTakeDamageInfo>(1);
if (param == null || param.Entity == null || param2 == null || param2.Attacker == null || param2.Attacker.Value == null)
return HookResult.Continue;
if (string.IsNullOrEmpty(param.Entity.Name)) return HookResult.Continue;
if (!param.Entity.Name.StartsWith("FortniteWall")) return HookResult.Continue;
var box = param.As<CDynamicProp>();
if (box == null || !box.IsValid) return HookResult.Continue;
box.EmitSound("Wood_Plank.BulletImpact", volume: 1f);
box.Remove();
return HookResult.Continue;
}
public class PlayerSkillInfo
{
public ulong SteamID { get; set; }
public bool CanUse { get; set; }
public DateTime Cooldown { get; set; }
public DateTime LastClick { get; set; }
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float Cooldown { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#1b04cc", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float cooldown = 2f) : base(skill, active, color, onlyTeam, needsTeammates)
{
Cooldown = cooldown;
}
}
}
}

View file

@ -0,0 +1,131 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Entities.Constants;
using CounterStrikeSharp.API.Modules.Memory;
using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using jRandomSkills.src.utils;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class FragileBomb : ISkill
{
private const Skills skillName = Skills.FragileBomb;
private static int bombHealth = Config.GetValue<int>(skillName, "maxBombHealth");
private static int maxBombHealth = Config.GetValue<int>(skillName, "maxBombHealth");
private static CPlantedC4 plantedC4;
private static CTriggerMultiple triggerC4;
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
bombHealth = maxBombHealth;
plantedC4 = null;
triggerC4 = null;
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventBombPlanted>((@event, info) =>
{
var plantedBomb = Utilities.FindAllEntitiesByDesignerName<CPlantedC4>("planted_c4").FirstOrDefault();
if (plantedBomb == null) return HookResult.Continue;
plantedC4 = plantedBomb;
CreateTrigger();
return HookResult.Continue;
});
VirtualFunctions.CBaseEntity_TakeDamageOldFunc.Hook(OnTakeDamage, HookMode.Pre);
}
private static void CreateTrigger()
{
var trigger = Utilities.CreateEntityByName<CTriggerMultiple>("trigger_multiple");
if (trigger == null || plantedC4 == null) return;
trigger.Collision.SolidType = SolidType_t.SOLID_CAPSULE;
trigger.Collision.SolidFlags = 0;
trigger.Spawnflags = 1;
trigger.Globalname = $"planted_bomb_prop_{trigger.Index}";
trigger.Collision.SolidFlags = 1;
trigger.AbsOrigin.X = plantedC4.AbsOrigin.X;
trigger.AbsOrigin.Y = plantedC4.AbsOrigin.Y;
trigger.AbsOrigin.Z = plantedC4.AbsOrigin.Z;
trigger.Collision.CapsuleRadius = 10;
trigger.Collision.BoundingRadius = 10;
trigger.Collision.CollisionGroup = (byte)CollisionGroup.COLLISION_GROUP_TRIGGER;
trigger.Collision.EnablePhysics = 1;
trigger.Collision.TriggerBloat = 0;
trigger.Collision.SurroundType = SurroundingBoundsType_t.USE_OBB_COLLISION_BOUNDS;
trigger.Collision.CollisionAttribute.CollisionFunctionMask = 39;
trigger.Collision.CollisionAttribute.CollisionGroup = 2;
trigger.DispatchSpawn();
triggerC4 = trigger;
}
private static void RemoveBomb()
{
if (plantedC4 != null && plantedC4.IsValid)
plantedC4.Remove();
if (triggerC4 != null && triggerC4.IsValid)
triggerC4.Remove();
SkillUtils.TerminateRound(CsTeam.CounterTerrorist);
}
private static HookResult OnTakeDamage(DynamicHook h)
{
CEntityInstance param = h.GetParam<CEntityInstance>(0);
CTakeDamageInfo param2 = h.GetParam<CTakeDamageInfo>(1);
if (param == null || param.Entity == null || param2 == null || param2.Attacker == null || param2.Attacker.Value == null)
return HookResult.Continue;
CCSPlayerPawn attackerPawn = new CCSPlayerPawn(param2.Attacker.Value.Handle);
if (attackerPawn.DesignerName != "player" || param.DesignerName != "trigger_multiple")
return HookResult.Continue;
CTriggerMultiple trigger = new CTriggerMultiple(param.Handle);
if (attackerPawn == null || attackerPawn.Controller?.Value == null || trigger == null || !trigger.Globalname.StartsWith("planted_bomb_prop_"))
return HookResult.Continue;
CCSPlayerController attacker = attackerPawn.Controller.Value.As<CCSPlayerController>();
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
if (playerInfo == null || playerInfo.Skill != skillName) return HookResult.Continue;
bombHealth -= (int)param2.TotalledDamage;
if (bombHealth <= 0)
{
RemoveBomb();
return HookResult.Continue;
}
Server.PrintToChatAll($" {ChatColors.Gold}{Localization.GetTranslation("fragilebomb_bomb_health")}: {ChatColors.Red}{bombHealth}{ChatColors.Gold}/{ChatColors.Green}{maxBombHealth}");
return HookResult.Continue;
}
public class SkillConfig : Config.DefaultSkillInfo
{
public int MaxBombHealth { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#5d00ff", CsTeam onlyTeam = CsTeam.CounterTerrorist, bool needsTeammates = false, int maxBombHealth = 1000) : base(skill, active, color, onlyTeam, needsTeammates)
{
MaxBombHealth = maxBombHealth;
}
}
}
}

View file

@ -0,0 +1,54 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class FriendlyFire : ISkill
{
private const Skills skillName = Skills.FriendlyFire;
private static float healthMultiplier = Config.GetValue<float>(skillName, "healthMultiplier");
private static string[] nades = { "inferno", "flashbang", "smokegrenade", "decoy", "hegrenade" };
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventPlayerHurt>((@event, info) =>
{
var damage = @event.DmgHealth;
var victim = @event.Userid;
var attacker = @event.Attacker;
var weapon = @event.Weapon;
HitGroup_t hitgroup = (HitGroup_t)@event.Hitgroup;
if (nades.Contains(weapon)) return HookResult.Continue;
if (!Instance.IsPlayerValid(attacker) || !Instance.IsPlayerValid(victim) || attacker == victim) return HookResult.Continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
if (playerInfo?.Skill != skillName || attacker.Team != victim.Team) return HookResult.Continue;
Server.ExecuteCommand("mp_autokick 0");
var pawn = victim.PlayerPawn.Value;
SkillUtils.AddHealth(pawn, damage + (int)(damage * healthMultiplier), pawn.MaxHealth);
return HookResult.Continue;
});
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float HealthMultiplier { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#ff0000", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = true, float healthMultiplier = 1.5f) : base(skill, active, color, onlyTeam, needsTeammates)
{
HealthMultiplier = healthMultiplier;
}
}
}
}

View file

@ -1,8 +1,6 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Entities.Constants;
using CounterStrikeSharp.API.Modules.Memory;
using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static CounterStrikeSharp.API.Core.Listeners;
@ -12,22 +10,21 @@ namespace jRandomSkills
{
public class FrozenDecoy : ISkill
{
private static Skills skillName = Skills.FrozenDecoy;
private static Dictionary<uint, float> gravities = new Dictionary<uint, float>();
private static List<CCSPlayerPawn> players = new List<CCSPlayerPawn>();
private static Dictionary<int, CTriggerMultiple> triggers = new Dictionary<int, CTriggerMultiple>();
private const Skills skillName = Skills.FrozenDecoy;
private static float decoyRadius = Config.GetValue<float>(skillName, "triggerRadius");
private static int slownessMultiplier = Config.GetValue<int>(skillName, "slownessMultiplier");
private static List<Vector> decoys = new List<Vector>();
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#00eaff");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundStart>((@event, info) =>
{
gravities.Clear();
players.Clear();
decoys.Clear();
return HookResult.Continue;
});
@ -47,71 +44,37 @@ namespace jRandomSkills
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventDecoyStarted>((@event, @info) =>
Instance.RegisterEventHandler<EventDecoyStarted>((@event, info) =>
{
var player = @event.Userid;
if (!Instance.IsPlayerValid(player)) return HookResult.Continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) return HookResult.Continue;
var trigger = Utilities.CreateEntityByName<CTriggerMultiple>("trigger_multiple");
if (trigger == null) return HookResult.Continue;
trigger.Collision.SolidType = SolidType_t.SOLID_CAPSULE;
trigger.Collision.SolidFlags = 0;
trigger.Spawnflags = 1;
trigger.Globalname = $"frozen_decoy_{trigger.Index}";
trigger.Collision.SolidFlags = 1;
trigger.AbsOrigin.X = @event.X;
trigger.AbsOrigin.Y = @event.Y;
trigger.AbsOrigin.Z = @event.Z;
trigger.Collision.CapsuleRadius = 150;
trigger.Collision.BoundingRadius = 150;
trigger.Collision.CollisionGroup = (byte)CollisionGroup.COLLISION_GROUP_TRIGGER;
trigger.Collision.EnablePhysics = 1;
trigger.Collision.TriggerBloat = 0;
trigger.Collision.SurroundType = SurroundingBoundsType_t.USE_OBB_COLLISION_BOUNDS;
trigger.Collision.CollisionAttribute.CollisionFunctionMask = 39;
trigger.Collision.CollisionAttribute.CollisionGroup = 2;
trigger.DispatchSpawn();
triggers.Add(@event.Entityid, trigger);
decoys.Add(new Vector(@event.X, @event.Y, @event.Z));
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventDecoyDetonate>((@event, @info) =>
{
var player = @event.Userid;
if (!Instance.IsPlayerValid(player)) return HookResult.Continue;
if (triggers.TryGetValue(@event.Entityid, out var existingTrigger))
{
existingTrigger.AcceptInput("Kill");
triggers.Remove(@event.Entityid);
}
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) return HookResult.Continue;
decoys.RemoveAll(v => v.X == @event.X && v.Y == @event.Y && v.Z == @event.Z);
return HookResult.Continue;
});
Instance.RegisterListener<OnTick>(() =>
{
foreach (CCSPlayerPawn player in players)
{
player.VelocityModifier = 0;
Utilities.SetStateChanged(player, "CCSPlayerPawn", "m_flVelocityModifier");
if ((player.Flags & (uint)PlayerFlags.FL_ONGROUND) != 0)
player.GravityScale = float.MaxValue;
}
foreach (Vector decoyPos in decoys)
foreach (var player in Utilities.GetPlayers())
{
double distance = SkillUtils.GetDistance(decoyPos, player.PlayerPawn.Value.AbsOrigin);
if (distance <= decoyRadius)
{
double modifier = Math.Clamp(distance / decoyRadius, 0f, 1f);
player.PlayerPawn.Value.VelocityModifier = (float)Math.Pow(modifier, slownessMultiplier);
}
}
});
VirtualFunctions.CBaseTrigger_StartTouchFunc.Hook(StartTouchFun, HookMode.Post);
VirtualFunctions.CBaseTrigger_EndTouchFunc.Hook(EndTouchFunc, HookMode.Post);
}
public static void EnableSkill(CCSPlayerController player)
@ -119,46 +82,15 @@ namespace jRandomSkills
SkillUtils.TryGiveWeapon(player, CsItem.DecoyGrenade);
}
private static HookResult StartTouchFun(DynamicHook h)
public class SkillConfig : Config.DefaultSkillInfo
{
CBaseTrigger trigger = h.GetParam<CBaseTrigger>(0);
CBaseEntity entity = h.GetParam<CBaseEntity>(1);
if (trigger == null || entity == null)
return HookResult.Continue;
;
CCSPlayerPawn player = new CCSPlayerPawn(entity.Handle);
if (player == null) return HookResult.Continue;
if (string.IsNullOrEmpty(trigger?.Globalname) || trigger?.Globalname?.StartsWith("frozen_decoy_") == false)
return HookResult.Continue;
if (!players.Contains(player))
players.Add(player);
gravities.TryAdd(player.Index, player.GravityScale);
return HookResult.Continue;
}
private static HookResult EndTouchFunc(DynamicHook h)
{
var trigger = h.GetParam<CBaseTrigger>(0);
var entity = h.GetParam<CBaseEntity>(1);
if (trigger == null || entity == null) return HookResult.Continue;
CCSPlayerPawn player = new CCSPlayerPawn(entity.Handle);
if (player == null) return HookResult.Continue;
if (string.IsNullOrEmpty(trigger?.Globalname) || trigger?.Globalname?.StartsWith("frozen_decoy_") == false)
return HookResult.Continue;
if (players.Contains(player))
players.Remove(player);
float grav = gravities.GetValueOrDefault(player.Index);
player.GravityScale = Math.Min(grav, 1);
return HookResult.Continue;
public float TriggerRadius { get; set; }
public int SlownessMultiplier { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#00eaff", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float triggerRadius = 180, int slownessMultiplier = 5) : base(skill, active, color, onlyTeam, needsTeammates)
{
TriggerRadius = triggerRadius;
SlownessMultiplier = slownessMultiplier;
}
}
}
}

View file

@ -1,6 +1,7 @@
using System.Drawing;
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using jRandomSkills.src.utils;
using static CounterStrikeSharp.API.Core.Listeners;
@ -10,7 +11,7 @@ namespace jRandomSkills
{
public class Ghost : ISkill
{
private static Skills skillName = Skills.Ghost;
private const Skills skillName = Skills.Ghost;
private static string[] disabledWeapons =
{
"weapon_deagle",
@ -55,7 +56,7 @@ namespace jRandomSkills
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#FFFFFF");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
@ -110,6 +111,13 @@ namespace jRandomSkills
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventRoundStart>((@event, info) =>
{
foreach (var player in Utilities.GetPlayers())
SetWeaponAttack(player, false);
return HookResult.Continue;
});
Instance.RegisterListener<OnTick>(OnTick);
}
@ -199,5 +207,12 @@ namespace jRandomSkills
var hudContent = infoLine + skillLine + remainingLine;
player.PrintToCenterHtml(hudContent);
}
public class SkillConfig : Config.DefaultSkillInfo
{
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#FFFFFF", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}
}

View file

@ -0,0 +1,89 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Attributes;
using CounterStrikeSharp.API.Modules.Entities.Constants;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class Glaz : ISkill
{
private const Skills skillName = Skills.Glaz;
private static bool exists = false;
private static List<int> smokes = new List<int>();
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, @info) =>
{
smokes.Clear();
Instance.AddTimer(2f, () =>
{
foreach (var player in Utilities.GetPlayers())
{
if (!Instance.IsPlayerValid(player)) continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill == skillName)
EnableSkill(player);
}
if (exists)
Instance.RegisterListener<Listeners.CheckTransmit>(CheckTransmit);
});
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventRoundEnd>((@event, @info) =>
{
smokes.Clear();
if (exists)
Instance.RemoveListener<Listeners.CheckTransmit>(CheckTransmit);
exists = false;
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventSmokegrenadeDetonate>((@event, @info) =>
{
smokes.Add(@event.Entityid);
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventSmokegrenadeExpired>((@event, @info) =>
{
smokes.Remove(@event.Entityid);
return HookResult.Continue;
});
}
public static void CheckTransmit([CastFrom(typeof(nint))] CCheckTransmitInfoList infoList)
{
foreach (var (info, player) in infoList)
{
if (player == null) continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) continue;
foreach (var smoke in smokes)
info.TransmitEntities.Remove(smoke);
}
}
public static void EnableSkill(CCSPlayerController player)
{
exists = true;
SkillUtils.TryGiveWeapon(player, CsItem.SmokeGrenade);
}
public class SkillConfig : Config.DefaultSkillInfo
{
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#5d00ff", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}
}

View file

@ -9,12 +9,12 @@ namespace jRandomSkills
{
public class Glitch : ISkill
{
private static Skills skillName = Skills.Glitch;
private const Skills skillName = Skills.Glitch;
private static HashSet<CCSPlayerController> glitchedPlayers = new HashSet<CCSPlayerController>();
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, "#f542ef", false);
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"), false);
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
@ -80,7 +80,7 @@ namespace jRandomSkills
if (enemies.Length > 0)
{
foreach (var enemy in enemies)
player.PrintToChat($" {ChatColors.Green}⠀⠀⠀{ChatColors.Red}{enemy.Index}{ChatColors.Green}] {enemy.PlayerName}");
player.PrintToChat($" {ChatColors.Green}⠀⠀⠀[{ChatColors.Red}{enemy.Index}{ChatColors.Green}] {enemy.PlayerName}");
}
else
player.PrintToChat($" {ChatColors.Red}⠀⠀⠀{Localization.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
@ -92,5 +92,12 @@ namespace jRandomSkills
player.ReplicateConVar("sv_disable_radar", "0");
glitchedPlayers.Remove(player);
}
public class SkillConfig : Config.DefaultSkillInfo
{
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#f542ef", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}
}

View file

@ -0,0 +1,41 @@
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class Glue : ISkill
{
private const Skills skillName = Skills.Glue;
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterListener<Listeners.OnEntitySpawned>(@event =>
{
var name = @event.DesignerName;
if (!name.EndsWith("_projectile"))
return;
var grenade = @event.As<CBaseCSGrenadeProjectile>();
if (grenade.OwnerEntity.Value == null || !grenade.OwnerEntity.Value.IsValid) return;
var pawn = grenade.OwnerEntity.Value.As<CCSPlayerPawn>();
var player = pawn.Controller.Value.As<CCSPlayerController>();
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) return;
grenade.Bounces = 555;
});
}
public class SkillConfig : Config.DefaultSkillInfo
{
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#fff52e", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}
}

View file

@ -10,16 +10,14 @@ namespace jRandomSkills
{
public class GodMode : ISkill
{
private static Skills skillName = Skills.GodMode;
private static float timerCooldown = (float)(Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Cooldown);
private const Skills skillName = Skills.GodMode;
private static float timerCooldown = Config.GetValue<float>(skillName, "cooldown");
private static float duration = Config.GetValue<float>(skillName, "duration");
private static readonly Dictionary<ulong, PlayerSkillInfo> SkillPlayerInfo = new Dictionary<ulong, PlayerSkillInfo>();
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#e0d83a");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
@ -108,12 +106,6 @@ namespace jRandomSkills
player.PrintToCenterHtml(hudContent);
}
private static void ActiveUse(CCSPlayerController player)
{
if (SkillPlayerInfo.TryGetValue(player.SteamID, out var skillInfo))
skillInfo.CanUse = true;
}
public static void UseSkill(CCSPlayerController player)
{
var playerPawn = player.PlayerPawn.Value;
@ -130,7 +122,7 @@ namespace jRandomSkills
player.PrintToChat($" {ChatColors.Green} {Localization.GetTranslation("godmode_on")}");
player.PlayerPawn.Value.TakesDamage = false;
Instance.AddTimer(2, () => {
Instance.AddTimer(duration, () => {
if (player.IsValid && player.PawnIsAlive)
{
player.PlayerPawn.Value.TakesDamage = true;
@ -150,5 +142,16 @@ namespace jRandomSkills
public DateTime Cooldown { get; set; }
public DateTime LastClick { get; set; }
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float Cooldown { get; set; }
public float Duration { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#e0d83a", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float cooldown = 30f, float duration = 2f) : base(skill, active, color, onlyTeam, needsTeammates)
{
Cooldown = cooldown;
Duration = duration;
}
}
}
}

View file

@ -0,0 +1,121 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Entities.Constants;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static CounterStrikeSharp.API.Core.Listeners;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class HealingSmoke : ISkill
{
private const Skills skillName = Skills.HealingSmoke;
private static int smokeHeal = Config.GetValue<int>(skillName, "smokeHeal");
private static float smokeRadius = Config.GetValue<float>(skillName, "smokeRadius");
private static List<Vector> smokes = new List<Vector>();
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundStart>((@event, info) =>
{
smokes.Clear();
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
Instance.AddTimer(0.1f, () =>
{
foreach (var player in Utilities.GetPlayers())
{
if (!Instance.IsPlayerValid(player)) continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) continue;
EnableSkill(player);
}
});
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventSmokegrenadeDetonate>((@event, info) =>
{
var player = @event.Userid;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) return HookResult.Continue;
smokes.Add(new Vector(@event.X, @event.Y, @event.Z));
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventSmokegrenadeExpired>((@event, @info) =>
{
var player = @event.Userid;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) return HookResult.Continue;
smokes.RemoveAll(v => v.X == @event.X && v.Y == @event.Y && v.Z == @event.Z);
return HookResult.Continue;
});
Instance.RegisterListener<OnEntitySpawned>(@event =>
{
var name = @event.DesignerName;
if (name != "smokegrenade_projectile") return;
var grenade = @event.As<CBaseCSGrenadeProjectile>();
var pawn = grenade.OwnerEntity.Value.As<CCSPlayerPawn>();
var player = pawn.Controller.Value.As<CCSPlayerController>();
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) return;
Server.NextFrame(() =>
{
var smoke = @event.As<CSmokeGrenadeProjectile>();
smoke.SmokeColor.X = 0;
smoke.SmokeColor.Y = 255;
smoke.SmokeColor.Z = 0;
});
});
Instance.RegisterListener<OnTick>(() =>
{
foreach (Vector smokePos in smokes)
foreach (var player in Utilities.GetPlayers())
if (Server.TickCount % 17 == 0)
if (SkillUtils.GetDistance(smokePos, player.PlayerPawn.Value.AbsOrigin) <= smokeRadius)
AddHealth(player.PlayerPawn.Value, smokeHeal);
});
}
public static void EnableSkill(CCSPlayerController player)
{
SkillUtils.TryGiveWeapon(player, CsItem.SmokeGrenade);
}
private static void AddHealth(CCSPlayerPawn player, int health)
{
if (player.LifeState != (byte)LifeState_t.LIFE_ALIVE)
return;
if (player.Health != player.MaxHealth)
player.EmitSound("Healthshot.Success");
player.Health = Math.Min(player.Health + health, player.MaxHealth);
Utilities.SetStateChanged(player, "CBaseEntity", "m_iHealth");
}
public class SkillConfig : Config.DefaultSkillInfo
{
public int SmokeHeal { get; set; }
public float SmokeRadius { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#1fe070", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int smokeHeal = 1, float smokeRadius = 180) : base(skill, active, color, onlyTeam, needsTeammates)
{
SmokeHeal = smokeHeal;
SmokeRadius = smokeRadius;
}
}
}
}

View file

@ -1,5 +1,6 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static jRandomSkills.jRandomSkills;
@ -7,7 +8,7 @@ namespace jRandomSkills
{
public class Hermit : ISkill
{
private static Skills skillName = Skills.Hermit;
private const Skills skillName = Skills.Hermit;
private static readonly Dictionary<string, int> maxReserveAmmo = new Dictionary<string, int>
{
{ "weapon_glock", 120 },
@ -47,12 +48,11 @@ namespace jRandomSkills
{ "weapon_negev", 300 }
};
private static int healthToAdd = Config.GetValue<int>(skillName, "healthToAdd");
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#ded678");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventPlayerDeath>((@event, info) =>
{
@ -74,10 +74,19 @@ namespace jRandomSkills
Utilities.SetStateChanged(weapon, "CBasePlayerWeapon", "m_iClip1");
Utilities.SetStateChanged(weapon, "CBasePlayerWeapon", "m_pReserveAmmo");
SkillUtils.AddHealth(pawn, 25);
SkillUtils.AddHealth(pawn, healthToAdd);
return HookResult.Continue;
});
}
public class SkillConfig : Config.DefaultSkillInfo
{
public int HealthToAdd { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#ded678", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int healthToAdd = 25) : base(skill, active, color, onlyTeam, needsTeammates)
{
HealthToAdd = healthToAdd;
}
}
}
}

View file

@ -1,6 +1,7 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Entities.Constants;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static jRandomSkills.jRandomSkills;
@ -8,14 +9,13 @@ namespace jRandomSkills
{
public class HolyHandGrenade : ISkill
{
private static Skills skillName = Skills.HolyHandGrenade;
private const Skills skillName = Skills.HolyHandGrenade;
private static float damageMultiplier = Config.GetValue<float>(skillName, "damageMultiplier");
private static float damageRadiusMultiplier = Config.GetValue<float>(skillName, "damageRadiusMultiplier");
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#ffdd00");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
@ -44,13 +44,14 @@ namespace jRandomSkills
var hegrenade = @event.As<CHEGrenadeProjectile>();
var playerPawn = hegrenade.Thrower.Value;
if (playerPawn == null || !playerPawn.IsValid) return;
var player = Utilities.GetPlayers().FirstOrDefault(p => p.PlayerPawn.Index == playerPawn.Index);
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName)
return;
hegrenade.Damage *= 2;
hegrenade.DmgRadius *= 2;
hegrenade.Damage *= damageMultiplier;
hegrenade.DmgRadius *= damageRadiusMultiplier;
});
});
}
@ -59,5 +60,16 @@ namespace jRandomSkills
{
SkillUtils.TryGiveWeapon(player, CsItem.HEGrenade);
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float DamageMultiplier { get; set; }
public float DamageRadiusMultiplier { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#ffdd00", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float damageMultiplier = 2f, float damageRadiusMultiplier = 2f) : base(skill, active, color, onlyTeam, needsTeammates)
{
DamageMultiplier = damageMultiplier;
DamageRadiusMultiplier = damageRadiusMultiplier;
}
}
}
}

View file

@ -9,16 +9,13 @@ namespace jRandomSkills
{
public class Impostor : ISkill
{
private static Skills skillName = Skills.Impostor;
private const Skills skillName = Skills.Impostor;
private static readonly string defaultCTModel = "characters/models/ctm_sas/ctm_sas.vmdl";
private static readonly string defaultTModel = "characters/models/tm_phoenix_heavy/tm_phoenix_heavy.vmdl";
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#99140B");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
@ -75,5 +72,12 @@ namespace jRandomSkills
pawn.Render = Color.FromArgb(255, originalRender.R, originalRender.G, originalRender.B);
});
}
public class SkillConfig : Config.DefaultSkillInfo
{
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#99140B", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}
}

View file

@ -1,4 +1,5 @@
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static jRandomSkills.jRandomSkills;
@ -6,14 +7,11 @@ namespace jRandomSkills
{
public class InfiniteAmmo : ISkill
{
private static Skills skillName = Skills.InfiniteAmmo;
private const Skills skillName = Skills.InfiniteAmmo;
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#0000FF");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventWeaponFire>((@event, info) =>
{
@ -70,5 +68,12 @@ namespace jRandomSkills
activeWeaponHandle.Value.Clip1 = 100;
}
}
public class SkillConfig : Config.DefaultSkillInfo
{
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#0000FF", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}
}

View file

@ -0,0 +1,184 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core.Attributes;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using jRandomSkills.src.utils;
using System.Drawing;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class Jackal : ISkill
{
private const Skills skillName = Skills.Jackal;
private static int maxStepBeam = Config.GetValue<int>(skillName, "maxStepBeam");
private static bool exists = false;
private static Dictionary<uint, uint> authorBeams = new Dictionary<uint, uint>();
private static Dictionary<CCSPlayerController, List<CBeam>> stepBeams = new Dictionary<CCSPlayerController, List<CBeam>>();
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"), false);
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
Instance.AddTimer(0.1f, () =>
{
foreach (var player in Utilities.GetPlayers())
{
if (!Instance.IsPlayerValid(player)) continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) continue;
EnableSkill(player);
}
if (exists)
Instance.RegisterListener<Listeners.CheckTransmit>(CheckTransmit);
});
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventRoundEnd>((@event, info) =>
{
foreach (var beams in stepBeams.Values)
foreach (var beam in beams)
if (beam != null && beam.IsValid)
beam.Remove();
foreach (var player in stepBeams.Keys)
DisableSkill(player);
authorBeams.Clear();
stepBeams.Clear();
if (exists)
Instance.RemoveListener<Listeners.CheckTransmit>(CheckTransmit);
exists = false;
return HookResult.Continue;
});
Instance.RegisterListener<Listeners.OnTick>(OnTick);
}
private static void OnTick()
{
foreach (var step in stepBeams)
{
if (Server.TickCount % 8 != 0) continue;
var pawn = step.Key.PlayerPawn.Value;
var beams = step.Value;
if (pawn.LifeState != (byte)LifeState_t.LIFE_ALIVE) continue;
Vector lastBeamVector = beams.LastOrDefault()?.EndPos ?? pawn.AbsOrigin;
var newBeam = CreateBeamStep(step.Key.Team, lastBeamVector, pawn.AbsOrigin);
if (newBeam != null)
beams.Add(newBeam);
if (beams.Count >= maxStepBeam)
{
beams[0].Remove();
beams.RemoveAt(0);
}
}
}
public static void CheckTransmit([CastFrom(typeof(nint))] CCheckTransmitInfoList infoList)
{
foreach(var (info, player) in infoList)
{
if (player == null) continue;
foreach (var step in stepBeams)
{
var enemy = step.Key;
var beams = step.Value;
foreach (var beam in beams)
if (!authorBeams.TryGetValue(player.Index, out uint enemyIndex) || enemyIndex != enemy.Index)
info.TransmitEntities.Remove(beam);
}
}
}
public static CBeam CreateBeamStep(CsTeam team, Vector start, Vector stop)
{
CBeam beam = Utilities.CreateEntityByName<CBeam>("beam")!;
if (beam == null) return null;
beam.Render = team == CsTeam.Terrorist ? Color.FromArgb(100, 255, 165, 0) : Color.FromArgb(100, 173, 216, 230);
beam.Width = 2.0f;
beam.EndWidth = 2.0f;
beam.Teleport(start);
beam.EndPos.X = stop.X;
beam.EndPos.Y = stop.Y;
beam.EndPos.Z = stop.Z;
beam.DispatchSpawn();
beam.AcceptInput("FollowEntity", beam, null!, "");
return beam;
}
public static void TypeSkill(CCSPlayerController player, string[] commands)
{
if (player == null || !player.IsValid || !player.PawnIsAlive) return;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) return;
if (playerInfo.SkillChance == 1)
{
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("areareaper_used_info")}");
return;
}
string enemyId = commands[0];
var enemy = Utilities.GetPlayers().FirstOrDefault(p => p.Team != player.Team && p.Index.ToString() == enemyId);
if (enemy == null)
{
player.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("selectplayerskill_incorrect_enemy_index"));
return;
}
authorBeams.Add(player.Index, enemy.Index);
stepBeams.Add(enemy, new List<CBeam>());
playerInfo.SkillChance = 1;
player.PrintToChat($" {ChatColors.Green}" + Localization.GetTranslation("jackal_player_info", enemy.PlayerName));
}
public static void EnableSkill(CCSPlayerController player)
{
exists = true;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
playerInfo.SkillChance = 0;
SkillUtils.PrintToChat(player, Localization.GetTranslation("jackal") + ":", false);
player.PrintToChat($" {ChatColors.Green}{Localization.GetTranslation("jackal_select_info")}");
var enemies = Utilities.GetPlayers().Where(p => p.Team != player.Team && p.IsValid && !p.IsBot).ToArray();
if (enemies.Length > 0)
{
foreach (var enemy in enemies)
player.PrintToChat($" {ChatColors.Green}⠀⠀⠀[{ChatColors.Red}{enemy.Index}{ChatColors.Green}] {enemy.PlayerName}");
}
else
player.PrintToChat($" {ChatColors.Red}⠀⠀⠀{Localization.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
player.PrintToChat($" {ChatColors.Green}{Localization.GetTranslation("selectplayerskill_command")} {ChatColors.Red}index");
}
public static void DisableSkill(CCSPlayerController player)
{
authorBeams.Remove(player.Index);
stepBeams.Remove(player);
}
public class SkillConfig : Config.DefaultSkillInfo
{
public int MaxStepBeam { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#f542ef", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int maxStepBeam = 50) : base(skill, active, color, onlyTeam, needsTeammates)
{
MaxStepBeam = maxStepBeam;
}
}
}
}

View file

@ -9,12 +9,12 @@ namespace jRandomSkills
{
public class Jammer : ISkill
{
private static Skills skillName = Skills.Jammer;
private const Skills skillName = Skills.Jammer;
private static HashSet<CCSPlayerController> jammedPlayers = new HashSet<CCSPlayerController>();
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, "#42f5a7", false);
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"), false);
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
@ -90,7 +90,7 @@ namespace jRandomSkills
if (enemies.Length > 0)
{
foreach (var enemy in enemies)
player.PrintToChat($" {ChatColors.Green}⠀⠀⠀{ChatColors.Red}{enemy.Index}{ChatColors.Green}] {enemy.PlayerName}");
player.PrintToChat($" {ChatColors.Green}⠀⠀⠀[{ChatColors.Red}{enemy.Index}{ChatColors.Green}] {enemy.PlayerName}");
}
else
player.PrintToChat($" {ChatColors.Red}⠀⠀⠀{Localization.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
@ -102,5 +102,12 @@ namespace jRandomSkills
SetCrosshair(player, true);
jammedPlayers.Remove(player);
}
public class SkillConfig : Config.DefaultSkillInfo
{
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#42f5a7", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}
}

View file

@ -0,0 +1,121 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using jRandomSkills.src.utils;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class JumpBan : ISkill
{
private const Skills skillName = Skills.JumpBan;
private static Dictionary<CCSPlayerPawn, int> bannedPlayers = new Dictionary<CCSPlayerPawn, int>();
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
Instance.AddTimer(0.1f, () =>
{
foreach (var player in Utilities.GetPlayers())
{
if (!Instance.IsPlayerValid(player)) continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) continue;
EnableSkill(player);
}
});
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventRoundEnd>((@event, info) =>
{
bannedPlayers.Clear();
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventPlayerJump>((@event, info) =>
{
var player = @event.Userid;
if (!bannedPlayers.TryGetValue(player.PlayerPawn.Value, out _)) return HookResult.Continue;
bannedPlayers[player.PlayerPawn.Value] = Server.TickCount + 10;
return HookResult.Stop;
});
Instance.RegisterListener<Listeners.OnTick>(OnTick);
}
private static void OnTick()
{
foreach (var item in bannedPlayers)
{
var pawn = item.Key;
var time = item.Value;
if (time > Server.TickCount)
pawn.AbsVelocity.Z = -100;
}
}
public static void TypeSkill(CCSPlayerController player, string[] commands)
{
if (player == null || !player.IsValid || !player.PawnIsAlive) return;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) return;
if (playerInfo.SkillChance == 1)
{
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("areareaper_used_info")}");
return;
}
string enemyId = commands[0];
var enemy = Utilities.GetPlayers().FirstOrDefault(p => p.Team != player.Team && p.Index.ToString() == enemyId);
if (enemy == null)
{
player.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("selectplayerskill_incorrect_enemy_index"));
return;
}
bannedPlayers[enemy.PlayerPawn.Value] = 0;
playerInfo.SkillChance = 1;
player.PrintToChat($" {ChatColors.Green}" + Localization.GetTranslation("jumpban_player_info", enemy.PlayerName));
enemy.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("jumpban_enemy_info"));
}
public static void EnableSkill(CCSPlayerController player)
{
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
playerInfo.SkillChance = 0;
SkillUtils.PrintToChat(player, Localization.GetTranslation("jumpban") + ":", false);
player.PrintToChat($" {ChatColors.Green}{Localization.GetTranslation("jumpban_select_info")}");
var enemies = Utilities.GetPlayers().Where(p => p.Team != player.Team && p.IsValid && !p.IsBot).ToArray();
if (enemies.Length > 0)
{
foreach (var enemy in enemies)
player.PrintToChat($" {ChatColors.Green}⠀⠀⠀[{ChatColors.Red}{enemy.Index}{ChatColors.Green}] {enemy.PlayerName}");
}
else
player.PrintToChat($" {ChatColors.Red}⠀⠀⠀{Localization.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
player.PrintToChat($" {ChatColors.Green}{Localization.GetTranslation("selectplayerskill_command")} {ChatColors.Red}index");
}
public static void DisableSkill(CCSPlayerController player)
{
bannedPlayers.Remove(player.PlayerPawn.Value);
}
public class SkillConfig : Config.DefaultSkillInfo
{
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#b01e5d", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}
}

View file

@ -0,0 +1,37 @@
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class JumpingJack : ISkill
{
private const Skills skillName = Skills.JumpingJack;
private static int addHealth = Config.GetValue<int>(skillName, "healthToAdd");
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventPlayerJump>((@event, info) =>
{
var player = @event.Userid;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) return HookResult.Continue;
SkillUtils.AddHealth(player.PlayerPawn.Value, addHealth);
return HookResult.Continue;
});
}
public class SkillConfig : Config.DefaultSkillInfo
{
public int HealthToAdd { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#a86eff", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int healthToAdd = 3) : base(skill, active, color, onlyTeam, needsTeammates)
{
HealthToAdd = healthToAdd;
}
}
}
}

View file

@ -1,6 +1,7 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Entities.Constants;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static jRandomSkills.jRandomSkills;
@ -8,14 +9,12 @@ namespace jRandomSkills
{
public class KillerFlash : ISkill
{
private static Skills skillName = Skills.KillerFlash;
private const Skills skillName = Skills.KillerFlash;
private static float flashDuration = Config.GetValue<float>(skillName, "flashDuration");
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#57bcff");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
@ -42,7 +41,7 @@ namespace jRandomSkills
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
var attackerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
if (attackerInfo?.Skill == skillName && playerInfo?.Skill != Skills.AntyFlash && player?.PlayerPawn.Value.FlashDuration >= 1)
if (attackerInfo?.Skill == skillName && playerInfo?.Skill != Skills.AntyFlash && player?.PlayerPawn.Value.FlashDuration >= flashDuration)
player?.PlayerPawn?.Value?.CommitSuicide(false, true);
return HookResult.Continue;
@ -53,5 +52,14 @@ namespace jRandomSkills
{
SkillUtils.TryGiveWeapon(player, CsItem.FlashbangGrenade);
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float FlashDuration { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#57bcff", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float flashDuration = 1f) : base(skill, active, color, onlyTeam, needsTeammates)
{
FlashDuration = flashDuration;
}
}
}
}

View file

@ -0,0 +1,103 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using jRandomSkills.src.utils;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class LifeSwap : ISkill
{
private const Skills skillName = Skills.LifeSwap;
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"), false);
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
Instance.AddTimer(0.1f, () =>
{
foreach (var player in Utilities.GetPlayers())
{
if (!Instance.IsPlayerValid(player)) continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) continue;
EnableSkill(player);
}
});
return HookResult.Continue;
});
}
public static void TypeSkill(CCSPlayerController player, string[] commands)
{
if (player == null || !player.IsValid || !player.PawnIsAlive) return;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) return;
if (playerInfo.SkillChance == 1)
{
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("areareaper_used_info")}");
return;
}
string enemyId = commands[0];
var enemy = Utilities.GetPlayers().FirstOrDefault(p => p.Team != player.Team && p.Index.ToString() == enemyId);
if (enemy == null)
{
player.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("selectplayerskill_incorrect_enemy_index"));
return;
}
SwapHealth(player, enemy);
playerInfo.SkillChance = 1;
player.PrintToChat($" {ChatColors.Green}" + Localization.GetTranslation("lifeswap_player_info", enemy.PlayerName));
enemy.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("lifeswap_enemy_info"));
}
public static void EnableSkill(CCSPlayerController player)
{
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
playerInfo.SkillChance = 0;
SkillUtils.PrintToChat(player, Localization.GetTranslation("lifeswap") + ":", false);
player.PrintToChat($" {ChatColors.Green}{Localization.GetTranslation("lifeswap_select_info")}");
var enemies = Utilities.GetPlayers().Where(p => p.Team != player.Team && p.IsValid && !p.IsBot).ToArray();
if (enemies.Length > 0)
{
foreach (var enemy in enemies)
player.PrintToChat($" {ChatColors.Green}⠀⠀⠀[{ChatColors.Red}{enemy.Index}{ChatColors.Green}] {enemy.PlayerName}");
}
else
player.PrintToChat($" {ChatColors.Red}⠀⠀⠀{Localization.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
player.PrintToChat($" {ChatColors.Green}{Localization.GetTranslation("selectplayerskill_command")} {ChatColors.Red}index");
}
private static void SwapHealth(CCSPlayerController player, CCSPlayerController enemy)
{
var playerPawn = player.PlayerPawn.Value;
var enemyPawn = enemy.PlayerPawn.Value;
if (playerPawn.LifeState != (byte)LifeState_t.LIFE_ALIVE || enemyPawn.LifeState != (byte)LifeState_t.LIFE_ALIVE)
return;
int playerHealth = playerPawn.Health;
playerPawn.Health = enemyPawn.Health;
enemyPawn.Health = playerHealth;
Utilities.SetStateChanged(playerPawn, "CBaseEntity", "m_iHealth");
Utilities.SetStateChanged(enemyPawn, "CBaseEntity", "m_iHealth");
}
public class SkillConfig : Config.DefaultSkillInfo
{
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#a3651a", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}
}

View file

@ -0,0 +1,74 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Entities.Constants;
using CounterStrikeSharp.API.Modules.Utils;
using CS2TraceRay.Class;
using CS2TraceRay.Struct;
using jRandomSkills.src.player;
using System.Numerics;
using static jRandomSkills.jRandomSkills;
using Vector = CounterStrikeSharp.API.Modules.Utils.Vector;
namespace jRandomSkills
{
public class LongKnife : ISkill
{
private const Skills skillName = Skills.LongKnife;
private static float maxDistance = Config.GetValue<float>(skillName, "maxDistance");
public unsafe static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventWeaponFire>((@event, info) =>
{
var player = @event.Userid;
if (!Instance.IsPlayerValid(player)) return HookResult.Continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) return HookResult.Continue;
var activeWeapon = player.Pawn.Value.WeaponServices.ActiveWeapon.Value;
if (activeWeapon?.DesignerName != "weapon_knife") return HookResult.Continue;
var pawn = player.PlayerPawn.Value;
Vector eyePos = new Vector(pawn.AbsOrigin.X, pawn.AbsOrigin.Y, pawn.AbsOrigin.Z + pawn.ViewOffset.Z);
Vector endPos = eyePos + SkillUtils.GetForwardVector(pawn.EyeAngles) * maxDistance;
Ray ray = new Ray(Vector3.Zero);
CTraceFilter filter = new CTraceFilter(pawn.Index, pawn.Index)
{
m_nObjectSetMask = 0xf,
m_nCollisionGroup = (byte)CollisionGroup.COLLISION_GROUP_PLAYER_MOVEMENT,
m_nInteractsWith = pawn.GetInteractsWith(),
m_nInteractsExclude = 0,
m_nBits = 11,
m_bIterateEntities = true,
m_bHitTriggers = false,
m_nInteractsAs = 0x40000
};
filter.m_nHierarchyIds[0] = pawn.GetHierarchyId();
filter.m_nHierarchyIds[1] = 0;
CGameTrace trace = TraceRay.TraceHull(eyePos, endPos, filter, ray);
if (!trace.HitPlayer(out CCSPlayerController? target) || target == null)
return HookResult.Continue;
if (target.Handle == player.Handle || trace.Distance() <= 70) return HookResult.Continue;
target.PlayerPawn.Value.EmitSound("Player.DamageBody.Onlooker");
SkillUtils.TakeHealth(target.PlayerPawn.Value, Instance.Random.Next(21, 34));
return HookResult.Continue;
});
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float MaxDistance { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#c9f8ff", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float maxDistance = 4096f) : base(skill, active, color, onlyTeam, needsTeammates)
{
MaxDistance = maxDistance;
}
}
}
}

View file

@ -0,0 +1,94 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Entities.Constants;
using CounterStrikeSharp.API.Modules.Utils;
using CS2TraceRay.Class;
using CS2TraceRay.Struct;
using jRandomSkills.src.player;
using System.Numerics;
using static jRandomSkills.jRandomSkills;
using Vector = CounterStrikeSharp.API.Modules.Utils.Vector;
namespace jRandomSkills
{
public class LongZeus : ISkill
{
private const Skills skillName = Skills.LongZeus;
private static float maxDistance = Config.GetValue<float>(skillName, "maxDistance");
public unsafe static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
Instance.AddTimer(0.1f, () =>
{
foreach (var player in Utilities.GetPlayers())
{
if (!Instance.IsPlayerValid(player)) continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) continue;
EnableSkill(player);
}
});
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventWeaponFire>((@event, info) =>
{
var player = @event.Userid;
if (!Instance.IsPlayerValid(player)) return HookResult.Continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) return HookResult.Continue;
var activeWeapon = player.Pawn.Value.WeaponServices.ActiveWeapon.Value;
if (activeWeapon?.DesignerName != "weapon_taser") return HookResult.Continue;
var pawn = player.PlayerPawn.Value;
Vector eyePos = new Vector(pawn.AbsOrigin.X, pawn.AbsOrigin.Y, pawn.AbsOrigin.Z + pawn.ViewOffset.Z);
Vector endPos = eyePos + SkillUtils.GetForwardVector(pawn.EyeAngles) * maxDistance;
Ray ray = new Ray(Vector3.Zero);
CTraceFilter filter = new CTraceFilter(pawn.Index, pawn.Index)
{
m_nObjectSetMask = 0xf,
m_nCollisionGroup = (byte)CollisionGroup.COLLISION_GROUP_PLAYER_MOVEMENT,
m_nInteractsWith = pawn.GetInteractsWith(),
m_nInteractsExclude = 0,
m_nBits = 11,
m_bIterateEntities = true,
m_bHitTriggers = false,
m_nInteractsAs = 0x40000
};
filter.m_nHierarchyIds[0] = pawn.GetHierarchyId();
filter.m_nHierarchyIds[1] = 0;
CGameTrace trace = TraceRay.TraceHull(eyePos, endPos, filter, ray);
if (!trace.HitPlayer(out CCSPlayerController? target) || target == null)
return HookResult.Continue;
if (target.Handle == player.Handle) return HookResult.Continue;
SkillUtils.TakeHealth(target.PlayerPawn.Value, 9999);
return HookResult.Continue;
});
}
public static void EnableSkill(CCSPlayerController player)
{
SkillUtils.TryGiveWeapon(player, CsItem.Zeus);
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float MaxDistance { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#6effc7", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float maxDistance = 4096f) : base(skill, active, color, onlyTeam, needsTeammates)
{
MaxDistance = maxDistance;
}
}
}
}

View file

@ -1,60 +1,150 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Entities.Constants;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using jRandomSkills.src.utils;
using static CounterStrikeSharp.API.Core.Listeners;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class Medic : ISkill
{
private static Skills skillName = Skills.Medic;
private const Skills skillName = Skills.Medic;
private static int healthToAdd = Config.GetValue<int>(skillName, "healthToAdd");
private static int healthShotLimit = Config.GetValue<int>(skillName, "healthShotLimit");
private static float timerCooldown = Config.GetValue<float>(skillName, "cooldown");
private static readonly Dictionary<ulong, PlayerSkillInfo> SkillPlayerInfo = new Dictionary<ulong, PlayerSkillInfo>();
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
SkillUtils.RegisterSkill(skillName, "#42FF5F");
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
Instance.AddTimer(0.1f, () =>
Instance.AddTimer(0.1f, () =>
{
foreach (var player in Utilities.GetPlayers())
{
if (!Instance.IsPlayerValid(player)) continue;
player.RemoveItemByDesignerName("weapon_healthshot");
if (!Instance.IsPlayerValid(player)) return;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) continue;
EnableSkill(player);
if (playerInfo?.Skill == skillName)
EnableSkill(player);
}
});
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventRoundEnd>((@event, info) =>
{
SkillPlayerInfo.Clear();
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventPlayerDeath>((@event, info) =>
{
var player = @event.Userid;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill == skillName)
if (SkillPlayerInfo.ContainsKey(player.SteamID))
SkillPlayerInfo.Remove(player.SteamID);
return HookResult.Continue;
});
Instance.RegisterListener<OnTick>(() =>
{
foreach (var player in Utilities.GetPlayers())
{
if (!Instance.IsPlayerValid(player)) return HookResult.Continue;
DisableSkill(player);
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill == skillName)
if (SkillPlayerInfo.TryGetValue(player.SteamID, out var skillInfo))
UpdateHUD(player, skillInfo);
}
return HookResult.Continue;
});
}
public static void EnableSkill(CCSPlayerController player)
{
int healthshot = Instance.Random.Next(1, 10);
SkillUtils.TryGiveWeapon(player, CsItem.Healthshot, healthshot);
SkillPlayerInfo[player.SteamID] = new PlayerSkillInfo
{
SteamID = player.SteamID,
CanUse = true,
Cooldown = DateTime.MinValue,
Count = healthShotLimit,
};
}
public static void DisableSkill(CCSPlayerController player)
{
player.RemoveItemByDesignerName("weapon_healthshot");
if (SkillPlayerInfo.ContainsKey(player.SteamID))
SkillPlayerInfo.Remove(player.SteamID);
}
private static void UpdateHUD(CCSPlayerController player, PlayerSkillInfo skillInfo)
{
float cooldown = 0;
if (skillInfo != null)
{
float time = (int)(skillInfo.Cooldown.AddSeconds(timerCooldown) - DateTime.Now).TotalSeconds;
cooldown = Math.Max(time, 0);
if (cooldown == 0 && skillInfo?.CanUse == false)
skillInfo.CanUse = true;
}
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == skillName);
if (skillData == null) return;
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{Localization.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{skillData.Name}</font> <br>";
string remainingLine = cooldown != 0
? $"<font class='fontSize-m' color='#FFFFFF'>{Localization.GetTranslation("hud_info", $"<font color='#FF0000'>{cooldown}</font>")}</font> <br>"
: $"<font class='fontSize-m' color='#{(skillInfo.Count == 0 ? "FF0000" : "00FF00")}'>{skillInfo.Count}/{healthShotLimit}</font> <br>";
var hudContent = infoLine + skillLine + remainingLine;
player.PrintToCenterHtml(hudContent);
}
public static void UseSkill(CCSPlayerController player)
{
var playerPawn = player.PlayerPawn.Value;
if (playerPawn?.CBodyComponent == null) return;
if (SkillPlayerInfo.TryGetValue(player.SteamID, out var skillInfo))
{
if (!player.IsValid || !player.PawnIsAlive) return;
if (skillInfo.CanUse && skillInfo.Count != 0)
{
skillInfo.CanUse = false;
skillInfo.Cooldown = DateTime.Now;
skillInfo.Count -= 1;
SkillUtils.AddHealth(playerPawn, healthToAdd);
player.EmitSound("Healthshot.Success");
}
}
}
public class PlayerSkillInfo
{
public ulong SteamID { get; set; }
public bool CanUse { get; set; }
public int Count { get; set; }
public DateTime Cooldown { get; set; }
}
public class SkillConfig : Config.DefaultSkillInfo
{
public int HealthToAdd { get; set; }
public int HealthShotLimit { get; set; }
public float Cooldown { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#10c212", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int healthToAdd = 50, int healthShotLimit = 3, float cooldown = 1f) : base(skill, active, color, onlyTeam, needsTeammates)
{
HealthToAdd = healthToAdd;
HealthShotLimit = healthShotLimit;
Cooldown = cooldown;
}
}
}
}

View file

@ -0,0 +1,102 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using jRandomSkills.src.utils;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class MoneySwap : ISkill
{
private const Skills skillName = Skills.MoneySwap;
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"), false);
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
Instance.AddTimer(0.1f, () =>
{
foreach (var player in Utilities.GetPlayers())
{
if (!Instance.IsPlayerValid(player)) continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) continue;
EnableSkill(player);
}
});
return HookResult.Continue;
});
}
public static void TypeSkill(CCSPlayerController player, string[] commands)
{
if (player == null || !player.IsValid || !player.PawnIsAlive) return;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) return;
if (playerInfo.SkillChance == 1)
{
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("areareaper_used_info")}");
return;
}
string enemyId = commands[0];
var enemy = Utilities.GetPlayers().FirstOrDefault(p => p.Team != player.Team && p.Index.ToString() == enemyId);
if (enemy == null)
{
player.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("selectplayerskill_incorrect_enemy_index"));
return;
}
SwapMoney(player, enemy);
playerInfo.SkillChance = 1;
player.PrintToChat($" {ChatColors.Green}" + Localization.GetTranslation("moneyswap_player_info", enemy.PlayerName));
enemy.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("moneyswap_enemy_info"));
}
public static void EnableSkill(CCSPlayerController player)
{
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
playerInfo.SkillChance = 0;
SkillUtils.PrintToChat(player, Localization.GetTranslation("moneyswap") + ":", false);
player.PrintToChat($" {ChatColors.Green}{Localization.GetTranslation("moneyswap_select_info")}");
var enemies = Utilities.GetPlayers().Where(p => p.Team != player.Team && p.IsValid && !p.IsBot).ToArray();
if (enemies.Length > 0)
{
foreach (var enemy in enemies)
player.PrintToChat($" {ChatColors.Green}⠀⠀⠀[{ChatColors.Red}{enemy.Index}{ChatColors.Green}] {enemy.PlayerName}: ${enemy.InGameMoneyServices.Account}");
}
else
player.PrintToChat($" {ChatColors.Red}⠀⠀⠀{Localization.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
player.PrintToChat($" {ChatColors.Green}{Localization.GetTranslation("selectplayerskill_command")} {ChatColors.Red}index");
}
private static void SwapMoney(CCSPlayerController player, CCSPlayerController enemy)
{
var playerMoneyServices = player?.InGameMoneyServices;
var enemyMoneyServices = enemy?.InGameMoneyServices;
if (playerMoneyServices == null || enemyMoneyServices == null) return;
int playerMoney = playerMoneyServices.Account;
playerMoneyServices.Account = enemyMoneyServices.Account;
Utilities.SetStateChanged(player, "CCSPlayerController", "m_pInGameMoneyServices");
enemyMoneyServices.Account = playerMoney;
Utilities.SetStateChanged(enemy, "CCSPlayerController", "m_pInGameMoneyServices");
}
public class SkillConfig : Config.DefaultSkillInfo
{
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#52f54c", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}
}

View file

@ -8,16 +8,13 @@ namespace jRandomSkills
{
public class Muhammed : ISkill
{
private static Skills skillName = Skills.Muhammed;
private const float ExplosionRadius = 500.0f;
private const int ExplosionDamage = 999;
private const Skills skillName = Skills.Muhammed;
private static float explosionRadius = Config.GetValue<float>(skillName, "explosionRadius");
private static int explosionDamage = Config.GetValue<int>(skillName, "explosionDamage");
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#F5CB42");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventPlayerDeath>((@event, info) =>
{
@ -42,8 +39,8 @@ namespace jRandomSkills
heProjectile.TicksAtZeroVelocity = 100;
heProjectile.TeamNum = player.TeamNum;
heProjectile.Damage = ExplosionDamage;
heProjectile.DmgRadius = (int)ExplosionRadius;
heProjectile.Damage = explosionDamage;
heProjectile.DmgRadius = (int)explosionRadius;
heProjectile.Teleport(pos, null, new Vector(0, 0, -10));
heProjectile.DispatchSpawn();
heProjectile.AcceptInput("InitializeSpawnFromWorld", player.PlayerPawn.Value, player.PlayerPawn.Value, "");
@ -62,5 +59,17 @@ namespace jRandomSkills
{
return player != null && player.IsValid && player.PlayerPawn?.Value != null;
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float ExplosionRadius { get; set; }
public int ExplosionDamage { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#F5CB42", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float explosionRadius = 500.0f, int explosionDamage = 999) : base(skill, active, color, onlyTeam, needsTeammates)
{
ExplosionRadius = explosionRadius;
ExplosionDamage = explosionDamage;
}
}
}
}

View file

@ -1,4 +1,4 @@
using CounterStrikeSharp.API;
/*using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using jRandomSkills.src.player;
using static jRandomSkills.jRandomSkills;
@ -7,7 +7,7 @@ namespace jRandomSkills
{
public class Mute : ISkill
{
private static Skills skillName = Skills.AntyHead;
private const Skills skillName = Skills.Mute;
public static void LoadSkill()
{
@ -19,17 +19,20 @@ namespace jRandomSkills
Instance.RegisterListener<Listeners.OnEntitySpawned>(@event =>
{
var name = @event.DesignerName;
if (!name.EndsWith("_projectile") && name != "instanced_scripted_scene")
if (!name.EndsWith("_projectile"))
return;
if (@event.DesignerName == "instanced_scripted_scene")
{
@event.AcceptInput("Kill");
@event.Remove();
return;
}
var grenade = @event.As<CBaseCSGrenadeProjectile>();
var pawn = grenade.OwnerEntity.Value.As<CCSPlayerPawn>();
var player = pawn.Controller.Value.As<CCSPlayerController>();
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) return;
Server.NextFrame(() => {
var grenade = @event.As<CBaseCSGrenadeProjectile>();
grenade.DetonateTime = float.MaxValue;
switch (name)
{
case "smokegrenade_projectile":
@ -39,6 +42,7 @@ namespace jRandomSkills
case "molotov_projectile":
var molotov = @event.As<CMolotovProjectile>();
molotov.Detonated = true;
molotov.StillTimer.Timestamp = float.MaxValue;
break;
case "decoy_projectile":
var decoy = @event.As<CDecoyProjectile>();
@ -46,12 +50,8 @@ namespace jRandomSkills
decoy.DecoyShotTick = int.MaxValue;
decoy.ShotsRemaining = int.MaxValue;
break;
default:
var grenade = @event.As<CBaseCSGrenadeProjectile>();
grenade.DetonateTime = float.MaxValue;
break;
}
// deoy smoke molo/inter
Instance.AddTimer(5f, () =>
{
if (@event != null && @event.IsValid)
@ -61,4 +61,4 @@ namespace jRandomSkills
});
}
}
}
}*/

View file

@ -10,20 +10,17 @@ namespace jRandomSkills
{
public class Ninja : ISkill
{
private static Skills skillName = Skills.Ninja;
private static float idlePercentInvisibility = 0.3f;
private static float duckPercentInvisibility = 0.3f;
private static float knifePercentInvisibility = 0.3f;
private const Skills skillName = Skills.Ninja;
private static float idlePercentInvisibility = Config.GetValue<float>(skillName, "idlePercentInvisibility");
private static float duckPercentInvisibility = Config.GetValue<float>(skillName, "duckPercentInvisibility");
private static float knifePercentInvisibility = Config.GetValue<float>(skillName, "knifePercentInvisibility");
private static Dictionary<nint, float> invisibilityChanged = new Dictionary<nint, float>();
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
SkillUtils.RegisterSkill(skillName, "#dedede");
Instance.RegisterEventHandler<EventRoundEnd>((@event, info) =>
Instance.RegisterEventHandler<EventRoundStart>((@event, info) =>
{
foreach (var player in Utilities.GetPlayers())
DisableSkill(player);
@ -31,6 +28,18 @@ namespace jRandomSkills
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventPlayerDeath>((@event, info) =>
{
var player = @event.Userid;
if (!player.IsValid || player.PlayerPawn.Value == null) return HookResult.Continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill == skillName)
DisableSkill(player);
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventItemPickup>((@event, info) =>
{
var player = @event.Userid;
@ -111,5 +120,18 @@ namespace jRandomSkills
}
}
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float IdlePercentInvisibility { get; set; }
public float DuckPercentInvisibility { get; set; }
public float KnifePercentInvisibility { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#dedede", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float idlePercentInvisibility = .3f, float duckPercentInvisibility = .3f, float knifePercentInvisibility = .3f) : base(skill, active, color, onlyTeam, needsTeammates)
{
IdlePercentInvisibility = idlePercentInvisibility;
DuckPercentInvisibility = duckPercentInvisibility;
KnifePercentInvisibility = knifePercentInvisibility;
}
}
}
}

View file

@ -0,0 +1,43 @@
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class NoNades : ISkill
{
private const Skills skillName = Skills.NoNades;
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventPlayerHurt>((@event, info) =>
{
var damage = @event.DmgHealth;
var player = @event.Userid;
var weapon = @event.Weapon;
if (!Instance.IsPlayerValid(player)) return HookResult.Continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) return HookResult.Continue;
if (weapon == "hegrenade" || weapon == "inferno")
{
SkillUtils.AddHealth(player.PlayerPawn.Value, damage);
damage = 0;
return HookResult.Stop;
}
return HookResult.Continue;
});
}
public class SkillConfig : Config.DefaultSkillInfo
{
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#a38c1a", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}
}

View file

@ -1,5 +1,6 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static CounterStrikeSharp.API.Core.Listeners;
using static jRandomSkills.jRandomSkills;
@ -8,14 +9,11 @@ namespace jRandomSkills
{
public class NoRecoil : ISkill
{
private static Skills skillName = Skills.NoRecoil;
private const Skills skillName = Skills.NoRecoil;
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#8a42f5");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
@ -24,7 +22,6 @@ namespace jRandomSkills
foreach (var player in Utilities.GetPlayers())
{
if (!Instance.IsPlayerValid(player)) continue;
player.RemoveItemByDesignerName("weapon_healthshot");
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) continue;
EnableSkill(player);
@ -73,5 +70,12 @@ namespace jRandomSkills
}
}
}
public class SkillConfig : Config.DefaultSkillInfo
{
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#8a42f5", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}
}

View file

@ -1,5 +1,6 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using jRandomSkills.src.utils;
using static CounterStrikeSharp.API.Core.Listeners;
@ -7,18 +8,16 @@ using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class TimeManipulator : ISkill
public class Noclip : ISkill
{
private static Skills skillName = Skills.TimeManipulator;
private static float timerCooldown = (float)(Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Cooldown);
private const Skills skillName = Skills.Noclip;
private static float timerCooldown = Config.GetValue<float>(skillName, "cooldown");
private static float duration = Config.GetValue<float>(skillName, "duration");
private static readonly Dictionary<ulong, PlayerSkillInfo> SkillPlayerInfo = new Dictionary<ulong, PlayerSkillInfo>();
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#2ec761");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
@ -87,11 +86,15 @@ namespace jRandomSkills
private static void UpdateHUD(CCSPlayerController player, PlayerSkillInfo skillInfo)
{
float cooldown = 0;
float flying = 0;
if (skillInfo != null)
{
float time = (int)(skillInfo.Cooldown.AddSeconds(timerCooldown) - DateTime.Now).TotalSeconds;
cooldown = Math.Max(time, 0);
float flyingTime = (int)(skillInfo.Cooldown.AddSeconds(duration) - DateTime.Now).TotalMilliseconds;
flying = Math.Max(flyingTime, 0);
if (cooldown == 0 && skillInfo?.CanUse == false)
skillInfo.CanUse = true;
}
@ -101,7 +104,12 @@ namespace jRandomSkills
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{Localization.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{skillData.Name}</font> <br>";
string remainingLine = cooldown != 0 ? $"<font class='fontSize-m' color='#FFFFFF'>{Localization.GetTranslation("hud_info", $"<font color='#FF0000'>{cooldown}</font>")}</font> <br>" : "";
string remainingLine = cooldown != 0
? (
flying != 0
? $"<font class='fontSize-m' color='#FFFFFF'>{Localization.GetTranslation("active_hud_info", $"<font color='#00FF00'>{Math.Round(flying / 100, 2)}</font>")}</font> <br>"
: $"<font class='fontSize-m' color='#FFFFFF'>{Localization.GetTranslation("hud_info", $"<font color='#FF0000'>{cooldown}</font>")}</font> <br>"
) : "";
var hudContent = infoLine + skillLine + remainingLine;
player.PrintToCenterHtml(hudContent);
@ -120,13 +128,8 @@ namespace jRandomSkills
skillInfo.CanUse = false;
skillInfo.Cooldown = DateTime.Now;
Server.ExecuteCommand("sv_cheats 1");
Server.ExecuteCommand("host_timescale 0.1");
Instance.AddTimer(.6f, () =>
{
Server.ExecuteCommand("host_timescale 1");
Server.ExecuteCommand("sv_cheats 0");
});
playerPawn.ActualMoveType = MoveType_t.MOVETYPE_NOCLIP;
Instance.AddTimer(duration, () => playerPawn.ActualMoveType = MoveType_t.MOVETYPE_WALK);
}
else
skillInfo.LastClick = DateTime.Now;
@ -140,5 +143,16 @@ namespace jRandomSkills
public DateTime Cooldown { get; set; }
public DateTime LastClick { get; set; }
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float Cooldown { get; set; }
public float Duration { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#44ebd4", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float cooldown = 30f, float duration = 2f) : base(skill, active, color, onlyTeam, needsTeammates)
{
Cooldown = cooldown;
Duration = duration;
}
}
}
}

View file

@ -1,14 +1,22 @@
using jRandomSkills.src.player;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
namespace jRandomSkills
{
public class None : ISkill
{
private static Skills skillName = Skills.None;
private const Skills skillName = Skills.None;
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, "#FFFFFF", false);
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"), false);
}
public class SkillConfig : Config.DefaultSkillInfo
{
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#FFFFFF", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}
}

View file

@ -1,7 +1,7 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Memory;
using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static jRandomSkills.jRandomSkills;
@ -9,14 +9,11 @@ namespace jRandomSkills
{
public class OneShot : ISkill
{
private static Skills skillName = Skills.OneShot;
private const Skills skillName = Skills.OneShot;
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#ff5CD9");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
VirtualFunctions.CBaseEntity_TakeDamageOldFunc.Hook(OnTakeDamage, HookMode.Pre);
}
@ -47,5 +44,12 @@ namespace jRandomSkills
param2.Damage = 1000f;
return HookResult.Changed;
}
public class SkillConfig : Config.DefaultSkillInfo
{
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#ff5CD9", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}
}

View file

@ -1,5 +1,6 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static jRandomSkills.jRandomSkills;
@ -7,14 +8,11 @@ namespace jRandomSkills
{
public class OnlyHead : ISkill
{
private static Skills skillName = Skills.OnlyHead;
private const Skills skillName = Skills.OnlyHead;
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#3c47de");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventPlayerHurt>((@event, info) =>
{
@ -45,5 +43,12 @@ namespace jRandomSkills
playerPawn.Health = (int)newHealth;
Utilities.SetStateChanged(playerPawn, "CBaseEntity", "m_iHealth");
}
public class SkillConfig : Config.DefaultSkillInfo
{
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#3c47de", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}
}

View file

@ -9,17 +9,14 @@ namespace jRandomSkills
{
public class PawelJumper : ISkill
{
private static Skills skillName = Skills.PawelJumper;
private const Skills skillName = Skills.PawelJumper;
private static readonly PlayerFlags[] LF = new PlayerFlags[64];
private static readonly int?[] J = new int?[64];
private static readonly PlayerButtons[] LB = new PlayerButtons[64];
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#FFA500");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterListener<OnTick>(() =>
{
@ -58,5 +55,12 @@ namespace jRandomSkills
LF[player.Slot] = flags;
LB[player.Slot] = buttons;
}
public class SkillConfig : Config.DefaultSkillInfo
{
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#FFA500", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}
}

View file

@ -9,14 +9,11 @@ namespace jRandomSkills
{
public class Phoenix : ISkill
{
private static Skills skillName = Skills.Phoenix;
private const Skills skillName = Skills.Phoenix;
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#ff5C0A", false);
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"), false);
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
@ -39,7 +36,7 @@ namespace jRandomSkills
{
var player = @event.Userid;
if (!Instance.IsPlayerValid(player)) return HookResult.Continue;
if (player == null || !player.IsValid || !player.PlayerPawn.Value.IsValid) return HookResult.Continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill == skillName)
@ -58,11 +55,8 @@ namespace jRandomSkills
public static void EnableSkill(CCSPlayerController player)
{
var skillConfig = Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString());
if (skillConfig == null) return;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
float newChance = (float)Instance.Random.NextDouble() * (skillConfig.ChanceTo - skillConfig.ChanceFrom) + skillConfig.ChanceFrom;
float newChance = (float)Instance.Random.NextDouble() * (Config.GetValue<float>(skillName, "ChanceTo") - Config.GetValue<float>(skillName, "ChanceFrom")) + Config.GetValue<float>(skillName, "ChanceFrom");
playerInfo.SkillChance = newChance;
newChance = (float)Math.Round(newChance, 2) * 100;
newChance = (float)Math.Round(newChance);
@ -73,5 +67,16 @@ namespace jRandomSkills
{
return player != null && player.IsValid && player.PlayerPawn?.Value != null;
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float ChanceFrom { get; set; }
public float ChanceTo { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#ff5C0A", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float chanceFrom = .2f, float chanceTo = .4f) : base(skill, active, color, onlyTeam, needsTeammates)
{
ChanceFrom = chanceFrom;
ChanceTo = chanceTo;
}
}
}
}

View file

@ -10,15 +10,13 @@ namespace jRandomSkills
{
public class Pilot : ISkill
{
private static Skills skillName = Skills.Pilot;
private const Skills skillName = Skills.Pilot;
private static float maximumFuel = Config.GetValue<float>(skillName, "maximumFuel");
private static readonly Dictionary<ulong, Pilot_PlayerInfo> PlayerPilotInfo = new Dictionary<ulong, Pilot_PlayerInfo>();
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#1466F5");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
@ -107,12 +105,12 @@ namespace jRandomSkills
private static void UpdateHUD(CCSPlayerController player, Pilot_PlayerInfo pilotInfo)
{
var buttons = player.Buttons;
float fuelPercentage = 100.0f;
float fuelPercentage = maximumFuel;
if (pilotInfo.PressedUse && pilotInfo.CanUsePilot)
{
float elapsedTime = (float)(DateTime.Now - pilotInfo.PilotStartTime).TotalSeconds;
fuelPercentage = Math.Max(0, 100.0f * (4.0f - elapsedTime) / 4.0f);
fuelPercentage = Math.Max(0, maximumFuel * (4.0f - elapsedTime) / 4.0f);
}
string fuelColor = GetFuelColor(fuelPercentage);
@ -129,8 +127,8 @@ namespace jRandomSkills
private static string GetFuelColor(float fuelPercentage)
{
if (fuelPercentage > 50) return "#00FF00";
if (fuelPercentage > 25) return "#FFFF00";
if (fuelPercentage > (maximumFuel/2f)) return "#00FF00";
if (fuelPercentage > (maximumFuel/4f)) return "#FFFF00";
return "#FF0000";
}
@ -184,5 +182,14 @@ namespace jRandomSkills
public bool PressedUse { get; set; }
public DateTime PilotStartTime { get; set; }
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float MaximumFuel { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#1466F5", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float maximumFuel = 100f) : base(skill, active, color, onlyTeam, needsTeammates)
{
MaximumFuel = maximumFuel;
}
}
}
}

View file

@ -1,8 +1,8 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Memory;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using jRandomSkills.src.utils;
using static CounterStrikeSharp.API.Core.Listeners;
using static jRandomSkills.jRandomSkills;
@ -10,14 +10,12 @@ namespace jRandomSkills
{
public class Planter : ISkill
{
private static Skills skillName = Skills.Planter;
private const Skills skillName = Skills.Planter;
private static int extraC4BlowTime = Config.GetValue<int>(skillName, "extraC4BlowTime");
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#7d7d7d");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundStart>((@event, @info) =>
{
@ -31,22 +29,15 @@ namespace jRandomSkills
Instance.RegisterEventHandler<EventBombPlanted>((@event, info) =>
{
foreach (var player in Utilities.GetPlayers())
{
if (!Instance.IsPlayerValid(player)) continue;
var player = @event.Userid;
if (!Instance.IsPlayerValid(player)) return HookResult.Continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) return HookResult.Continue;
var plantedBomb = Utilities.FindAllEntitiesByDesignerName<CPlantedC4>("planted_c4").FirstOrDefault();
if (plantedBomb != null)
{
Server.NextFrame(() =>
{
plantedBomb.C4Blow = (float)Server.EngineTime + 60;
});
}
}
var plantedBomb = Utilities.FindAllEntitiesByDesignerName<CPlantedC4>("planted_c4").FirstOrDefault();
if (plantedBomb != null)
Server.NextFrame(() => plantedBomb.C4Blow = (float)Server.EngineTime + extraC4BlowTime);
return HookResult.Continue;
});
@ -70,5 +61,14 @@ namespace jRandomSkills
Schema.SetSchemaValue<bool>(player.Pawn.Value.Handle, "CCSPlayerPawn", "m_bInBombZone", true);
}
}
public class SkillConfig : Config.DefaultSkillInfo
{
public int ExtraC4BlowTime { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#7d7d7d", CsTeam onlyTeam = CsTeam.Terrorist, bool needsTeammates = false, int extraC4BlowTime = 60) : base(skill, active, color, onlyTeam, needsTeammates)
{
ExtraC4BlowTime = extraC4BlowTime;
}
}
}
}

View file

@ -0,0 +1,120 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using jRandomSkills.src.utils;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class Poison : ISkill
{
private const Skills skillName = Skills.Poison;
private static int cooldown = Config.GetValue<int>(skillName, "Cooldown");
private static int healthToDamage = Config.GetValue<int>(skillName, "Damage");
private static HashSet<CCSPlayerController> poisonedPlayers = new HashSet<CCSPlayerController>();
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"), false);
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
Instance.AddTimer(0.1f, () =>
{
foreach (var player in Utilities.GetPlayers())
{
if (!Instance.IsPlayerValid(player)) continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) continue;
EnableSkill(player);
}
});
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventRoundEnd>((@event, info) =>
{
foreach (var player in poisonedPlayers)
DisableSkill(player);
return HookResult.Continue;
});
Instance.RegisterListener<Listeners.OnTick>(OnTick);
}
private static void OnTick()
{
if (Server.TickCount % (64 * cooldown) != 0) return;
foreach (var player in poisonedPlayers)
{
var pawn = player.PlayerPawn.Value;
if (pawn == null || !pawn.IsValid) continue;
SkillUtils.TakeHealth(pawn, healthToDamage);
}
}
public static void TypeSkill(CCSPlayerController player, string[] commands)
{
if (player == null || !player.IsValid || !player.PawnIsAlive) return;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) return;
if (playerInfo.SkillChance == 1)
{
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("areareaper_used_info")}");
return;
}
string enemyId = commands[0];
var enemy = Utilities.GetPlayers().FirstOrDefault(p => p.Team != player.Team && p.Index.ToString() == enemyId);
if (enemy == null)
{
player.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("selectplayerskill_incorrect_enemy_index"));
return;
}
poisonedPlayers.Add(enemy);
playerInfo.SkillChance = 1;
player.PrintToChat($" {ChatColors.Green}" + Localization.GetTranslation("poison_player_info", enemy.PlayerName));
enemy.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("poison_enemy_info"));
}
public static void EnableSkill(CCSPlayerController player)
{
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
playerInfo.SkillChance = 0;
SkillUtils.PrintToChat(player, Localization.GetTranslation("poison") + ":", false);
player.PrintToChat($" {ChatColors.Green}{Localization.GetTranslation("poison_select_info")}");
var enemies = Utilities.GetPlayers().Where(p => p.Team != player.Team && p.IsValid && !p.IsBot).ToArray();
if (enemies.Length > 0)
{
foreach (var enemy in enemies)
player.PrintToChat($" {ChatColors.Green}⠀⠀⠀[{ChatColors.Red}{enemy.Index}{ChatColors.Green}] {enemy.PlayerName}");
}
else
player.PrintToChat($" {ChatColors.Red}⠀⠀⠀{Localization.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
player.PrintToChat($" {ChatColors.Green}{Localization.GetTranslation("selectplayerskill_command")} {ChatColors.Red}index");
}
public static void DisableSkill(CCSPlayerController player)
{
poisonedPlayers.Remove(player);
}
public class SkillConfig : Config.DefaultSkillInfo
{
public int Damage { get; set; }
public int Cooldown { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#902eff", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int cooldown = 2, int damage = 1) : base(skill, active, color, onlyTeam, needsTeammates)
{
Damage = damage;
Cooldown = cooldown;
}
}
}
}

View file

@ -0,0 +1,126 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using jRandomSkills.src.utils;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class PrimaryBan : ISkill
{
private const Skills skillName = Skills.PrimaryBan;
private static HashSet<ulong> bannedPlayers = new HashSet<ulong>();
private static string[] disabledWeapons =
{
"ak47", "m4a1", "m4a4", "m4a1_silencer", "famas", "galilar", "aug", "sg553", "mp9", "mac10", "bizon", "mp7", "ump45",
"p90", "mp5sd", "ssg08", "awp", "scar20", "g3sg1", "nova", "xm1014", "mag7", "sawedoff", "m249", "negev"
};
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
Instance.AddTimer(0.1f, () =>
{
foreach (var player in Utilities.GetPlayers())
{
if (!Instance.IsPlayerValid(player)) continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) continue;
EnableSkill(player);
}
});
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventRoundEnd>((@event, info) =>
{
bannedPlayers.Clear();
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventItemEquip>((@event, info) =>
{
var player = @event.Userid;
var weapon = @event.Item;
if (!bannedPlayers.Contains(player.SteamID) || !disabledWeapons.Contains(weapon)) return HookResult.Continue;
player.ExecuteClientCommand("slot3");
return HookResult.Stop;
});
}
public static void TypeSkill(CCSPlayerController player, string[] commands)
{
if (player == null || !player.IsValid || !player.PawnIsAlive) return;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) return;
if (playerInfo.SkillChance == 1)
{
player.PrintToChat($" {ChatColors.Red}{Localization.GetTranslation("areareaper_used_info")}");
return;
}
string enemyId = commands[0];
var enemy = Utilities.GetPlayers().FirstOrDefault(p => p.Team != player.Team && p.Index.ToString() == enemyId);
if (enemy == null)
{
player.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("selectplayerskill_incorrect_enemy_index"));
return;
}
bannedPlayers.Add(enemy.SteamID);
CheckWeapon(enemy);
playerInfo.SkillChance = 1;
player.PrintToChat($" {ChatColors.Green}" + Localization.GetTranslation("primaryban_player_info", enemy.PlayerName));
enemy.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("primaryban_enemy_info"));
}
private static void CheckWeapon(CCSPlayerController player)
{
var activeWeapon = player.PlayerPawn.Value?.WeaponServices?.ActiveWeapon?.Value;
if (activeWeapon == null || !activeWeapon.IsValid) return;
if (activeWeapon.DesignerName == null || string.IsNullOrEmpty(activeWeapon.DesignerName)) return;
if (!bannedPlayers.Contains(player.SteamID) || !disabledWeapons.Contains(activeWeapon.DesignerName?.Replace("weapon_", ""))) return;
player.ExecuteClientCommand("slot3");
}
public static void EnableSkill(CCSPlayerController player)
{
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
playerInfo.SkillChance = 0;
SkillUtils.PrintToChat(player, Localization.GetTranslation("primaryban") + ":", false);
player.PrintToChat($" {ChatColors.Green}{Localization.GetTranslation("primaryban_select_info")}");
var enemies = Utilities.GetPlayers().Where(p => p.Team != player.Team && p.IsValid && !p.IsBot).ToArray();
if (enemies.Length > 0)
{
foreach (var enemy in enemies)
player.PrintToChat($" {ChatColors.Green}⠀⠀⠀[{ChatColors.Red}{enemy.Index}{ChatColors.Green}] {enemy.PlayerName}");
}
else
player.PrintToChat($" {ChatColors.Red}⠀⠀⠀{Localization.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
player.PrintToChat($" {ChatColors.Green}{Localization.GetTranslation("selectplayerskill_command")} {ChatColors.Red}index");
}
public static void DisableSkill(CCSPlayerController player)
{
bannedPlayers.Remove(player.SteamID);
}
public class SkillConfig : Config.DefaultSkillInfo
{
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#ffc061", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}
}

View file

@ -1,7 +1,6 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Memory;
using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static jRandomSkills.jRandomSkills;
@ -9,14 +8,11 @@ namespace jRandomSkills
{
public class Prosthesis : ISkill
{
private static Skills skillName = Skills.Prosthesis;
private const Skills skillName = Skills.Prosthesis;
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#9c9c9c");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventPlayerHurt>((@event, info) =>
{
@ -47,5 +43,12 @@ namespace jRandomSkills
playerPawn.Health = (int)newHealth;
Utilities.SetStateChanged(playerPawn, "CBaseEntity", "m_iHealth");
}
public class SkillConfig : Config.DefaultSkillInfo
{
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#9c9c9c", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}
}

View file

@ -0,0 +1,153 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using jRandomSkills.src.utils;
using static CounterStrikeSharp.API.Core.Listeners;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class PsychicDefusing : ISkill
{
private const Skills skillName = Skills.PsychicDefusing;
private static readonly Dictionary<CCSPlayerPawn, PlayerSkillInfo> SkillPlayerInfo = new Dictionary<CCSPlayerPawn, PlayerSkillInfo>();
private static Vector bombLocation = null;
private static float maxDefusingRange = Config.GetValue<float>(skillName, "maxDefusingRange");
private static float defusingTime = Config.GetValue<float>(skillName, "defusingTime");
private static float tickRate = 64f;
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
Instance.AddTimer(0.1f, () =>
{
foreach (var player in Utilities.GetPlayers())
{
if (!Instance.IsPlayerValid(player)) continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) continue;
EnableSkill(player);
}
});
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventRoundEnd>((@event, info) =>
{
SkillPlayerInfo.Clear();
bombLocation = null;
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventPlayerDeath>((@event, info) =>
{
var player = @event.Userid;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill == skillName)
if (SkillPlayerInfo.ContainsKey(player.PlayerPawn.Value))
SkillPlayerInfo.Remove(player.PlayerPawn.Value);
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventBombPlanted>((@event, info) =>
{
var plantedBomb = Utilities.FindAllEntitiesByDesignerName<CPlantedC4>("planted_c4").FirstOrDefault();
if (plantedBomb != null)
bombLocation = plantedBomb.AbsOrigin;
return HookResult.Continue;
});
Instance.RegisterListener<OnTick>(() =>
{
if (bombLocation == null) return;
foreach (var skillInfo in SkillPlayerInfo)
{
var player = skillInfo.Key;
var info = skillInfo.Value;
if (SkillUtils.GetDistance(player.AbsOrigin, bombLocation) > maxDefusingRange)
{
info.Defusing = false;
info.DefusingTime = defusingTime;
continue;
}
if (!info.Defusing)
player.EmitSound("c4.disarmstart");
info.Defusing = true;
info.DefusingTime -= (1f / tickRate);
if (info.DefusingTime <= 0)
{
var plantedBomb = Utilities.FindAllEntitiesByDesignerName<CPlantedC4>("planted_c4").FirstOrDefault();
if (plantedBomb != null)
{
plantedBomb.Remove();
SkillUtils.TerminateRound(CsTeam.CounterTerrorist);
}
SkillPlayerInfo.Clear();
}
UpdateHUD(player.Controller.Value.As<CCSPlayerController>(), info);
}
});
}
public static void EnableSkill(CCSPlayerController player)
{
SkillPlayerInfo[player.PlayerPawn.Value] = new PlayerSkillInfo
{
SteamID = player.SteamID,
Defusing = false,
DefusingTime = defusingTime,
};
}
public static void DisableSkill(CCSPlayerController player)
{
if (SkillPlayerInfo.ContainsKey(player.PlayerPawn.Value))
SkillPlayerInfo.Remove(player.PlayerPawn.Value);
}
private static void UpdateHUD(CCSPlayerController player, PlayerSkillInfo skillInfo)
{
if (!skillInfo.Defusing) return;
int cooldown = (int)skillInfo.DefusingTime + 1;
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == skillName);
if (skillData == null) return;
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{Localization.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{skillData.Name}</font> <br>";
string remainingLine = cooldown != 0 ? $"<font class='fontSize-m' color='#FFFFFF'>{Localization.GetTranslation("psychicdefusing_hud_info", $"<font color='#00d5ff'>{cooldown}</font>")}</font> <br>" : "";
var hudContent = infoLine + skillLine + remainingLine;
player.PrintToCenterHtml(hudContent);
}
public class PlayerSkillInfo
{
public ulong SteamID { get; set; }
public bool Defusing { get; set; }
public float DefusingTime { get; set; }
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float MaxDefusingRange { get; set; }
public float DefusingTime { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#507529", CsTeam onlyTeam = CsTeam.CounterTerrorist, bool needsTeammates = false, float maxDefusingRange = 80f, float defusingTime = 10f) : base(skill, active, color, onlyTeam, needsTeammates)
{
MaxDefusingRange = maxDefusingRange;
DefusingTime = defusingTime;
}
}
}
}

View file

@ -0,0 +1,96 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using jRandomSkills.src.utils;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class Push : ISkill
{
private const Skills skillName = Skills.Push;
private static float jumpVelocity = Config.GetValue<float>(skillName, "jumpVelocity");
private static float pushVelocity = Config.GetValue<float>(skillName, "pushVelocity");
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"), false);
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
Instance.AddTimer(0.1f, () =>
{
foreach (var player in Utilities.GetPlayers())
{
if (!Instance.IsPlayerValid(player)) continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) continue;
EnableSkill(player);
}
});
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventPlayerHurt>((@event, info) =>
{
var attacker = @event!.Attacker;
var victim = @event!.Userid;
if (!Instance.IsPlayerValid(attacker) || !Instance.IsPlayerValid(victim) || attacker == victim)
return HookResult.Continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
if (playerInfo?.Skill == skillName && victim.PawnIsAlive)
{
if (Instance.Random.NextDouble() <= playerInfo.SkillChance)
PushEnemy(victim, attacker.PlayerPawn.Value.EyeAngles);
}
return HookResult.Continue;
});
}
public static void EnableSkill(CCSPlayerController player)
{
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
float newChance = (float)Instance.Random.NextDouble() * (Config.GetValue<float>(skillName, "ChanceTo") - Config.GetValue<float>(skillName, "ChanceFrom")) + Config.GetValue<float>(skillName, "ChanceFrom");
playerInfo.SkillChance = newChance;
newChance = (float)Math.Round(newChance, 2) * 100;
newChance = (float)Math.Round(newChance);
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{Localization.GetTranslation("push")}{ChatColors.Lime}: " + Localization.GetTranslation("push_desc2", newChance), false);
}
private static void PushEnemy(CCSPlayerController player, QAngle attackerAngle)
{
if (player.PlayerPawn.Value.LifeState != (int)LifeState_t.LIFE_ALIVE)
return;
var currentPosition = player.PlayerPawn.Value.AbsOrigin;
var currentAngles = player.PlayerPawn.Value.EyeAngles;
Vector newVelocity = SkillUtils.GetForwardVector(attackerAngle) * pushVelocity;
newVelocity.Z = player.PlayerPawn.Value.AbsVelocity.Z + jumpVelocity;
player.PlayerPawn.Value.Teleport(currentPosition, currentAngles, newVelocity);
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float ChanceFrom { get; set; }
public float ChanceTo { get; set; }
public float JumpVelocity { get; set; }
public float PushVelocity { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#1e9ab0", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float chanceFrom = 1f, float chanceTo = 1f, float jumpVelocity = 300f, float pushVelocity = 400f) : base(skill, active, color, onlyTeam, needsTeammates)
{
ChanceFrom = chanceFrom;
ChanceTo = chanceTo;
JumpVelocity = jumpVelocity;
PushVelocity = pushVelocity;
}
}
}
}

View file

@ -0,0 +1,76 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Entities.Constants;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class Pyro : ISkill
{
private const Skills skillName = Skills.Pyro;
private static float regenerationMultiplier = Config.GetValue<float>(skillName, "regenerationMultiplier");
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
Instance.AddTimer(0.1f, () =>
{
foreach (var player in Utilities.GetPlayers())
{
if (!Instance.IsPlayerValid(player)) continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) continue;
EnableSkill(player);
}
});
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventPlayerHurt>((@event, info) =>
{
var victim = @event.Userid;
int damage = @event.DmgHealth;
string weapon = @event.Weapon;
if (weapon != "inferno" || !Instance.IsPlayerValid(victim)) return HookResult.Continue;
var victimInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == victim.SteamID);
if (victimInfo == null || victimInfo.Skill != skillName) return HookResult.Continue;
RestoreHealth(victim, damage * regenerationMultiplier);
return HookResult.Stop;
});
}
public static void EnableSkill(CCSPlayerController player)
{
SkillUtils.TryGiveWeapon(player, player.Team == CsTeam.CounterTerrorist ? CsItem.IncendiaryGrenade : CsItem.Molotov);
}
private static void RestoreHealth(CCSPlayerController victim, float damage)
{
var playerPawn = victim.PlayerPawn.Value;
var newHealth = playerPawn.Health + damage;
if (newHealth > 100)
newHealth = 100;
playerPawn.Health = (int)newHealth;
Utilities.SetStateChanged(playerPawn, "CBaseEntity", "m_iHealth");
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float RegenerationMultiplier { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#3c47de", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float regenerationMultiplier = 1.5f) : base(skill, active, color, onlyTeam, needsTeammates)
{
RegenerationMultiplier = regenerationMultiplier;
}
}
}
}

View file

@ -1,5 +1,6 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Modules.Memory;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static CounterStrikeSharp.API.Core.Listeners;
using static jRandomSkills.jRandomSkills;
@ -8,14 +9,11 @@ namespace jRandomSkills
{
public class QuickShot : ISkill
{
private static Skills skillName = Skills.QuickShot;
private const Skills skillName = Skills.QuickShot;
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#8a42f5");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterListener<OnTick>(OnTick);
}
@ -42,5 +40,12 @@ namespace jRandomSkills
}
}
}
public class SkillConfig : Config.DefaultSkillInfo
{
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#8a42f5", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}
}

View file

@ -1,5 +1,6 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static CounterStrikeSharp.API.Core.Listeners;
using static jRandomSkills.jRandomSkills;
@ -8,14 +9,11 @@ namespace jRandomSkills
{
public class RadarHack : ISkill
{
private static Skills skillName = Skills.RadarHack;
private const Skills skillName = Skills.RadarHack;
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#2effcb");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterListener<OnTick>(CheckRadarowiec);
}
@ -54,5 +52,12 @@ namespace jRandomSkills
bomb.EntitySpottedState.SpottedByMask[0] |= (1u << (int)(playerIndex % 32));
}
}
public class SkillConfig : Config.DefaultSkillInfo
{
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#2effcb", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}
}

View file

@ -1,5 +1,6 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static jRandomSkills.jRandomSkills;
@ -7,14 +8,13 @@ namespace jRandomSkills
{
public class Rambo : ISkill
{
private static Skills skillName = Skills.Rambo;
private const Skills skillName = Skills.Rambo;
private static int minExtraHealth = Config.GetValue<int>(skillName, "minExtraHealth");
private static int maxExtraHealth = Config.GetValue<int>(skillName, "maxExtraHealth");
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#009905");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
@ -34,7 +34,7 @@ namespace jRandomSkills
public static void EnableSkill(CCSPlayerController player)
{
int healthBonus = Instance.Random.Next(50, 501);
int healthBonus = Instance.Random.Next(minExtraHealth, maxExtraHealth);
AddHealth(player, healthBonus);
}
@ -66,5 +66,16 @@ namespace jRandomSkills
pawn.Health = Math.Min(pawn.Health, 100);
Utilities.SetStateChanged(pawn, "CBaseEntity", "m_iHealth");
}
public class SkillConfig : Config.DefaultSkillInfo
{
public int MinExtraHealth { get; set; }
public int MaxExtraHealth { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#009905", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int minExtraHealth = 50, int maxExtraHealth = 501) : base(skill, active, color, onlyTeam, needsTeammates)
{
MinExtraHealth = minExtraHealth;
MaxExtraHealth = maxExtraHealth;
}
}
}
}

View file

@ -1,5 +1,6 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using jRandomSkills.src.utils;
using System.Collections.Immutable;
@ -10,8 +11,8 @@ namespace jRandomSkills
{
public class RandomWeapon : ISkill
{
private static Skills skillName = Skills.RandomWeapon;
private static float timerCooldown = (float)(Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Cooldown);
private const Skills skillName = Skills.RandomWeapon;
private static float timerCooldown = Config.GetValue<float>(skillName, "cooldown");
private static readonly Dictionary<ulong, PlayerSkillInfo> SkillPlayerInfo = new Dictionary<ulong, PlayerSkillInfo>();
private static string[] pistols = { "weapon_deagle", "weapon_revolver", "weapon_glock", "weapon_usp_silencer",
@ -24,10 +25,7 @@ namespace jRandomSkills
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#e0873a");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
@ -179,5 +177,14 @@ namespace jRandomSkills
public DateTime Cooldown { get; set; }
public DateTime LastClick { get; set; }
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float Cooldown { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#e0873a", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float cooldown = 15f) : base(skill, active, color, onlyTeam, needsTeammates)
{
Cooldown = cooldown;
}
}
}
}

View file

@ -0,0 +1,91 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using System.Drawing;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class ReZombie : ISkill
{
private const Skills skillName = Skills.ReZombie;
private static int zombieHealth = Config.GetValue<int>(skillName, "zombieHealth");
private static HashSet<CCSPlayerController> zombies = new HashSet<CCSPlayerController>();
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventItemEquip>((@event, info) =>
{
var player = @event.Userid;
var weapon = @event.Item;
if (!zombies.Contains(player) || weapon == "c4") return HookResult.Continue;
player.ExecuteClientCommand("slot3");
return HookResult.Stop;
});
Instance.RegisterEventHandler<EventRoundStart>((@event, info) =>
{
foreach(var player in zombies)
DisableSkill(player);
zombies.Clear();
return HookResult.Stop;
});
Instance.RegisterEventHandler<EventPlayerDeath>((@event, info) =>
{
var player = @event.Userid;
if (player == null || !player.IsValid || !player.PlayerPawn.Value.IsValid || zombies.Contains(player)) return HookResult.Continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) return HookResult.Continue;
var pawn = player.PlayerPawn.Value;
Vector deadPosition = new Vector(pawn.AbsOrigin.X, pawn.AbsOrigin.Y, pawn.AbsOrigin.Z);
QAngle deadRotation = new QAngle(pawn.EyeAngles.X, pawn.EyeAngles.Y, pawn.EyeAngles.Z);
player.Respawn();
Instance.AddTimer(.2f, () => {
player.Respawn();
zombies.Add(player);
player.ExecuteClientCommand("slot3");
SetPlayerColor(pawn, false);
SkillUtils.AddHealth(pawn, zombieHealth - 100, zombieHealth);
pawn.Teleport(deadPosition, deadRotation);
});
return HookResult.Continue;
});
}
public static void EnableSkill(CCSPlayerController player)
{
zombies.Remove(player);
}
public static void DisableSkill(CCSPlayerController player)
{
zombies.Remove(player);
SetPlayerColor(player.PlayerPawn.Value, true);
}
private static void SetPlayerColor(CCSPlayerPawn pawn, bool normal)
{
var color = normal ? Color.FromArgb(255, 255, 255, 255) : Color.FromArgb(255, 255, 0, 0);
pawn.Render = color;
Utilities.SetStateChanged(pawn, "CBaseModelEntity", "m_clrRender");
}
public class SkillConfig : Config.DefaultSkillInfo
{
public int ZombieHealth { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#ff5C0A", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int zombieHealth = 200) : base(skill, active, color, onlyTeam, needsTeammates)
{
ZombieHealth = zombieHealth;
}
}
}
}

View file

@ -1,7 +1,6 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Memory;
using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using jRandomSkills.src.utils;
using static CounterStrikeSharp.API.Core.Listeners;
@ -11,16 +10,13 @@ namespace jRandomSkills
{
public class ReactiveArmor : ISkill
{
private static Skills skillName = Skills.ReactiveArmor;
private static float timerCooldown = (float)(Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Cooldown);
private const Skills skillName = Skills.ReactiveArmor;
private static float timerCooldown = Config.GetValue<float>(skillName, "cooldown");
private static readonly Dictionary<ulong, PlayerSkillInfo> SkillPlayerInfo = new Dictionary<ulong, PlayerSkillInfo>();
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#3cded3");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
@ -73,7 +69,6 @@ namespace jRandomSkills
int damage = @event.DmgHealth;
if (!Instance.IsPlayerValid(attacker) || !Instance.IsPlayerValid(victim)) return HookResult.Continue;
if (SkillPlayerInfo.TryGetValue(victim.SteamID, out var skillInfo))
{
if (!victim.IsValid || !victim.PawnIsAlive || !skillInfo.CanUse) return HookResult.Continue;
@ -146,5 +141,14 @@ namespace jRandomSkills
public DateTime Cooldown { get; set; }
public DateTime LastClick { get; set; }
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float Cooldown { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#3cded3", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float cooldown = 15) : base(skill, active, color, onlyTeam, needsTeammates)
{
Cooldown = cooldown;
}
}
}
}

View file

@ -0,0 +1,46 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class Regeneration : ISkill
{
private const Skills skillName = Skills.Regeneration;
private static int cooldown = Config.GetValue<int>(skillName, "cooldown");
private static int healthToAdd = Config.GetValue<int>(skillName, "healthToAdd");
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterListener<Listeners.OnTick>(OnTick);
}
private static void OnTick()
{
if (Server.TickCount % (64 * cooldown) != 0) return;
foreach (var player in Utilities.GetPlayers())
{
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) continue;
var pawn = player.PlayerPawn.Value;
if (pawn == null || !pawn.IsValid) continue;
SkillUtils.AddHealth(pawn, healthToAdd);
}
}
public class SkillConfig : Config.DefaultSkillInfo
{
public int HealthToAdd { get; set; }
public int Cooldown { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#ff462e", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int healthToAdd = 1, int cooldown = 1) : base(skill, active, color, onlyTeam, needsTeammates)
{
HealthToAdd = healthToAdd;
Cooldown = cooldown;
}
}
}
}

View file

@ -12,16 +12,13 @@ namespace jRandomSkills
{
public class Replicator : ISkill
{
private static Skills skillName = Skills.Replicator;
private static float timerCooldown = (float)(Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Cooldown);
private const Skills skillName = Skills.Replicator;
private static float timerCooldown = Config.GetValue<float>(skillName, "cooldown");
private static readonly Dictionary<ulong, PlayerSkillInfo> SkillPlayerInfo = new Dictionary<ulong, PlayerSkillInfo>();
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#a3000b");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
@ -68,7 +65,6 @@ namespace jRandomSkills
});
VirtualFunctions.CBaseEntity_TakeDamageOldFunc.Hook(OnTakeDamage, HookMode.Pre);
}
public static void EnableSkill(CCSPlayerController player)
@ -183,5 +179,14 @@ namespace jRandomSkills
public DateTime Cooldown { get; set; }
public DateTime LastClick { get; set; }
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float Cooldown { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#a3000b", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float cooldown = 15f) : base(skill, active, color, onlyTeam, needsTeammates)
{
Cooldown = cooldown;
}
}
}
}

View file

@ -10,16 +10,13 @@ namespace jRandomSkills
{
public class Retreat : ISkill
{
private static Skills skillName = Skills.Retreat;
private static float timerCooldown = (float)(Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Cooldown);
private const Skills skillName = Skills.Retreat;
private static float timerCooldown = Config.GetValue<float>(skillName, "cooldown");
private static readonly Dictionary<ulong, PlayerSkillInfo> SkillPlayerInfo = new Dictionary<ulong, PlayerSkillInfo>();
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#a86eff");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
@ -146,5 +143,14 @@ namespace jRandomSkills
public DateTime Cooldown { get; set; }
public DateTime LastClick { get; set; }
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float Cooldown { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#a86eff", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float cooldown = 15f) : base(skill, active, color, onlyTeam, needsTeammates)
{
Cooldown = cooldown;
}
}
}
}

View file

@ -1,7 +1,5 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Memory;
using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static jRandomSkills.jRandomSkills;
@ -10,15 +8,12 @@ namespace jRandomSkills
{
public class ReturnToSender : ISkill
{
private static Skills skillName = Skills.ReturnToSender;
private const Skills skillName = Skills.ReturnToSender;
private static HashSet<nint> playersToSender = new HashSet<nint>();
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#a68132");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundEnd>((@event, info) =>
{
@ -32,7 +27,7 @@ namespace jRandomSkills
var victim = @event.Userid;
int damage = @event.DmgHealth;
if (!Instance.IsPlayerValid(attacker) || !Instance.IsPlayerValid(victim)) return HookResult.Continue;
if (!Instance.IsPlayerValid(attacker) || !Instance.IsPlayerValid(victim) || attacker == victim) return HookResult.Continue;
var attackerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
if (attackerInfo == null || attackerInfo.Skill != skillName) return HookResult.Continue;
@ -61,5 +56,12 @@ namespace jRandomSkills
}
return new Vector(abs.X, abs.Y, abs.Z);
}
public class SkillConfig : Config.DefaultSkillInfo
{
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#a68132", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}
}

View file

@ -1,5 +1,6 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static jRandomSkills.jRandomSkills;
@ -7,14 +8,13 @@ namespace jRandomSkills
{
public class RichBoy : ISkill
{
private static Skills skillName = Skills.RichBoy;
private const Skills skillName = Skills.RichBoy;
private static int minMoney = Config.GetValue<int>(skillName, "minMoney");
private static int maxMoney = Config.GetValue<int>(skillName, "maxMoney");
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#D4AF37");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
@ -26,7 +26,7 @@ namespace jRandomSkills
if (playerInfo?.Skill == skillName)
{
int moneyBonus = Instance.Random.Next(5000, 15000);
int moneyBonus = Instance.Random.Next(minMoney, maxMoney);
playerInfo.SkillChance = moneyBonus;
AddMoney(player, moneyBonus);
}
@ -39,7 +39,7 @@ namespace jRandomSkills
public static void EnableSkill(CCSPlayerController player)
{
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
int moneyBonus = Instance.Random.Next(5000, 15000);
int moneyBonus = Instance.Random.Next(minMoney, maxMoney);
playerInfo.SkillChance = moneyBonus;
AddMoney(player, moneyBonus);
}
@ -59,5 +59,16 @@ namespace jRandomSkills
moneyServices.Account = Math.Max(moneyServices.Account + money, 0);
Utilities.SetStateChanged(player, "CCSPlayerController", "m_pInGameMoneyServices");
}
public class SkillConfig : Config.DefaultSkillInfo
{
public int MinMoney { get; set; }
public int MaxMoney { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#D4AF37", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int minMoney = 5000, int maxMoney = 15000) : base(skill, active, color, onlyTeam, needsTeammates)
{
MinMoney = minMoney;
MaxMoney = maxMoney;
}
}
}
}

View file

@ -1,5 +1,6 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static jRandomSkills.jRandomSkills;
@ -7,25 +8,24 @@ namespace jRandomSkills
{
public class RobinHood : ISkill
{
private static Skills skillName = Skills.RobinHood;
private const Skills skillName = Skills.RobinHood;
private static int moneyMultiplier = Config.GetValue<int>(skillName, "moneyMultiplier");
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#119125");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventPlayerHurt>((@event, info) =>
{
var victim = @event.Userid;
var attacker = @event.Attacker;
var damage = @event.DmgHealth;
if (!Instance.IsPlayerValid(victim) || !Instance.IsPlayerValid(attacker)) return HookResult.Continue;
if (!Instance.IsPlayerValid(attacker) || !Instance.IsPlayerValid(victim) || attacker == victim) return HookResult.Continue;
var attackerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
if (attackerInfo?.Skill != skillName) return HookResult.Continue;
int moneyToSteal = damage * 35;
int moneyToSteal = damage * moneyMultiplier;
StealMoney(victim, attacker, moneyToSteal);
return HookResult.Continue;
@ -45,5 +45,14 @@ namespace jRandomSkills
attackerMoneyServices.Account = Math.Min(attackerMoneyServices.Account + moneyToAdd, 16000);
Utilities.SetStateChanged(attacker, "CCSPlayerController", "m_pInGameMoneyServices");
}
public class SkillConfig : Config.DefaultSkillInfo
{
public int MoneyMultiplier { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#119125", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int moneyMultiplier = 35) : base(skill, active, color, onlyTeam, needsTeammates)
{
MoneyMultiplier = moneyMultiplier;
}
}
}
}

View file

@ -0,0 +1,74 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class Rubber: ISkill
{
private const Skills skillName = Skills.Rubber;
private static float rubberTime = Config.GetValue<float>(skillName, "slownessTime");
private static float rubberModifier = Config.GetValue<float>(skillName, "slownessModifier");
private static Dictionary<CCSPlayerPawn, float> playersToSlow = new Dictionary<CCSPlayerPawn, float>();
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventPlayerHurt>((@event, info) =>
{
var attacker = @event.Attacker;
var victim = @event.Userid;
if (!Instance.IsPlayerValid(attacker) || !Instance.IsPlayerValid(victim) || attacker == victim) return HookResult.Continue;
var attackerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == attacker.SteamID);
if (attackerInfo?.Skill == skillName)
playersToSlow.Add(victim.PlayerPawn.Value, Server.TickCount + (64 * rubberTime));
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventRoundEnd>((@event, info) =>
{
playersToSlow.Clear();
return HookResult.Continue;
});
Instance.RegisterListener<Listeners.OnTick>(OnTick);
}
private static void OnTick()
{
foreach(var item in playersToSlow)
{
var pawn = item.Key;
var time = item.Value;
if (time >= Server.TickCount)
ChangeVelocity(pawn);
else
playersToSlow.Remove(item.Key);
}
}
private static void ChangeVelocity(CCSPlayerPawn pawn)
{
if (pawn == null || !pawn.IsValid) return;
pawn.VelocityModifier = rubberModifier;
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float SlownessTime { get; set; }
public float SlownessModifier { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#8B4513", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float slownessTime = 2f, float slownessModifier = .2f) : base(skill, active, color, onlyTeam, needsTeammates)
{
SlownessTime = slownessTime;
SlownessModifier = slownessModifier;
}
}
}
}

View file

@ -1,18 +1,18 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using jRandomSkills.src.utils;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class Saper : ISkill
{
private static Skills skillName = Skills.Saper;
private const Skills skillName = Skills.Saper;
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, "#8A2BE2");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventBombBeginplant>((@event, info) =>
{
@ -62,5 +62,12 @@ namespace jRandomSkills
return HookResult.Continue;
});
}
public class SkillConfig : Config.DefaultSkillInfo
{
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#8A2BE2", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}
}

View file

@ -8,16 +8,13 @@ namespace jRandomSkills
{
public class SecondLife : ISkill
{
private static Skills skillName = Skills.SecondLife;
private static int secondLifeHealth = 50;
private const Skills skillName = Skills.SecondLife;
private static int secondLifeHealth = Config.GetValue<int>(skillName, "startHealth");
private static HashSet<nint> secondLifePlayers = new HashSet<nint>();
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#d41c1c");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
@ -44,21 +41,20 @@ namespace jRandomSkills
Instance.RegisterEventHandler<EventPlayerHurt>((@event, info) =>
{
var attacker = @event.Attacker;
var victim = @event.Userid;
int damage = @event.DmgHealth;
if (!Instance.IsPlayerValid(attacker) || !Instance.IsPlayerValid(victim)) return HookResult.Continue;
if (!Instance.IsPlayerValid(victim)) return HookResult.Continue;
var victimInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == victim.SteamID);
if (victimInfo == null || victimInfo.Skill != skillName) return HookResult.Continue;
var victimPawn = victim.PlayerPawn.Value;
if (victimPawn.Health - damage >= 0 || secondLifePlayers.TryGetValue(victim.Handle, out _))
if (victimPawn.Health > 0 || secondLifePlayers.TryGetValue(victim.Handle, out _) == true)
return HookResult.Continue;
secondLifePlayers.Add(victim.Handle);
SetHealth(victim, secondLifeHealth);
victimPawn.Teleport(GetSpawnVector(victim));
victimPawn.Teleport(GetSpawnVector(victim), victimPawn.AbsRotation, null);
return HookResult.Stop;
});
}
@ -98,5 +94,14 @@ namespace jRandomSkills
}
return new Vector(abs.X, abs.Y, abs.Z);
}
public class SkillConfig : Config.DefaultSkillInfo
{
public int StartHealth { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#d41c1c", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int startHealth = 50) : base(skill, active, color, onlyTeam, needsTeammates)
{
StartHealth = startHealth;
}
}
}
}

View file

@ -1,23 +1,27 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Entities.Constants;
using CounterStrikeSharp.API.Modules.Utils;
using CS2TraceRay.Class;
using CS2TraceRay.Struct;
using jRandomSkills.src.player;
using jRandomSkills.src.utils;
using System.Numerics;
using static CounterStrikeSharp.API.Core.Listeners;
using static jRandomSkills.jRandomSkills;
using Vector = CounterStrikeSharp.API.Modules.Utils.Vector;
namespace jRandomSkills
{
public class Shade : ISkill
{
private static Skills skillName = Skills.Shade;
private const float TeleportDistance = 100.0f;
private const Skills skillName = Skills.Shade;
private static float teleportDistance = Config.GetValue<float>(skillName, "teleportDistance");
private static Dictionary<CCSPlayerController, float> noSpace = new Dictionary<CCSPlayerController, float>();
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#18171A");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventPlayerHurt>((@event, info) =>
{
@ -35,14 +39,60 @@ namespace jRandomSkills
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventRoundEnd>((@event, info) =>
{
noSpace.Clear();
return HookResult.Continue;
});
Instance.RegisterListener<OnTick>(() =>
{
var skillInfo = Instance.skillPlayer.FirstOrDefault(p => p.Skill == skillName);
if (skillInfo == null) return;
var player = Utilities.GetPlayerFromSteamId(skillInfo.SteamID);
foreach (var item in noSpace)
if (item.Value >= Server.TickCount)
UpdateHUD(item.Key);
});
}
public static void DisableSkill(CCSPlayerController player)
{
if (noSpace.ContainsKey(player))
noSpace.Remove(player);
}
private static void UpdateHUD(CCSPlayerController player)
{
var skillData = SkillData.Skills.FirstOrDefault(s => s.Skill == skillName);
if (skillData == null) return;
string infoLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='#FFFFFF'>{Localization.GetTranslation("your_skill")}:</font> <br>";
string skillLine = $"<font class='fontSize-l' class='fontWeight-Bold' color='{skillData.Color}'>{skillData.Name}</font> <br>";
string remainingLine = $"<font class='fontSize-m' color='#FF0000'>{Localization.GetTranslation("shade_nospace")}</font> <br>";
var hudContent = infoLine + skillLine + remainingLine;
player.PrintToCenterHtml(hudContent);
}
private unsafe static bool CheckTeleport(CCSPlayerController player, Vector startPos, Vector endPos)
{
var pawn = player.PlayerPawn.Value;
Ray ray = new Ray(new Vector3(-16, -16, -0), new Vector3(16, 16, 72));
CTraceFilter filter = new CTraceFilter(pawn.Index, pawn.Index)
{
m_nObjectSetMask = 0xf,
m_nCollisionGroup = (byte)CollisionGroup.COLLISION_GROUP_PLAYER_MOVEMENT,
m_nInteractsWith = pawn.GetInteractsWith(),
m_nInteractsExclude = 0,
m_nBits = 11,
m_bIterateEntities = true,
m_bHitTriggers = false,
m_nInteractsAs = 0x40000
};
filter.m_nHierarchyIds[0] = pawn.GetHierarchyId();
filter.m_nHierarchyIds[1] = 0;
CGameTrace trace = TraceRay.TraceHull(startPos, endPos, filter, ray);
return !trace.HitWorld(out _);
}
private static void TeleportAttackerBehindVictim(CCSPlayerController attacker, CCSPlayerController victim)
{
var victimPawn = victim.PlayerPawn.Value;
@ -50,11 +100,31 @@ namespace jRandomSkills
if (victimPawn == null || attackerPawn == null) return;
Vector victimPosition = victimPawn.AbsOrigin;
QAngle victimAngles = victimPawn.AbsRotation;
Vector victimEyePos = new Vector(victimPawn.AbsOrigin.X, victimPawn.AbsOrigin.Y, victimPawn.AbsOrigin.Z + victimPawn.ViewOffset.Z);
int[] angles = { 0, 90, -90 };
Vector behindPosition = victimPosition - SkillUtils.GetForwardVector(victimAngles) * TeleportDistance;
attackerPawn.Teleport(behindPosition, victimAngles, new Vector(0, 0, 0));
bool teleported = false;
foreach (int extraAngle in angles)
{
QAngle newAngle = new QAngle(victimAngles.X, victimAngles.Y + extraAngle, victimAngles.Z);
Vector behindPosition = victimEyePos - SkillUtils.GetForwardVector(newAngle) * teleportDistance;
if (!CheckTeleport(victim, victimEyePos, behindPosition)) continue;
attackerPawn.Teleport(behindPosition, newAngle, new Vector(0, 0, 0));
teleported = true;
break;
}
if (!teleported)
noSpace[attacker] = Server.TickCount + (64 * 2);
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float TeleportDistance { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#4d4d4d", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float teleportDistance = 100f) : base(skill, active, color, onlyTeam, needsTeammates)
{
TeleportDistance = teleportDistance;
}
}
}
}

View file

@ -0,0 +1,43 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class ShortBomb : ISkill
{
private const Skills skillName = Skills.ShortBomb;
private static int detonationTime = Config.GetValue<int>(skillName, "detonationTime");
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventBombPlanted>((@event, info) =>
{
var player = @event.Userid;
if (!Instance.IsPlayerValid(player)) return HookResult.Continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) return HookResult.Continue;
var plantedBomb = Utilities.FindAllEntitiesByDesignerName<CPlantedC4>("planted_c4").FirstOrDefault();
if (plantedBomb != null)
Server.NextFrame(() => plantedBomb.C4Blow = (float)Server.EngineTime + detonationTime);
return HookResult.Continue;
});
}
public class SkillConfig : Config.DefaultSkillInfo
{
public int DetonationTime { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#f5b74c", CsTeam onlyTeam = CsTeam.Terrorist, bool needsTeammates = false, int detonationTime = 20) : base(skill, active, color, onlyTeam, needsTeammates)
{
DetonationTime = detonationTime;
}
}
}
}

View file

@ -1,5 +1,6 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static jRandomSkills.jRandomSkills;
@ -7,14 +8,11 @@ namespace jRandomSkills
{
public class Silent : ISkill
{
private static Skills skillName = Skills.Silent;
private const Skills skillName = Skills.Silent;
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#333333");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.HookUserMessage(208, um =>
{
@ -36,5 +34,12 @@ namespace jRandomSkills
return HookResult.Handled;
}, HookMode.Pre);
}
public class SkillConfig : Config.DefaultSkillInfo
{
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#333333", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}
}

View file

@ -0,0 +1,117 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class SniperElite : ISkill
{
private const Skills skillName = Skills.SniperElite;
private static readonly Dictionary<ulong, string> sniperElites = new Dictionary<ulong, string>();
private static string[] rifles = { "weapon_mp9", "weapon_mac10", "weapon_bizon", "weapon_mp7", "weapon_ump45", "weapon_p90",
"weapon_mp5sd", "weapon_famas", "weapon_galilar", "weapon_m4a1", "weapon_m4a1_silencer", "weapon_ak47",
"weapon_aug", "weapon_sg553", "weapon_ssg08", "weapon_awp", "weapon_scar20", "weapon_g3sg1",
"weapon_nova", "weapon_xm1014", "weapon_mag7", "weapon_sawedoff", "weapon_m249", "weapon_negev" };
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
Instance.AddTimer(0.1f, () =>
{
foreach (var player in Utilities.GetPlayers())
{
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill == skillName)
EnableSkill(player);
}
});
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventRoundEnd>((@event, info) =>
{
sniperElites.Clear();
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventPlayerDeath>((@event, info) =>
{
var player = @event.Userid;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill == skillName)
if (sniperElites.ContainsKey(player.SteamID))
sniperElites.Remove(player.SteamID);
return HookResult.Continue;
});
}
public static void EnableSkill(CCSPlayerController player)
{
sniperElites.Add(player.SteamID, "weapon_awp");
}
public static void DisableSkill(CCSPlayerController player)
{
if (sniperElites.ContainsKey(player.SteamID))
sniperElites.Remove(player.SteamID);
}
public static void UseSkill(CCSPlayerController player)
{
var playerPawn = player.PlayerPawn.Value;
if (playerPawn?.CBodyComponent == null) return;
if (sniperElites.ContainsKey(player.SteamID))
RemoveAndGiveWeapon(player);
}
private static void RemoveAndGiveWeapon(CCSPlayerController player)
{
string holdedWeapon = "weapon_awp";
if (sniperElites.TryGetValue(player.SteamID, out string weapon))
holdedWeapon = weapon;
try
{
string activeRifle = GetActiveRifle(player);
if (activeRifle != null)
player.RemoveItemByDesignerName(activeRifle, true);
sniperElites[player.SteamID] = activeRifle;
Server.NextFrame(() =>
{
player.GiveNamedItem(holdedWeapon ?? "weapon_awp");
});
}
catch { }
}
private static string GetActiveRifle(CCSPlayerController player)
{
string rifle = null;
var weapons = player.PlayerPawn.Value.WeaponServices.MyWeapons;
if (weapons == null) return rifle;
foreach (var weapon in weapons)
if (weapon != null && weapon.IsValid && weapon.Value != null && weapon.Value.IsValid)
if (rifles.Contains(weapon.Value.DesignerName))
rifle = weapon.Value.DesignerName;
return rifle;
}
public class SkillConfig : Config.DefaultSkillInfo
{
public SkillConfig(Skills skill = skillName, bool active = false, string color = "#e0873a", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}
}

View file

@ -11,14 +11,11 @@ namespace jRandomSkills
{
public class Soldier : ISkill
{
private static Skills skillName = Skills.Soldier;
private const Skills skillName = Skills.Soldier;
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#09ba00", false);
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"), false);
VirtualFunctions.CBaseEntity_TakeDamageOldFunc.Hook(OnTakeDamage, HookMode.Pre);
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
@ -42,11 +39,7 @@ namespace jRandomSkills
public static void EnableSkill(CCSPlayerController player)
{
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
var skillConfig = Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString());
if (skillConfig == null) return;
float newScale = (float)Instance.Random.NextDouble() * (skillConfig.ChanceTo - skillConfig.ChanceFrom) + skillConfig.ChanceFrom;
float newScale = (float)Instance.Random.NextDouble() * (Config.GetValue<float>(skillName, "ChanceTo") - Config.GetValue<float>(skillName, "ChanceFrom")) + Config.GetValue<float>(skillName, "ChanceFrom");
playerInfo.SkillChance = newScale;
newScale = (float)Math.Round(newScale, 2);
SkillUtils.PrintToChat(player, $"{ChatColors.DarkRed}{Localization.GetTranslation("soldier")}{ChatColors.Lime}: " + Localization.GetTranslation("soldier_desc2", newScale), false);
@ -82,5 +75,16 @@ namespace jRandomSkills
return HookResult.Continue;
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float ChanceFrom { get; set; }
public float ChanceTo { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#09ba00", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float chanceFrom = 1.15f, float chanceTo = 1.35f) : base(skill, active, color, onlyTeam, needsTeammates)
{
ChanceFrom = chanceFrom;
ChanceTo = chanceTo;
}
}
}
}

View file

@ -1,5 +1,6 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using jRandomSkills.src.utils;
using static CounterStrikeSharp.API.Core.Listeners;
@ -9,16 +10,13 @@ namespace jRandomSkills
{
public class SoundMaker : ISkill
{
private static Skills skillName = Skills.SoundMaker;
private static float timerCooldown = (float)(Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Cooldown);
private const Skills skillName = Skills.SoundMaker;
private static float timerCooldown = Config.GetValue<float>(skillName, "Cooldown");
private static readonly Dictionary<ulong, PlayerSkillInfo> SkillPlayerInfo = new Dictionary<ulong, PlayerSkillInfo>();
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#e3ed8c");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
@ -128,10 +126,7 @@ namespace jRandomSkills
{
foreach (var enemy in Utilities.GetPlayers().Where(p => p.Team != player.Team))
if (enemy != null && enemy.IsValid && enemy.PawnIsAlive)
{
Server.PrintToChatAll($"Sound event on {enemy.PlayerName}");
enemy.PlayerPawn.Value.EmitSound($"weapon.C4Beep.Impact", volume: 1f);
}
}
public class PlayerSkillInfo
@ -141,5 +136,14 @@ namespace jRandomSkills
public DateTime Cooldown { get; set; }
public DateTime LastClick { get; set; }
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float Cooldown { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#e3ed8c", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float cooldown = 5f) : base(skill, active, color, onlyTeam, needsTeammates)
{
Cooldown = cooldown;
}
}
}
}

View file

@ -0,0 +1,153 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using System.Drawing;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class Spectator : ISkill
{
private const Skills skillName = Skills.Spectator;
private static bool blocked = false;
private static float distance = Config.GetValue<float>(skillName, "distance");
private static Dictionary<ulong, (uint, CDynamicProp, CCSPlayerPawn)> cameras = new Dictionary<ulong, (uint, CDynamicProp, CCSPlayerPawn)>();
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundEnd>((@event, info) =>
{
blocked = true;
foreach (var player in Utilities.GetPlayers())
if (cameras.TryGetValue(player.SteamID, out _))
DisableSkill(player);
foreach (var camera in cameras)
camera.Value.Item2.Remove();
cameras.Clear();
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
blocked = false;
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventItemPickup>((@event, info) =>
{
var player = @event.Userid;
if (!Instance.IsPlayerValid(player)) return HookResult.Continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) return HookResult.Continue;
if (cameras.TryGetValue(player.SteamID, out var cameraInfo) && cameraInfo.Item1 != player.PlayerPawn.Value.CameraServices!.ViewEntity!.Raw)
BlockWeapon(player, true);
return HookResult.Continue;
});
Instance.RegisterListener<Listeners.OnTick>(OnTick);
}
public static void UseSkill(CCSPlayerController player)
{
var playerPawn = player.PlayerPawn.Value;
if (playerPawn?.CBodyComponent == null || blocked) return;
ChangeCamera(player);
}
public static void DisableSkill(CCSPlayerController player)
{
ChangeCamera(player, true);
}
private static void OnTick()
{
foreach (var player in Utilities.GetPlayers())
if (cameras.TryGetValue(player.SteamID, out var cameraInfo) && cameraInfo.Item2.IsValid)
{
var pawn = cameraInfo.Item3;
if (pawn.LifeState != (byte)LifeState_t.LIFE_ALIVE)
{
ChangeCamera(player, true);
continue;
}
var pos = pawn.AbsOrigin - SkillUtils.GetForwardVector(pawn.EyeAngles) * distance;
pos.Z += pawn.ViewOffset.Z;
cameraInfo.Item2.Teleport(pos, pawn.V_angle);
}
}
private static void ChangeCamera(CCSPlayerController player, bool forceToDefault = false)
{
uint orginalCameraRaw;
uint newCameraRaw;
var pawn = player.PlayerPawn.Value;
if (cameras.TryGetValue(player.SteamID, out var cameraInfo) && cameraInfo.Item2.IsValid)
{
orginalCameraRaw = cameraInfo.Item1;
cameraInfo.Item2.Remove();
newCameraRaw = CreateCamera(player);
} else
{
orginalCameraRaw = pawn!.CameraServices!.ViewEntity.Raw;
newCameraRaw = CreateCamera(player);
}
if (newCameraRaw == 0)
return;
bool defaultCam = forceToDefault ? true : (pawn.CameraServices!.ViewEntity!.Raw == orginalCameraRaw ? false : true);
pawn!.CameraServices!.ViewEntity.Raw = defaultCam ? orginalCameraRaw : newCameraRaw;
Utilities.SetStateChanged(pawn, "CBasePlayerPawn", "m_pCameraServices");
BlockWeapon(player, !defaultCam);
}
private static uint CreateCamera(CCSPlayerController player)
{
var camera = Utilities.CreateEntityByName<CDynamicProp>("prop_dynamic");
if (camera == null || !camera.IsValid) return 0;
var enemies = Utilities.GetPlayers().Where(p => p.PawnIsAlive && p.Team != player.Team).ToList();
if (enemies.Count == 0)
return 0;
var enemy = enemies[Instance.Random.Next(enemies.Count)];
var pawn = enemy.PlayerPawn.Value;
camera.Render = Color.FromArgb(0, 255, 255, 255);
camera.Teleport(pawn!.AbsOrigin, pawn.EyeAngles);
camera.DispatchSpawn();
if (cameras.TryGetValue(player.SteamID, out var cameraInfo))
cameras[player.SteamID] = (cameraInfo.Item1, camera, pawn);
else
cameras[player.SteamID] = (player.PlayerPawn.Value.CameraServices!.ViewEntity.Raw, camera, pawn);
return camera.EntityHandle.Raw;
}
private static void BlockWeapon(CCSPlayerController player, bool block)
{
foreach (var weapon in player.Pawn.Value.WeaponServices?.MyWeapons)
if (weapon != null && weapon.IsValid && weapon.Value != null && weapon.Value.IsValid)
{
weapon.Value.NextPrimaryAttackTick = block ? int.MaxValue : Server.TickCount;
weapon.Value.NextSecondaryAttackTick = block ? int.MaxValue : Server.TickCount;
Utilities.SetStateChanged(weapon.Value, "CBasePlayerWeapon", "m_nNextPrimaryAttackTick");
Utilities.SetStateChanged(weapon.Value, "CBasePlayerWeapon", "m_nNextSecondaryAttackTick");
}
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float Distance { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#42f5da", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float distance = 100f) : base(skill, active, color, onlyTeam, needsTeammates)
{
Distance = distance;
}
}
}
}

View file

@ -10,16 +10,13 @@ namespace jRandomSkills
{
public class SwapPosition : ISkill
{
private static Skills skillName = Skills.SwapPosition;
private static float timerCooldown = (float)(Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Cooldown);
private const Skills skillName = Skills.SwapPosition;
private static float timerCooldown = Config.GetValue<float>(skillName, "cooldown");
private static readonly Dictionary<ulong, ZamianaMiejsc_PlayerInfo> SkillPlayerInfo = new Dictionary<ulong, ZamianaMiejsc_PlayerInfo>();
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#1466F5");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
@ -173,5 +170,14 @@ namespace jRandomSkills
public DateTime LastClick { get; set; }
public bool FindedEnemy { get; set; }
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float Cooldown { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#1466F5", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float cooldown = 30f) : base(skill, active, color, onlyTeam, needsTeammates)
{
Cooldown = cooldown;
}
}
}
}

View file

@ -8,14 +8,11 @@ namespace jRandomSkills
{
public class Teleporter : ISkill
{
private static Skills skillName = Skills.Teleporter;
private const Skills skillName = Skills.Teleporter;
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#8A2BE2");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventPlayerHurt>((@event, info) =>
{
@ -51,5 +48,12 @@ namespace jRandomSkills
victimPawn.Teleport(attackerPosition, attackerAngles, attackerVelocity);
attackerPawn.Teleport(victimPosition, victimAngles, victimVelocity);
}
public class SkillConfig : Config.DefaultSkillInfo
{
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#8A2BE2", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}
}

View file

@ -3,21 +3,17 @@ using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using jRandomSkills.src.utils;
using static CounterStrikeSharp.API.Core.Listeners;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class Thief : ISkill
{
private static Skills skillName = Skills.Thief;
private const Skills skillName = Skills.Thief;
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#adaec7", false);
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"), false);
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
@ -106,5 +102,12 @@ namespace jRandomSkills
enemy.PrintToChat($" {ChatColors.Red}" + Localization.GetTranslation("thief_enemy_info"));
}
}
public class SkillConfig : Config.DefaultSkillInfo
{
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#adaec7", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false) : base(skill, active, color, onlyTeam, needsTeammates)
{
}
}
}
}

View file

@ -0,0 +1,122 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using System.Drawing;
using static jRandomSkills.jRandomSkills;
namespace jRandomSkills
{
public class ThirdEye : ISkill
{
private const Skills skillName = Skills.ThirdEye;
private static bool blocked = false;
private static float distance = Config.GetValue<float>(skillName, "distance");
private static Dictionary<ulong, (uint, CDynamicProp)> cameras = new Dictionary<ulong, (uint, CDynamicProp)>();
public static void LoadSkill()
{
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundEnd>((@event, info) =>
{
blocked = true;
foreach (var player in Utilities.GetPlayers())
if (cameras.TryGetValue(player.SteamID, out _))
DisableSkill(player);
foreach (var camera in cameras)
camera.Value.Item2.Remove();
cameras.Clear();
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
blocked = false;
return HookResult.Continue;
});
Instance.RegisterListener<Listeners.OnTick>(OnTick);
}
public static void UseSkill(CCSPlayerController player)
{
var playerPawn = player.PlayerPawn.Value;
if (playerPawn?.CBodyComponent == null || blocked) return;
ChangeCamera(player);
}
public static void DisableSkill(CCSPlayerController player)
{
ChangeCamera(player, true);
}
private static void OnTick()
{
foreach (var player in Utilities.GetPlayers())
if (cameras.TryGetValue(player.SteamID, out var cameraInfo) && cameraInfo.Item2.IsValid)
{
var pawn = player.PlayerPawn.Value;
if (pawn.LifeState != (byte)LifeState_t.LIFE_ALIVE)
{
ChangeCamera(player, true);
continue;
}
var pos = pawn.AbsOrigin - SkillUtils.GetForwardVector(pawn.EyeAngles) * distance;
pos.Z += pawn.ViewOffset.Z;
cameraInfo.Item2.Teleport(pos, pawn.V_angle);
}
}
private static void ChangeCamera(CCSPlayerController player, bool forceToDefault = false)
{
uint orginalCameraRaw;
uint newCameraRaw;
var pawn = player.PlayerPawn.Value;
if (cameras.TryGetValue(player.SteamID, out var cameraInfo) && cameraInfo.Item2.IsValid)
{
orginalCameraRaw = cameraInfo.Item1;
newCameraRaw = cameraInfo.Item2.EntityHandle.Raw;
} else
{
orginalCameraRaw = pawn!.CameraServices!.ViewEntity.Raw;
newCameraRaw = CreateCamera(player);
}
if (newCameraRaw == 0)
return;
if (forceToDefault)
pawn!.CameraServices!.ViewEntity.Raw = orginalCameraRaw;
else
pawn!.CameraServices!.ViewEntity.Raw =
pawn.CameraServices!.ViewEntity!.Raw == orginalCameraRaw
? newCameraRaw
: orginalCameraRaw;
Utilities.SetStateChanged(pawn, "CBasePlayerPawn", "m_pCameraServices");
}
private static uint CreateCamera(CCSPlayerController player)
{
var camera = Utilities.CreateEntityByName<CDynamicProp>("prop_dynamic");
if (camera == null || !camera.IsValid) return 0;
var pawn = player.PlayerPawn.Value;
camera.Render = Color.FromArgb(0, 255, 255, 255);
camera.Teleport(pawn!.AbsOrigin, pawn.EyeAngles);
camera.DispatchSpawn();
cameras[player.SteamID] = (pawn.CameraServices!.ViewEntity.Raw, camera);
return camera.EntityHandle.Raw;
}
public class SkillConfig : Config.DefaultSkillInfo
{
public float Distance { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#1b04cc", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, float distance = 100f) : base(skill, active, color, onlyTeam, needsTeammates)
{
Distance = distance;
}
}
}
}

View file

@ -1,9 +1,6 @@
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
using CounterStrikeSharp.API.Modules.Entities;
using CounterStrikeSharp.API.Modules.Entities.Constants;
using CounterStrikeSharp.API.Modules.Memory;
using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions;
using CounterStrikeSharp.API.Modules.Utils;
using jRandomSkills.src.player;
using static CounterStrikeSharp.API.Core.Listeners;
@ -13,85 +10,89 @@ namespace jRandomSkills
{
public class ToxicSmoke : ISkill
{
private static Skills skillName = Skills.ToxicSmoke;
private static List<CCSPlayerPawn> players = new List<CCSPlayerPawn>();
private static Dictionary<int, CTriggerMultiple> triggers = new Dictionary<int, CTriggerMultiple>();
private const Skills skillName = Skills.ToxicSmoke;
private static int smokeDamage = Config.GetValue<int>(skillName, "smokeDamage");
private static float smokeRadius = Config.GetValue<float>(skillName, "smokeRadius");
private static List<Vector> smokes = new List<Vector>();
public static void LoadSkill()
{
if (Config.config.SkillsInfo.FirstOrDefault(s => s.Name == skillName.ToString())?.Active != true)
return;
SkillUtils.RegisterSkill(skillName, "#507529");
SkillUtils.RegisterSkill(skillName, Config.GetValue<string>(skillName, "color"));
Instance.RegisterEventHandler<EventRoundStart>((@event, info) =>
{
players.Clear();
smokes.Clear();
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventSmokegrenadeDetonate>((@event, @info) =>
Instance.RegisterEventHandler<EventRoundFreezeEnd>((@event, info) =>
{
Instance.AddTimer(0.1f, () =>
{
foreach (var player in Utilities.GetPlayers())
{
if (!Instance.IsPlayerValid(player)) continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) continue;
EnableSkill(player);
}
});
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventSmokegrenadeDetonate>((@event, info) =>
{
var player = @event.Userid;
if (!Instance.IsPlayerValid(player)) return HookResult.Continue;
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) return HookResult.Continue;
var trigger = Utilities.CreateEntityByName<CTriggerMultiple>("trigger_multiple");
if (trigger == null) return HookResult.Continue;
trigger.Collision.SolidType = SolidType_t.SOLID_CAPSULE;
trigger.Collision.SolidFlags = 0;
trigger.Spawnflags = 1;
trigger.Globalname = $"toxic_smoke_{trigger.Index}";
trigger.Collision.SolidFlags = 1;
trigger.AbsOrigin.X = @event.X;
trigger.AbsOrigin.Y = @event.Y;
trigger.AbsOrigin.Z = @event.Z;
trigger.Collision.CapsuleRadius = 160;
trigger.Collision.BoundingRadius = 160;
trigger.Collision.CollisionGroup = (byte)CollisionGroup.COLLISION_GROUP_TRIGGER;
trigger.Collision.EnablePhysics = 1;
trigger.Collision.TriggerBloat = 0;
trigger.Collision.SurroundType = SurroundingBoundsType_t.USE_OBB_COLLISION_BOUNDS;
trigger.Collision.CollisionAttribute.CollisionFunctionMask = 39;
trigger.Collision.CollisionAttribute.CollisionGroup = 2;
trigger.DispatchSpawn();
triggers.Add(@event.Entityid, trigger);
smokes.Add(new Vector(@event.X, @event.Y, @event.Z));
return HookResult.Continue;
});
Instance.RegisterEventHandler<EventSmokegrenadeExpired>((@event, @info) =>
{
var player = @event.Userid;
if (!Instance.IsPlayerValid(player)) return HookResult.Continue;
if (triggers.TryGetValue(@event.Entityid, out var existingTrigger))
{
existingTrigger.AcceptInput("Kill");
triggers.Remove(@event.Entityid);
}
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) return HookResult.Continue;
smokes.RemoveAll(v => v.X == @event.X && v.Y == @event.Y && v.Z == @event.Z);
return HookResult.Continue;
});
Instance.RegisterListener<OnEntitySpawned>(@event =>
{
var name = @event.DesignerName;
if (name != "smokegrenade_projectile") return;
var grenade = @event.As<CBaseCSGrenadeProjectile>();
var pawn = grenade.OwnerEntity.Value.As<CCSPlayerPawn>();
var player = pawn.Controller.Value.As<CCSPlayerController>();
var playerInfo = Instance.skillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
if (playerInfo?.Skill != skillName) return;
Server.NextFrame(() =>
{
var smoke = @event.As<CSmokeGrenadeProjectile>();
smoke.SmokeColor.X = 255;
smoke.SmokeColor.Y = 0;
smoke.SmokeColor.Z = 255;
});
});
Instance.RegisterListener<OnTick>(() =>
{
foreach (CCSPlayerPawn player in players)
{
if (Server.TickCount % 10 == 0)
AddHealth(player, -2);
}
foreach (Vector smokePos in smokes)
foreach (var player in Utilities.GetPlayers())
if (Server.TickCount % 17 == 0)
if (SkillUtils.GetDistance(smokePos, player.PlayerPawn.Value.AbsOrigin) <= smokeRadius)
AddHealth(player.PlayerPawn.Value, -smokeDamage);
});
}
VirtualFunctions.CBaseTrigger_StartTouchFunc.Hook(StartTouchFun, HookMode.Post);
VirtualFunctions.CBaseTrigger_EndTouchFunc.Hook(EndTouchFunc, HookMode.Post);
public static void EnableSkill(CCSPlayerController player)
{
SkillUtils.TryGiveWeapon(player, CsItem.SmokeGrenade);
}
private static void AddHealth(CCSPlayerPawn player, int health)
@ -102,46 +103,20 @@ namespace jRandomSkills
player.Health += health;
Utilities.SetStateChanged(player, "CBaseEntity", "m_iHealth");
player.EmitSound("");
player.EmitSound("Player.DamageBody.Onlooker");
if (player.Health <= 0)
player.CommitSuicide(false, true);
}
private static HookResult StartTouchFun(DynamicHook h)
public class SkillConfig : Config.DefaultSkillInfo
{
CBaseTrigger trigger = h.GetParam<CBaseTrigger>(0);
CBaseEntity entity = h.GetParam<CBaseEntity>(1);
if (trigger == null || entity == null)
return HookResult.Continue;
CCSPlayerPawn player = new CCSPlayerPawn(entity.Handle);
if (player == null) return HookResult.Continue;
if (string.IsNullOrEmpty(trigger?.Globalname) || trigger?.Globalname?.StartsWith("toxic_smoke_") == false)
return HookResult.Continue;
if (!players.Contains(player))
players.Add(player);
return HookResult.Continue;
}
private static HookResult EndTouchFunc(DynamicHook h)
{
var trigger = h.GetParam<CBaseTrigger>(0);
var entity = h.GetParam<CBaseEntity>(1);
if (trigger == null || entity == null) return HookResult.Continue;
CCSPlayerPawn player = new CCSPlayerPawn(entity.Handle);
if (player == null) return HookResult.Continue;
if (string.IsNullOrEmpty(trigger?.Globalname) || trigger?.Globalname?.StartsWith("toxic_smoke_") == false)
return HookResult.Continue;
if (players.Contains(player))
players.Remove(player);
return HookResult.Continue;
public int SmokeDamage { get; set; }
public float SmokeRadius { get; set; }
public SkillConfig(Skills skill = skillName, bool active = true, string color = "#507529", CsTeam onlyTeam = CsTeam.None, bool needsTeammates = false, int smokeDamage = 2, float smokeRadius = 180) : base(skill, active, color, onlyTeam, needsTeammates)
{
SmokeDamage = smokeDamage;
SmokeRadius = smokeRadius;
}
}
}
}

Some files were not shown because too many files have changed in this diff Show more