(CURRENTYLY BROKEN) Add new skills, signatures and fixes
Introduce multiple new skill implementations and related updates: add AimLock, HealingChicken, HomingNades, HotBomb, Illusionist, MagneticDecoy, ThrowingKnife, Weightless and WildThrow; register skills and HUD/cooldown handling. Update ISkill enum to include new skills. Add SnapViewAngles signature to gamedata. Improve existing skills to handle bayonet (BladeMaster, Cutter, Disarmament, LongKnife) and fix iteration/null-check issues in FrozenDecoy. Make HealingSmoke tick interval configurable and extend its config. Update English and Polish language files with new skill strings and tweaks. Also sync server-side gamedata and language files.
This commit is contained in:
parent
4e4458ad38
commit
97887118bf
31 changed files with 1625 additions and 73 deletions
149
jRandomSkills - SRC Files/src/player/skills/WildThrow.cs
Normal file
149
jRandomSkills - SRC Files/src/player/skills/WildThrow.cs
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
using CounterStrikeSharp.API;
|
||||
using CounterStrikeSharp.API.Core;
|
||||
using CounterStrikeSharp.API.Modules.Utils;
|
||||
using src.utils;
|
||||
using System.Collections.Concurrent;
|
||||
using static src.jRandomSkills;
|
||||
|
||||
namespace src.player.skills
|
||||
{
|
||||
public class WildThrow : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.WildThrow;
|
||||
private readonly static ConcurrentDictionary<ulong, byte> infectedPlayers = [];
|
||||
private static readonly object setLock = new();
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
SkillUtils.RegisterSkill(skillName, SkillsInfo.GetValue<string>(skillName, "color"));
|
||||
}
|
||||
|
||||
public static void NewRound()
|
||||
{
|
||||
lock (setLock)
|
||||
infectedPlayers.Clear();
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
DisableSkill(player);
|
||||
}
|
||||
|
||||
public static void PlayerDeath(EventPlayerDeath @event)
|
||||
{
|
||||
var player = @event.Userid;
|
||||
if (player == null) return;
|
||||
DisableSkill(player);
|
||||
}
|
||||
|
||||
public static void EnableSkill(CCSPlayerController player)
|
||||
{
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
if (playerInfo == null) return;
|
||||
playerInfo.SkillUsed = false;
|
||||
|
||||
var enemies = Utilities.GetPlayers().Where(p => p.PawnIsAlive && p.Team != player.Team && p.IsValid && !p.IsBot && !p.IsHLTV && p.Team != CsTeam.Spectator && p.Team != CsTeam.None).ToArray();
|
||||
if (enemies.Length > 0)
|
||||
{
|
||||
ConcurrentBag<(string, string)> menuItems = new(enemies.Select(e => (e.PlayerName, e.Index.ToString())));
|
||||
SkillUtils.CreateMenu(player, menuItems);
|
||||
}
|
||||
else
|
||||
player.PrintToChat($" {ChatColors.Red}{player.GetTranslation("selectplayerskill_incorrect_enemy_index")}");
|
||||
}
|
||||
|
||||
public static void DisableSkill(CCSPlayerController player)
|
||||
{
|
||||
infectedPlayers.TryRemove(player.SteamID, out _);
|
||||
SkillUtils.CloseMenu(player);
|
||||
}
|
||||
|
||||
public static void OnTick()
|
||||
{
|
||||
if (Server.TickCount % 32 != 0) return;
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
if (!SkillUtils.HasMenu(player)) continue;
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
|
||||
if (playerInfo == null || playerInfo.Skill != skillName) continue;
|
||||
var enemies = Utilities.GetPlayers().Where(p => p.PawnIsAlive && p.Team != player.Team && p.IsValid && !p.IsBot && !p.IsHLTV && p.Team != CsTeam.Spectator && p.Team != CsTeam.None).ToArray();
|
||||
|
||||
ConcurrentBag<(string, string)> menuItems = new(enemies.Select(e => (e.PlayerName, e.Index.ToString())));
|
||||
SkillUtils.UpdateMenu(player, menuItems);
|
||||
}
|
||||
}
|
||||
|
||||
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.SkillUsed)
|
||||
{
|
||||
player.PrintToChat($" {ChatColors.Red}{player.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}" + player.GetTranslation("selectplayerskill_incorrect_enemy_index"));
|
||||
return;
|
||||
}
|
||||
|
||||
infectedPlayers.TryAdd(enemy.SteamID, 0);
|
||||
|
||||
playerInfo.SkillUsed = true;
|
||||
player.PrintToChat($" {ChatColors.Green}" + player.GetTranslation("wildthrow_player_info", enemy.PlayerName));
|
||||
}
|
||||
|
||||
public static void OnEntitySpawned(CEntityInstance @event)
|
||||
{
|
||||
var name = @event.DesignerName;
|
||||
if (!name.EndsWith("_projectile")) return;
|
||||
|
||||
var grenade = @event.As<CBaseCSGrenadeProjectile>();
|
||||
if (grenade == null || !grenade.IsValid) return;
|
||||
|
||||
if (grenade.OwnerEntity.Value == null || !grenade.OwnerEntity.Value.IsValid) return;
|
||||
var pawn = grenade.OwnerEntity.Value.As<CCSPlayerPawn>();
|
||||
|
||||
if (pawn.Controller.Value == null || !pawn.Controller.Value.IsValid) return;
|
||||
var player = pawn.Controller.Value.As<CCSPlayerController>();
|
||||
|
||||
if (!infectedPlayers.ContainsKey(player.SteamID)) return;
|
||||
|
||||
Server.NextFrame(() => {
|
||||
if (grenade == null || !grenade.IsValid) return;
|
||||
|
||||
float forceMultiplier = (float)(Instance.Random.NextDouble() * .6 + .7);
|
||||
float min = 150;
|
||||
float max = 450;
|
||||
|
||||
float devX = GetRandom(min, max);
|
||||
float devY = GetRandom(min, max);
|
||||
float devZ = GetRandom(min, max);
|
||||
|
||||
Vector randomDev = new(devX, devY, devZ);
|
||||
Vector newVelocity = new(
|
||||
(grenade.Velocity.X + randomDev.X) * forceMultiplier,
|
||||
(grenade.Velocity.Y + randomDev.Y) * forceMultiplier,
|
||||
(grenade.Velocity.Z + randomDev.Z) * forceMultiplier
|
||||
);
|
||||
|
||||
grenade.Teleport(null, null, newVelocity);
|
||||
});
|
||||
}
|
||||
|
||||
private static float GetRandom(float min, float max)
|
||||
{
|
||||
float val = (float)(Instance.Random.NextDouble() * (max - min) + min);
|
||||
return Instance.Random.Next(0, 2) == 0 ? val : -val;
|
||||
}
|
||||
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#384728", CsTeam onlyTeam = CsTeam.None, bool disableOnFreezeTime = false, bool needsTeammates = false, string requiredPermission = "") : SkillsInfo.DefaultSkillInfo(skill, active, color, onlyTeam, disableOnFreezeTime, needsTeammates, requiredPermission)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue