From f5f2dd9bdb10e76f09ce061f9be1a76526395288 Mon Sep 17 00:00:00 2001 From: terencehill Date: Sat, 22 Jun 2024 18:58:29 +0200 Subject: [PATCH] Fix arc beam not spawning decals when the shooter is facing a wall (client-side beam was fired outside the map) --- qcsrc/common/weapons/weapon/arc.qc | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/qcsrc/common/weapons/weapon/arc.qc b/qcsrc/common/weapons/weapon/arc.qc index 39066bb14..2869843a4 100644 --- a/qcsrc/common/weapons/weapon/arc.qc +++ b/qcsrc/common/weapons/weapon/arc.qc @@ -953,19 +953,30 @@ void Draw_ArcBeam(entity this) else { start_pos = this.origin; } + vector start_pos_saved = start_pos; + int v_shot_idx; // used later + (v_shot_idx = gettagindex(wepent, "shot")) || (v_shot_idx = gettagindex(wepent, "tag_shot")); + if(v_shot_idx && this.beam_usevieworigin == 2) + { + start_pos = gettaginfo(wepent, v_shot_idx) - '0 0 2'; + traceline(start_pos_saved, start_pos, MOVE_NORMAL, this); + if (trace_fraction < 1) + { + // found an obstacle between view origin and shot tag + v_shot_idx = 0; + start_pos = trace_endpos; + start_pos_saved = start_pos; + } + } + // trace forward with an estimation WarpZone_TraceLine( - start_pos, - start_pos + forward * this.beam_range, + start_pos_saved, + start_pos_saved + forward * this.beam_range, MOVE_NOMONSTERS, this ); - int v_shot_idx; // used later - (v_shot_idx = gettagindex(wepent, "shot")) || (v_shot_idx = gettagindex(wepent, "tag_shot")); - if(v_shot_idx && this.beam_usevieworigin == 2) - start_pos = gettaginfo(wepent, v_shot_idx) - '0 0 2'; - // untransform in case our trace went through a warpzone vector end_pos = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos); @@ -990,7 +1001,10 @@ void Draw_ArcBeam(entity this) start_pos = trace_endpos; // calculate the aim direction now - wantdir = normalize(end_pos - start_pos); + if (vdist(end_pos - start_pos, >, 0.001)) + wantdir = normalize(end_pos - start_pos); + else + wantdir = view_forward; if(!this.beam_initialized) { -- 2.39.2