diff --git a/Game.Server/BaseCombatWeapon.cs b/Game.Server/BaseCombatWeapon.cs index 020f6e37..2f2a2502 100644 --- a/Game.Server/BaseCombatWeapon.cs +++ b/Game.Server/BaseCombatWeapon.cs @@ -111,8 +111,36 @@ public override void Use(BaseEntity? activator, BaseEntity? caller, UseType useT public override bool IsWeapon() => true; public override GarrysMod.LuaClass Lua_GetLuaClass() => GarrysMod.LuaEntity.LC_Weapon; + public static short g_sModelIndexLaser; + public const string g_pModelNameLaser = "sprites/laserbeam.vmt"; + public static short g_sModelIndexFireball; + public static short g_sModelIndexSmoke; + public static short g_sModelIndexBubbles; + public static void W_Precache() { + WeaponParse.PrecacheFileWeaponInfoDatabase(filesystem); + + g_sModelIndexFireball = -1; + + g_sModelIndexSmoke = (short)PrecacheModel("sprites/steam1.vmt"); + g_sModelIndexBubbles = (short)PrecacheModel("sprites/bubble.vmt"); + g_sModelIndexLaser = (short)PrecacheModel(g_pModelNameLaser); + + PrecacheParticleSystem("blood_impact_red_01"); + PrecacheParticleSystem("blood_impact_green_01"); + PrecacheParticleSystem("blood_impact_yellow_01"); +#if GMOD_DLL + PrecacheParticleSystem("blood_impact_antlion_01"); + PrecacheParticleSystem("blood_impact_zombie_01"); + PrecacheParticleSystem("blood_impact_antlion_worker_01"); +#endif + + PrecacheModel("effects/bubble.vmt"); + + PrecacheModel("models/weapons/w_bullet.mdl"); + PrecacheScriptSound("BaseCombatWeapon.WeaponDrop"); + PrecacheScriptSound("BaseCombatWeapon.WeaponMaterialize"); } public virtual Capability CapabilitiesGet() => 0; diff --git a/Game.Server/BaseTempEntity.cs b/Game.Server/BaseTempEntity.cs index f53105fe..2fce6120 100644 --- a/Game.Server/BaseTempEntity.cs +++ b/Game.Server/BaseTempEntity.cs @@ -1,5 +1,8 @@ using Source.Common; +using Source.Common.Mathematics; + +using System.Numerics; namespace Game.Server; @@ -25,10 +28,22 @@ public void Create(scoped ref IRF filter, float delay) where IRF : IRecipie } public static BaseTempEntity? GetList() => s_pTempEntities; + public ReadOnlySpan GetName() => Name; public BaseTempEntity? GetNext() => Next; - public void Precache(){ + public virtual void Precache(){ + + } + + public virtual void Test(in Vector3 current_origin, in QAngle current_angles) { + Msg($"{Name}\n"); + MathLib.AngleVectors(current_angles, out Vector3 forward); + + MathLib.VectorMA(current_origin, 20, forward, out Vector3 origin); + + BroadcastRecipientFilter filter = new(); + Create(ref filter, 0.0f); } public static void PrecacheTempEnts() { diff --git a/Game.Server/TE.cs b/Game.Server/TE.cs index 5f781fad..2430fae1 100644 --- a/Game.Server/TE.cs +++ b/Game.Server/TE.cs @@ -2,6 +2,7 @@ using Game.Shared; +using Source; using Source.Common; using Source.Common.Formats.Keyvalues; using Source.Common.Mathematics; @@ -38,71 +39,88 @@ public bool SuppressTE(scoped ref IRF filter) where IRF : IRecipientFilter } public override void ArmorRicochet(scoped ref IRF filer, float delay, in Vector3 pos, in Vector3 dir) { - throw new NotImplementedException(); + if (!SuppressTE(ref filer)) + TE_ArmorRicochet(ref filer, delay, pos, dir); } public override void BeamEntPoint(scoped ref IRF filer, float delay, int nStartEntity, in Vector3 start, int nEndEntity, in Vector3 end, int modelindex, int haloindex, int startframe, int framerate, float life, float width, float endWidth, int fadeLength, float amplitude, int r, int g, int b, int a, int speed) { - throw new NotImplementedException(); + if (!SuppressTE(ref filer)) + TE_BeamEntPoint(ref filer, delay, nStartEntity, start, nEndEntity, end, modelindex, haloindex, startframe, framerate, life, width, endWidth, fadeLength, amplitude, r, g, b, a, speed); } public override void BeamEnts(scoped ref IRF filer, float delay, int start, int end, int modelindex, int haloindex, int startframe, int framerate, float life, float width, float endWidth, int fadeLength, float amplitude, int r, int g, int b, int a, int speed) { - throw new NotImplementedException(); + if (!SuppressTE(ref filer)) + TE_BeamEnts(ref filer, delay, start, end, modelindex, haloindex, startframe, framerate, life, width, endWidth, fadeLength, amplitude, r, g, b, a, speed); } public override void BeamFollow(scoped ref IRecipientFilter filter, float delay, int iEntIndex, int modelIndex, int haloIndex, float life, float width, float endWidth, float fadeLength, float r, float g, float b, float a) { - throw new NotImplementedException(); + if (!SuppressTE(ref filter)) + TE_BeamFollow(ref filter, delay, iEntIndex, modelIndex, haloIndex, life, width, endWidth, fadeLength, r, g, b, a); } public override void BeamLaser(scoped ref IRF filer, float delay, int start, int end, int modelindex, int haloindex, int startframe, int framerate, float life, float width, float endWidth, int fadeLength, float amplitude, int r, int g, int b, int a, int speed) { - throw new NotImplementedException(); + if (!SuppressTE(ref filer)) + TE_BeamLaser(ref filer, delay, start, end, modelindex, haloindex, startframe, framerate, life, width, endWidth, fadeLength, amplitude, r, g, b, a, speed); } public override void BeamPoints(scoped ref IRF filer, float delay, in Vector3 start, in Vector3 end, int modelindex, int haloindex, int startframe, int framerate, float life, float width, float endWidth, int fadeLength, float amplitude, int r, int g, int b, int a, int speed) { - throw new NotImplementedException(); + if (!SuppressTE(ref filer)) + TE_BeamPoints(ref filer, delay, start, end, modelindex, haloindex, startframe, framerate, life, width, endWidth, fadeLength, amplitude, r, g, b, a, speed); } public override void BeamRing(scoped ref IRF filer, float delay, int start, int end, int modelindex, int haloindex, int startframe, int framerate, float life, float width, int spread, float amplitude, int r, int g, int b, int a, int speed, int flags = 0) { - throw new NotImplementedException(); + if (!SuppressTE(ref filer)) + TE_BeamRing(ref filer, delay, start, end, modelindex, haloindex, startframe, framerate, life, width, spread, amplitude, r, g, b, a, speed, flags); } public override void BeamRingPoint(scoped ref IRF filer, float delay, in Vector3 center, float start_radius, float end_radius, int modelindex, int haloindex, int startframe, int framerate, float life, float width, int spread, float amplitude, int r, int g, int b, int a, int speed, int flags = 0) { - throw new NotImplementedException(); + if (!SuppressTE(ref filer)) + TE_BeamRingPoint(ref filer, delay, center, start_radius, end_radius, modelindex, haloindex, startframe, framerate, life, width, spread, amplitude, r, g, b, a, speed, flags); } public override void BeamSpline(scoped ref IRF filer, float delay, int points, Span rgPoints) { - throw new NotImplementedException(); + if (!SuppressTE(ref filer)) + TE_BeamSpline(ref filer, delay, points, rgPoints); } public override void BloodSprite(scoped ref IRF filer, float delay, in Vector3 org, in Vector3 dir, int r, int g, int b, int a, int size) { - throw new NotImplementedException(); + if (!SuppressTE(ref filer)) + TE_BloodSprite(ref filer, delay, org, dir, r, g, b, a, size); } public override void BloodStream(scoped ref IRF filer, float delay, in Vector3 org, in Vector3 dir, int r, int g, int b, int a, int amount) { - throw new NotImplementedException(); + if (!SuppressTE(ref filer)) + TE_BloodStream(ref filer, delay, org, dir, r, g, b, a, amount); } public override void BreakModel(scoped ref IRF filer, float delay, in Vector3 pos, in QAngle angle, in Vector3 size, in Vector3 vel, int modelindex, int randomization, int count, float time, int flags) { - throw new NotImplementedException(); + if (!SuppressTE(ref filer)) + TE_BreakModel(ref filer, delay, pos, angle, size, vel, modelindex, randomization, count, time, flags); } public override void BSPDecal(scoped ref IRF filer, float delay, in Vector3 pos, int entity, int index) { - throw new NotImplementedException(); + if (!SuppressTE(ref filer)) + TE_BSPDecal(ref filer, delay, pos, entity, index); } public override void Bubbles(scoped ref IRF filer, float delay, in Vector3 mins, in Vector3 maxs, float height, int modelindex, int count, float speed) { - throw new NotImplementedException(); + if (!SuppressTE(ref filer)) + TE_Bubbles(ref filer, delay, mins, maxs, height, modelindex, count, speed); } public override void BubbleTrail(scoped ref IRF filer, float delay, in Vector3 mins, in Vector3 maxs, float height, int modelindex, int count, float speed) { - throw new NotImplementedException(); + if (!SuppressTE(ref filer)) + TE_BubbleTrail(ref filer, delay, mins, maxs, height, modelindex, count, speed); } public override void ClientProjectile(scoped ref IRF filter, float delay, in Vector3 vecOrigin, in Vector3 vecVelocity, int modelindex, int lifetime, BaseEntity? owner) { - throw new NotImplementedException(); + if (!SuppressTE(ref filter)) + TE_ClientProjectile(ref filter, delay, vecOrigin, vecVelocity, modelindex, lifetime, owner); } public override void Decal(scoped ref IRF filer, float delay, in Vector3 pos, in Vector3 start, int entity, int hitbox, int index) { - throw new NotImplementedException(); + if (!SuppressTE(ref filer)) + TE_Decal(ref filer, delay, pos, start, entity, hitbox, index); } public override void DispatchEffect(scoped ref IRF filter, float delay, in Vector3 pos, ReadOnlySpan name, EffectData data) { @@ -116,39 +134,50 @@ public override void Dust(scoped ref IRF filer, float delay, in Vector3 pos } public override void DynamicLight(scoped ref IRF filer, float delay, in Vector3 org, int r, int g, int b, int exponent, float radius, float time, float decay) { - throw new NotImplementedException(); + if (!SuppressTE(ref filer)) + TE_DynamicLight(ref filer, delay, org, r, g, b, exponent, radius, time, decay); } public override void EnergySplash(scoped ref IRF filer, float delay, in Vector3 pos, in Vector3 dir, bool bExplosive) { - throw new NotImplementedException(); + if (!SuppressTE(ref filer)) + TE_EnergySplash(ref filer, delay, pos, dir, bExplosive); } public override void Explosion(scoped ref IRF filer, float delay, in Vector3 pos, int modelindex, float scale, int framerate, int flags, int radius, int magnitude, Vector3? normal = null, byte materialType = 67) { - throw new NotImplementedException(); + if (!SuppressTE(ref filer)) + TE_Explosion(ref filer, delay, pos, modelindex, scale, framerate, flags, radius, magnitude, normal, materialType); } public override void Fizz(scoped ref IRF filer, float delay, BaseEntity? ed, int modelindex, int density, int current) { - throw new NotImplementedException(); + if (!SuppressTE(ref filer)) + TE_Fizz(ref filer, delay, ed, modelindex, density, current); } public override void FootprintDecal(scoped ref IRF filer, float delay, in Vector3 origin, in Vector3 right, int entity, int index, byte materialType) { - throw new NotImplementedException(); + if (!SuppressTE(ref filer)) + TE_FootprintDecal(ref filer, delay, origin, right, entity, index, materialType); } public override void GaussExplosion(scoped ref IRF filer, float delay, in Vector3 pos, in Vector3 dir, int type) { - throw new NotImplementedException(); +#if HL2_DLL + if (!SuppressTE(ref filer)) + TE_GaussExplosion(ref filer, delay, pos, dir, type); +#endif } public override void GlowSprite(scoped ref IRF filer, float delay, in Vector3 pos, int modelindex, float life, float size, int brightness) { - throw new NotImplementedException(); + if (!SuppressTE(ref filer)) + TE_GlowSprite(ref filer, delay, pos, modelindex, life, size, brightness); } public override void KillPlayerAttachments(scoped ref IRF filer, float delay, int player) { - throw new NotImplementedException(); + if (!SuppressTE(ref filer)) + TE_KillPlayerAttachments(ref filer, delay, player); } public override void LargeFunnel(scoped ref IRF filer, float delay, in Vector3 pos, int modelindex, int reversed) { - throw new NotImplementedException(); + if (!SuppressTE(ref filer)) + TE_LargeFunnel(ref filer, delay, pos, modelindex, reversed); } public override void MetalSparks(scoped ref IRF filer, float delay, in Vector3 pos, in Vector3 dir) { @@ -157,50 +186,61 @@ public override void MetalSparks(scoped ref IRF filer, float delay, in Vect } public override void MuzzleFlash(scoped ref IRF filer, float delay, in Vector3 start, in QAngle angles, float scale, int type) { - throw new NotImplementedException(); + if (!SuppressTE(ref filer)) + TE_MuzzleFlash(ref filer, delay, start, angles, scale, type); } - public override void PhysicsProp(scoped ref IRF filter, float delay, int modelindex, int skin, in Vector3 pos, in QAngle angles, in Vector3 vel, int flags, int effects) { - throw new NotImplementedException(); + public override void PhysicsProp(scoped ref IRF filter, float delay, int modelindex, int skin, in Vector3 pos, in QAngle angles, in Vector3 vel, int flags, int effects, Color clrRender, float modelScale) { + if (!SuppressTE(ref filter)) + TE_PhysicsProp(ref filter, delay, modelindex, skin, pos, angles, vel, flags, effects, clrRender, modelScale); } public override void PlayerDecal(scoped ref IRF filer, float delay, in Vector3 pos, int player, int entity) { - throw new NotImplementedException(); + if (!SuppressTE(ref filer)) + TE_PlayerDecal(ref filer, delay, pos, player, entity); } public override void ProjectDecal(scoped ref IRF filter, float delay, in Vector3 pos, in QAngle angles, float distance, int index) { - throw new NotImplementedException(); + if (!SuppressTE(ref filter)) + TE_ProjectDecal(ref filter, delay, pos, angles, distance, index); } public override void ShatterSurface(scoped ref IRF filer, float delay, in Vector3 pos, in QAngle angle, in Vector3 force, in Vector3 forcePos, float width, float height, float shardsize, ShatterSurface surfacetype, int front_r, int front_g, int front_b, int back_r, int back_g, int back_b) { - throw new NotImplementedException(); + if (!SuppressTE(ref filer)) + TE_ShatterSurface(ref filer, delay, pos, angle, force, forcePos, width, height, shardsize, surfacetype, front_r, front_g, front_b, back_r, back_g, back_b); } public override void ShowLine(scoped ref IRF filer, float delay, in Vector3 start, in Vector3 end) { - throw new NotImplementedException(); + if (!SuppressTE(ref filer)) + TE_ShowLine(ref filer, delay, start, end); } public override void Smoke(scoped ref IRF filer, float delay, in Vector3 pos, int modelindex, float scale, int framerate) { - throw new NotImplementedException(); + if (!SuppressTE(ref filer)) + TE_Smoke(ref filer, delay, pos, modelindex, scale, framerate); } public override void Sparks(scoped ref IRF filer, float delay, in Vector3 pos, int nMagnitude, int nTrailLength, in Vector3 pDir) { - throw new NotImplementedException(); + if (!SuppressTE(ref filer)) + TE_Sparks(ref filer, delay, pos, nMagnitude, nTrailLength, pDir); } public override void Sprite(scoped ref IRF filer, float delay, in Vector3 pos, int modelindex, float size, int brightness) { - throw new NotImplementedException(); + if (!SuppressTE(ref filer)) + TE_Sprite(ref filer, delay, pos, modelindex, size, brightness); } public override void SpriteSpray(scoped ref IRF filer, float delay, in Vector3 pos, in Vector3 dir, int modelindex, int speed, float noise, int count) { - throw new NotImplementedException(); + if (!SuppressTE(ref filer)) + TE_SpriteSpray(ref filer, delay, pos, dir, modelindex, speed, noise, count); } public override void TriggerTempEntity(KeyValues pKeyValues) { - throw new NotImplementedException(); + Assert(false); } public override void WorldDecal(scoped ref IRF filer, float delay, in Vector3 pos, int index) { - throw new NotImplementedException(); + if (!SuppressTE(ref filer)) + TE_WorldDecal(ref filer, delay, pos, index); } } diff --git a/Game.Server/TEAntlionDust.cs b/Game.Server/TEAntlionDust.cs index 1412c451..5275ecce 100644 --- a/Game.Server/TEAntlionDust.cs +++ b/Game.Server/TEAntlionDust.cs @@ -1,4 +1,5 @@ using Source.Common; +using Source.Common.Mathematics; using Source; using Game.Shared; using System.Numerics; @@ -17,4 +18,8 @@ public partial class TEAntlionDust(ReadOnlySpan name) : TEParticleSystem(n public Vector3 Angles; [NetworkVar("m_bBlockedSpawner")] public bool BlockedSpawner; + + // todo: UTIL_CreateAntlionDust sender (hl2/antlion_dust.cpp) + + public override void Test(in Vector3 current_origin, in QAngle current_angles) { } } diff --git a/Game.Server/TEArmorRicochet.cs b/Game.Server/TEArmorRicochet.cs index 1e502dd3..142c22c2 100644 --- a/Game.Server/TEArmorRicochet.cs +++ b/Game.Server/TEArmorRicochet.cs @@ -11,3 +11,15 @@ public partial class TEArmorRicochet(ReadOnlySpan name) : TEMetalSparks(na ]; } + +public static partial class TempEnts +{ + static readonly TEArmorRicochet g_TEArmorRicochet = new("Armor Ricochet"); + + public static void TE_ArmorRicochet(scoped ref IRF filter, float delay, in Vector3 pos, in Vector3 dir) where IRF : IRecipientFilter { + g_TEArmorRicochet.Pos = pos; + g_TEArmorRicochet.Dir = dir; + + g_TEArmorRicochet.Create(ref filter, delay); + } +} diff --git a/Game.Server/TEBSPDecal.cs b/Game.Server/TEBSPDecal.cs index e3d3f9a3..7c2105c8 100644 --- a/Game.Server/TEBSPDecal.cs +++ b/Game.Server/TEBSPDecal.cs @@ -1,4 +1,6 @@ using Source.Common; +using Source.Common.Formats.BSP; +using Source.Common.Mathematics; using Source; using Game.Shared; using System.Numerics; @@ -19,4 +21,39 @@ public partial class TEBSPDecal(ReadOnlySpan name) : BaseTempEntity(name) public int Entity; [NetworkVar("m_nIndex")] public int Index; + + public override void Test(in Vector3 current_origin, in QAngle current_angles) { + Entity = 0; + Index = 0; + Origin = current_origin; + + Origin.Z += 24; + + MathLib.AngleVectors(current_angles, out Vector3 forward); + forward.Z = 0.0f; + MathLib.VectorNormalize(ref forward); + + Origin += forward * 50.0f; + Vector3 vecEnd = Origin + forward * 1024.0f; + + Util.TraceLine(Origin, vecEnd, Mask.SolidBrushOnly, null, Source.CollisionGroup.None, out Trace tr); + + Origin = tr.EndPos; + + BroadcastRecipientFilter filter = new(); + Create(ref filter, 0.0f); + } +} + +public static partial class TempEnts +{ + static readonly TEBSPDecal g_TEBSPDecal = new("BSP Decal"); + + public static void TE_BSPDecal(scoped ref IRF filter, float delay, in Vector3 pos, int entity, int index) where IRF : IRecipientFilter { + g_TEBSPDecal.Origin = pos; + g_TEBSPDecal.Entity = entity; + g_TEBSPDecal.Index = index; + + g_TEBSPDecal.Create(ref filter, delay); + } } diff --git a/Game.Server/TEBeamEntPoint.cs b/Game.Server/TEBeamEntPoint.cs index e486d0f0..85868ad1 100644 --- a/Game.Server/TEBeamEntPoint.cs +++ b/Game.Server/TEBeamEntPoint.cs @@ -1,4 +1,5 @@ using Source.Common; +using Source.Common.Mathematics; using Source; using Game.Shared; using System.Numerics; @@ -22,4 +23,60 @@ public partial class TEBeamEntPoint(ReadOnlySpan name) : BaseBeam(name) public Vector3 StartPoint; [NetworkVar("m_vecEndPoint")] public Vector3 EndPoint; + + public override void Test(in Vector3 current_origin, in QAngle current_angles) { + StartEntity = 1; + ModelIndex = BaseCombatWeapon.g_sModelIndexSmoke; + StartFrame = 0; + FrameRate = 10; + Life = 2.0f; + Width = 1.0f; + Amplitude = 1.0f; + R = 0; + G = 63; + B = 127; + A = 150; + Speed = 1; + + EndPoint = current_origin; + + EndPoint += new Vector3(0, 0, 24); + + MathLib.AngleVectors(current_angles, out Vector3 forward, out Vector3 right, out _); + forward.Z = 0.0f; + MathLib.VectorNormalize(ref forward); + + EndPoint += forward * 50.0f; + + BroadcastRecipientFilter filter = new(); + Create(ref filter, 0.0f); + } +} + +public static partial class TempEnts +{ + static readonly TEBeamEntPoint g_TEBeamEntPoint = new("BeamEntPoint"); + + public static void TE_BeamEntPoint(scoped ref IRF filter, float delay, int startEntity, in Vector3 start, int endEntity, in Vector3 end, int modelindex, int haloindex, int startframe, int framerate, float life, float width, float endWidth, int fadeLength, float amplitude, int r, int g, int b, int a, int speed) where IRF : IRecipientFilter { + g_TEBeamEntPoint.StartEntity = (startEntity > 0) ? (startEntity & 0x0FFF) | ((1 & 0xF) << 12) : 0; + g_TEBeamEntPoint.EndEntity = (endEntity > 0) ? (endEntity & 0x0FFF) | ((1 & 0xF) << 12) : 0; + g_TEBeamEntPoint.StartPoint = start; + g_TEBeamEntPoint.EndPoint = end; + g_TEBeamEntPoint.ModelIndex = modelindex; + g_TEBeamEntPoint.HaloIndex = haloindex; + g_TEBeamEntPoint.StartFrame = startframe; + g_TEBeamEntPoint.FrameRate = framerate; + g_TEBeamEntPoint.Life = life; + g_TEBeamEntPoint.Width = width; + g_TEBeamEntPoint.EndWidth = endWidth; + g_TEBeamEntPoint.FadeLength = fadeLength; + g_TEBeamEntPoint.Amplitude = amplitude; + g_TEBeamEntPoint.Speed = speed; + g_TEBeamEntPoint.R = r; + g_TEBeamEntPoint.G = g; + g_TEBeamEntPoint.B = b; + g_TEBeamEntPoint.A = a; + + g_TEBeamEntPoint.Create(ref filter, delay); + } } diff --git a/Game.Server/TEBeamEnts.cs b/Game.Server/TEBeamEnts.cs index 878a1703..9189fec1 100644 --- a/Game.Server/TEBeamEnts.cs +++ b/Game.Server/TEBeamEnts.cs @@ -1,4 +1,5 @@ using Source.Common; +using Source.Common.Mathematics; using Source; using Game.Shared; using System.Numerics; @@ -16,4 +17,49 @@ public partial class TEBeamEnts(ReadOnlySpan name) : BaseBeam(name) public int StartEntity; [NetworkVar("m_nEndEntity")] public int EndEntity; + + public override void Test(in Vector3 current_origin, in QAngle current_angles) { + StartEntity = 1; + EndEntity = 0; + ModelIndex = BaseCombatWeapon.g_sModelIndexSmoke; + StartFrame = 0; + FrameRate = 10; + Life = 2.0f; + Width = 1.0f; + Amplitude = 1.0f; + R = 127; + G = 63; + B = 0; + A = 150; + Speed = 1; + + BroadcastRecipientFilter filter = new(); + Create(ref filter, 0.0f); + } +} + +public static partial class TempEnts +{ + static readonly TEBeamEnts g_TEBeamEnts = new("BeamEnts"); + + public static void TE_BeamEnts(scoped ref IRF filter, float delay, int start, int end, int modelindex, int haloindex, int startframe, int framerate, float life, float width, float endWidth, int fadeLength, float amplitude, int r, int g, int b, int a, int speed) where IRF : IRecipientFilter { + g_TEBeamEnts.StartEntity = (start & 0x0FFF) | ((1 & 0xF) << 12); + g_TEBeamEnts.EndEntity = (end & 0x0FFF) | ((1 & 0xF) << 12); + g_TEBeamEnts.ModelIndex = modelindex; + g_TEBeamEnts.HaloIndex = haloindex; + g_TEBeamEnts.StartFrame = startframe; + g_TEBeamEnts.FrameRate = framerate; + g_TEBeamEnts.Life = life; + g_TEBeamEnts.Width = width; + g_TEBeamEnts.EndWidth = endWidth; + g_TEBeamEnts.FadeLength = fadeLength; + g_TEBeamEnts.Amplitude = amplitude; + g_TEBeamEnts.Speed = speed; + g_TEBeamEnts.R = r; + g_TEBeamEnts.G = g; + g_TEBeamEnts.B = b; + g_TEBeamEnts.A = a; + + g_TEBeamEnts.Create(ref filter, delay); + } } diff --git a/Game.Server/TEBeamFollow.cs b/Game.Server/TEBeamFollow.cs index eede823a..ff12ead6 100644 --- a/Game.Server/TEBeamFollow.cs +++ b/Game.Server/TEBeamFollow.cs @@ -1,4 +1,5 @@ using Source.Common; +using Source.Common.Mathematics; using Source; using Game.Shared; using System.Numerics; @@ -13,4 +14,31 @@ public partial class TEBeamFollow(ReadOnlySpan name) : BaseBeam(name) [NetworkVar("m_iEntIndex")] public int EntIndex; + + public override void Test(in Vector3 current_origin, in QAngle current_angles) { + EntIndex = 1; + } +} + +public static partial class TempEnts +{ + static readonly TEBeamFollow g_TEBeamFollow = new("BeamFollow"); + + public static void TE_BeamFollow(scoped ref IRF filter, float delay, int entIndex, int modelIndex, int haloIndex, float life, float width, float endWidth, float fadeLength, float r, float g, float b, float a) where IRF : IRecipientFilter { + g_TEBeamFollow.EntIndex = (entIndex & 0x0FFF) | ((1 & 0xF) << 12); + g_TEBeamFollow.ModelIndex = modelIndex; + g_TEBeamFollow.HaloIndex = haloIndex; + g_TEBeamFollow.StartFrame = 0; + g_TEBeamFollow.FrameRate = 0; + g_TEBeamFollow.Life = life; + g_TEBeamFollow.Width = width; + g_TEBeamFollow.EndWidth = endWidth; + g_TEBeamFollow.FadeLength = (int)fadeLength; + g_TEBeamFollow.R = (int)r; + g_TEBeamFollow.G = (int)g; + g_TEBeamFollow.B = (int)b; + g_TEBeamFollow.A = (int)a; + + g_TEBeamFollow.Create(ref filter, delay); + } } diff --git a/Game.Server/TEBeamLaser.cs b/Game.Server/TEBeamLaser.cs index fd6b930b..1c4bd302 100644 --- a/Game.Server/TEBeamLaser.cs +++ b/Game.Server/TEBeamLaser.cs @@ -1,4 +1,5 @@ using Source.Common; +using Source.Common.Mathematics; using Source; using Game.Shared; using System.Numerics; @@ -16,4 +17,49 @@ public partial class TEBeamLaser(ReadOnlySpan name) : BaseBeam(name) public int StartEntity; [NetworkVar("m_nEndEntity")] public int EndEntity; + + public override void Test(in Vector3 current_origin, in QAngle current_angles) { + StartEntity = 1; + EndEntity = 0; + ModelIndex = BaseCombatWeapon.g_sModelIndexSmoke; + StartFrame = 0; + FrameRate = 10; + Life = 2.0f; + Width = 1.0f; + Amplitude = 1.0f; + R = 127; + G = 63; + B = 0; + A = 150; + Speed = 1; + + BroadcastRecipientFilter filter = new(); + Create(ref filter, 0.0f); + } +} + +public static partial class TempEnts +{ + static readonly TEBeamLaser g_TEBeamLaser = new("BeamLaser"); + + public static void TE_BeamLaser(scoped ref IRF filter, float delay, int start, int end, int modelindex, int haloindex, int startframe, int framerate, float life, float width, float endWidth, int fadeLength, float amplitude, int r, int g, int b, int a, int speed) where IRF : IRecipientFilter { + g_TEBeamLaser.StartEntity = (start & 0x0FFF) | ((1 & 0xF) << 12); + g_TEBeamLaser.EndEntity = (end & 0x0FFF) | ((1 & 0xF) << 12); + g_TEBeamLaser.ModelIndex = modelindex; + g_TEBeamLaser.HaloIndex = haloindex; + g_TEBeamLaser.StartFrame = startframe; + g_TEBeamLaser.FrameRate = framerate; + g_TEBeamLaser.Life = life; + g_TEBeamLaser.Width = width; + g_TEBeamLaser.EndWidth = endWidth; + g_TEBeamLaser.FadeLength = fadeLength; + g_TEBeamLaser.Amplitude = amplitude; + g_TEBeamLaser.Speed = speed; + g_TEBeamLaser.R = r; + g_TEBeamLaser.G = g; + g_TEBeamLaser.B = b; + g_TEBeamLaser.A = a; + + g_TEBeamLaser.Create(ref filter, delay); + } } diff --git a/Game.Server/TEBeamPoints.cs b/Game.Server/TEBeamPoints.cs index 63dd72c1..9212557b 100644 --- a/Game.Server/TEBeamPoints.cs +++ b/Game.Server/TEBeamPoints.cs @@ -1,4 +1,5 @@ using Source.Common; +using Source.Common.Mathematics; using Source; using Game.Shared; using System.Numerics; @@ -16,4 +17,59 @@ public partial class TEBeamPoints(ReadOnlySpan name) : BaseBeam(name) public Vector3 StartPoint; [NetworkVar("m_vecEndPoint")] public Vector3 EndPoint; + + public override void Test(in Vector3 current_origin, in QAngle current_angles) { + ModelIndex = BaseCombatWeapon.g_sModelIndexSmoke; + StartFrame = 0; + FrameRate = 10; + Life = 2.0f; + Width = 1.0f; + Amplitude = 1.0f; + R = 0; + G = 63; + B = 127; + A = 150; + Speed = 1; + + StartPoint = current_origin; + + StartPoint += new Vector3(0, 0, 30); + + MathLib.AngleVectors(current_angles, out Vector3 forward, out Vector3 right, out _); + forward.Z = 0.0f; + MathLib.VectorNormalize(ref forward); + + StartPoint += forward * 75.0f; + EndPoint = StartPoint + right * 25.0f; + StartPoint += right * -25.0f; + + BroadcastRecipientFilter filter = new(); + Create(ref filter, 0.0f); + } +} + +public static partial class TempEnts +{ + static readonly TEBeamPoints g_TEBeamPoints = new("BeamPoints"); + + public static void TE_BeamPoints(scoped ref IRF filter, float delay, in Vector3 start, in Vector3 end, int modelindex, int haloindex, int startframe, int framerate, float life, float width, float endWidth, int fadeLength, float amplitude, int r, int g, int b, int a, int speed) where IRF : IRecipientFilter { + g_TEBeamPoints.StartPoint = start; + g_TEBeamPoints.EndPoint = end; + g_TEBeamPoints.ModelIndex = modelindex; + g_TEBeamPoints.HaloIndex = haloindex; + g_TEBeamPoints.StartFrame = startframe; + g_TEBeamPoints.FrameRate = framerate; + g_TEBeamPoints.Life = life; + g_TEBeamPoints.Width = width; + g_TEBeamPoints.EndWidth = endWidth; + g_TEBeamPoints.FadeLength = fadeLength; + g_TEBeamPoints.Amplitude = amplitude; + g_TEBeamPoints.Speed = speed; + g_TEBeamPoints.R = r; + g_TEBeamPoints.G = g; + g_TEBeamPoints.B = b; + g_TEBeamPoints.A = a; + + g_TEBeamPoints.Create(ref filter, delay); + } } diff --git a/Game.Server/TEBeamRing.cs b/Game.Server/TEBeamRing.cs index a766bdad..053ee234 100644 --- a/Game.Server/TEBeamRing.cs +++ b/Game.Server/TEBeamRing.cs @@ -1,4 +1,5 @@ using Source.Common; +using Source.Common.Mathematics; using Source; using Game.Shared; using System.Numerics; @@ -16,4 +17,50 @@ public partial class TEBeamRing(ReadOnlySpan name) : BaseBeam(name) public int StartEntity; [NetworkVar("m_nEndEntity")] public int EndEntity; + + public override void Test(in Vector3 current_origin, in QAngle current_angles) { + StartEntity = 1; + EndEntity = 0; + ModelIndex = BaseCombatWeapon.g_sModelIndexSmoke; + StartFrame = 0; + FrameRate = 2; + Life = 10.0f; + Width = 2.0f; + Amplitude = 1.0f; + R = 255; + G = 255; + B = 0; + A = 127; + Speed = 5; + + BroadcastRecipientFilter filter = new(); + Create(ref filter, 0.0f); + } +} + +public static partial class TempEnts +{ + static readonly TEBeamRing g_TEBeamRing = new("BeamRing"); + + public static void TE_BeamRing(scoped ref IRF filter, float delay, int start, int end, int modelindex, int haloindex, int startframe, int framerate, float life, float width, int spread, float amplitude, int r, int g, int b, int a, int speed, int flags = 0) where IRF : IRecipientFilter { + g_TEBeamRing.StartEntity = (start & 0x0FFF) | ((1 & 0xF) << 12); + g_TEBeamRing.EndEntity = (end & 0x0FFF) | ((1 & 0xF) << 12); + g_TEBeamRing.ModelIndex = modelindex; + g_TEBeamRing.HaloIndex = haloindex; + g_TEBeamRing.StartFrame = startframe; + g_TEBeamRing.FrameRate = framerate; + g_TEBeamRing.Life = life; + g_TEBeamRing.Width = width; + g_TEBeamRing.EndWidth = width; + g_TEBeamRing.FadeLength = 0; + g_TEBeamRing.Amplitude = amplitude; + g_TEBeamRing.Speed = speed; + g_TEBeamRing.R = r; + g_TEBeamRing.G = g; + g_TEBeamRing.B = b; + g_TEBeamRing.A = a; + g_TEBeamRing.Flags = flags; + + g_TEBeamRing.Create(ref filter, delay); + } } diff --git a/Game.Server/TEBeamRingPoint.cs b/Game.Server/TEBeamRingPoint.cs index 5ccb69d6..10b1f7c9 100644 --- a/Game.Server/TEBeamRingPoint.cs +++ b/Game.Server/TEBeamRingPoint.cs @@ -1,4 +1,5 @@ using Source.Common; +using Source.Common.Mathematics; using Source; using Game.Shared; using System.Numerics; @@ -19,4 +20,52 @@ public partial class TEBeamRingPoint(ReadOnlySpan name) : BaseBeam(name) public float LStartRadius; [NetworkVar("m_flEndRadius")] public float LEndRadius; + + public override void Test(in Vector3 current_origin, in QAngle current_angles) { + Center = current_origin; + LEndRadius = 256.0f; + LStartRadius = 16.0f; + ModelIndex = BaseCombatWeapon.g_sModelIndexSmoke; + StartFrame = 0; + FrameRate = 2; + Life = 10.0f; + Width = 2.0f; + Amplitude = 1.0f; + R = 255; + G = 255; + B = 0; + A = 127; + Speed = 5; + + BroadcastRecipientFilter filter = new(); + Create(ref filter, 0.0f); + } +} + +public static partial class TempEnts +{ + static readonly TEBeamRingPoint g_TEBeamRingPoint = new("BeamRingPoint"); + + public static void TE_BeamRingPoint(scoped ref IRF filter, float delay, in Vector3 center, float startRadius, float endRadius, int modelindex, int haloindex, int startframe, int framerate, float life, float width, int spread, float amplitude, int r, int g, int b, int a, int speed, int flags = 0) where IRF : IRecipientFilter { + g_TEBeamRingPoint.Center = center; + g_TEBeamRingPoint.LStartRadius = startRadius; + g_TEBeamRingPoint.LEndRadius = endRadius; + g_TEBeamRingPoint.ModelIndex = modelindex; + g_TEBeamRingPoint.HaloIndex = haloindex; + g_TEBeamRingPoint.StartFrame = startframe; + g_TEBeamRingPoint.FrameRate = framerate; + g_TEBeamRingPoint.Life = life; + g_TEBeamRingPoint.Width = width; + g_TEBeamRingPoint.EndWidth = width; + g_TEBeamRingPoint.FadeLength = 0; + g_TEBeamRingPoint.Amplitude = amplitude; + g_TEBeamRingPoint.Speed = speed; + g_TEBeamRingPoint.R = r; + g_TEBeamRingPoint.G = g; + g_TEBeamRingPoint.B = b; + g_TEBeamRingPoint.A = a; + g_TEBeamRingPoint.Flags = flags; + + g_TEBeamRingPoint.Create(ref filter, delay); + } } diff --git a/Game.Server/TEBeamSpline.cs b/Game.Server/TEBeamSpline.cs index f720020a..af4dd746 100644 --- a/Game.Server/TEBeamSpline.cs +++ b/Game.Server/TEBeamSpline.cs @@ -1,4 +1,5 @@ using Source.Common; +using Source.Common.Mathematics; using Source; using Game.Shared; using System.Numerics; @@ -16,4 +17,49 @@ public partial class TEBeamSpline(ReadOnlySpan name) : BaseTempEntity(name public int NumPoints; [NetworkVar("m_vecPoints")] public InlineArrayMaxSplinePoints Points; + + public override void Test(in Vector3 current_origin, in QAngle current_angles) { + NumPoints = 6; + Vector3 vecStart = current_origin; + + vecStart.Z += 24; + + MathLib.AngleVectors(current_angles, out Vector3 forward, out Vector3 right, out _); + forward.Z = 0.0f; + MathLib.VectorNormalize(ref forward); + + vecStart += forward * 100.0f; + vecStart += right * -128.0f; + + for (int i = 0; i < NumPoints; i++) { + Points[i] = vecStart; + vecStart += right * (128 / NumPoints); + vecStart += forward * (30.0f / NumPoints); + } + + BroadcastRecipientFilter filter = new(); + Create(ref filter, 0.0f); + } +} + +public static partial class TempEnts +{ + static readonly TEBeamSpline g_TEBeamSpline = new("BeamSpline"); + + public static void TE_BeamSpline(scoped ref IRF filter, float delay, int points, Span rgPoints) where IRF : IRecipientFilter { + int i; + g_TEBeamSpline.NumPoints = points; + for (i = 0; i < points; i++) { +#if GMOD_DLL + if (i >= MAX_SPLINE_POINTS) + continue; +#endif + g_TEBeamSpline.Points[i] = rgPoints[i]; + } + + for (; i < MAX_SPLINE_POINTS; i++) + g_TEBeamSpline.Points[i] = default; + + g_TEBeamSpline.Create(ref filter, delay); + } } diff --git a/Game.Server/TEBloodSprite.cs b/Game.Server/TEBloodSprite.cs index 54e85fe9..ec0c61cf 100644 --- a/Game.Server/TEBloodSprite.cs +++ b/Game.Server/TEBloodSprite.cs @@ -1,4 +1,5 @@ using Source.Common; +using Source.Common.Mathematics; using Source; using Game.Shared; using System.Numerics; @@ -29,8 +30,43 @@ public partial class TEBloodSprite(ReadOnlySpan name) : BaseTempEntity(nam public int B; [NetworkVar("a")] public int A; - public int SprayModel; - public int DropModel; [NetworkVar("m_nSize")] public int Size; + + public override void Test(in Vector3 current_origin, in QAngle current_angles) { + R = 255; + G = 255; + B = 63; + A = 255; + Size = 16; + Origin = current_origin; + + Origin.Z += 24; + + MathLib.AngleVectors(current_angles, out Vector3 forward); + forward.Z = 0.0f; + MathLib.VectorNormalize(ref forward); + + Origin += forward * 50.0f; + + BroadcastRecipientFilter filter = new(); + Create(ref filter, 0.0f); + } +} + +public static partial class TempEnts +{ + static readonly TEBloodSprite g_TEBloodSprite = new("Blood Sprite"); + + public static void TE_BloodSprite(scoped ref IRF filter, float delay, in Vector3 org, in Vector3 dir, int r, int g, int b, int a, int size) where IRF : IRecipientFilter { + g_TEBloodSprite.Origin = org; + g_TEBloodSprite.Direction = dir; + g_TEBloodSprite.R = r; + g_TEBloodSprite.G = g; + g_TEBloodSprite.B = b; + g_TEBloodSprite.A = a; + g_TEBloodSprite.Size = size; + + g_TEBloodSprite.Create(ref filter, delay); + } } diff --git a/Game.Server/TEBloodStream.cs b/Game.Server/TEBloodStream.cs index e0a6a797..4efdff2c 100644 --- a/Game.Server/TEBloodStream.cs +++ b/Game.Server/TEBloodStream.cs @@ -1,4 +1,5 @@ using Source.Common; +using Source.Common.Mathematics; using Source; using Game.Shared; using System.Numerics; @@ -28,4 +29,43 @@ public partial class TEBloodStream(ReadOnlySpan name) : TEParticleSystem(n public int A; [NetworkVar("m_nAmount")] public int Amount; + + public override void Test(in Vector3 current_origin, in QAngle current_angles) { + R = 247; + G = 0; + B = 0; + A = 255; + Amount = random.RandomInt(50, 150); + Origin = current_origin; + + Origin.Z += 24; + + MathLib.AngleVectors(current_angles, out Vector3 forward); + forward.Z = 0.0f; + MathLib.VectorNormalize(ref forward); + + Origin += forward * 50.0f; + + Direction = Util.RandomBloodVector(); + + BroadcastRecipientFilter filter = new(); + Create(ref filter, 0.0f); + } +} + +public static partial class TempEnts +{ + static readonly TEBloodStream g_TEBloodStream = new("Blood Stream"); + + public static void TE_BloodStream(scoped ref IRF filter, float delay, in Vector3 org, in Vector3 dir, int r, int g, int b, int a, int amount) where IRF : IRecipientFilter { + g_TEBloodStream.Origin = org; + g_TEBloodStream.Direction = dir; + g_TEBloodStream.R = r; + g_TEBloodStream.G = g; + g_TEBloodStream.B = b; + g_TEBloodStream.A = a; + g_TEBloodStream.Amount = amount; + + g_TEBloodStream.Create(ref filter, delay); + } } diff --git a/Game.Server/TEBreakModel.cs b/Game.Server/TEBreakModel.cs index 58b91383..08ffd622 100644 --- a/Game.Server/TEBreakModel.cs +++ b/Game.Server/TEBreakModel.cs @@ -40,4 +40,49 @@ public partial class TEBreakModel(ReadOnlySpan name) : BaseTempEntity(name public float Time; [NetworkVar("m_nFlags")] public int Flags; + + public override void Precache() => BaseEntity.PrecacheModel("models/gibs/hgibs.mdl"); + + public override void Test(in Vector3 current_origin, in QAngle current_angles) { + ModelIndex = BaseEntity.PrecacheModel("models/gibs/hgibs.mdl"); + Origin = current_origin; + Rotation = current_angles; + Size = new Vector3(16, 16, 16); + Velocity = new Vector3(random.RandomFloat(-10, 10), random.RandomFloat(-10, 10), random.RandomFloat(0, 20)); + Randomization = 100; + Count = 10; + Time = 5.0f; + Flags = 0; + + Origin += new Vector3(0, 0, 24); + + MathLib.AngleVectors(current_angles, out Vector3 forward, out Vector3 right, out _); + forward.Z = 0.0f; + MathLib.VectorNormalize(ref forward); + + Origin += forward * 50.0f; + Origin += right * 25.0f; + + BroadcastRecipientFilter filter = new(); + Create(ref filter, 0.0f); + } +} + +public static partial class TempEnts +{ + static readonly TEBreakModel g_TEBreakModel = new("breakmodel"); + + public static void TE_BreakModel(scoped ref IRF filter, float delay, in Vector3 pos, in QAngle angles, in Vector3 size, in Vector3 vel, int modelindex, int randomization, int count, float time, int flags) where IRF : IRecipientFilter { + g_TEBreakModel.Origin = pos; + g_TEBreakModel.Rotation = angles; + g_TEBreakModel.Size = size; + g_TEBreakModel.Velocity = vel; + g_TEBreakModel.ModelIndex = modelindex; + g_TEBreakModel.Randomization = randomization; + g_TEBreakModel.Count = count; + g_TEBreakModel.Time = time; + g_TEBreakModel.Flags = flags; + + g_TEBreakModel.Create(ref filter, delay); + } } diff --git a/Game.Server/TEBubbleTrail.cs b/Game.Server/TEBubbleTrail.cs index 7d6b7626..313c36e7 100644 --- a/Game.Server/TEBubbleTrail.cs +++ b/Game.Server/TEBubbleTrail.cs @@ -1,4 +1,5 @@ using Source.Common; +using Source.Common.Mathematics; using Source; using Game.Shared; using System.Numerics; @@ -6,6 +7,9 @@ namespace Game.Server; [NetworkName("CTEBubbleTrail")] public partial class TEBubbleTrail(ReadOnlySpan name) : BaseTempEntity(name) { + public const int BUBBLE_TRAIL_COUNT_BITS = 8; + public const int BUBBLE_TRAIL_MAX_COUNT = (1 << BUBBLE_TRAIL_COUNT_BITS) - 1; + [NetworkTable] public static readonly NetworkProp[] Props = [ new(nameof(Mins)) { Bits = 0, Flags = PropFlags.Coord }, @@ -28,4 +32,43 @@ public partial class TEBubbleTrail(ReadOnlySpan name) : BaseTempEntity(nam public int Count; [NetworkVar("m_fSpeed")] public float Speed; + + public override void Test(in Vector3 current_origin, in QAngle current_angles) { + Mins = current_origin; + + Mins.Z += 24; + + MathLib.AngleVectors(current_angles, out Vector3 forward); + forward.Z = 0.0f; + MathLib.VectorNormalize(ref forward); + + Mins += forward * 100.0f; + + Maxs = Mins + new Vector3(256, 256, 256); + + Speed = 8; + Count = 20; + LWaterZ = 0; + + ModelIndex = BaseCombatWeapon.g_sModelIndexBubbles; + + BroadcastRecipientFilter filter = new(); + Create(ref filter, 0.0f); + } +} + +public static partial class TempEnts +{ + static readonly TEBubbleTrail g_TEBubbleTrail = new("Bubble Trail"); + + public static void TE_BubbleTrail(scoped ref IRF filter, float delay, in Vector3 mins, in Vector3 maxs, float waterZ, int modelindex, int count, float speed) where IRF : IRecipientFilter { + g_TEBubbleTrail.Mins = mins; + g_TEBubbleTrail.Maxs = maxs; + g_TEBubbleTrail.LWaterZ = waterZ; + g_TEBubbleTrail.ModelIndex = modelindex; + g_TEBubbleTrail.Count = Math.Min(count, TEBubbleTrail.BUBBLE_TRAIL_MAX_COUNT); + g_TEBubbleTrail.Speed = speed; + + g_TEBubbleTrail.Create(ref filter, delay); + } } diff --git a/Game.Server/TEBubbles.cs b/Game.Server/TEBubbles.cs index 84d4bc0f..4c974f1a 100644 --- a/Game.Server/TEBubbles.cs +++ b/Game.Server/TEBubbles.cs @@ -1,4 +1,5 @@ using Source.Common; +using Source.Common.Mathematics; using Source; using Game.Shared; using System.Numerics; @@ -28,4 +29,43 @@ public partial class TEBubbles(ReadOnlySpan name) : BaseTempEntity(name) public int Count; [NetworkVar("m_fSpeed")] public float Speed; + + public override void Test(in Vector3 current_origin, in QAngle current_angles) { + Mins = current_origin; + + Mins.Z += 24; + + MathLib.AngleVectors(current_angles, out Vector3 forward); + forward.Z = 0.0f; + MathLib.VectorNormalize(ref forward); + + Mins += forward * 100.0f; + + Maxs = Mins + new Vector3(256, 256, 256); + + Speed = 2; + Count = 50; + Height = 256; + + ModelIndex = BaseCombatWeapon.g_sModelIndexBubbles; + + BroadcastRecipientFilter filter = new(); + Create(ref filter, 0.0f); + } +} + +public static partial class TempEnts +{ + static readonly TEBubbles g_TEBubbles = new("Bubbles"); + + public static void TE_Bubbles(scoped ref IRF filter, float delay, in Vector3 mins, in Vector3 maxs, float height, int modelindex, int count, float speed) where IRF : IRecipientFilter { + g_TEBubbles.Mins = mins; + g_TEBubbles.Maxs = maxs; + g_TEBubbles.Height = height; + g_TEBubbles.ModelIndex = modelindex; + g_TEBubbles.Count = count; + g_TEBubbles.Speed = speed; + + g_TEBubbles.Create(ref filter, delay); + } } diff --git a/Game.Server/TEClientProjectile.cs b/Game.Server/TEClientProjectile.cs index 1512bb69..9fa75cc6 100644 --- a/Game.Server/TEClientProjectile.cs +++ b/Game.Server/TEClientProjectile.cs @@ -1,4 +1,5 @@ using Source.Common; +using Source.Common.Mathematics; using Source; using Game.Shared; using System.Numerics; @@ -12,7 +13,7 @@ public partial class TEClientProjectile(ReadOnlySpan name) : BaseTempEntit new(nameof(Velocity)) { Bits = 0, Flags = PropFlags.Coord }, new(nameof(ModelIndex)) { Bits = 14 }, new(nameof(LifeTime)) { Bits = 6, Flags = PropFlags.Unsigned }, - new(nameof(HOwner)) { Bits = 23, Flags = PropFlags.Unsigned }, + nameof(HOwner), ]; [NetworkVar("m_vecOrigin")] @@ -24,5 +25,35 @@ public partial class TEClientProjectile(ReadOnlySpan name) : BaseTempEntit [NetworkVar("m_nLifeTime")] public int LifeTime; [NetworkVar("m_hOwner")] - public int HOwner; + public EHANDLE HOwner = new(); + + public override void Test(in Vector3 current_origin, in QAngle current_angles) { + Origin = current_origin; + + MathLib.AngleVectors(current_angles, out Vector3 forward); + forward.Z = 0.0f; + MathLib.VectorNormalize(ref forward); + + Velocity = forward * 2048; + LifeTime = 5; + HOwner.Set(null); + + BroadcastRecipientFilter filter = new(); + Create(ref filter, 0.0f); + } +} + +public static partial class TempEnts +{ + static readonly TEClientProjectile g_TEClientProjectile = new("Client Projectile"); + + public static void TE_ClientProjectile(scoped ref IRF filter, float delay, in Vector3 origin, in Vector3 velocity, int modelindex, int lifetime, BaseEntity? owner) where IRF : IRecipientFilter { + g_TEClientProjectile.Origin = origin; + g_TEClientProjectile.Velocity = velocity; + g_TEClientProjectile.ModelIndex = modelindex; + g_TEClientProjectile.LifeTime = lifetime; + g_TEClientProjectile.HOwner.Set(owner); + + g_TEClientProjectile.Create(ref filter, delay); + } } diff --git a/Game.Server/TEConcussiveExplosion.cs b/Game.Server/TEConcussiveExplosion.cs index 7d881bb7..9af39339 100644 --- a/Game.Server/TEConcussiveExplosion.cs +++ b/Game.Server/TEConcussiveExplosion.cs @@ -22,4 +22,6 @@ public partial class TEConcussiveExplosion(ReadOnlySpan name) : TEParticle public int Radius; [NetworkVar("m_nMagnitude")] public int Magnitude; + + // todo: TE_ConcussiveExplosion sender (hl2/weapon_cguard.cpp) } diff --git a/Game.Server/TEDecal.cs b/Game.Server/TEDecal.cs index 559968ea..e841f97a 100644 --- a/Game.Server/TEDecal.cs +++ b/Game.Server/TEDecal.cs @@ -1,4 +1,6 @@ using Source.Common; +using Source.Common.Formats.BSP; +using Source.Common.Mathematics; using Source; using Game.Shared; using System.Numerics; @@ -25,4 +27,41 @@ public partial class TEDecal(ReadOnlySpan name) : BaseTempEntity(name) public int Hitbox; [NetworkVar("m_nIndex")] public int Index; + + public override void Test(in Vector3 current_origin, in QAngle current_angles) { + Entity = 0; + Index = 0; + Origin = current_origin; + + Origin.Z += 24; + + MathLib.AngleVectors(current_angles, out Vector3 forward); + forward.Z = 0.0f; + MathLib.VectorNormalize(ref forward); + + Origin += forward * 50.0f; + Vector3 vecEnd = Origin + forward * 1024.0f; + + Util.TraceLine(Origin, vecEnd, Mask.SolidBrushOnly, null, Source.CollisionGroup.None, out Trace tr); + + Origin = tr.EndPos; + + BroadcastRecipientFilter filter = new(); + Create(ref filter, 0.0f); + } +} + +public static partial class TempEnts +{ + static readonly TEDecal g_TEDecal = new("Entity Decal"); + + public static void TE_Decal(scoped ref IRF filter, float delay, in Vector3 pos, in Vector3 start, int entity, int hitbox, int index) where IRF : IRecipientFilter { + g_TEDecal.Origin = pos; + g_TEDecal.Start = start; + g_TEDecal.Entity = entity; + g_TEDecal.Hitbox = hitbox; + g_TEDecal.Index = index; + + g_TEDecal.Create(ref filter, delay); + } } diff --git a/Game.Server/TEDust.cs b/Game.Server/TEDust.cs index 3a55d7ca..28d74d46 100644 --- a/Game.Server/TEDust.cs +++ b/Game.Server/TEDust.cs @@ -1,4 +1,5 @@ using Source.Common; +using Source.Common.Mathematics; using Source; using Game.Shared; using System.Numerics; @@ -19,6 +20,8 @@ public partial class TEDust(ReadOnlySpan name) : TEParticleSystem(name) public float LSpeed; [NetworkVar("m_vecDirection")] public Vector3 Direction; + + public override void Test(in Vector3 current_origin, in QAngle current_angles) { } } public static partial class TempEnts diff --git a/Game.Server/TEDynamicLight.cs b/Game.Server/TEDynamicLight.cs index 050733cd..0395e6c3 100644 --- a/Game.Server/TEDynamicLight.cs +++ b/Game.Server/TEDynamicLight.cs @@ -1,4 +1,5 @@ using Source.Common; +using Source.Common.Mathematics; using Source; using Game.Shared; using System.Numerics; @@ -34,4 +35,44 @@ public partial class TEDynamicLight(ReadOnlySpan name) : BaseTempEntity(na public float Time; [NetworkVar("m_fDecay")] public float Decay; + + public override void Test(in Vector3 current_origin, in QAngle current_angles) { + R = 255; + G = 255; + B = 63; + Origin = current_origin; + + Radius = 200; + Time = 2.0f; + Decay = 0.0f; + + Origin.Z += 24; + + MathLib.AngleVectors(current_angles, out Vector3 forward); + forward.Z = 0.0f; + MathLib.VectorNormalize(ref forward); + + Origin += forward * 50.0f; + + BroadcastRecipientFilter filter = new(); + Create(ref filter, 0.0f); + } +} + +public static partial class TempEnts +{ + static readonly TEDynamicLight g_TEDynamicLight = new("Dynamic Light"); + + public static void TE_DynamicLight(scoped ref IRF filter, float delay, in Vector3 org, int r, int g, int b, int exponent, float radius, float time, float decay) where IRF : IRecipientFilter { + g_TEDynamicLight.Origin = org; + g_TEDynamicLight.R = r; + g_TEDynamicLight.G = g; + g_TEDynamicLight.B = b; + g_TEDynamicLight.Exponent = exponent; + g_TEDynamicLight.Radius = radius; + g_TEDynamicLight.Time = time; + g_TEDynamicLight.Decay = decay; + + g_TEDynamicLight.Create(ref filter, delay); + } } diff --git a/Game.Server/TEEnergySplash.cs b/Game.Server/TEEnergySplash.cs index 41fd93b2..09a5ca19 100644 --- a/Game.Server/TEEnergySplash.cs +++ b/Game.Server/TEEnergySplash.cs @@ -1,4 +1,5 @@ using Source.Common; +using Source.Common.Mathematics; using Source; using Game.Shared; using System.Numerics; @@ -19,4 +20,34 @@ public partial class TEEnergySplash(ReadOnlySpan name) : BaseTempEntity(na public Vector3 Dir; [NetworkVar("m_bExplosive")] public int Explosive; + + public override void Test(in Vector3 current_origin, in QAngle current_angles) { + Pos = current_origin; + + MathLib.AngleVectors(current_angles, out Dir); + + Pos.Z += 24; + + Vector3 forward = Dir; + forward.Z = 0.0f; + MathLib.VectorNormalize(ref forward); + + Pos += forward * 100.0f; + + BroadcastRecipientFilter filter = new(); + Create(ref filter, 0.0f); + } +} + +public static partial class TempEnts +{ + static readonly TEEnergySplash g_TEEnergySplash = new("Energy Splash"); + + public static void TE_EnergySplash(scoped ref IRF filter, float delay, in Vector3 pos, in Vector3 dir, bool explosive) where IRF : IRecipientFilter { + g_TEEnergySplash.Pos = pos; + g_TEEnergySplash.Dir = dir; + g_TEEnergySplash.Explosive = explosive ? 1 : 0; + + g_TEEnergySplash.Create(ref filter, delay); + } } diff --git a/Game.Server/TEExplosion.cs b/Game.Server/TEExplosion.cs index 73b2af81..386b876c 100644 --- a/Game.Server/TEExplosion.cs +++ b/Game.Server/TEExplosion.cs @@ -1,4 +1,5 @@ using Source.Common; +using Source.Common.Mathematics; using Source; using Game.Shared; using System.Numerics; @@ -14,16 +15,44 @@ public partial class TEExplosion(ReadOnlySpan name) : TEParticleSystem(nam new(nameof(Magnitude)) { Bits = 16, Flags = PropFlags.Unsigned }, ]; - public int ModelIndex; [NetworkVar("m_fScale")] public float Scale; - public int FrameRate; [NetworkVar("m_nFlags")] public int Flags; - public Vector3 Normal; - public int ChMaterialType; [NetworkVar("m_nRadius")] public int Radius; [NetworkVar("m_nMagnitude")] public int Magnitude; + + public override void Test(in Vector3 current_origin, in QAngle current_angles) { + Scale = 0.5f; + Flags = (int)TempEntExplFlags.None; + Origin = current_origin; + + Origin.Z += 24; + + MathLib.AngleVectors(current_angles, out Vector3 forward); + forward.Z = 0.0f; + MathLib.VectorNormalize(ref forward); + + Origin += forward * 50; + + BroadcastRecipientFilter filter = new(); + Create(ref filter, 0.0f); + } +} + +public static partial class TempEnts +{ + static readonly TEExplosion g_TEExplosion = new("Explosion"); + + public static void TE_Explosion(scoped ref IRF filter, float delay, in Vector3 pos, int modelindex, float scale, int framerate, int flags, int radius, int magnitude, Vector3? normal = null, byte materialType = (byte)'C') where IRF : IRecipientFilter { + g_TEExplosion.Origin = pos; + g_TEExplosion.Scale = scale; + g_TEExplosion.Flags = flags; + g_TEExplosion.Radius = radius; + g_TEExplosion.Magnitude = magnitude; + + g_TEExplosion.Create(ref filter, delay); + } } diff --git a/Game.Server/TEFizz.cs b/Game.Server/TEFizz.cs index cccf951d..0296e0da 100644 --- a/Game.Server/TEFizz.cs +++ b/Game.Server/TEFizz.cs @@ -1,4 +1,5 @@ using Source.Common; +using Source.Common.Mathematics; using Source; using Game.Shared; using System.Numerics; @@ -22,4 +23,32 @@ public partial class TEFizz(ReadOnlySpan name) : BaseTempEntity(name) public int Density; [NetworkVar("m_nCurrent")] public int Current; + + public override void Precache() => BaseEntity.PrecacheModel("sprites/bubble.vmt"); + + public override void Test(in Vector3 current_origin, in QAngle current_angles) { + ModelIndex = BaseEntity.PrecacheModel("sprites/bubble.vmt"); + Density = 200; + Entity = 1; + Current = 100; + + BroadcastRecipientFilter filter = new(); + Create(ref filter, 0.0f); + } +} + +public static partial class TempEnts +{ + static readonly TEFizz g_TEFizz = new("Fizz"); + + public static void TE_Fizz(scoped ref IRF filter, float delay, BaseEntity? entity, int modelindex, int density, int current) where IRF : IRecipientFilter { + Assert(entity != null); + + g_TEFizz.Entity = entity!.EntIndex(); + g_TEFizz.ModelIndex = modelindex; + g_TEFizz.Density = density; + g_TEFizz.Current = current; + + g_TEFizz.Create(ref filter, delay); + } } diff --git a/Game.Server/TEFootprintDecal.cs b/Game.Server/TEFootprintDecal.cs index dcad87ed..1b686ccb 100644 --- a/Game.Server/TEFootprintDecal.cs +++ b/Game.Server/TEFootprintDecal.cs @@ -1,4 +1,5 @@ using Source.Common; +using Source.Common.Mathematics; using Source; using Game.Shared; using System.Numerics; @@ -22,5 +23,20 @@ public partial class TEFootprintDecal(ReadOnlySpan name) : BaseTempEntity( public int Entity; [NetworkVar("m_nIndex")] public int Index; - public int ChMaterialType; +} + +public static partial class TempEnts +{ + static readonly TEFootprintDecal g_TEFootprintDecal = new("Footprint Decal"); + + public static void TE_FootprintDecal(scoped ref IRF filter, float delay, in Vector3 origin, in Vector3 right, int entity, int index, byte materialType) where IRF : IRecipientFilter { + g_TEFootprintDecal.Origin = origin; + g_TEFootprintDecal.Direction = right; + g_TEFootprintDecal.Entity = entity; + g_TEFootprintDecal.Index = index; + + MathLib.VectorNormalize(ref g_TEFootprintDecal.Direction); + + g_TEFootprintDecal.Create(ref filter, delay); + } } diff --git a/Game.Server/TEGaussExplosion.cs b/Game.Server/TEGaussExplosion.cs index 0d0da739..8255f326 100644 --- a/Game.Server/TEGaussExplosion.cs +++ b/Game.Server/TEGaussExplosion.cs @@ -1,4 +1,5 @@ using Source.Common; +using Source.Common.Mathematics; using Source; using Game.Shared; using System.Numerics; @@ -16,4 +17,19 @@ public partial class TEGaussExplosion(ReadOnlySpan name) : TEParticleSyste public int Type; [NetworkVar("m_vecDirection")] public Vector3 Direction; + + public override void Test(in Vector3 current_origin, in QAngle current_angles) { } +} + +public static partial class TempEnts +{ + static readonly TEGaussExplosion g_TEGaussExplosion = new("GaussExplosion"); + + public static void TE_GaussExplosion(scoped ref IRF filter, float delay, in Vector3 pos, in Vector3 dir, int type) where IRF : IRecipientFilter { + g_TEGaussExplosion.Origin = pos; + g_TEGaussExplosion.Direction = dir; + g_TEGaussExplosion.Type = type; + + g_TEGaussExplosion.Create(ref filter, delay); + } } diff --git a/Game.Server/TEGlowSprite.cs b/Game.Server/TEGlowSprite.cs index a3f4cca7..55c6c905 100644 --- a/Game.Server/TEGlowSprite.cs +++ b/Game.Server/TEGlowSprite.cs @@ -1,4 +1,5 @@ using Source.Common; +using Source.Common.Mathematics; using Source; using Game.Shared; using System.Numerics; @@ -25,4 +26,39 @@ public partial class TEGlowSprite(ReadOnlySpan name) : BaseTempEntity(name public float Life; [NetworkVar("m_nBrightness")] public int Brightness; + + public override void Test(in Vector3 current_origin, in QAngle current_angles) { + ModelIndex = BaseCombatWeapon.g_sModelIndexSmoke; + Scale = 0.8f; + Brightness = 200; + Life = 2.0f; + Origin = current_origin; + + Origin.Z += 24; + + MathLib.AngleVectors(current_angles, out Vector3 forward, out Vector3 right, out _); + forward.Z = 0.0f; + MathLib.VectorNormalize(ref forward); + + Origin += forward * 50.0f; + Origin += right * -25.0f; + + BroadcastRecipientFilter filter = new(); + Create(ref filter, 0.0f); + } +} + +public static partial class TempEnts +{ + static readonly TEGlowSprite g_TEGlowSprite = new("GlowSprite"); + + public static void TE_GlowSprite(scoped ref IRF filter, float delay, in Vector3 pos, int modelindex, float life, float size, int brightness) where IRF : IRecipientFilter { + g_TEGlowSprite.Origin = pos; + g_TEGlowSprite.ModelIndex = modelindex; + g_TEGlowSprite.Life = life; + g_TEGlowSprite.Scale = size; + g_TEGlowSprite.Brightness = brightness; + + g_TEGlowSprite.Create(ref filter, delay); + } } diff --git a/Game.Server/TEHL2MPFireBullets.cs b/Game.Server/TEHL2MPFireBullets.cs index 3a9933b5..2f0c503f 100644 --- a/Game.Server/TEHL2MPFireBullets.cs +++ b/Game.Server/TEHL2MPFireBullets.cs @@ -43,4 +43,6 @@ public partial class TEHL2MPFireBullets(ReadOnlySpan name) : BaseTempEntit public InlineArray256 TracerType; [NetworkVar("m_flSpreadY")] public float SpreadY; + + // todo: TE_HL2MPFireBullets sender (hl2mp/te_hl2mp_shotgun_shot.cpp) } diff --git a/Game.Server/TEKillPlayerAttachments.cs b/Game.Server/TEKillPlayerAttachments.cs index 9d61a7e7..fd10b270 100644 --- a/Game.Server/TEKillPlayerAttachments.cs +++ b/Game.Server/TEKillPlayerAttachments.cs @@ -1,4 +1,5 @@ using Source.Common; +using Source.Common.Mathematics; using Source; using Game.Shared; using System.Numerics; @@ -13,4 +14,22 @@ public partial class TEKillPlayerAttachments(ReadOnlySpan name) : BaseTemp [NetworkVar("m_nPlayer")] public int Player; + + public override void Test(in Vector3 current_origin, in QAngle current_angles) { + Player = 1; + + BroadcastRecipientFilter filter = new(); + Create(ref filter, 0.0f); + } +} + +public static partial class TempEnts +{ + static readonly TEKillPlayerAttachments g_TEKillPlayerAttachments = new("KillPlayerAttachments"); + + public static void TE_KillPlayerAttachments(scoped ref IRF filter, float delay, int player) where IRF : IRecipientFilter { + g_TEKillPlayerAttachments.Player = player; + + g_TEKillPlayerAttachments.Create(ref filter, delay); + } } diff --git a/Game.Server/TELargeFunnel.cs b/Game.Server/TELargeFunnel.cs index 4154209c..1a452e23 100644 --- a/Game.Server/TELargeFunnel.cs +++ b/Game.Server/TELargeFunnel.cs @@ -1,4 +1,5 @@ using Source.Common; +using Source.Common.Mathematics; using Source; using Game.Shared; using System.Numerics; @@ -11,7 +12,35 @@ public partial class TELargeFunnel(ReadOnlySpan name) : TEParticleSystem(n new(nameof(Reversed)) { Bits = 2, Flags = PropFlags.Unsigned }, ]; - public int ModelIndex; [NetworkVar("m_nReversed")] public int Reversed; + + public override void Test(in Vector3 current_origin, in QAngle current_angles) { + Reversed = 0; + Origin = current_origin; + + Origin.Z += 24; + + MathLib.AngleVectors(current_angles, out Vector3 forward, out Vector3 right, out _); + forward.Z = 0.0f; + MathLib.VectorNormalize(ref forward); + + Origin += forward * 50.0f; + Origin += right * 25.0f; + + BroadcastRecipientFilter filter = new(); + Create(ref filter, 0.0f); + } +} + +public static partial class TempEnts +{ + static readonly TELargeFunnel g_TELargeFunnel = new("Large Funnel"); + + public static void TE_LargeFunnel(scoped ref IRF filter, float delay, in Vector3 pos, int modelindex, int reversed) where IRF : IRecipientFilter { + g_TELargeFunnel.Origin = pos; + g_TELargeFunnel.Reversed = reversed; + + g_TELargeFunnel.Create(ref filter, delay); + } } diff --git a/Game.Server/TEMetalSparks.cs b/Game.Server/TEMetalSparks.cs index 42bc1502..d924cd4e 100644 --- a/Game.Server/TEMetalSparks.cs +++ b/Game.Server/TEMetalSparks.cs @@ -1,4 +1,5 @@ using Source.Common; +using Source.Common.Mathematics; using Source; using Game.Shared; using System.Numerics; @@ -16,6 +17,23 @@ public partial class TEMetalSparks(ReadOnlySpan name) : BaseTempEntity(nam public Vector3 Pos; [NetworkVar("m_vecDir")] public Vector3 Dir; + + public override void Test(in Vector3 current_origin, in QAngle current_angles) { + Pos = current_origin; + + MathLib.AngleVectors(current_angles, out Dir); + + Pos += new Vector3(0, 0, 24); + + MathLib.AngleVectors(current_angles, out Vector3 forward); + forward.Z = 0.0f; + MathLib.VectorNormalize(ref forward); + + Pos += forward * 100.0f; + + BroadcastRecipientFilter filter = new(); + Create(ref filter, 0.0f); + } } public static partial class TempEnts diff --git a/Game.Server/TEMuzzleFlash.cs b/Game.Server/TEMuzzleFlash.cs index 5ef7c324..cfd0c796 100644 --- a/Game.Server/TEMuzzleFlash.cs +++ b/Game.Server/TEMuzzleFlash.cs @@ -1,4 +1,5 @@ using Source.Common; +using Source.Common.Mathematics; using Source; using Game.Shared; using System.Numerics; @@ -22,4 +23,20 @@ public partial class TEMuzzleFlash(ReadOnlySpan name) : BaseTempEntity(nam public float Scale; [NetworkVar("m_nType")] public int Type; + + public override void Test(in Vector3 current_origin, in QAngle current_angles) { } +} + +public static partial class TempEnts +{ + static readonly TEMuzzleFlash g_TEMuzzleFlash = new("MuzzleFlash"); + + public static void TE_MuzzleFlash(scoped ref IRF filter, float delay, in Vector3 start, in QAngle angles, float scale, int type) where IRF : IRecipientFilter { + g_TEMuzzleFlash.Origin = start; + g_TEMuzzleFlash.Angles = angles; + g_TEMuzzleFlash.Scale = scale; + g_TEMuzzleFlash.Type = type; + + g_TEMuzzleFlash.Create(ref filter, delay); + } } diff --git a/Game.Server/TEPhysicsProp.cs b/Game.Server/TEPhysicsProp.cs index c07cd910..62c3a524 100644 --- a/Game.Server/TEPhysicsProp.cs +++ b/Game.Server/TEPhysicsProp.cs @@ -35,7 +35,50 @@ public partial class TEPhysicsProp(ReadOnlySpan name) : BaseTempEntity(nam [NetworkVar("m_nEffects")] public int Effects; [NetworkVar("m_clrRender")] - public int ClrRender; + public int ClrRender = -1; [NetworkVar("m_fModelScale")] - public float ModelScale; + public float ModelScale = 1.0f; + + public override void Precache() => BaseEntity.PrecacheModel("models/gibs/hgibs.mdl"); + + public override void Test(in Vector3 current_origin, in QAngle current_angles) { + ModelIndex = BaseEntity.PrecacheModel("models/gibs/hgibs.mdl"); + Skin = 0; + Origin = current_origin; + Rotation = current_angles; + Velocity = new Vector3(random.RandomFloat(-10, 10), random.RandomFloat(-10, 10), random.RandomFloat(0, 20)); + Flags = 0; + Effects = 0; + + Origin += new Vector3(0, 0, 24); + + MathLib.AngleVectors(current_angles, out Vector3 forward, out Vector3 right, out _); + forward.Z = 0.0f; + MathLib.VectorNormalize(ref forward); + + Origin += forward * 50.0f; + Origin += right * 25.0f; + + BroadcastRecipientFilter filter = new(); + Create(ref filter, 0.0f); + } +} + +public static partial class TempEnts +{ + static readonly TEPhysicsProp s_TEPhysicsProp = new("physicsprop"); + + public static void TE_PhysicsProp(scoped ref IRF filter, float delay, int modelindex, int skin, in Vector3 pos, in QAngle angles, in Vector3 vel, int flags, int effects, Color clrRender, float modelScale) where IRF : IRecipientFilter { + s_TEPhysicsProp.Origin = pos; + s_TEPhysicsProp.Rotation = angles; + s_TEPhysicsProp.Velocity = vel; + s_TEPhysicsProp.ModelIndex = modelindex; + s_TEPhysicsProp.Skin = skin; + s_TEPhysicsProp.Flags = flags; + s_TEPhysicsProp.Effects = effects; + s_TEPhysicsProp.ClrRender = clrRender.GetRawColor(); + s_TEPhysicsProp.ModelScale = modelScale; + + s_TEPhysicsProp.Create(ref filter, delay); + } } diff --git a/Game.Server/TEPlayerDecal.cs b/Game.Server/TEPlayerDecal.cs index dd5d633b..824a1957 100644 --- a/Game.Server/TEPlayerDecal.cs +++ b/Game.Server/TEPlayerDecal.cs @@ -1,4 +1,6 @@ using Source.Common; +using Source.Common.Formats.BSP; +using Source.Common.Mathematics; using Source; using Game.Shared; using System.Numerics; @@ -19,4 +21,39 @@ public partial class TEPlayerDecal(ReadOnlySpan name) : BaseTempEntity(nam public int Entity; [NetworkVar("m_nPlayer")] public int Player; + + public override void Test(in Vector3 current_origin, in QAngle current_angles) { + Player = 1; + Entity = 0; + Origin = current_origin; + + Origin.Z += 24; + + MathLib.AngleVectors(current_angles, out Vector3 forward); + forward.Z = 0.0f; + MathLib.VectorNormalize(ref forward); + + Origin += forward * 50.0f; + Vector3 vecEnd = Origin + forward * 1024.0f; + + Util.TraceLine(Origin, vecEnd, Mask.SolidBrushOnly, null, Source.CollisionGroup.None, out Trace tr); + + Origin = tr.EndPos; + + BroadcastRecipientFilter filter = new(); + Create(ref filter, 0.0f); + } +} + +public static partial class TempEnts +{ + static readonly TEPlayerDecal g_TEPlayerDecal = new("Player Decal"); + + public static void TE_PlayerDecal(scoped ref IRF filter, float delay, in Vector3 pos, int player, int entity) where IRF : IRecipientFilter { + g_TEPlayerDecal.Origin = pos; + g_TEPlayerDecal.Player = player; + g_TEPlayerDecal.Entity = entity; + + g_TEPlayerDecal.Create(ref filter, delay); + } } diff --git a/Game.Server/TEProjectedDecal.cs b/Game.Server/TEProjectedDecal.cs index 5c3639fe..a4f6db71 100644 --- a/Game.Server/TEProjectedDecal.cs +++ b/Game.Server/TEProjectedDecal.cs @@ -1,4 +1,5 @@ using Source.Common; +using Source.Common.Mathematics; using Source; using Game.Shared; using System.Numerics; @@ -22,4 +23,36 @@ public partial class TEProjectedDecal(ReadOnlySpan name) : BaseTempEntity( public float LDistance; [NetworkVar("m_nIndex")] public int Index; + + public override void Test(in Vector3 current_origin, in QAngle current_angles) { + LDistance = 1024.0f; + Index = 0; + Origin = current_origin; + Rotation = current_angles; + + Origin.Z += 24; + + MathLib.AngleVectors(current_angles, out Vector3 forward); + forward.Z = 0.0f; + MathLib.VectorNormalize(ref forward); + + Origin += forward * 24.0f; + + BroadcastRecipientFilter filter = new(); + Create(ref filter, 0.0f); + } +} + +public static partial class TempEnts +{ + static readonly TEProjectedDecal g_TEProjectedDecal = new("Projected Decal"); + + public static void TE_ProjectDecal(scoped ref IRF filter, float delay, in Vector3 pos, in QAngle angles, float distance, int index) where IRF : IRecipientFilter { + g_TEProjectedDecal.Origin = pos; + g_TEProjectedDecal.Rotation = angles; + g_TEProjectedDecal.LDistance = distance; + g_TEProjectedDecal.Index = index; + + g_TEProjectedDecal.Create(ref filter, delay); + } } diff --git a/Game.Server/TEShatterSurface.cs b/Game.Server/TEShatterSurface.cs index 2a64d390..3c1d1bb5 100644 --- a/Game.Server/TEShatterSurface.cs +++ b/Game.Server/TEShatterSurface.cs @@ -1,4 +1,6 @@ using Source.Common; +using Source.Common.Formats.BSP; +using Source.Common.Mathematics; using Source; using Game.Shared; using System.Numerics; @@ -41,4 +43,48 @@ public partial class TEShatterSurface(ReadOnlySpan name) : BaseTempEntity( public InlineArray3 UchFrontColor; [NetworkVar("m_uchBackColor")] public InlineArray3 UchBackColor; + + public override void Test(in Vector3 current_origin, in QAngle current_angles) { + Origin = current_origin; + + Origin.Z += 24; + + MathLib.AngleVectors(current_angles, out Vector3 forward); + forward.Z = 0.0f; + MathLib.VectorNormalize(ref forward); + + Origin += forward * 50.0f; + Vector3 vecEnd = Origin + forward * 1024.0f; + + Util.TraceLine(Origin, vecEnd, Mask.SolidBrushOnly, null, Source.CollisionGroup.None, out Trace tr); + + Origin = tr.EndPos; + + BroadcastRecipientFilter filter = new(); + Create(ref filter, 0.0f); + } +} + +public static partial class TempEnts +{ + static readonly TEShatterSurface g_TEShatterSurface = new("Surface Shatter"); + + public static void TE_ShatterSurface(scoped ref IRF filter, float delay, in Vector3 pos, in QAngle angle, in Vector3 force, in Vector3 forcePos, float width, float height, float shardsize, ShatterSurface surfacetype, int front_r, int front_g, int front_b, int back_r, int back_g, int back_b) where IRF : IRecipientFilter { + g_TEShatterSurface.Origin = pos; + g_TEShatterSurface.Angles = angle; + g_TEShatterSurface.Force = force; + g_TEShatterSurface.ForcePos = forcePos; + g_TEShatterSurface.Width = width; + g_TEShatterSurface.Height = height; + g_TEShatterSurface.ShardSize = shardsize; + g_TEShatterSurface.SurfaceType = (int)surfacetype; + g_TEShatterSurface.UchFrontColor[0] = (byte)front_r; + g_TEShatterSurface.UchFrontColor[1] = (byte)front_g; + g_TEShatterSurface.UchFrontColor[2] = (byte)front_b; + g_TEShatterSurface.UchBackColor[0] = (byte)back_r; + g_TEShatterSurface.UchBackColor[1] = (byte)back_g; + g_TEShatterSurface.UchBackColor[2] = (byte)back_b; + + g_TEShatterSurface.Create(ref filter, delay); + } } diff --git a/Game.Server/TEShowLine.cs b/Game.Server/TEShowLine.cs index 86202a7e..7ca8297b 100644 --- a/Game.Server/TEShowLine.cs +++ b/Game.Server/TEShowLine.cs @@ -1,4 +1,5 @@ using Source.Common; +using Source.Common.Mathematics; using Source; using Game.Shared; using System.Numerics; @@ -13,4 +14,34 @@ public partial class TEShowLine(ReadOnlySpan name) : TEParticleSystem(name [NetworkVar("m_vecEnd")] public Vector3 End; + + public override void Test(in Vector3 current_origin, in QAngle current_angles) { + Origin = current_origin; + + Origin.Z += 24; + + MathLib.AngleVectors(current_angles, out Vector3 forward, out Vector3 right, out _); + forward.Z = 0.0f; + MathLib.VectorNormalize(ref forward); + + End = Origin + forward * 100.0f; + + Origin = End + right * -128; + End += right * 128; + + BroadcastRecipientFilter filter = new(); + Create(ref filter, 0.0f); + } +} + +public static partial class TempEnts +{ + static readonly TEShowLine g_TEShowLine = new("Show Line"); + + public static void TE_ShowLine(scoped ref IRF filter, float delay, in Vector3 start, in Vector3 end) where IRF : IRecipientFilter { + g_TEShowLine.Origin = start; + g_TEShowLine.End = end; + + g_TEShowLine.Create(ref filter, delay); + } } diff --git a/Game.Server/TESmoke.cs b/Game.Server/TESmoke.cs index 8f50aaf1..647067fb 100644 --- a/Game.Server/TESmoke.cs +++ b/Game.Server/TESmoke.cs @@ -1,4 +1,5 @@ using Source.Common; +using Source.Common.Mathematics; using Source; using Game.Shared; using System.Numerics; @@ -22,4 +23,37 @@ public partial class TESmoke(ReadOnlySpan name) : BaseTempEntity(name) public float Scale; [NetworkVar("m_nFrameRate")] public int FrameRate; + + public override void Test(in Vector3 current_origin, in QAngle current_angles) { + ModelIndex = BaseCombatWeapon.g_sModelIndexSmoke; + Scale = 5.0f; + FrameRate = 12; + Origin = current_origin; + + Origin.Z += 24; + + MathLib.AngleVectors(current_angles, out Vector3 forward, out Vector3 right, out _); + forward.Z = 0.0f; + MathLib.VectorNormalize(ref forward); + + Origin += forward * 50.0f; + Origin += right * 25.0f; + + BroadcastRecipientFilter filter = new(); + Create(ref filter, 0.0f); + } +} + +public static partial class TempEnts +{ + static readonly TESmoke g_TESmoke = new("Smoke"); + + public static void TE_Smoke(scoped ref IRF filter, float delay, in Vector3 pos, int modelindex, float scale, int framerate) where IRF : IRecipientFilter { + g_TESmoke.Origin = pos; + g_TESmoke.ModelIndex = modelindex; + g_TESmoke.Scale = scale; + g_TESmoke.FrameRate = framerate; + + g_TESmoke.Create(ref filter, delay); + } } diff --git a/Game.Server/TESparks.cs b/Game.Server/TESparks.cs index d6543fe6..8d5a2ff4 100644 --- a/Game.Server/TESparks.cs +++ b/Game.Server/TESparks.cs @@ -1,4 +1,5 @@ using Source.Common; +using Source.Common.Mathematics; using Source; using Game.Shared; using System.Numerics; @@ -19,4 +20,33 @@ public partial class TESparks(ReadOnlySpan name) : TEParticleSystem(name) public int TrailLength; [NetworkVar("m_vecDir")] public Vector3 Dir; + + public override void Test(in Vector3 current_origin, in QAngle current_angles) { + Origin = current_origin; + + Origin.Z += 24; + + MathLib.AngleVectors(current_angles, out Vector3 forward); + forward.Z = 0.0f; + MathLib.VectorNormalize(ref forward); + + Origin += forward * 100; + + BroadcastRecipientFilter filter = new(); + Create(ref filter, 0.0f); + } +} + +public static partial class TempEnts +{ + static readonly TESparks g_TESparks = new("Sparks"); + + public static void TE_Sparks(scoped ref IRF filter, float delay, in Vector3 pos, int magnitude, int trailLength, in Vector3 dir) where IRF : IRecipientFilter { + g_TESparks.Origin = pos; + g_TESparks.Magnitude = magnitude; + g_TESparks.TrailLength = trailLength; + g_TESparks.Dir = dir; + + g_TESparks.Create(ref filter, delay); + } } diff --git a/Game.Server/TESprite.cs b/Game.Server/TESprite.cs index 5af4ddce..299a3d72 100644 --- a/Game.Server/TESprite.cs +++ b/Game.Server/TESprite.cs @@ -1,4 +1,5 @@ using Source.Common; +using Source.Common.Mathematics; using Source; using Game.Shared; using System.Numerics; @@ -22,4 +23,39 @@ public partial class TESprite(ReadOnlySpan name) : BaseTempEntity(name) public float Scale; [NetworkVar("m_nBrightness")] public int Brightness; + + public override void Precache() => BaseEntity.PrecacheModel("sprites/gunsmoke.vmt"); + + public override void Test(in Vector3 current_origin, in QAngle current_angles) { + ModelIndex = BaseEntity.PrecacheModel("sprites/gunsmoke.vmt"); + Scale = 0.8f; + Brightness = 200; + Origin = current_origin; + + Origin.Z += 24; + + MathLib.AngleVectors(current_angles, out Vector3 forward, out Vector3 right, out _); + forward.Z = 0.0f; + MathLib.VectorNormalize(ref forward); + + Origin += forward * 50.0f; + Origin += right * -25.0f; + + BroadcastRecipientFilter filter = new(); + Create(ref filter, 0.0f); + } +} + +public static partial class TempEnts +{ + static readonly TESprite g_TESprite = new("Sprite"); + + public static void TE_Sprite(scoped ref IRF filter, float delay, in Vector3 pos, int modelindex, float size, int brightness) where IRF : IRecipientFilter { + g_TESprite.Origin = pos; + g_TESprite.ModelIndex = modelindex; + g_TESprite.Scale = size; + g_TESprite.Brightness = brightness; + + g_TESprite.Create(ref filter, delay); + } } diff --git a/Game.Server/TESpriteSpray.cs b/Game.Server/TESpriteSpray.cs index effb39cd..eceaf7fb 100644 --- a/Game.Server/TESpriteSpray.cs +++ b/Game.Server/TESpriteSpray.cs @@ -1,4 +1,5 @@ using Source.Common; +using Source.Common.Mathematics; using Source; using Game.Shared; using System.Numerics; @@ -28,4 +29,42 @@ public partial class TESpriteSpray(ReadOnlySpan name) : BaseTempEntity(nam public int Speed; [NetworkVar("m_nCount")] public int Count; + + public override void Test(in Vector3 current_origin, in QAngle current_angles) { + ModelIndex = BaseCombatWeapon.g_sModelIndexSmoke; + Noise = 0.8f; + Count = 5; + Speed = 30; + Origin = current_origin; + + Origin.Z += 24; + + MathLib.AngleVectors(current_angles, out Vector3 forward, out Vector3 right, out _); + forward.Z = 0.0f; + MathLib.VectorNormalize(ref forward); + + Origin += forward * 50.0f; + Origin += right * -25.0f; + + Direction = new Vector3(random.RandomInt(-100, 100), random.RandomInt(-100, 100), random.RandomInt(0, 100)); + + BroadcastRecipientFilter filter = new(); + Create(ref filter, 0.0f); + } +} + +public static partial class TempEnts +{ + static readonly TESpriteSpray g_TESpriteSpray = new("Sprite Spray"); + + public static void TE_SpriteSpray(scoped ref IRF filter, float delay, in Vector3 pos, in Vector3 dir, int modelindex, int speed, float noise, int count) where IRF : IRecipientFilter { + g_TESpriteSpray.Origin = pos; + g_TESpriteSpray.Direction = dir; + g_TESpriteSpray.ModelIndex = modelindex; + g_TESpriteSpray.Speed = speed; + g_TESpriteSpray.Noise = noise; + g_TESpriteSpray.Count = count; + + g_TESpriteSpray.Create(ref filter, delay); + } } diff --git a/Game.Server/TEWorldDecal.cs b/Game.Server/TEWorldDecal.cs index 8f22f028..76024bea 100644 --- a/Game.Server/TEWorldDecal.cs +++ b/Game.Server/TEWorldDecal.cs @@ -1,4 +1,6 @@ using Source.Common; +using Source.Common.Formats.BSP; +using Source.Common.Mathematics; using Source; using Game.Shared; using System.Numerics; @@ -16,4 +18,37 @@ public partial class TEWorldDecal(ReadOnlySpan name) : BaseTempEntity(name public Vector3 Origin; [NetworkVar("m_nIndex")] public int Index; + + public override void Test(in Vector3 current_origin, in QAngle current_angles) { + Index = 0; + Origin = current_origin; + + Origin.Z += 24; + + MathLib.AngleVectors(current_angles, out Vector3 forward); + forward.Z = 0.0f; + MathLib.VectorNormalize(ref forward); + + Origin += forward * 50.0f; + Vector3 vecEnd = Origin + forward * 1024.0f; + + Util.TraceLine(Origin, vecEnd, Mask.SolidBrushOnly, null, Source.CollisionGroup.None, out Trace tr); + + Origin = tr.EndPos; + + BroadcastRecipientFilter filter = new(); + Create(ref filter, 0.0f); + } +} + +public static partial class TempEnts +{ + static readonly TEWorldDecal g_TEWorldDecal = new("World Decal"); + + public static void TE_WorldDecal(scoped ref IRF filter, float delay, in Vector3 pos, int index) where IRF : IRecipientFilter { + g_TEWorldDecal.Origin = pos; + g_TEWorldDecal.Index = index; + + g_TEWorldDecal.Create(ref filter, delay); + } } diff --git a/Game.Server/Util.cs b/Game.Server/Util.cs index 936d2c2e..a1246f74 100644 --- a/Game.Server/Util.cs +++ b/Game.Server/Util.cs @@ -734,6 +734,16 @@ public static void RemoveSafe(BaseEntity? entity) { } #endif + public static Vector3 RandomBloodVector() { + Vector3 direction; + + direction.X = random.RandomFloat(-1, 1); + direction.Y = random.RandomFloat(-1, 1); + direction.Z = random.RandomFloat(0, 1); + + return direction; + } + public static void Remove(BaseEntity? entity) { if (entity == null) return; diff --git a/Game.Shared/IPredictionSystem.cs b/Game.Shared/IPredictionSystem.cs index 77ef0209..2a2742e4 100644 --- a/Game.Shared/IPredictionSystem.cs +++ b/Game.Shared/IPredictionSystem.cs @@ -42,6 +42,7 @@ public static void SuppressHostEvents(BaseEntity? host) { public bool SuppressEvent; + // todo: GMod keeps the suppress host as an EHANDLE, so a removed host counts as no host public BaseEntity? SuppressHost; public int StatusPushed; diff --git a/Game.Shared/ITempEnts.cs b/Game.Shared/ITempEnts.cs index 1333f347..30a90505 100644 --- a/Game.Shared/ITempEnts.cs +++ b/Game.Shared/ITempEnts.cs @@ -1,4 +1,5 @@ #if CLIENT_DLL || GAME_DLL +using Source; using Source.Common; using Source.Common.Formats.Keyvalues; using Source.Common.Mathematics; @@ -102,7 +103,7 @@ public abstract void GaussExplosion(scoped ref IRF filer, float delay, public abstract void DispatchEffect(scoped ref IRF filter, float delay, in Vector3 pos, ReadOnlySpan name, EffectData data) where IRF : IRecipientFilter; public abstract void PhysicsProp(scoped ref IRF filter, float delay, int modelindex, int skin, - in Vector3 pos, in QAngle angles, in Vector3 vel, int flags, int effects) where IRF : IRecipientFilter; + in Vector3 pos, in QAngle angles, in Vector3 vel, int flags, int effects, Color clrRender, float modelScale) where IRF : IRecipientFilter; // For playback from external tools public abstract void TriggerTempEntity(KeyValues pKeyValues);