From f3b239abbc35c6622744290334c2a271a9519fc8 Mon Sep 17 00:00:00 2001 From: Marco Cawthorne Date: Thu, 5 Oct 2023 00:32:47 -0700 Subject: [PATCH] Concussion grenade and Hallucination grenade implementation coming along further --- src/client/defs.h | 3 ++ src/client/hallucination.qc | 84 +++++++++++++++++++++++++++++++++++++ src/client/progs.src | 1 + src/server/nades.qc | 20 +++++++++ src/shared/player.qc | 38 ++++++++++++++++- 5 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 src/client/hallucination.qc diff --git a/src/client/defs.h b/src/client/defs.h index ec658c4..5106619 100644 --- a/src/client/defs.h +++ b/src/client/defs.h @@ -27,3 +27,6 @@ var string g_tfchud6_spr; var string g_tfchud7_spr; var int MUZZLE_ROUND; + + +void TFCHallucination_Insert(vector, vector); \ No newline at end of file diff --git a/src/client/hallucination.qc b/src/client/hallucination.qc new file mode 100644 index 0000000..30e197f --- /dev/null +++ b/src/client/hallucination.qc @@ -0,0 +1,84 @@ +class +TFCHallucination:NSEntity +{ + +}; + +void +TFCHallucination_Insert(vector viewPosition, vector viewDirection) +{ + int r = 0i; + vector halluPos = viewPosition; + + halluPos += v_forward * random(8, 128); + halluPos += v_up * random(-64, 128); + halluPos += v_right * random(-256, 256); + + traceline(viewPosition, halluPos, MOVE_NORMAL, pSeat->m_ePlayer); + halluPos = trace_endpos; + + makevectors(viewDirection); + + r = (int)(floor(random(0, 8))); + + switch (r) { + case 1: + for (int i = 0; i < 3; i++) { + FX_Blood(halluPos, [1,0,0]); + halluPos += v_forward * random(8, 128); + halluPos += v_up * random(-64, 128); + halluPos += v_right * random(-256, 256); + } + break; + case 2: + pointparticles(particleeffectnum("fx_explosion.main"), halluPos, [0,0,0], 1); + pSeat->m_flShakeDuration = 2; + pSeat->m_flShakeAmp = 5.0; + pSeat->m_flShakeFreq = 2; + pSeat->m_flShakeTime = 2; + pointsound(halluPos, sprintf("weapons/explode%d.wav", floor(random() * 2) + 3), 1, ATTN_NORM); + break; + case 3: + traceline(viewPosition, halluPos + (v_forward * 1024), MOVE_NORMAL, pSeat->m_ePlayer); + SurfData_Impact(world, trace_endpos, [0,0,0]); + DecalGroups_Place("Impact.Shot", trace_endpos); + pointsound(halluPos, "weapons/sbarrel1.wav", 1, ATTN_NORM); + break; + case 4: + pSeat->m_flShakeDuration = 1; + pSeat->m_flShakeAmp = 1.0; + pSeat->m_flShakeFreq = 2; + pSeat->m_flShakeTime = 2; + pointsound(halluPos, "weapons/cbar_hitbod1.wav", 1, ATTN_NORM); + break; + case 5: + traceline(viewPosition, halluPos + (v_forward * 1024), MOVE_NORMAL, pSeat->m_ePlayer); + SurfData_Impact(world, trace_endpos, [0,0,0]); + DecalGroups_Place("Impact.Shot", trace_endpos); + pointsound(halluPos, "weapons/sniper.wav", 1, ATTN_NORM); + break; + case 6: + traceline(viewPosition, halluPos + (v_forward * 1024), MOVE_NORMAL, pSeat->m_ePlayer); + SurfData_Impact(world, trace_endpos, [0,0,0]); + DecalGroups_Place("Impact.Shot", trace_endpos); + pointsound(halluPos, "weapons/airgun_1.wav", 1, ATTN_NORM); + break; + case 7: + NSRenderableEntity eNade = spawn(NSRenderableEntity); + eNade.SetModel("models/w_grenade.mdl"); + eNade.SetOrigin(halluPos); + eNade.SetMovetype(MOVETYPE_BOUNCE); + eNade.SetSolid(SOLID_NOT); + eNade.SetGravity(1.0f); + eNade.SetVelocity(v_forward * random(-320,320) + v_right * random(-64, 64) + v_up * 200); + eNade.SetAngularVelocity([300, 300, 300]); + eNade.SetAngles(vectoangles(eNade.GetVelocity())); + eNade.ScheduleThink(eNade.Destroy, 5.0f); + eNade.drawmask = MASK_ENGINE; + pointsound(halluPos, "weapons/grenade_hit3.wav", 1, ATTN_NORM); + break; + default: + pointsound(halluPos, "weapons/rocketfire1.wav", 1, ATTN_NORM); + break; + } +}; \ No newline at end of file diff --git a/src/client/progs.src b/src/client/progs.src index a0137a9..5826ec4 100644 --- a/src/client/progs.src +++ b/src/client/progs.src @@ -29,6 +29,7 @@ init.qc entities.qc cmds.qc game_event.qc +hallucination.qc ../../../valve/src/client/camera.qc ../../../valve/src/client/viewmodel.qc ../../../valve/src/client/view.qc diff --git a/src/server/nades.qc b/src/server/nades.qc index a4f2425..9a62ff6 100644 --- a/src/server/nades.qc +++ b/src/server/nades.qc @@ -90,6 +90,19 @@ TFCNade_ThrowConcussion(player pl) } static void TFCNade_ThrowConcussion_Explode(void) { + for (player f = world; (f = (player)find(f, ::classname, "player"));) { + float dist = vlen(f.origin - self.origin); + + if (dist < 256) { + vector pushVel; + f.m_flIdleScale = 15.0f; + makevectors(f.origin - self.origin); + pushVel = v_forward * 300; + pushVel[2] += 300; + f.SetVelocity(pushVel); + } + } + NSEntity::Destroy(); } @@ -335,6 +348,13 @@ TFCNade_ThrowHallucination(player pl) } static void TFCNade_ThrowConcussion_Explode(void) { + for (player f = world; (f = (player)find(f, ::classname, "player"));) { + float dist = vlen(f.origin - self.origin); + + if (dist < 192) { + f.m_flHallucination = 15.0f; + } + } NSEntity::Destroy(); } diff --git a/src/shared/player.qc b/src/shared/player.qc index 418f89f..73a4e9f 100644 --- a/src/shared/player.qc +++ b/src/shared/player.qc @@ -58,6 +58,9 @@ class player:NSClientPlayer /* ammo 3 */ PREDICTED_INT(mode_tempstate) + PREDICTED_FLOAT(m_flIdleScale) + PREDICTED_FLOAT(m_flHallucination) + virtual void Physics_Jump(void); virtual float Physics_MaxSpeed(void); @@ -76,6 +79,8 @@ class player:NSClientPlayer virtual void UpdateAliveCam(void); virtual void UpdatePlayerAttachments(bool); + float m_flNextHallucination; + #else NSTimer gren1; NSTimer gren2; @@ -98,7 +103,7 @@ class player:NSClientPlayer virtual void ServerInputFrame(void); nonvirtual void TFC_FragSelf(void); - nonvirtual void TFC_FragSelf(void); + nonvirtual void TFC_ThrowSecondary(void); #endif }; @@ -328,6 +333,13 @@ player::UpdateAliveCam(void) g_view.SetCameraOrigin(cam_pos); Camera_StrafeRoll(view_angles); + + if (m_flIdleScale > 0.0) { + float wave = sin(time); + view_angles[0] -= m_flIdleScale * sin(1 * time) * 0.9; + view_angles[1] -= m_flIdleScale * sin(2 * time) * 0.9; + view_angles[2] -= m_flIdleScale * sin(0.5 * time) * 0.3; + } g_view.SetCameraAngle(view_angles); if (vehicle) { @@ -381,6 +393,8 @@ player::ReceiveEntity(float new, float flChanged) READENTITY_BYTE(mode_tempstate, PLAYER_AMMO3) READENTITY_BYTE(classtype, PLAYER_AMMO3) + READENTITY_FLOAT(m_flIdleScale, PLAYER_AMMO3) + READENTITY_FLOAT(m_flHallucination, PLAYER_AMMO3) setorigin(this, origin); @@ -400,6 +414,14 @@ player::ReceiveEntity(float new, float flChanged) if (flChanged & PLAYER_ITEMS || flChanged & PLAYER_HEALTH) HUD_ItemNotify_Check(this); + + if (m_flHallucination > 0.0) { + if (m_flNextHallucination > time) + return; + + TFCHallucination_Insert(origin, v_angle); + m_flNextHallucination = time + 0.5f + random(); + } } /* @@ -436,6 +458,8 @@ player::PredictPreFrame(void) SAVE_STATE(mode_tempstate) SAVE_STATE(classtype) + SAVE_STATE(m_flIdleScale) + SAVE_STATE(m_flHallucination) } /* @@ -471,6 +495,8 @@ player::PredictPostFrame(void) ROLL_BACK(mode_tempstate) ROLL_BACK(classtype) + ROLL_BACK(m_flIdleScale) + ROLL_BACK(m_flHallucination) } #else @@ -480,6 +506,12 @@ player::ServerInputFrame(void) super::ServerInputFrame(); gflags &= ~GF_NOBUILDZONE; gflags &= ~GF_NOGRENADEZONE; + + m_flIdleScale -= input_timelength; + m_flHallucination -= input_timelength; + + if (m_flIdleScale <= 0.0) + m_flIdleScale = 0.0f; } void @@ -509,6 +541,8 @@ player::EvaluateEntity(void) EVALUATE_FIELD(mode_tempstate, PLAYER_AMMO3) EVALUATE_FIELD(classtype, PLAYER_AMMO3) + EVALUATE_FIELD(m_flIdleScale, PLAYER_AMMO3) + EVALUATE_FIELD(m_flHallucination, PLAYER_AMMO3) } void @@ -777,6 +811,8 @@ player::SendEntity(entity ePEnt, float flChanged) SENDENTITY_BYTE(mode_tempstate, PLAYER_AMMO3) SENDENTITY_BYTE(classtype, PLAYER_AMMO3) + SENDENTITY_FLOAT(m_flIdleScale, PLAYER_AMMO3) + SENDENTITY_FLOAT(m_flHallucination, PLAYER_AMMO3) return (1); }