fighting crashes #1
This commit is contained in:
parent
10dbf6629e
commit
0fb3d63cd8
145 changed files with 677278 additions and 1703 deletions
|
|
@ -12,8 +12,8 @@ namespace src.player.skills
|
|||
public class Wallhack : ISkill
|
||||
{
|
||||
private const Skills skillName = Skills.Wallhack;
|
||||
private static readonly ConcurrentDictionary<ulong, byte> playersInAction = [];
|
||||
private static readonly ConcurrentBag<(CDynamicProp, CDynamicProp, CsTeam, uint)> glows = [];
|
||||
private static readonly ConcurrentDictionary<ulong, byte> playersInAction = new();
|
||||
private static ConcurrentDictionary<uint, (uint RelayIndex, uint GlowIndex, CsTeam Team)> glows = new();
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
|
|
@ -30,18 +30,21 @@ namespace src.player.skills
|
|||
var observedPlayer = Utilities.GetPlayers().FirstOrDefault(p => p?.Pawn?.Value?.Handle == player?.Pawn?.Value?.ObserverServices?.ObserverTarget?.Value?.Handle);
|
||||
var observerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == observedPlayer?.SteamID);
|
||||
|
||||
foreach (var glow in glows)
|
||||
foreach (var kvp in glows)
|
||||
{
|
||||
var enemy = Utilities.GetPlayers().FirstOrDefault(e => e.IsValid && e.Index == glow.Item4);
|
||||
var enemyIndex = kvp.Key;
|
||||
var glowInfo = kvp.Value;
|
||||
|
||||
var enemy = Utilities.GetPlayers().FirstOrDefault(e => e.IsValid && e.Index == enemyIndex);
|
||||
|
||||
if (enemy != null && enemy.PawnIsAlive)
|
||||
if (glow.Item3 != player.Team && (playerInfo?.Skill == skillName || (observerInfo != null && observerInfo?.Skill == skillName)))
|
||||
if (glowInfo.Team != player.Team && (playerInfo?.Skill == skillName || (observerInfo != null && observerInfo?.Skill == skillName)))
|
||||
continue;
|
||||
|
||||
var glowEntity1 = Utilities.GetEntityFromIndex<CBaseEntity>((int)glow.Item1.Index);
|
||||
var glowEntity1 = Utilities.GetEntityFromIndex<CBaseEntity>((int)glowInfo.RelayIndex);
|
||||
if (glowEntity1 == null || !glowEntity1.IsValid) continue;
|
||||
|
||||
var glowEntity2 = Utilities.GetEntityFromIndex<CBaseEntity>((int)glow.Item2.Index);
|
||||
var glowEntity2 = Utilities.GetEntityFromIndex<CBaseEntity>((int)glowInfo.GlowIndex);
|
||||
if (glowEntity2 == null || !glowEntity2.IsValid) continue;
|
||||
|
||||
info.TransmitEntities.Remove(glowEntity1.Index);
|
||||
|
|
@ -52,13 +55,15 @@ namespace src.player.skills
|
|||
|
||||
public static void NewRound()
|
||||
{
|
||||
foreach (var glow in glows)
|
||||
foreach (var kvp in glows)
|
||||
{
|
||||
if (glow.Item1 != null && glow.Item1.IsValid)
|
||||
glow.Item1.AcceptInput("Kill");
|
||||
if (glow.Item2 != null && glow.Item2.IsValid)
|
||||
glow.Item2.AcceptInput("Kill");
|
||||
var relayIndex = kvp.Value.RelayIndex;
|
||||
var glowIndex = kvp.Value.GlowIndex;
|
||||
|
||||
SkillUtils.SafeKillEntity<CDynamicProp>(relayIndex);
|
||||
SkillUtils.SafeKillEntity<CDynamicProp>(glowIndex);
|
||||
}
|
||||
|
||||
glows.Clear();
|
||||
playersInAction.Clear();
|
||||
}
|
||||
|
|
@ -80,44 +85,63 @@ namespace src.player.skills
|
|||
|
||||
private static void SetGlowEffectForAll()
|
||||
{
|
||||
foreach (var enemy in Utilities.GetPlayers().FindAll(p => p.PawnIsAlive && p.Team is CsTeam.Terrorist or CsTeam.CounterTerrorist))
|
||||
var enemies = Utilities.GetPlayers().Where(p => p.PawnIsAlive && (p.Team == CsTeam.Terrorist || p.Team == CsTeam.CounterTerrorist)).ToList();
|
||||
foreach (var enemy in enemies)
|
||||
{
|
||||
var enemyInfo = Instance.SkillPlayer.FirstOrDefault(e => e.SteamID == enemy.SteamID);
|
||||
if (enemyInfo?.Skill == Skills.Ghost)
|
||||
return;
|
||||
continue;
|
||||
|
||||
var enemyPawn = enemy.PlayerPawn?.Value;
|
||||
if (enemyPawn == null || !enemyPawn.IsValid) continue;
|
||||
|
||||
var skeleton = enemyPawn.CBodyComponent?.SceneNode?.GetSkeletonInstance();
|
||||
var modelName = skeleton?.ModelState?.ModelName;
|
||||
if (string.IsNullOrEmpty(modelName)) continue;
|
||||
|
||||
var enemyPawn = enemy.PlayerPawn.Value;
|
||||
var modelGlow = Utilities.CreateEntityByName<CDynamicProp>("prop_dynamic");
|
||||
var modelRelay = Utilities.CreateEntityByName<CDynamicProp>("prop_dynamic");
|
||||
|
||||
if (modelGlow == null || modelRelay == null)
|
||||
return;
|
||||
if (modelGlow == null || !modelGlow.IsValid || modelRelay == null || !modelRelay.IsValid)
|
||||
continue;
|
||||
|
||||
modelRelay.CBodyComponent!.SceneNode!.Owner!.Entity!.Flags = (uint)(modelRelay.CBodyComponent!.SceneNode!.Owner!.Entity!.Flags & ~(1 << 2));
|
||||
modelRelay.SetModel(enemyPawn!.CBodyComponent!.SceneNode!.GetSkeletonInstance().ModelState.ModelName);
|
||||
var relayEntity = modelRelay.CBodyComponent?.SceneNode?.Owner?.Entity;
|
||||
if (relayEntity != null)
|
||||
relayEntity.Flags = (uint)(relayEntity.Flags & ~(1 << 2));
|
||||
|
||||
modelRelay.SetModel(modelName);
|
||||
modelRelay.Spawnflags = 256u;
|
||||
modelRelay.RenderMode = RenderMode_t.kRenderNone;
|
||||
modelRelay.DispatchSpawn();
|
||||
|
||||
modelGlow.CBodyComponent!.SceneNode!.Owner!.Entity!.Flags = (uint)(modelGlow.CBodyComponent!.SceneNode!.Owner!.Entity!.Flags & ~(1 << 2));
|
||||
modelGlow.SetModel(enemyPawn!.CBodyComponent!.SceneNode!.GetSkeletonInstance().ModelState.ModelName);
|
||||
var glowEntity = modelGlow.CBodyComponent?.SceneNode?.Owner?.Entity;
|
||||
if (glowEntity != null)
|
||||
glowEntity.Flags = (uint)(glowEntity.Flags & ~(1 << 2));
|
||||
|
||||
modelGlow.SetModel(modelName);
|
||||
modelGlow.Spawnflags = 256u;
|
||||
modelGlow.Render = Color.FromArgb(1, 255, 255, 255);
|
||||
modelGlow.DispatchSpawn();
|
||||
|
||||
modelGlow.Glow.GlowColorOverride = enemy.Team == CsTeam.Terrorist ? Color.FromArgb(255, 255, 165, 0) : Color.FromArgb(255, 173, 216, 230);
|
||||
modelGlow.Glow.GlowRange = 5000;
|
||||
modelGlow.Glow.GlowTeam = -1;
|
||||
modelGlow.Glow.GlowType = 3;
|
||||
modelGlow.Glow.GlowRangeMin = 100;
|
||||
try
|
||||
{
|
||||
modelGlow.Glow.GlowColorOverride = enemy.Team == CsTeam.Terrorist ? Color.FromArgb(255, 255, 165, 0) : Color.FromArgb(255, 173, 216, 230);
|
||||
modelGlow.Glow.GlowRange = 5000;
|
||||
modelGlow.Glow.GlowTeam = -1;
|
||||
modelGlow.Glow.GlowType = 3;
|
||||
modelGlow.Glow.GlowRangeMin = 100;
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
|
||||
modelRelay.AcceptInput("FollowEntity", enemyPawn, modelRelay, "!activator");
|
||||
modelGlow.AcceptInput("FollowEntity", modelRelay, modelGlow, "!activator");
|
||||
glows.Add((modelRelay, modelGlow, enemy.Team, enemy.Index));
|
||||
|
||||
glows.TryAdd(enemy.Index, (modelRelay.Index, modelGlow.Index, enemy.Team));
|
||||
}
|
||||
}
|
||||
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#5d00ff", CsTeam onlyTeam = CsTeam.None, bool disableOnFreezeTime = false, bool needsTeammates = false, string requiredPermission = "") : SkillsInfo.DefaultSkillInfo(skill, active, color, onlyTeam, disableOnFreezeTime, needsTeammates, requiredPermission)
|
||||
public class SkillConfig(Skills skill = skillName, bool active = true, string color = "#5d00ff", CsTeam onlyTeam = CsTeam.None, bool disableOnFreezeTime = false, bool needsTeammates = false, string requiredPermission = "", int maxPerServer = 1, Rarity rarity = Rarity.Epic) : SkillsInfo.DefaultSkillInfo(skill, active, color, onlyTeam, disableOnFreezeTime, needsTeammates, requiredPermission, maxPerServer, rarity)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue