v1.2.2.b1
This commit is contained in:
parent
0fb3d63cd8
commit
46195c2663
147 changed files with 3470 additions and 2161 deletions
|
|
@ -5,6 +5,7 @@ using CounterStrikeSharp.API.Modules.Utils;
|
|||
using src.utils;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Immutable;
|
||||
using System.Drawing;
|
||||
using static src.jRandomSkills;
|
||||
|
||||
namespace src.player.skills
|
||||
|
|
@ -26,11 +27,13 @@ namespace src.player.skills
|
|||
];
|
||||
private static readonly ConcurrentDictionary<uint, byte> invisiblePlayers = [];
|
||||
private const string bloodParticle = "particles/blood_impact/blood_impact_high.vpcf";
|
||||
private const string cameraViewModel = "models/sprays/spray_plane.vmdl";
|
||||
|
||||
public static void LoadSkill()
|
||||
{
|
||||
SkillUtils.RegisterSkill(skillName, SkillsInfo.GetValue<string>(skillName, "color"));
|
||||
Instance.AddToManifest(bloodParticle);
|
||||
Instance.AddToManifest(cameraViewModel);
|
||||
}
|
||||
|
||||
public static void NewRound()
|
||||
|
|
@ -42,9 +45,9 @@ namespace src.player.skills
|
|||
|
||||
public static void WeaponPickup(EventItemPickup @event)
|
||||
{
|
||||
var player = @event.Userid;
|
||||
var player = PlayerManager.GetPlayerEvent(@event.Userid);
|
||||
if (!Instance.IsPlayerValid(player)) return;
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player?.SteamID);
|
||||
var playerInfo = PlayerManager.GetPlayerByIndex(player!.Index);
|
||||
|
||||
if (playerInfo?.Skill != skillName) return;
|
||||
SetWeaponAttack(player!, true);
|
||||
|
|
@ -52,9 +55,9 @@ namespace src.player.skills
|
|||
|
||||
public static void WeaponEquip(EventItemEquip @event)
|
||||
{
|
||||
var player = @event.Userid;
|
||||
var player = PlayerManager.GetPlayerEvent(@event.Userid);
|
||||
if (!Instance.IsPlayerValid(player)) return;
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player?.SteamID);
|
||||
var playerInfo = PlayerManager.GetPlayerByIndex(player!.Index);
|
||||
|
||||
if (playerInfo?.Skill != skillName) return;
|
||||
SetWeaponAttack(player!, true);
|
||||
|
|
@ -64,7 +67,7 @@ namespace src.player.skills
|
|||
{
|
||||
foreach (var (info, player) in infoList)
|
||||
{
|
||||
if (player == null || !player.IsValid) continue;
|
||||
if (player == null || !player.IsValid || player.Team == CsTeam.Spectator) continue;
|
||||
|
||||
var targetHandle = player.Pawn.Value?.ObserverServices?.ObserverTarget.Value?.Handle ?? nint.Zero;
|
||||
bool isObservingGhost = false;
|
||||
|
|
@ -72,14 +75,17 @@ namespace src.player.skills
|
|||
if (targetHandle != nint.Zero)
|
||||
{
|
||||
var target = Utilities.GetPlayers().FirstOrDefault(p => p?.Pawn?.Value?.Handle == targetHandle);
|
||||
var targetInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == target?.SteamID);
|
||||
var targetInfo = PlayerManager.GetPlayerByIndex(target?.Index);
|
||||
if (targetInfo?.Skill == skillName) isObservingGhost = true;
|
||||
}
|
||||
|
||||
foreach (var playerIndex in invisiblePlayers.Keys)
|
||||
{
|
||||
var playerController = Utilities.GetPlayerFromIndex((int)playerIndex);
|
||||
if (playerController == null || !playerController.IsValid || playerController.SteamID == player.SteamID)
|
||||
if (playerController == null || !playerController.IsValid || playerController.Index == player.Index)
|
||||
continue;
|
||||
|
||||
if (player.Team == playerController.Team)
|
||||
continue;
|
||||
|
||||
if (!isObservingGhost)
|
||||
|
|
@ -108,48 +114,92 @@ namespace src.player.skills
|
|||
{
|
||||
Event.EnableTransmit();
|
||||
SetWeaponAttack(player, true);
|
||||
SkillUtils.SetPlayerInvisibility(player, .5f);
|
||||
invisiblePlayers.TryAdd(player.Index, 0);
|
||||
|
||||
if (EntityManager.GetPlayerEntities(player.Index, "empty_prop").Count == 0)
|
||||
CreatePlayerPosProp(player);
|
||||
}
|
||||
|
||||
private static void CreatePlayerPosProp(CCSPlayerController player)
|
||||
{
|
||||
if (player == null || !player.IsValid) return;
|
||||
|
||||
var emptyProp = EntityManager.CreateTrackedDynamicProp(player.Index);
|
||||
if (emptyProp == null || !emptyProp.IsValid) return;
|
||||
|
||||
var playerPawn = player.PlayerPawn?.Value;
|
||||
if (playerPawn == null || !playerPawn.IsValid || playerPawn.AbsOrigin == null || playerPawn.AbsRotation == null) return;
|
||||
|
||||
emptyProp.CBodyComponent!.SceneNode!.Owner!.Entity!.Flags = (uint)(emptyProp.CBodyComponent!.SceneNode!.Owner!.Entity!.Flags & ~(1 << 2));
|
||||
emptyProp.SetModel(cameraViewModel);
|
||||
emptyProp.Render = Color.FromArgb(1, 255, 255, 255);
|
||||
|
||||
Vector newPos = new(playerPawn.AbsOrigin.X, playerPawn.AbsOrigin.Y, playerPawn.AbsOrigin.Z + 30);
|
||||
QAngle newAngle = new(playerPawn.AbsRotation.X, playerPawn.AbsRotation.Y, playerPawn.AbsRotation.Z);
|
||||
|
||||
emptyProp.Teleport(newPos, newAngle);
|
||||
emptyProp.DispatchSpawn();
|
||||
|
||||
Utilities.SetStateChanged(emptyProp, "CBaseEntity", "m_CBodyComponent");
|
||||
|
||||
EntityManager.RegisterExisting(emptyProp, player.Index, "empty_prop");
|
||||
}
|
||||
|
||||
public static void DisableSkill(CCSPlayerController player)
|
||||
{
|
||||
SkillUtils.ResetPrintHTML(player);
|
||||
SetWeaponAttack(player, false);
|
||||
SkillUtils.SetPlayerInvisibility(player, 0);
|
||||
|
||||
invisiblePlayers.TryRemove(player.Index, out _);
|
||||
EntityManager.DestroyPlayerEntities(player.Index);
|
||||
}
|
||||
|
||||
public static void OnTick()
|
||||
{
|
||||
if (Server.TickCount % 2 != 0) return;
|
||||
|
||||
foreach (var player in Utilities.GetPlayers())
|
||||
{
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(p => p.SteamID == player.SteamID);
|
||||
var playerInfo = PlayerManager.GetPlayerByIndex(player!.Index);
|
||||
if (playerInfo?.Skill == skillName)
|
||||
UpdateHUD(player);
|
||||
|
||||
if (!player.PawnIsAlive)
|
||||
if (player.LifeState != (byte)LifeState_t.LIFE_ALIVE)
|
||||
invisiblePlayers.TryRemove(player.Index, out _);
|
||||
|
||||
if (!invisiblePlayers.ContainsKey(player.Index)) continue;
|
||||
|
||||
var props = EntityManager.GetPlayerEntities(player.Index, "empty_prop");
|
||||
if (props.Count == 0) continue;
|
||||
|
||||
var prop = Utilities.GetEntityFromIndex<CDynamicProp>((int)props[0]);
|
||||
if (prop == null || !prop.IsValid) continue;
|
||||
|
||||
var pawn = player.PlayerPawn?.Value;
|
||||
if (pawn == null || !pawn.IsValid || pawn.AbsOrigin == null) continue;
|
||||
|
||||
Vector newPos = new(pawn.AbsOrigin.X, pawn.AbsOrigin.Y, pawn.AbsOrigin.Z + 30);
|
||||
QAngle newAngle = new(0, pawn.V_angle.Y, 0);
|
||||
prop.Teleport(newPos, newAngle, null);
|
||||
}
|
||||
}
|
||||
|
||||
public static void PlayerHurt(EventPlayerHurt @event)
|
||||
{
|
||||
var player = @event.Userid;
|
||||
var player = PlayerManager.GetPlayerEvent(@event.Userid);
|
||||
if (player == null || !player.IsValid) return;
|
||||
if (!invisiblePlayers.ContainsKey(player.Index)) return;
|
||||
|
||||
var playerPawn = player.PlayerPawn.Value;
|
||||
if (playerPawn == null || !playerPawn.IsValid || playerPawn.AbsOrigin == null) return;
|
||||
|
||||
CParticleSystem particle = Utilities.CreateEntityByName<CParticleSystem>("info_particle_system")!;
|
||||
var particle = EntityManager.CreateTrackedParticleSystem(player.Index, bloodParticle, autoDestroySeconds: 3f);
|
||||
if (particle == null) return;
|
||||
|
||||
particle.EffectName = bloodParticle;
|
||||
particle.StartActive = true;
|
||||
|
||||
Vector pos = new(playerPawn.AbsOrigin.X, playerPawn.AbsOrigin.Y, playerPawn.AbsOrigin.Z + 50);
|
||||
particle.Teleport(pos);
|
||||
particle.DispatchSpawn();
|
||||
|
||||
particle.AcceptInput("Start");
|
||||
}
|
||||
|
||||
|
|
@ -177,7 +227,7 @@ namespace src.player.skills
|
|||
var pawn = player.PlayerPawn.Value;
|
||||
if (pawn == null || !pawn.IsValid || pawn.WeaponServices == null) return;
|
||||
|
||||
var playerInfo = Instance.SkillPlayer.FirstOrDefault(s => s.SteamID == player?.SteamID);
|
||||
var playerInfo = PlayerManager.GetPlayerByIndex(player!.Index);
|
||||
if (playerInfo == null) return;
|
||||
|
||||
var weapon = pawn.WeaponServices.ActiveWeapon.Value;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue