v1.21.1.b8
This commit is contained in:
parent
abd3aed8fd
commit
10dbf6629e
77 changed files with 1507 additions and 974 deletions
|
|
@ -5,6 +5,7 @@ using CounterStrikeSharp.API.Modules.Utils;
|
|||
using src.utils;
|
||||
using System.Collections.Concurrent;
|
||||
using static src.jRandomSkills;
|
||||
using Timer = CounterStrikeSharp.API.Modules.Timers.Timer;
|
||||
|
||||
namespace src.player.skills
|
||||
{
|
||||
|
|
@ -12,8 +13,8 @@ namespace src.player.skills
|
|||
{
|
||||
private const Skills skillName = Skills.Jackal;
|
||||
private static readonly ConcurrentDictionary<ulong, byte> playersInAction = [];
|
||||
private static readonly ConcurrentDictionary<CCSPlayerController, CParticleSystem?> playersStep = [];
|
||||
private static readonly string particleName = "particles/ui/hud/ui_map_def_utility_trail.vpcf";
|
||||
private static readonly ConcurrentDictionary<uint, uint?> playersStep = [];
|
||||
private static readonly ConcurrentDictionary<ulong, Timer?> activeTimers = [];
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -23,9 +24,15 @@ namespace src.player.skills
|
|||
|
||||
public static void NewRound()
|
||||
{
|
||||
foreach (var step in playersStep.Values)
|
||||
if (step != null && step.IsValid)
|
||||
step.AcceptInput("Kill");
|
||||
foreach (var particleIndex in playersStep.Values)
|
||||
{
|
||||
if (particleIndex == null) continue;
|
||||
var particle = Utilities.GetEntityFromIndex<CParticleSystem>((int)particleIndex);
|
||||
|
||||
if (particle != null && particle.IsValid)
|
||||
particle.AcceptInput("Kill");
|
||||
}
|
||||
|
||||
playersStep.Clear();
|
||||
playersInAction.Clear();
|
||||
}
|
||||
|
|
@ -51,11 +58,15 @@ namespace src.player.skills
|
|||
|
||||
foreach (var param in playersStep)
|
||||
{
|
||||
var enemy = param.Key;
|
||||
var step = param.Value;
|
||||
if (step == null || !step.IsValid) continue;
|
||||
var enemyIndex = param.Key;
|
||||
var particleIndex = param.Value;
|
||||
|
||||
var entity = Utilities.GetEntityFromIndex<CBaseEntity>((int)step.Index);
|
||||
if (particleIndex == null) continue;
|
||||
|
||||
var enemy = Utilities.GetPlayerFromIndex((int)enemyIndex);
|
||||
if (enemy == null || !enemy.IsValid) continue;
|
||||
|
||||
var entity = Utilities.GetEntityFromIndex<CBaseEntity>((int)particleIndex);
|
||||
if (entity == null || !entity.IsValid) continue;
|
||||
|
||||
if (!hasSkill || enemy.Team == player.Team)
|
||||
|
|
@ -69,13 +80,17 @@ namespace src.player.skills
|
|||
if (player == null) return;
|
||||
var playerPawn = player.PlayerPawn.Value;
|
||||
|
||||
ulong steamID = player.SteamID;
|
||||
if (activeTimers.TryRemove(steamID, out var oldTimer))
|
||||
oldTimer?.Kill();
|
||||
|
||||
if (playerPawn == null || !playerPawn.IsValid || playerPawn.AbsOrigin == null || playerPawn.LifeState != (byte)LifeState_t.LIFE_ALIVE) return;
|
||||
if (!playersStep.ContainsKey(player)) return;
|
||||
if (!playersStep.ContainsKey(player.Index)) return;
|
||||
|
||||
CParticleSystem particle = Utilities.CreateEntityByName<CParticleSystem>("info_particle_system")!;
|
||||
if (particle == null) return;
|
||||
|
||||
particle.EffectName = particleName;
|
||||
particle.EffectName = SkillsInfo.GetValue<string>(skillName, "particleName");
|
||||
particle.StartActive = true;
|
||||
|
||||
particle.Teleport(playerPawn.AbsOrigin);
|
||||
|
|
@ -84,12 +99,18 @@ namespace src.player.skills
|
|||
particle.AcceptInput("SetParent", playerPawn, particle, "!activator");
|
||||
particle.AcceptInput("Start");
|
||||
|
||||
playersStep.AddOrUpdate(player, particle, (k, v) => particle);
|
||||
uint particleId = particle.Index;
|
||||
|
||||
Instance.AddTimer(2.5f, () => {
|
||||
playersStep.AddOrUpdate(player.Index, particle.Index, (k, v) => particle.Index);
|
||||
|
||||
activeTimers[player.SteamID] = Instance.AddTimer(2.5f, () => {
|
||||
var particle = Utilities.GetEntityFromIndex<CParticleSystem>((int)particleId);
|
||||
if (particle != null && particle.IsValid)
|
||||
particle.AcceptInput("Kill");
|
||||
CreatePlayerTrail(player);
|
||||
|
||||
var player = Utilities.GetPlayerFromSteamId(steamID);
|
||||
if (player != null && player.IsValid && playersStep.ContainsKey(player.Index))
|
||||
CreatePlayerTrail(player);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -99,23 +120,30 @@ namespace src.player.skills
|
|||
playersInAction.TryAdd(player.SteamID, 0);
|
||||
foreach (var _player in Utilities.GetPlayers().Where(p => p.Team != player.Team && p.IsValid && !p.IsBot && !p.IsHLTV && p.PawnIsAlive && p.Team is CsTeam.CounterTerrorist or CsTeam.Terrorist))
|
||||
{
|
||||
if (!playersStep.ContainsKey(_player))
|
||||
playersStep.TryAdd(_player, null);
|
||||
if (!playersStep.ContainsKey(_player.Index))
|
||||
playersStep.TryAdd(_player.Index, null);
|
||||
CreatePlayerTrail(_player);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DisableSkill(CCSPlayerController player)
|
||||
{
|
||||
playersStep.TryRemove(player, out _);
|
||||
playersInAction.TryRemove(player.SteamID, out _);
|
||||
|
||||
if (playersStep.TryRemove(player.Index, out var particleIndex) && particleIndex != null)
|
||||
{
|
||||
var particle = Utilities.GetEntityFromIndex<CParticleSystem>((int)particleIndex);
|
||||
if (particle != null && particle.IsValid)
|
||||
particle.AcceptInput("Kill");
|
||||
}
|
||||
|
||||
if (playersInAction.IsEmpty)
|
||||
NewRound();
|
||||
}
|
||||
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#f542ef", CsTeam onlyTeam = CsTeam.None, bool disableOnFreezeTime = false, bool needsTeammates = false, string requiredPermission = "", string particleName = "particles/ui/hud/ui_map_def_utility_trail.vpcf") : SkillsInfo.DefaultSkillInfo(skill, active, color, onlyTeam, disableOnFreezeTime, needsTeammates, requiredPermission)
|
||||
{
|
||||
string ParticleName { get; set; } = particleName;
|
||||
public string ParticleName { get; set; } = particleName;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue