]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Working on more code cleanup
authorSamual Lenks <samual@xonotic.org>
Thu, 27 Feb 2014 00:35:20 +0000 (19:35 -0500)
committerSamual Lenks <samual@xonotic.org>
Thu, 27 Feb 2014 00:35:20 +0000 (19:35 -0500)
qcsrc/client/particles.qc
qcsrc/common/weapons/w_arc.qc

index 0e4e2b8871009540928ff8d71ee50234fdb921cb..80925bc22d969a54ee93b7c71c4875cb4342f41e 100644 (file)
@@ -523,7 +523,11 @@ void Draw_ArcBeam()
                        shothitpos = view_origin + (view_forward * g_trueaim_minrange);
 
                // move shot origin to the actual gun muzzle origin
-               vector origin_offset = view_forward * self.beam_shotorigin_x + view_right * -self.beam_shotorigin_y + view_up * self.beam_shotorigin_z;
+               vector origin_offset =
+                       view_forward * self.beam_shotorigin_x
+                       + view_right * -self.beam_shotorigin_y 
+                       + view_up * self.beam_shotorigin_z;
+
                start_pos = start_pos + origin_offset;
 
                // calculate the aim direction now
@@ -570,25 +574,36 @@ void Draw_ArcBeam()
                        float max_allowed_segments;
 
                        if(WEP_CVAR(arc, beam_distancepersegment))
-                               max_allowed_segments = min(ARC_MAX_SEGMENTS, 1 + (vlen(w_shotdir / WEP_CVAR(arc, beam_distancepersegment))));
-                       else
-                               max_allowed_segments = ARC_MAX_SEGMENTS;
-
-                       if(WEP_CVAR(arc, beam_degreespersegment))
                        {
-                               segments = min( max(1, ( min(angle, WEP_CVAR(arc, beam_maxangle)) / WEP_CVAR(arc, beam_degreespersegment) ) ), max_allowed_segments );
+                               max_allowed_segments = min(
+                                       ARC_MAX_SEGMENTS,
+                                       1 + (vlen(w_shotdir / WEP_CVAR(arc, beam_distancepersegment)))
+                               );
                        }
-                       else
+                       else { max_allowed_segments = ARC_MAX_SEGMENTS; }
+
+                       if(WEP_CVAR(arc, beam_degreespersegment))
                        {
-                               segments = 1;
+                               segments = min(
+                                       max(
+                                               1,
+                                               (
+                                                       min(
+                                                               angle,
+                                                               WEP_CVAR(arc, beam_maxangle)
+                                                       )
+                                                       /
+                                                       WEP_CVAR(arc, beam_degreespersegment)
+                                               )
+                                       ),
+                                       max_allowed_segments
+                               );
                        }
+                       else { segments = 1; }
                        #endif
                }
                #if 0
-               else
-               {
-                       segments = 1;
-               }
+               else { segments = 1; }
                #endif
 
                // set the beam direction which the rest of the code will refer to
@@ -613,23 +628,34 @@ void Draw_ArcBeam()
                        float max_allowed_segments;
 
                        if(WEP_CVAR(arc, beam_distancepersegment))
-                               max_allowed_segments = min(ARC_MAX_SEGMENTS, 1 + (vlen(w_shotdir / WEP_CVAR(arc, beam_distancepersegment))));
-                       else
-                               max_allowed_segments = ARC_MAX_SEGMENTS;
-
-                       if(WEP_CVAR(arc, beam_degreespersegment))
                        {
-                               segments = min( max(1, ( min(angle, WEP_CVAR(arc, beam_maxangle)) / WEP_CVAR(arc, beam_degreespersegment) ) ), max_allowed_segments );
+                               max_allowed_segments = min(
+                                       ARC_MAX_SEGMENTS,
+                                       1 + (vlen(w_shotdir / WEP_CVAR(arc, beam_distancepersegment)))
+                               );
                        }
-                       else
+                       else { max_allowed_segments = ARC_MAX_SEGMENTS; }
+
+                       if(WEP_CVAR(arc, beam_degreespersegment))
                        {
-                               segments = 1;
+                               segments = min(
+                                       max(
+                                               1,
+                                               (
+                                                       min(
+                                                               angle,
+                                                               WEP_CVAR(arc, beam_maxangle)
+                                                       )
+                                                       /
+                                                       WEP_CVAR(arc, beam_degreespersegment)
+                                               )
+                                       ),
+                                       max_allowed_segments
+                               );
                        }
+                       else { segments = 1; }
                }
-               else
-               {
-                       segments = 1;
-               }
+               else { segments = 1; }
                #endif
        }
 
@@ -676,7 +702,13 @@ void Draw_ArcBeam()
                float segmentblend = bound(0, (i/segments) + self.beam_tightness, 1);
                float segmentdist = vlen(beam_endpos_estimate - last_origin) * (i/segments);
 
-               vector new_dir = normalize( (wantdir * (1 - segmentblend)) + (normalize(beam_endpos_estimate - last_origin) * segmentblend) );
+               // WEAPONTODO: Apparently, normalize is not the correct function to use here...
+               // Figure out how this actually should work.
+               vector new_dir = normalize(
+                       (wantdir * (1 - segmentblend))
+                       +
+                       (normalize(beam_endpos_estimate - last_origin) * segmentblend)
+               );
                vector new_origin = last_origin + (new_dir * segmentdist);
 
                Draw_ArcBeam_callback_segmentdist = segmentdist;
index b1be318b8205da8286b306346769ffafa3546b83..184980f8e649a975b04c00fe4994c9a5886690c2 100644 (file)
@@ -142,7 +142,16 @@ void W_Arc_Beam_Think(void)
                remove(self);
                return;
        }
-       if((self.owner.WEP_AMMO(ARC) <= 0 && !(self.owner.items & IT_UNLIMITED_WEAPON_AMMO)) || self.owner.deadflag != DEAD_NO || (!self.owner.BUTTON_ATCK && !self.beam_bursting) || self.owner.freezetag_frozen)
+
+       if(
+               (self.owner.WEP_AMMO(ARC) <= 0 && !(self.owner.items & IT_UNLIMITED_WEAPON_AMMO))
+               ||
+               self.owner.deadflag != DEAD_NO
+               ||
+               (!self.owner.BUTTON_ATCK && !self.beam_bursting)
+               ||
+               self.owner.freezetag_frozen
+       )
        {
                if(self == self.owner.arc_beam) { self.owner.arc_beam = world; } // is this needed? I thought this is changed to world when removed ANYWAY
                entity oldself = self;
@@ -251,23 +260,34 @@ void W_Arc_Beam_Think(void)
                float max_allowed_segments;
 
                if(WEP_CVAR(arc, beam_distancepersegment))
-                       max_allowed_segments = min(ARC_MAX_SEGMENTS, 1 + (vlen(w_shotdir / WEP_CVAR(arc, beam_distancepersegment))));
-               else
-                       max_allowed_segments = ARC_MAX_SEGMENTS;
-
-               if(WEP_CVAR(arc, beam_degreespersegment))
                {
-                       segments = min( max(1, ( min(angle, WEP_CVAR(arc, beam_maxangle)) / WEP_CVAR(arc, beam_degreespersegment) ) ), max_allowed_segments );
+                       max_allowed_segments = min(
+                               ARC_MAX_SEGMENTS,
+                               1 + (vlen(w_shotdir / WEP_CVAR(arc, beam_distancepersegment)))
+                       );
                }
-               else
+               else { max_allowed_segments = ARC_MAX_SEGMENTS; }
+
+               if(WEP_CVAR(arc, beam_degreespersegment))
                {
-                       segments = 1;
+                       segments = min(
+                               max(
+                                       1,
+                                       (
+                                               min(
+                                                       angle,
+                                                       WEP_CVAR(arc, beam_maxangle)
+                                               )
+                                               /
+                                               WEP_CVAR(arc, beam_degreespersegment)
+                                       )
+                               ),
+                               max_allowed_segments
+                       );
                }
+               else { segments = 1; }
        }
-       else
-       {
-               segments = 1;
-       }
+       else { segments = 1; }
 
        vector beam_endpos_estimate = (w_shotorg + (self.beam_dir * WEP_CVAR(arc, beam_range)));
 
@@ -304,7 +324,13 @@ void W_Arc_Beam_Think(void)
                float segmentblend = bound(0, (i/segments) + WEP_CVAR(arc, beam_tightness), 1);
                float segmentdist = vlen(beam_endpos_estimate - last_origin) * (i/segments);
 
-               vector new_dir = normalize( (w_shotdir * (1 - segmentblend)) + (normalize(beam_endpos_estimate - last_origin) * segmentblend) );
+               // WEAPONTODO: Apparently, normalize is not the correct function to use here...
+               // Figure out how this actually should work.
+               vector new_dir = normalize(
+                       (w_shotdir * (1 - segmentblend))
+                       +
+                       (normalize(beam_endpos_estimate - last_origin) * segmentblend)
+               );
                vector new_origin = last_origin + (new_dir * segmentdist);
 
                WarpZone_traceline_antilag(
@@ -316,7 +342,14 @@ void W_Arc_Beam_Think(void)
                        ANTILAG_LATENCY(self.owner)
                );
 
-               float is_player = (trace_ent.classname == "player" || trace_ent.classname == "body" || (trace_ent.flags & FL_MONSTER));
+               float is_player = (
+                       trace_ent.classname == "player"
+                       ||
+                       trace_ent.classname == "body"
+                       ||
+                       (trace_ent.flags & FL_MONSTER)
+               );
+
                if(trace_ent && trace_ent.takedamage && (is_player || WEP_CVAR(arc, beam_nonplayerdamage)))
                {
                        // calculate our own hit origin as trace_endpos tends to jump around annoyingly (to player origin?)
@@ -345,18 +378,30 @@ void W_Arc_Beam_Think(void)
 
                                if(trace_ent.health <= WEP_CVAR(arc, beam_healing_hmax) && roothealth)
                                {
-                                       trace_ent.health = min(trace_ent.health + (roothealth * dt), WEP_CVAR(arc, beam_healing_hmax));
+                                       trace_ent.health = min(
+                                               trace_ent.health + (roothealth * dt),
+                                               WEP_CVAR(arc, beam_healing_hmax)
+                                       );
                                }
                                if(trace_ent.armorvalue <= WEP_CVAR(arc, beam_healing_amax) && rootarmor)
                                {
-                                       trace_ent.armorvalue = min(trace_ent.armorvalue + (rootarmor * dt), WEP_CVAR(arc, beam_healing_amax));
+                                       trace_ent.armorvalue = min(
+                                               trace_ent.armorvalue + (rootarmor * dt),
+                                               WEP_CVAR(arc, beam_healing_amax)
+                                       );
                                }
 
                                // stop rot, set visual effect
                                if(roothealth || rootarmor)
                                {
-                                       trace_ent.pauserothealth_finished = max(trace_ent.pauserothealth_finished, time + autocvar_g_balance_pause_health_rot);
-                                       trace_ent.pauserotarmor_finished = max(trace_ent.pauserotarmor_finished, time + autocvar_g_balance_pause_armor_rot);
+                                       trace_ent.pauserothealth_finished = max(
+                                               trace_ent.pauserothealth_finished,
+                                               time + autocvar_g_balance_pause_health_rot
+                                       );
+                                       trace_ent.pauserotarmor_finished = max(
+                                               trace_ent.pauserotarmor_finished,
+                                               time + autocvar_g_balance_pause_armor_rot
+                                       );
                                        new_beam_type = ARC_BT_HEAL;
                                }
                        }