From 2db9152e1b730b57df2e08d713a50a4b4d06f963 Mon Sep 17 00:00:00 2001 From: Xylemon Date: Tue, 17 Jan 2023 16:44:48 -0800 Subject: [PATCH] Railgun now fully works, just needs visual fluff. Nailgun now uses modern crosshair approach --- src/shared/w_nailgun.qc | 35 ++-------- src/shared/w_railgun.qc | 91 ++++++++++++++++++++++--- zpak001.pk3dir/sound/weapons_tfc.sndshd | 5 ++ 3 files changed, 93 insertions(+), 38 deletions(-) diff --git a/src/shared/w_nailgun.qc b/src/shared/w_nailgun.qc index 12c6597..28dc0cf 100644 --- a/src/shared/w_nailgun.qc +++ b/src/shared/w_nailgun.qc @@ -136,38 +136,13 @@ w_nailgun_primary(player pl) } void -w_nailgun_hud(player pl) +w_nailgun_crosshair(player pl) { #ifdef CLIENT - vector cross_pos; - vector aicon_pos; - - /* crosshair/laser */ - cross_pos = g_hudmins + (g_hudres / 2) + [-12,-12]; - drawsubpic( - cross_pos, - [24,24], - g_cross_spr, - [0.1875,0], - [0.1875, 0.1875], - [1,1,1], - 1.0f, - DRAWFLAG_NORMAL - ); - + Cross_DrawSub(g_cross_spr, [24,24], [0.1875,0], [0.1875, 0.1875]); HUD_DrawAmmo2(); - - aicon_pos = g_hudmins + [g_hudres[0] - 48, g_hudres[1] - 42]; - drawsubpic( - aicon_pos, - [24,24], - g_hud7_spr, - [0,72/128], - [24/256, 24/128], - g_hud_color, - pSeatLocal->m_flAmmo2Alpha, - DRAWFLAG_ADDITIVE - ); + vector aicon_pos = g_hudmins + [g_hudres[0] - 48, g_hudres[1] - 42]; + drawsubpic(aicon_pos, [24,24], g_hud7_spr, [0,72/128],[24/256, 24/128], g_hud_color, pSeatLocal->m_flAmmo2Alpha, DRAWFLAG_ADDITIVE); #endif } @@ -213,7 +188,7 @@ weapon_t w_nailgun = .secondary = __NULL__, .reload = __NULL__, .release = __NULL__, - .postdraw = w_nailgun_hud, + .postdraw = w_nailgun_crosshair, .precache = w_nailgun_precache, .pickup = __NULL__, .updateammo = w_nailgun_updateammo, diff --git a/src/shared/w_railgun.qc b/src/shared/w_railgun.qc index dab3db6..dcfeb0f 100644 --- a/src/shared/w_railgun.qc +++ b/src/shared/w_railgun.qc @@ -1,5 +1,6 @@ /* - * Copyright (c) 2016-2020 Marco Cawthorne + * Copyright (c) 2016-2023 Marco Cawthorne + * Copyright (c) 2023 Gethyn ThomasQuail * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -14,20 +15,27 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +enum +{ + RAILGUN_IDLE, + RAILGUN_SHOOT, + RAILGUN_DRAW, + RAILGUN_HOLSTER, +}; + void w_railgun_precache(void) { precache_model("models/v_tfc_railgun.mdl"); precache_model("models/w_railgun.mdl"); precache_model("models/p_railgun.mdl"); + Sound_Precache("weapon_railgun.fire"); } void w_railgun_updateammo(player pl) { -#ifdef SERVER - Weapons_UpdateAmmo(pl, __NULL__, __NULL__, __NULL__); -#endif + Weapons_UpdateAmmo(pl, __NULL__, pl.m_iAmmoNails, __NULL__); } string @@ -44,7 +52,7 @@ w_railgun_pmodel(player pl) string w_railgun_deathmsg(void) { - return "%s was assaulted by %s's Assault Cannon."; + return "%s was assaulted by %s's railgun."; } void @@ -57,7 +65,74 @@ w_railgun_draw(player pl) float w_railgun_aimanim(player pl) { - return self.flags & FL_CROUCHING ? ANIM_CR_AIMCROWBAR : ANIM_AIMCROWBAR; + return pl.flags & FL_CROUCHING ? ANIM_CR_AIM1HAND : ANIM_AIM1HAND; +} + +void +w_railgun_shootbeam(player pl) +{ + static void w_railgun_shootbeam_touch(void) { + #ifndef CLIENT + /* impact per bullet */ + if (trace_ent.iBleeds == 0) { + DecalGroups_Place("Impact.BigShot", trace_endpos + (v_forward * -2)); + SurfData_Impact(trace_ent, trace_surfaceflagsi, trace_endpos, trace_plane_normal); + } + #endif + remove(self); + } + + Weapons_MakeVectors(pl); + entity p = spawn(); + setmodel(p, "models/nail.mdl"); + setorigin(p, Weapons_GetCameraPos(pl) + (v_forward * 14) + (v_up * -4) + (v_right * 2)); + p.owner = self; + p.movetype = MOVETYPE_FLYMISSILE; + p.solid = SOLID_BBOX; + p.gravity = 0.5f; + p.velocity = (v_forward * 1000) + (v_up * 4) + (v_right * -2); + p.angles = vectoangles(p.velocity); + p.touch = w_railgun_shootbeam_touch; + p.think = Util_Destroy; + p.nextthink = time + 5.0f; +} + +void +w_railgun_primary(player pl) +{ + int s = w_baseprojectile_fire(pl, WEAPON_RAILGUN, player::m_iAmmoNails, w_railgun_shootbeam); + + switch (s) { + case AUTO_FIRE_FAILED: + return; + break; + case AUTO_FIRED: + case AUTO_LAST: + int r = (float)input_sequence % 3; + Weapons_ViewAnimation(pl, RAILGUN_SHOOT); + Weapons_ViewPunchAngle(pl, [-1,0,0]); + #ifndef CLIENT + Sound_Play(pl, CHAN_WEAPON, "weapon_railgun.fire"); + #endif + pl.w_attack_next = 0.4f; + break; + case AUTO_EMPTY: + pl.w_attack_next = 0.2f; + break; + } + + pl.w_idle_next = 1.5f; +} + +void +w_railgun_crosshair(player pl) +{ +#ifdef CLIENT + Cross_DrawSub(g_cross_spr, [24,24], [48/128,24/128], [0.1875, 0.1875]); + HUD_DrawAmmo2(); + vector aicon_pos = g_hudmins + [g_hudres[0] - 48, g_hudres[1] - 42]; + drawsubpic(aicon_pos, [24,24], g_hud7_spr, [0,72/128],[24/256, 24/128], g_hud_color, pSeatLocal->m_flAmmo2Alpha, DRAWFLAG_ADDITIVE); +#endif } void @@ -98,11 +173,11 @@ weapon_t w_railgun = .slot_pos = 3, .draw = w_railgun_draw, .holster = __NULL__, - .primary = __NULL__, + .primary = w_railgun_primary, .secondary = __NULL__, .reload = __NULL__, .release = __NULL__, - .postdraw = __NULL__, + .postdraw = w_railgun_crosshair, .precache = w_railgun_precache, .pickup = __NULL__, .updateammo = w_railgun_updateammo, diff --git a/zpak001.pk3dir/sound/weapons_tfc.sndshd b/zpak001.pk3dir/sound/weapons_tfc.sndshd index 359eab3..65f9f3d 100644 --- a/zpak001.pk3dir/sound/weapons_tfc.sndshd +++ b/zpak001.pk3dir/sound/weapons_tfc.sndshd @@ -23,6 +23,11 @@ weapon_nailgun.fire sample weapons/airgun_1.wav } +weapon_railgun.fire +{ + sample weapons/railgun.wav +} + weapon_sniper.fire { sample weapons/sniper.wav