]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix arc beam not spawning decals when the shooter is facing a wall (client-side beam...
authorterencehill <piuntn@gmail.com>
Sat, 22 Jun 2024 16:58:29 +0000 (18:58 +0200)
committerterencehill <piuntn@gmail.com>
Sat, 22 Jun 2024 16:58:29 +0000 (18:58 +0200)
qcsrc/common/weapons/weapon/arc.qc

index 39066bb149cfb8861ae3b4a14f0ddcacc71c434f..2869843a416dd97f598d1b9c19c92943cf28a7ad 100644 (file)
@@ -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)
                {