From: Samual Lenks Date: Thu, 27 Feb 2014 00:35:20 +0000 (-0500) Subject: Working on more code cleanup X-Git-Tag: xonotic-v0.8.0~152^2~51 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7c92152b922cef6ae5bbce5fd45976faeced8fa4;p=xonotic%2Fxonotic-data.pk3dir.git Working on more code cleanup --- diff --git a/qcsrc/client/particles.qc b/qcsrc/client/particles.qc index 0e4e2b887..80925bc22 100644 --- a/qcsrc/client/particles.qc +++ b/qcsrc/client/particles.qc @@ -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; diff --git a/qcsrc/common/weapons/w_arc.qc b/qcsrc/common/weapons/w_arc.qc index b1be318b8..184980f8e 100644 --- a/qcsrc/common/weapons/w_arc.qc +++ b/qcsrc/common/weapons/w_arc.qc @@ -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; } }