Simplify maths for most vlen cases
authorMario <mario@smbclan.net>
Mon, 4 Jan 2016 05:41:51 +0000 (15:41 +1000)
committerMario <mario@smbclan.net>
Mon, 4 Jan 2016 05:41:51 +0000 (15:41 +1000)
46 files changed:
qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc
qcsrc/common/minigames/minigame/pong.qc
qcsrc/common/monsters/monster/mage.qc
qcsrc/common/monsters/monster/shambler.qc
qcsrc/common/monsters/monster/wyvern.qc
qcsrc/common/monsters/sv_monsters.qc
qcsrc/common/mutators/mutator/buffs/buffs.qc
qcsrc/common/mutators/mutator/dodging/dodging.qc
qcsrc/common/mutators/mutator/overkill/hmg.qc
qcsrc/common/mutators/mutator/sandbox/sandbox.qc
qcsrc/common/mutators/mutator/spawn_near_teammate/spawn_near_teammate.qc
qcsrc/common/physics/movetypes/movetypes.qc
qcsrc/common/triggers/teleporters.qc
qcsrc/common/turrets/sv_turrets.qc
qcsrc/common/turrets/turret/ewheel.qc
qcsrc/common/turrets/turret/flac_weapon.qc
qcsrc/common/turrets/turret/fusionreactor.qc
qcsrc/common/turrets/turret/hellion_weapon.qc
qcsrc/common/turrets/turret/hk_weapon.qc
qcsrc/common/turrets/turret/walker.qc
qcsrc/common/vehicles/sv_vehicles.qc
qcsrc/common/vehicles/vehicle/bumblebee.qc
qcsrc/common/vehicles/vehicle/racer.qc
qcsrc/common/vehicles/vehicle/racer_weapon.qc
qcsrc/common/vehicles/vehicle/raptor.qc
qcsrc/common/vehicles/vehicle/raptor_weapons.qc
qcsrc/common/vehicles/vehicle/spiderbot.qc
qcsrc/common/vehicles/vehicle/spiderbot_weapons.qc
qcsrc/common/weapons/weapon/arc.qc
qcsrc/common/weapons/weapon/devastator.qc
qcsrc/common/weapons/weapon/electro.qc
qcsrc/common/weapons/weapon/fireball.qc
qcsrc/common/weapons/weapon/hook.qc
qcsrc/common/weapons/weapon/machinegun.qc
qcsrc/common/weapons/weapon/minelayer.qc
qcsrc/common/weapons/weapon/porto.qc
qcsrc/common/weapons/weapon/rifle.qc
qcsrc/common/weapons/weapon/seeker.qc
qcsrc/common/weapons/weapon/shotgun.qc
qcsrc/lib/warpzone/common.qc
qcsrc/lib/warpzone/server.qc
qcsrc/menu/menu.qc
qcsrc/server/anticheat.qc
qcsrc/server/bot/aim.qc
qcsrc/server/steerlib.qc
qcsrc/server/weapons/tracing.qc

index acd372c..b4d7672 100644 (file)
@@ -570,11 +570,9 @@ void ons_ControlPoint_Icon_Think()
        {
                int _enemy_count = 0;
                int _friendly_count = 0;
-               float _dist;
 
                FOREACH_CLIENT(IS_PLAYER(it) && !IS_DEAD(it), LAMBDA(
-                       _dist = vlen(it.origin - self.origin);
-                       if(_dist < autocvar_g_onslaught_cp_proxydecap_distance)
+                       if(vdist(it.origin - self.origin, <, autocvar_g_onslaught_cp_proxydecap_distance))
                        {
                                if(SAME_TEAM(it, self))
                                        ++_friendly_count;
@@ -1622,8 +1620,8 @@ entity ons_Nearest_ControlPoint(vector pos, float max_dist)
        {
                if(SAME_TEAM(tmp_entity, self))
                if(tmp_entity.iscaptured)
-               if(max_dist <= 0 || vlen(tmp_entity.origin - pos) <= max_dist)
-               if(vlen(tmp_entity.origin - pos) <= vlen(closest_target.origin - pos) || closest_target == world)
+               if(max_dist <= 0 || vdist(tmp_entity.origin - pos, <=, max_dist))
+               if(vlen2(tmp_entity.origin - pos) <= vlen2(closest_target.origin - pos) || closest_target == world)
                        closest_target = tmp_entity;
                tmp_entity = tmp_entity.chain;
        }
@@ -1631,8 +1629,8 @@ entity ons_Nearest_ControlPoint(vector pos, float max_dist)
        while(tmp_entity)
        {
                if(SAME_TEAM(tmp_entity, self))
-               if(max_dist <= 0 || vlen(tmp_entity.origin - pos) < max_dist)
-               if(vlen(tmp_entity.origin - pos) <= vlen(closest_target.origin - pos) || closest_target == world)
+               if(max_dist <= 0 || vdist(tmp_entity.origin - pos, <, max_dist))
+               if(vlen2(tmp_entity.origin - pos) <= vlen2(closest_target.origin - pos) || closest_target == world)
                        closest_target = tmp_entity;
                tmp_entity = tmp_entity.chain;
        }
index 359003f..87c75f4 100644 (file)
@@ -124,7 +124,7 @@ bool pong_paddle_hit(entity ball, int pteam)
                return false;
        vector near_point = box_nearest(paddle.mins+paddle.origin,
                                                                        paddle.maxs+paddle.origin, ball.origin);
-       return vlen(near_point-ball.origin) <= ball.pong_length ;
+       return vdist(near_point - ball.origin, <=, ball.pong_length);
 }
 
 // Checks for a goal, when that happes adds scores and resets the ball
index c72e550..37c6301 100644 (file)
@@ -192,13 +192,12 @@ void M_Mage_Attack_Spike_Think()
                float turnrate = (autocvar_g_monster_mage_attack_spike_turnrate); // how fast to turn
                vector desireddir = normalize(eorg - self.origin);
                vector olddir = normalize(self.velocity); // get my current direction
-               float dist = vlen(eorg - self.origin);
 
                // Do evasive maneuvers for world objects? ( this should be a cpu hog. :P )
-               if ((autocvar_g_monster_mage_attack_spike_smart) && (dist > (autocvar_g_monster_mage_attack_spike_smart_mindist)))
+               if ((autocvar_g_monster_mage_attack_spike_smart) && vdist(eorg - self.origin, >, autocvar_g_monster_mage_attack_spike_smart_mindist))
                {
                        // Is it a better idea (shorter distance) to trace to the target itself?
-                       if ( vlen(self.origin + olddir * self.wait) < dist)
+                       if ( vlen2(self.origin + olddir * self.wait) < vlen2(eorg - self.origin))
                                traceline(self.origin, self.origin + olddir * self.wait, false, self);
                        else
                                traceline(self.origin, eorg, false, self);
index 136b24f..0ffa60f 100644 (file)
@@ -189,11 +189,11 @@ bool M_Shambler_Attack(int attack_type, entity actor, entity targ)
                }
                case MONSTER_ATTACK_RANGED:
                {
-                       float randomness = random(), enemy_len = vlen(actor.enemy.origin - actor.origin);
+                       float randomness = random();
 
                        if(time >= actor.shambler_lastattack) // shambler doesn't attack much
                        if(IS_ONGROUND(actor))
-                       if(randomness <= 0.5 && enemy_len <= autocvar_g_monster_shambler_attack_smash_range)
+                       if(randomness <= 0.5 && vdist(actor.enemy.origin - actor.origin, <=, autocvar_g_monster_shambler_attack_smash_range))
                        {
                                setanim(actor, actor.anim_melee2, true, true, false);
                                Monster_Delay(actor, 1, 0.7, M_Shambler_Attack_Smash);
@@ -203,7 +203,7 @@ bool M_Shambler_Attack(int attack_type, entity actor, entity targ)
                                actor.shambler_lastattack = time + 3 + random() * 1.5;
                                return true;
                        }
-                       else if(randomness <= 0.1 && enemy_len >= autocvar_g_monster_shambler_attack_smash_range * 1.5) // small chance, don't want this spammed
+                       else if(randomness <= 0.1 && vdist(actor.enemy.origin - actor.origin, >=, autocvar_g_monster_shambler_attack_smash_range * 1.5)) // small chance, don't want this spammed
                        {
                                setanim(actor, actor.anim_shoot, true, true, false);
                                actor.state = MONSTER_ATTACK_MELEE; // maybe we should rename this to something more general
index 02b6a59..b7d398d 100644 (file)
@@ -101,13 +101,15 @@ void M_Wyvern_Attack_Fireball_Explode()
        SELFPARAM();
        Send_Effect(EFFECT_FIREBALL_EXPLODE, self.origin, '0 0 0', 1);
 
-       entity owner = self.realowner;
+       entity own = self.realowner;
 
-       RadiusDamage(self, owner, autocvar_g_monster_wyvern_attack_fireball_damage, autocvar_g_monster_wyvern_attack_fireball_edgedamage, autocvar_g_monster_wyvern_attack_fireball_force, world, world, autocvar_g_monster_wyvern_attack_fireball_radius, self.projectiledeathtype, world);
+       RadiusDamage(self, own, autocvar_g_monster_wyvern_attack_fireball_damage, autocvar_g_monster_wyvern_attack_fireball_edgedamage, autocvar_g_monster_wyvern_attack_fireball_force, world, world, autocvar_g_monster_wyvern_attack_fireball_radius, self.projectiledeathtype, world);
 
-       for (entity e = world; (e = findfloat(e, takedamage, DAMAGE_AIM)); )
-       if (vlen(e.origin - self.origin) <= (autocvar_g_monster_wyvern_attack_fireball_radius))
-               Fire_AddDamage(e, owner, 5 * MONSTER_SKILLMOD(owner), (autocvar_g_monster_wyvern_attack_fireball_damagetime), self.projectiledeathtype);
+       FOREACH_ENTITY_FLOAT(takedamage, DAMAGE_AIM,
+       {
+               if(vdist(it.origin - self.origin, <=, autocvar_g_monster_wyvern_attack_fireball_radius))
+                       Fire_AddDamage(it, own, 5 * MONSTER_SKILLMOD(own), autocvar_g_monster_wyvern_attack_fireball_damagetime, self.projectiledeathtype);
+       });
 
        remove(self);
 }
index 10725c0..ccc3b83 100644 (file)
@@ -138,7 +138,7 @@ entity Monster_FindTarget(entity mon)
                        if(closest_target)
                        {
                                vector closest_target_center = CENTER_OR_VIEWOFS(closest_target);
-                               if(vlen(ent_center - head_center) < vlen(ent_center - closest_target_center))
+                               if(vlen2(ent_center - head_center) < vlen2(ent_center - closest_target_center))
                                        { closest_target = head; }
                        }
                        else { closest_target = head; }
@@ -429,9 +429,7 @@ void Monster_Attack_Check(entity this, entity targ)
        || (time < this.attack_finished_single[0])
        ) { return; }
 
-       float targ_vlen = vlen(targ.origin - this.origin);
-
-       if(targ_vlen <= this.attack_range)
+       if(vdist(targ.origin - this.origin, <=, this.attack_range))
        {
                bool attack_success = this.monster_attackfunc(MONSTER_ATTACK_MELEE, this, targ);
                if(attack_success == 1)
@@ -440,7 +438,7 @@ void Monster_Attack_Check(entity this, entity targ)
                        return;
        }
 
-       if(targ_vlen > this.attack_range)
+       if(vdist(targ.origin - this.origin, >, this.attack_range))
        {
                float attack_success = this.monster_attackfunc(MONSTER_ATTACK_RANGED, this, targ);
                if(attack_success == 1)
@@ -569,7 +567,7 @@ vector Monster_Move_Target(entity this, entity targ)
                        || (this.enemy.flags & FL_NOTARGET)
                        || (this.enemy.alpha < 0.5 && this.enemy.alpha != 0)
                        || (this.enemy.takedamage == DAMAGE_NO)
-                       || (vlen(this.origin - targ_origin) > this.target_range)
+                       || (vdist(this.origin - targ_origin, >, this.target_range))
                        || ((trace_fraction < 1) && (trace_ent != this.enemy)))
                {
                        this.enemy = world;
@@ -858,7 +856,7 @@ void Monster_Move(entity this, float runspeed, float walkspeed, float stpspeed)
        if(!(this.spawnflags & MONSTERFLAG_FLY_VERTICAL) && !(this.flags & FL_SWIM))
                this.moveto_z = this.origin_z;
 
-       if(vlen(this.origin - this.moveto) > 100)
+       if(vdist(this.origin - this.moveto, >, 100))
        {
                float do_run = (this.enemy || this.monster_moveto);
                if(IS_ONGROUND(this) || ((this.flags & FL_FLY) || (this.flags & FL_SWIM)))
@@ -867,7 +865,7 @@ void Monster_Move(entity this, float runspeed, float walkspeed, float stpspeed)
                if(time > this.pain_finished) // TODO: use anim_finished instead!
                if(!this.state)
                if(time > this.anim_finished)
-               if(vlen(this.velocity) > 10)
+               if(vdist(this.velocity, >, 10))
                        setanim(this, ((do_run) ? this.anim_run : this.anim_walk), true, false, false);
                else
                        setanim(this, this.anim_idle, true, false, false);
@@ -884,7 +882,7 @@ void Monster_Move(entity this, float runspeed, float walkspeed, float stpspeed)
                if(time > this.anim_finished)
                if(time > this.pain_finished)
                if(!this.state)
-               if(vlen(this.velocity) <= 30)
+               if(vdist(this.velocity, <=, 30))
                        setanim(this, this.anim_idle, true, false, false);
        }
 
@@ -1171,7 +1169,7 @@ void Monster_Move_2D(entity this, float mspeed, bool allow_jumpoff)
 
        if(time > this.pain_finished)
        if(time > this.attack_finished_single[0])
-       if(vlen(this.velocity) > 10)
+       if(vdist(this.velocity, >, 10))
                setanim(this, this.anim_walk, true, false, false);
        else
                setanim(this, this.anim_idle, true, false, false);
index 889b0db..32fe2d8 100644 (file)
@@ -545,11 +545,10 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerDamage_Calculate)
 
        if(frag_target.buffs & BUFF_BASH.m_itemid)
        if(frag_attacker != frag_target)
-       if(vlen(frag_force))
                frag_force = '0 0 0';
 
        if(frag_attacker.buffs & BUFF_BASH.m_itemid)
-       if(vlen(frag_force))
+       if(frag_force)
        if(frag_attacker == frag_target)
                frag_force *= autocvar_g_buffs_bash_force_self;
        else
@@ -700,10 +699,13 @@ MUTATOR_HOOKFUNCTION(buffs, ForbidThrowCurrentWeapon)
                FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
                        if(!IS_DEAD(it) && !STAT(FROZEN, it) && !it.vehicle)
                        if(DIFF_TEAM(it, self))
-                       if(vlen(self.origin - it.origin) <= best_distance)
                        {
-                               best_distance = vlen(self.origin - it.origin);
-                               closest = it;
+                               float test = vlen2(self.origin - it.origin);
+                               if(test <= best_distance * best_distance)
+                               {
+                                       best_distance = sqrt(test);
+                                       closest = it;
+                               }
                        }
                ));
 
index 915dbe6..09f169e 100644 (file)
@@ -92,15 +92,15 @@ bool check_close_to_wall(entity this, float threshold)
 {
        if (PHYS_DODGING_WALL == 0) { return false; }
 
-       #define X(OFFSET)                                                                                                                               \
-       tracebox(this.origin, this.mins, this.maxs, this.origin + OFFSET, true, this);  \
-       if (trace_fraction < 1 && vlen (this.origin - trace_endpos) < threshold)                \
+#define X(OFFSET) \
+       tracebox(this.origin, this.mins, this.maxs, this.origin + OFFSET, true, this); \
+       if(trace_fraction < 1 && vdist(this.origin - trace_endpos, <, threshold)) \
                return true;
        X(1000*v_right);
        X(-1000*v_right);
        X(1000*v_forward);
        X(-1000*v_forward);
-       #undef X
+#undef X
 
        return false;
 }
index 6da57cb..c08c369 100644 (file)
@@ -100,7 +100,7 @@ void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weapone
 
                METHOD(HeavyMachineGun, wr_aim, void(entity thiswep))
                {
-                       if(vlen(self.origin-self.enemy.origin) < 3000 - bound(0, skill, 10) * 200)
+                       if(vdist(self.origin - self.enemy.origin, <, 3000 - bound(0, skill, 10) * 200))
                                self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, false);
                        else
                                self.BUTTON_ATCK2 = bot_aim(1000000, 0, 0.001, false);
index 6b97a28..2dffb42 100644 (file)
@@ -108,7 +108,7 @@ entity sandbox_ObjectEdit_Get(float permissions)
        // Attached objects are SOLID_NOT and do not get traced.
 
        crosshair_trace_plusvisibletriggers(self);
-       if(vlen(self.origin - trace_ent.origin) > autocvar_g_sandbox_editor_distance_edit)
+       if(vdist(self.origin - trace_ent.origin, >, autocvar_g_sandbox_editor_distance_edit))
                return world; // out of trace range
        if(trace_ent.classname != "object")
                return world; // entity is not an object
index 51c598f..168a06d 100644 (file)
@@ -77,7 +77,7 @@ MUTATOR_HOOKFUNCTION(spawn_near_teammate, PlayerSpawn)
                                        pc = pointcontents(trace_endpos + '0 0 1');
                                        if(pc == CONTENT_EMPTY)
                                        {
-                                               if(vlen(it.velocity) > 5)
+                                               if(vdist(it.velocity, >, 5))
                                                        fixedmakevectors(vectoangles(it.velocity));
                                                else
                                                        fixedmakevectors(it.angles);
index ef9f059..324f67b 100644 (file)
@@ -419,7 +419,7 @@ bool _Movetype_TestEntityPosition(entity this, vector ofs)  // SV_TestEntityPosi
        if(trace_startsolid)
                return true;
 
-       if(vlen(trace_endpos - this.move_origin) > 0.0001)
+       if(vdist(trace_endpos - this.move_origin, >, 0.0001))
                this.move_origin = trace_endpos;
        return false;
 }
index c00a4de..eae31ea 100644 (file)
@@ -215,21 +215,21 @@ entity Simple_TeleportPlayer(entity teleporter, entity player)
 
 #ifdef SVQC
        if(e.speed)
-               if(vlen(player.velocity) > e.speed)
+               if(vdist(player.velocity, >, e.speed))
                        player.velocity = normalize(player.velocity) * max(0, e.speed);
 #elif defined(CSQC)
        if(e.speed)
-               if(vlen(player.move_velocity) > e.speed)
+               if(vdist(player.move_velocity, >, e.speed))
                        player.move_velocity = normalize(player.move_velocity) * max(0, e.speed);
 #endif
 
 #ifdef SVQC
        if(STAT(TELEPORT_MAXSPEED, player))
-               if(vlen(player.velocity) > STAT(TELEPORT_MAXSPEED, player))
+               if(vdist(player.velocity, >, STAT(TELEPORT_MAXSPEED, player)))
                        player.velocity = normalize(player.velocity) * max(0, STAT(TELEPORT_MAXSPEED, player));
 #elif defined(CSQC)
        if(STAT(TELEPORT_MAXSPEED, player))
-               if(vlen(player.move_velocity) > STAT(TELEPORT_MAXSPEED, player))
+               if(vdist(player.move_velocity, >, STAT(TELEPORT_MAXSPEED, player)))
                        player.move_velocity = normalize(player.move_velocity) * max(0, STAT(TELEPORT_MAXSPEED, player));
 #endif
 
index bbd9c99..a06fbcb 100644 (file)
@@ -816,7 +816,7 @@ float turret_validate_target(entity e_turret, entity e_target, float validate_fl
 
                traceline(e_turret.origin + '0 0 16', v_tmp, 0, e_turret);
 
-               if (e_turret.aim_firetolerance_dist < vlen(v_tmp - trace_endpos))
+               if(vdist(v_tmp - trace_endpos, >, e_turret.aim_firetolerance_dist))
                        return -19;
        }
 
@@ -1376,7 +1376,7 @@ float turret_initialize(Turret tur)
 
 #ifdef TURRET_DEBUG
        self.tur_debug_start = self.nextthink;
-       while (vlen(self.tur_debug_rvec) < 2)
+       while(vdist(self.tur_debug_rvec, <, 2))
                self.tur_debug_rvec = randomvec() * 4;
 
        self.tur_debug_rvec_x = fabs(self.tur_debug_rvec_x);
index 09c4155..dc3b460 100644 (file)
@@ -42,7 +42,7 @@ void ewheel_move_path()
 {SELFPARAM();
 #ifdef EWHEEL_FANCYPATH
     // Are we close enougth to a path node to switch to the next?
-    if (vlen(self.origin  - self.pathcurrent.origin) < 64)
+    if(vdist(self.origin - self.pathcurrent.origin, <, 64))
         if (self.pathcurrent.path_next == world)
         {
             // Path endpoint reached
@@ -67,7 +67,7 @@ void ewheel_move_path()
             self.pathcurrent = self.pathcurrent.path_next;
 
 #else
-    if (vlen(self.origin - self.pathcurrent.origin) < 64)
+    if(vdist(self.origin - self.pathcurrent.origin, <, 64))
         self.pathcurrent = self.pathcurrent.enemy;
 #endif
 
@@ -131,7 +131,7 @@ void ewheel_move_idle()
     }
 
     self.frame = 0;
-    if (vlen(self.velocity))
+    if(self.velocity)
         movelib_brake_simple(self, (autocvar_g_turrets_unit_ewheel_speed_stop));
 }
 
@@ -168,7 +168,7 @@ spawnfunc(turret_ewheel) { if(!turret_initialize(TUR_EWHEEL)) remove(self); }
 
             self.velocity_z = vz;
 
-            if(vlen(self.velocity))
+            if(self.velocity)
                 self.SendFlags |= TNSF_MOVE;
         }
         METHOD(EWheel, tr_death, void(EWheel this, entity it))
index d1b560b..f4bc70c 100644 (file)
@@ -50,8 +50,8 @@ METHOD(FlacAttack, wr_think, void(entity thiswep, entity actor, .entity weaponen
 void turret_flac_projectile_think_explode()
 {
     SELFPARAM();
-    if (self.enemy != world)
-    if (vlen(self.origin - self.enemy.origin) < self.owner.shot_radius * 3)
+    if(self.enemy != world)
+    if(vdist(self.origin - self.enemy.origin, <, self.owner.shot_radius * 3))
         setorigin(self,self.enemy.origin + randomvec() * self.owner.shot_radius);
 
 #ifdef TURRET_DEBUG
index 55dcd62..8ea1cbb 100644 (file)
@@ -34,7 +34,7 @@ bool turret_fusionreactor_firecheck()
     if (self.enemy.ammo >= self.enemy.ammo_max)
         return false;
 
-    if (vlen(self.enemy.origin - self.origin) > self.target_range)
+    if(vdist(self.enemy.origin - self.origin, >, self.target_range))
         return false;
 
     if(self.team != self.enemy.team)
index 4a559b0..0b118be 100644 (file)
@@ -75,7 +75,7 @@ void turret_hellion_missile_think()
         // Turn model
         self.angles = vectoangles(self.velocity);
 
-        if ( (vlen(self.origin - self.owner.origin)) > (self.owner.shot_radius * 5) )
+        if(vdist(self.origin - self.owner.origin, >, (self.owner.shot_radius * 5)))
             turret_projectile_explode();
 
         // Accelerate
@@ -87,7 +87,7 @@ void turret_hellion_missile_think()
     }
 
     // Enemy in range?
-    if (vlen(self.origin - self.enemy.origin) < self.owner.shot_radius * 0.2)
+    if(vdist(self.origin - self.enemy.origin, <, self.owner.shot_radius * 0.2))
         turret_projectile_explode();
 
     // Predict enemy position
index 58c22a7..5060e57 100644 (file)
@@ -88,7 +88,7 @@ void turret_hk_missile_think()
                 if (!self.enemy)
                     self.enemy = e;
                 else
-                    if (vlen(self.origin - e.origin) < vlen(self.origin - self.enemy.origin))
+                    if (vlen2(self.origin - e.origin) < vlen2(self.origin - self.enemy.origin))
                         self.enemy = e;
             }
             e = e.chain;
index f15a6d0..599e00c 100644 (file)
@@ -182,7 +182,7 @@ void walker_rocket_loop3()
         return;
     }
 
-    if (vlen(self.origin - self.tur_shotorg) < 100 )
+    if(vdist(self.origin - self.tur_shotorg, <, 100))
     {
         self.think = walker_rocket_think;
         return;
@@ -206,7 +206,7 @@ void walker_rocket_loop2()
         return;
     }
 
-    if (vlen(self.origin - self.tur_shotorg) < 100 )
+    if(vdist(self.origin - self.tur_shotorg, <, 100))
     {
         self.tur_shotorg = self.origin - '0 0 200';
         self.think = walker_rocket_loop3;
@@ -305,7 +305,7 @@ void walker_move_path()
 {SELFPARAM();
 #ifdef WALKER_FANCYPATHING
     // Are we close enougth to a path node to switch to the next?
-    if (vlen(self.origin  - self.pathcurrent.origin) < 64)
+    if(vdist(self.origin - self.pathcurrent.origin, <, 64))
         if (self.pathcurrent.path_next == world)
         {
             // Path endpoint reached
@@ -334,7 +334,7 @@ void walker_move_path()
     walker_move_to(self.moveto, 0);
 
 #else
-    if (vlen(self.origin - self.pathcurrent.origin) < 64)
+    if(vdist(self.origin - self.pathcurrent.origin, <, 64))
         self.pathcurrent = self.pathcurrent.enemy;
 
     if(!self.pathcurrent)
@@ -362,7 +362,7 @@ spawnfunc(turret_walker) { if(!turret_initialize(TUR_WALKER)) remove(self); }
                 {
                     if(self.enemy_last_time != 0)
                     {
-                        if(vlen(self.origin - self.enemy_last_loc) < 128 || time - self.enemy_last_time > 10)
+                        if(vdist(self.origin - self.enemy_last_loc, <, 128) || time - self.enemy_last_time > 10)
                             self.enemy_last_time = 0;
                         else
                             walker_move_to(self.enemy_last_loc, 0);
index 391ce99..0c1574e 100644 (file)
@@ -922,7 +922,7 @@ void vehicles_touch()
                if((self.origin_z + self.maxs_z) > (other.origin_z))
                if(vehicles_crushable(other))
                {
-                       if(vlen(self.velocity) >= 30)
+                       if(vdist(self.velocity, >=, 30))
                                Damage(other, self, self.owner, autocvar_g_vehicles_crush_dmg, DEATH_VH_CRUSH.m_id, '0 0 0', normalize(other.origin - self.origin) * autocvar_g_vehicles_crush_force);
 
                        return; // Dont do selfdamage when hitting "soft targets".
index 3bad3bc..cd2804a 100644 (file)
@@ -300,7 +300,7 @@ bool bumblebee_gunner_enter()
        if(!vehic.gunner1 && !vehic.gunner2 && ((time >= vehic.gun1.phase) + (time >= vehic.gun2.phase)) == 2)
        {
                // we can have some fun
-               if(vlen(real_origin(vehic.gun2) - player.origin) < vlen(real_origin(vehic.gun1) - player.origin))
+               if(vlen2(real_origin(vehic.gun2) - player.origin) < vlen2(real_origin(vehic.gun1) - player.origin))
                {
                        gunner = vehic.gun2;
                        vehic.gunner2 = player;
@@ -679,7 +679,7 @@ void bumblebee_exit(float eject)
 
        fixedmakevectors(self.angles);
        vector spot;
-       if(vlen(self.velocity) > autocvar_g_vehicle_bumblebee_speed_forward * 0.5)
+       if(vdist(self.velocity, >, autocvar_g_vehicle_bumblebee_speed_forward * 0.5))
                spot = self.origin + v_up * 128 + v_forward * 300;
        else
                spot = self.origin + v_up * 128 - v_forward * 300;
index 25d0761..848fa2f 100644 (file)
@@ -220,7 +220,7 @@ float racer_frame()
        //racer.velocity_z = ftmp;
 
        int cont = pointcontents(racer.origin);
-       if(vlen(player.movement) != 0)
+       if(player.movement)
        {
                if(cont == CONTENT_WATER || cont == CONTENT_LAVA || cont == CONTENT_SLIME)
                {
@@ -454,7 +454,7 @@ void racer_exit(float eject)
        }
        else
        {
-               if(vlen(self.velocity) > 2 * autocvar_sv_maxairspeed)
+               if(vdist(self.velocity, >, 2 * autocvar_sv_maxairspeed))
                {
                        self.owner.velocity = normalize(self.velocity) * autocvar_sv_maxairspeed * 2;
                        self.owner.velocity_z += 200;
index a4cf0dd..675d8f1 100644 (file)
@@ -135,7 +135,7 @@ void racer_rocket_tracker()
     //vector
     float height_diff = predicted_origin_z - self.origin_z;
 
-    if(vlen(newdir - v_forward) > autocvar_g_vehicle_racer_rocket_locked_maxangle)
+    if(vdist(newdir - v_forward, >, autocvar_g_vehicle_racer_rocket_locked_maxangle))
     {
         //bprint("Target lost!\n");
         //dprint("OF:", ftos(vlen(newdir - v_forward)), "\n");
index 6499776..d012bd5 100644 (file)
@@ -136,7 +136,7 @@ void raptor_exit(float eject)
        }
        else
        {
-               if(vlen(self.velocity) > 2 * autocvar_sv_maxairspeed)
+               if(vdist(self.velocity, >, 2 * autocvar_sv_maxairspeed))
                {
                        self.owner.velocity = normalize(self.velocity) * autocvar_sv_maxairspeed * 2;
                        self.owner.velocity_z += 200;
@@ -446,7 +446,7 @@ float raptor_frame()
                {
                        if(_missile.flags & FL_PROJECTILE)
                        if(MISSILE_IS_TRACKING(_missile))
-                       if(vlen(self.origin - _missile.origin) < 2 * autocvar_g_vehicle_raptor_flare_range)
+                       if(vdist(self.origin - _missile.origin, <, 2 * autocvar_g_vehicle_raptor_flare_range))
                                ++_incomming;
 
                        _missile = _missile.chain;
index 92c6476..175dbd0 100644 (file)
@@ -165,7 +165,7 @@ void raptor_bomb_burst()
     {
         self.nextthink = time;
         traceline(self.origin, self.origin + (normalize(self.velocity) * autocvar_g_vehicle_raptor_bomblet_alt), MOVE_NORMAL, self);
-        if((trace_fraction == 1.0) || (vlen(self.origin - self.owner.origin) < autocvar_g_vehicle_raptor_bomblet_radius))
+        if((trace_fraction == 1.0) || (vdist(self.origin - self.owner.origin, <, autocvar_g_vehicle_raptor_bomblet_radius)))
         {
             UpdateCSQCProjectile(self);
             return;
@@ -251,7 +251,7 @@ void raptor_flare_think()
     while(_missile)
     {
         if(_missile.flags & FL_PROJECTILE)
-        if(vlen(self.origin - _missile.origin) < autocvar_g_vehicle_raptor_flare_range)
+        if(vdist(self.origin - _missile.origin, <, autocvar_g_vehicle_raptor_flare_range))
         if(random() > autocvar_g_vehicle_raptor_flare_chase)
             _missile.enemy = self;
         _missile = _missile.chain;
index 0004667..edb2a47 100644 (file)
@@ -181,7 +181,7 @@ float spiderbot_frame()
                }
                else if(time >= spider.jump_delay)
                {
-                       if(vlen(player.movement) == 0)
+                       if(!player.movement)
                        {
                                if(IS_ONGROUND(spider))
                                {
@@ -384,7 +384,7 @@ void spiderbot_exit(float eject)
        }
        else
        {
-               if(vlen(self.velocity) > autocvar_g_vehicle_spiderbot_speed_strafe)
+               if(vdist(self.velocity, >, autocvar_g_vehicle_spiderbot_speed_strafe))
                {
                        self.owner.velocity = normalize(self.velocity) * vlen(self.velocity);
                        self.owner.velocity_z += 200;
index 7a65796..257eac8 100644 (file)
@@ -50,7 +50,7 @@ void spiderbot_rocket_unguided()
 
     UpdateCSQCProjectile(self);
 
-    if (IS_DEAD(self.owner) || self.cnt < time || vlen(self.pos1 - self.origin) < 16)
+    if (IS_DEAD(self.owner) || self.cnt < time || vdist(self.pos1 - self.origin, <, 16))
         self.use();
 }
 
index 2a12c45..ba36d8f 100644 (file)
@@ -902,7 +902,7 @@ void Draw_ArcBeam(entity this)
                vector end_pos = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos);
 
                // un-adjust trueaim if shotend is too close
-               if(vlen(end_pos - start_pos) < g_trueaim_minrange)
+               if(vdist(end_pos - start_pos, <, g_trueaim_minrange))
                        end_pos = start_pos + (forward * g_trueaim_minrange);
 
                // move shot origin to the actual gun muzzle origin
index d714aca..0272e42 100644 (file)
@@ -211,7 +211,7 @@ void W_Devastator_RemoteExplode(.entity weaponentity)
        {
                if((self.spawnshieldtime >= 0)
                        ? (time >= self.spawnshieldtime) // timer
-                       : (vlen(NearestPointOnBox(self.realowner, self.origin) - self.origin) > WEP_CVAR(devastator, remote_radius)) // safety device
+                       : (vdist(NearestPointOnBox(self.realowner, self.origin) - self.origin, >, WEP_CVAR(devastator, remote_radius))) // safety device
                )
                {
                        W_Devastator_DoRemoteExplode(weaponentity);
index d766e6a..3e93644 100644 (file)
@@ -86,7 +86,7 @@ void W_Electro_TriggerCombo(vector org, float rad, entity own)
                        if(WEP_CVAR(electro, combo_comboradius_thruwall))
                        {
                                // if distance is greater than thruwall distance, check to make sure it's not through a wall
-                               if(vlen(e.WarpZone_findradius_dist) > WEP_CVAR(electro, combo_comboradius_thruwall))
+                               if(vdist(e.WarpZone_findradius_dist, >, WEP_CVAR(electro, combo_comboradius_thruwall)))
                                {
                                        WarpZone_TraceLine(org, e.origin, MOVE_NOMONSTERS, e);
                                        if(trace_fraction != 1)
@@ -428,7 +428,7 @@ void W_Electro_CheckAttack(Weapon thiswep, entity actor, .entity weaponentity, i
                METHOD(Electro, wr_aim, void(entity thiswep))
                {
                        self.BUTTON_ATCK = self.BUTTON_ATCK2 = false;
-                       if(vlen(self.origin-self.enemy.origin) > 1000) { self.bot_secondary_electromooth = 0; }
+                       if(vdist(self.origin - self.enemy.origin, >, 1000)) { self.bot_secondary_electromooth = 0; }
                        if(self.bot_secondary_electromooth == 0)
                        {
                                float shoot;
index f39ad47..50119a6 100644 (file)
@@ -270,7 +270,7 @@ void W_Fireball_Firemine_Think()
        // make it "hot" once it leaves its owner
        if(self.owner)
        {
-               if(vlen(self.origin - self.owner.origin - self.owner.view_ofs) > WEP_CVAR_SEC(fireball, laserradius))
+               if(vdist(self.origin - self.owner.origin - self.owner.view_ofs, >, WEP_CVAR_SEC(fireball, laserradius)))
                {
                        self.cnt += 1;
                        if(self.cnt == 3)
index e2884ff..d76095e 100644 (file)
@@ -451,7 +451,7 @@ void Draw_GrapplingHook(entity this)
        {
                default:
                case NET_ENT_CLIENT_HOOK:
-                       if(vlen(trace_endpos - atrans) > 0.5)
+                       if(vdist(trace_endpos - atrans, >, 0.5))
                        {
                                setorigin(this, trace_endpos); // hook endpoint!
                                this.angles = vectoangles(trace_endpos - atrans);
index c17d07d..f220752 100644 (file)
@@ -244,7 +244,7 @@ void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, .entity weaponentit
 
                METHOD(MachineGun, wr_aim, void(entity thiswep))
                {
-                       if(vlen(self.origin-self.enemy.origin) < 3000 - bound(0, skill, 10) * 200)
+                       if(vdist(self.origin - self.enemy.origin, <, 3000 - bound(0, skill, 10) * 200))
                                self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, false);
                        else
                                self.BUTTON_ATCK2 = bot_aim(1000000, 0, 0.001, false);
index f9c43f6..e5c43f3 100644 (file)
@@ -172,7 +172,7 @@ void W_MineLayer_RemoteExplode()
        if(!IS_DEAD(self.realowner))
                if((self.spawnshieldtime >= 0)
                        ? (time >= self.spawnshieldtime) // timer
-                       : (vlen(NearestPointOnBox(self.realowner, self.origin) - self.origin) > WEP_CVAR(minelayer, remote_radius)) // safety device
+                       : (vdist(NearestPointOnBox(self.realowner, self.origin) - self.origin, >, WEP_CVAR(minelayer, remote_radius))) // safety device
                )
                {
                        W_MineLayer_DoRemoteExplode();
index 580a5be..56b2759 100644 (file)
@@ -91,7 +91,7 @@ void W_Porto_Fail(float failhard)
                        self.flags = FL_ITEM;
                        self.velocity = trigger_push_calculatevelocity(self.origin, self.realowner, 128);
                        tracetoss(self, self);
-                       if(vlen(trace_endpos - self.realowner.origin) < 128)
+                       if(vdist(trace_endpos - self.realowner.origin, <, 128))
                        {
                                W_ThrowNewWeapon(self.realowner, WEP_PORTO.m_id, 0, self.origin, self.velocity);
                                Send_Notification(NOTIF_ONE, self.realowner, MSG_CENTER, CENTER_PORTO_FAILED);
index 1f79e59..526ba0e 100644 (file)
@@ -142,7 +142,7 @@ void W_Rifle_BulletHail(.entity weaponentity, float mode, void() AttackFunc, WFR
                {
                        self.BUTTON_ATCK=false;
                        self.BUTTON_ATCK2=false;
-                       if(vlen(self.origin-self.enemy.origin) > 1000)
+                       if(vdist(self.origin - self.enemy.origin, >, 1000))
                                self.bot_secondary_riflemooth = 0;
                        if(self.bot_secondary_riflemooth == 0)
                        {
index 98fe8c8..a25e928 100644 (file)
@@ -147,7 +147,7 @@ void W_Seeker_Missile_Think()
                if(WEP_CVAR(seeker, missile_smart) && (dist > WEP_CVAR(seeker, missile_smart_mindist)))
                {
                        // Is it a better idea (shorter distance) to trace to the target itself?
-                       if( vlen(self.origin + olddir * self.wait) < dist)
+                       if( vdist(self.origin + olddir * self.wait, <, dist))
                                traceline(self.origin, self.origin + olddir * self.wait, false, self);
                        else
                                traceline(self.origin, eorg, false, self);
@@ -400,7 +400,7 @@ void W_Seeker_Attack()
        {
                if(closest_target)
                {
-                       if(vlen(self.origin - tracker.tag_target.origin) < vlen(self.origin - closest_target.origin))
+                       if(vlen2(self.origin - tracker.tag_target.origin) < vlen2(self.origin - closest_target.origin))
                                closest_target = tracker.tag_target;
                }
                else
index 928ec4b..dba351e 100644 (file)
@@ -229,7 +229,7 @@ void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, .entity weaponentity
 
                METHOD(Shotgun, wr_aim, void(entity thiswep))
                {
-                       if(vlen(self.origin-self.enemy.origin) <= WEP_CVAR_SEC(shotgun, melee_range))
+                       if(vdist(self.origin - self.enemy.origin, <=, WEP_CVAR_SEC(shotgun, melee_range)))
                                self.BUTTON_ATCK2 = bot_aim(1000000, 0, 0.001, false);
                        else
                                self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, false);
@@ -293,7 +293,7 @@ void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, .entity weaponentity
                METHOD(Shotgun, wr_checkammo2, bool(entity thiswep))
                {
                        if(IS_BOT_CLIENT(self))
-                       if(vlen(self.origin-self.enemy.origin) > WEP_CVAR_SEC(shotgun, melee_range))
+                       if(vdist(self.origin - self.enemy.origin, >, WEP_CVAR_SEC(shotgun, melee_range)))
                                return false; // bots cannot use secondary out of range (fixes constant melee when out of ammo)
                        switch(WEP_CVAR(shotgun, secondary))
                        {
index 080c631..5a9b2ab 100644 (file)
@@ -43,7 +43,7 @@ vector WarpZone_camera_transform(vector org, vector ang)
 {SELFPARAM();
        vector vf, vr, vu;
        if(self.warpzone_fadestart)
-               if(vlen(org - self.origin - 0.5 * (self.mins + self.maxs)) > self.warpzone_fadeend + 400)
+               if(vdist(org - self.origin - 0.5 * (self.mins + self.maxs), >, self.warpzone_fadeend + 400))
                        return org;
                        // don't transform if zone faded out (plus 400qu safety margin for typical speeds and latencies)
                        // unneeded on client, on server this helps a lot
@@ -81,7 +81,7 @@ vector WarpZone_Camera_camera_transform(vector org, vector ang)
 {SELFPARAM();
        // a fixed camera view
        if(self.warpzone_fadestart)
-               if(vlen(org - self.origin - 0.5 * (self.mins + self.maxs)) > self.warpzone_fadeend + 400)
+               if(vdist(org - self.origin - 0.5 * (self.mins + self.maxs), >, self.warpzone_fadeend + 400))
                        return org;
                        // don't transform if zone faded out (plus 400qu safety margin for typical speeds and latencies)
                        // unneeded on client, on server this helps a lot
@@ -616,7 +616,7 @@ void WarpZone_FindRadius_Recurse(vector org, float rad,        vector org0,
                        if(trace_fraction < 1)
                                continue;
                }
-               if(!e.WarpZone_findradius_hit || vlen(e.WarpZone_findradius_dist) > vlen(org0 - p))
+               if(!e.WarpZone_findradius_hit || vlen2(e.WarpZone_findradius_dist) > vlen2(org0 - p))
                {
                        e.WarpZone_findradius_nearest = p;
                        e.WarpZone_findradius_dist = org0 - p;
index 9273750..22aaba8 100644 (file)
@@ -634,7 +634,7 @@ void WarpZone_InitStep_UpdateTransform()
        {
                norm = norm * (1 / area);
                point = point * (1 / (3 * area));
-               if(vlen(norm) < 0.99)
+               if(vdist(norm, <, 0.99))
                {
                        LOG_INFO("trigger_warpzone near ", vtos(self.aiment.origin), " is nonplanar. BEWARE.\n");
                        area = 0; // no autofixing in this case
@@ -660,7 +660,7 @@ void WarpZone_InitStep_UpdateTransform()
                        ang.x = -ang.x;
                        if(norm * v_forward < 0.99)
                                LOG_INFO("trigger_warpzone near ", vtos(self.aiment.origin), " has been turned to match plane orientation (", vtos(self.aiment.angles), " -> ", vtos(ang), "\n");
-                       if(vlen(org - self.aiment.origin) > 0.5)
+                       if(vdist(org - self.aiment.origin, >, 0.5))
                                LOG_INFO("trigger_warpzone near ", vtos(self.aiment.origin), " has been moved to match the plane (", vtos(self.aiment.origin), " -> ", vtos(org), ").\n");
                }
        }
index 22ab704..1c7ed03 100644 (file)
@@ -524,8 +524,7 @@ void m_tooltip(vector pos)
        {
                float f = bound(0, frametime * 2, 1);
                menuTooltipAveragedMousePos = menuTooltipAveragedMousePos * (1 - f) + pos * f;
-               f = vlen(pos - menuTooltipAveragedMousePos);
-               if (f < 0.01)
+               if (vdist(pos - menuTooltipAveragedMousePos, <, 0.01))
                {
                        it = m_findtooltipitem(main, pos);
 
index 877d416..865010f 100644 (file)
@@ -85,7 +85,7 @@ void anticheat_physics(entity this)
        this.anticheat_div0_strafebot_movement_prev = this.movement;
 
        // Note: this actually tries to detect snap-aim.
-       if(vlen(this.anticheat_div0_strafebot_forward_prev) && time > this.anticheat_fixangle_endtime) {
+       if(this.anticheat_div0_strafebot_forward_prev && time > this.anticheat_fixangle_endtime) {
                float cosangle = this.anticheat_div0_strafebot_forward_prev * v_forward;
                float angle = cosangle < -1 ? M_PI : cosangle > 1 ? 0 : acos(cosangle);
                /*
index 0692659..79f0a27 100644 (file)
@@ -303,7 +303,7 @@ float bot_aimdir(vector v, float maxfiredeviation)
        // note the maxfiredeviation is in degrees so this has to convert to radians first
        //if ((normalize(v) * shotdir) >= cos(maxfiredeviation * (3.14159265358979323846 / 180)))
        if ((normalize(v) * shotdir) >= cos(maxfiredeviation * (3.14159265358979323846 / 180)))
-       if (vlen(trace_endpos-shotorg) < 500+500*bound(0, skill+self.bot_aggresskill, 10) || random()*random()>bound(0,(skill+self.bot_aggresskill)*0.05,1))
+       if(vdist(trace_endpos-shotorg, <, 500 + 500 * bound(0, skill + self.bot_aggresskill, 10)) || random()*random()>bound(0,(skill+self.bot_aggresskill)*0.05,1))
                self.bot_firetimer = time + bound(0.1, 0.5-(skill+self.bot_aggresskill)*0.05, 0.5);
        //traceline(shotorg,shotorg+shotdir*1000,false,world);
        //dprint(ftos(maxfiredeviation),"\n");
index ae85061..7e05e7c 100644 (file)
@@ -591,7 +591,7 @@ void flocker_hunter_think()
     self.angles_x = self.angles.x * -1;
 
     if(self.enemy)
-    if(vlen(self.enemy.origin - self.origin) < 64)
+    if(vdist(self.enemy.origin - self.origin, <, 64))
     {
         ee = self.enemy;
         ee.health = -1;
index 01a23c1..facf13f 100644 (file)
@@ -46,7 +46,7 @@ void W_SetupShot_Dir_ProjectileSize_Range(entity ent, vector s_forward, vector m
        v_up = vu;
 
        // un-adjust trueaim if shotend is too close
-       if(vlen(w_shotend - (ent.origin + ent.view_ofs)) < autocvar_g_trueaim_minrange)
+       if(vdist(w_shotend - (ent.origin + ent.view_ofs), <, autocvar_g_trueaim_minrange))
                w_shotend = ent.origin + ent.view_ofs + s_forward * autocvar_g_trueaim_minrange;
 
        // track max damage
@@ -342,7 +342,7 @@ void FireRailgunBullet (vector start, vector end, float bdamage, float bforce, f
 
 void fireBullet_trace_callback(vector start, vector hit, vector end)
 {
-       if(vlen(hit - start) > 16)
+       if(vdist(hit - start, >, 16))
                trailparticles(world, fireBullet_trace_callback_eff, start, hit);
        WarpZone_trace_forent = world;
        fireBullet_last_hit = world;
@@ -473,7 +473,7 @@ void fireBullet(vector start, vector dir, float spread, float max_solid_penetrat
 
                // Only show effect when going through a player (invisible otherwise)
                if (hit && (hit.solid != SOLID_BSP))
-                       if(vlen(trace_endpos - start) > 4)
+                       if(vdist(trace_endpos - start, >, 4))
                                trailparticles(self, fireBullet_trace_callback_eff, start, trace_endpos);
 
                start = trace_endpos;