From: Mario Date: Mon, 4 Jan 2016 05:41:51 +0000 (+1000) Subject: Simplify maths for most vlen cases X-Git-Tag: xonotic-v0.8.2~1293 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f8ae7c7b2490de9c4f18f10f8986c977d7931571;p=xonotic%2Fxonotic-data.pk3dir.git Simplify maths for most vlen cases --- diff --git a/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc b/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc index acd372c98..b4d767295 100644 --- a/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc +++ b/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc @@ -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; } diff --git a/qcsrc/common/minigames/minigame/pong.qc b/qcsrc/common/minigames/minigame/pong.qc index 359003fff..87c75f48c 100644 --- a/qcsrc/common/minigames/minigame/pong.qc +++ b/qcsrc/common/minigames/minigame/pong.qc @@ -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 diff --git a/qcsrc/common/monsters/monster/mage.qc b/qcsrc/common/monsters/monster/mage.qc index c72e55015..37c6301fb 100644 --- a/qcsrc/common/monsters/monster/mage.qc +++ b/qcsrc/common/monsters/monster/mage.qc @@ -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); diff --git a/qcsrc/common/monsters/monster/shambler.qc b/qcsrc/common/monsters/monster/shambler.qc index 136b24f2f..0ffa60f8c 100644 --- a/qcsrc/common/monsters/monster/shambler.qc +++ b/qcsrc/common/monsters/monster/shambler.qc @@ -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 diff --git a/qcsrc/common/monsters/monster/wyvern.qc b/qcsrc/common/monsters/monster/wyvern.qc index 02b6a5950..b7d398da6 100644 --- a/qcsrc/common/monsters/monster/wyvern.qc +++ b/qcsrc/common/monsters/monster/wyvern.qc @@ -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); } diff --git a/qcsrc/common/monsters/sv_monsters.qc b/qcsrc/common/monsters/sv_monsters.qc index 10725c0d6..ccc3b83aa 100644 --- a/qcsrc/common/monsters/sv_monsters.qc +++ b/qcsrc/common/monsters/sv_monsters.qc @@ -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); diff --git a/qcsrc/common/mutators/mutator/buffs/buffs.qc b/qcsrc/common/mutators/mutator/buffs/buffs.qc index 889b0db2f..32fe2d87d 100644 --- a/qcsrc/common/mutators/mutator/buffs/buffs.qc +++ b/qcsrc/common/mutators/mutator/buffs/buffs.qc @@ -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; + } } )); diff --git a/qcsrc/common/mutators/mutator/dodging/dodging.qc b/qcsrc/common/mutators/mutator/dodging/dodging.qc index 915dbe663..09f169eb3 100644 --- a/qcsrc/common/mutators/mutator/dodging/dodging.qc +++ b/qcsrc/common/mutators/mutator/dodging/dodging.qc @@ -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; } diff --git a/qcsrc/common/mutators/mutator/overkill/hmg.qc b/qcsrc/common/mutators/mutator/overkill/hmg.qc index 6da57cb82..c08c3690e 100644 --- a/qcsrc/common/mutators/mutator/overkill/hmg.qc +++ b/qcsrc/common/mutators/mutator/overkill/hmg.qc @@ -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); diff --git a/qcsrc/common/mutators/mutator/sandbox/sandbox.qc b/qcsrc/common/mutators/mutator/sandbox/sandbox.qc index 6b97a28f1..2dffb42f8 100644 --- a/qcsrc/common/mutators/mutator/sandbox/sandbox.qc +++ b/qcsrc/common/mutators/mutator/sandbox/sandbox.qc @@ -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 diff --git a/qcsrc/common/mutators/mutator/spawn_near_teammate/spawn_near_teammate.qc b/qcsrc/common/mutators/mutator/spawn_near_teammate/spawn_near_teammate.qc index 51c598f17..168a06d2e 100644 --- a/qcsrc/common/mutators/mutator/spawn_near_teammate/spawn_near_teammate.qc +++ b/qcsrc/common/mutators/mutator/spawn_near_teammate/spawn_near_teammate.qc @@ -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); diff --git a/qcsrc/common/physics/movetypes/movetypes.qc b/qcsrc/common/physics/movetypes/movetypes.qc index ef9f05981..324f67b31 100644 --- a/qcsrc/common/physics/movetypes/movetypes.qc +++ b/qcsrc/common/physics/movetypes/movetypes.qc @@ -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; } diff --git a/qcsrc/common/triggers/teleporters.qc b/qcsrc/common/triggers/teleporters.qc index c00a4de26..eae31ead0 100644 --- a/qcsrc/common/triggers/teleporters.qc +++ b/qcsrc/common/triggers/teleporters.qc @@ -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 diff --git a/qcsrc/common/turrets/sv_turrets.qc b/qcsrc/common/turrets/sv_turrets.qc index bbd9c990a..a06fbcbb9 100644 --- a/qcsrc/common/turrets/sv_turrets.qc +++ b/qcsrc/common/turrets/sv_turrets.qc @@ -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); diff --git a/qcsrc/common/turrets/turret/ewheel.qc b/qcsrc/common/turrets/turret/ewheel.qc index 09c41550e..dc3b460e9 100644 --- a/qcsrc/common/turrets/turret/ewheel.qc +++ b/qcsrc/common/turrets/turret/ewheel.qc @@ -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)) diff --git a/qcsrc/common/turrets/turret/flac_weapon.qc b/qcsrc/common/turrets/turret/flac_weapon.qc index d1b560bfb..f4bc70ccc 100644 --- a/qcsrc/common/turrets/turret/flac_weapon.qc +++ b/qcsrc/common/turrets/turret/flac_weapon.qc @@ -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 diff --git a/qcsrc/common/turrets/turret/fusionreactor.qc b/qcsrc/common/turrets/turret/fusionreactor.qc index 55dcd6253..8ea1cbbd4 100644 --- a/qcsrc/common/turrets/turret/fusionreactor.qc +++ b/qcsrc/common/turrets/turret/fusionreactor.qc @@ -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) diff --git a/qcsrc/common/turrets/turret/hellion_weapon.qc b/qcsrc/common/turrets/turret/hellion_weapon.qc index 4a559b08e..0b118be13 100644 --- a/qcsrc/common/turrets/turret/hellion_weapon.qc +++ b/qcsrc/common/turrets/turret/hellion_weapon.qc @@ -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 diff --git a/qcsrc/common/turrets/turret/hk_weapon.qc b/qcsrc/common/turrets/turret/hk_weapon.qc index 58c22a79b..5060e5772 100644 --- a/qcsrc/common/turrets/turret/hk_weapon.qc +++ b/qcsrc/common/turrets/turret/hk_weapon.qc @@ -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; diff --git a/qcsrc/common/turrets/turret/walker.qc b/qcsrc/common/turrets/turret/walker.qc index f15a6d0a7..599e00c29 100644 --- a/qcsrc/common/turrets/turret/walker.qc +++ b/qcsrc/common/turrets/turret/walker.qc @@ -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); diff --git a/qcsrc/common/vehicles/sv_vehicles.qc b/qcsrc/common/vehicles/sv_vehicles.qc index 391ce9984..0c1574e2e 100644 --- a/qcsrc/common/vehicles/sv_vehicles.qc +++ b/qcsrc/common/vehicles/sv_vehicles.qc @@ -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". diff --git a/qcsrc/common/vehicles/vehicle/bumblebee.qc b/qcsrc/common/vehicles/vehicle/bumblebee.qc index 3bad3bcf1..cd2804a33 100644 --- a/qcsrc/common/vehicles/vehicle/bumblebee.qc +++ b/qcsrc/common/vehicles/vehicle/bumblebee.qc @@ -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; diff --git a/qcsrc/common/vehicles/vehicle/racer.qc b/qcsrc/common/vehicles/vehicle/racer.qc index 25d07612c..848fa2ff7 100644 --- a/qcsrc/common/vehicles/vehicle/racer.qc +++ b/qcsrc/common/vehicles/vehicle/racer.qc @@ -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; diff --git a/qcsrc/common/vehicles/vehicle/racer_weapon.qc b/qcsrc/common/vehicles/vehicle/racer_weapon.qc index a4cf0dde2..675d8f17b 100644 --- a/qcsrc/common/vehicles/vehicle/racer_weapon.qc +++ b/qcsrc/common/vehicles/vehicle/racer_weapon.qc @@ -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"); diff --git a/qcsrc/common/vehicles/vehicle/raptor.qc b/qcsrc/common/vehicles/vehicle/raptor.qc index 649977603..d012bd573 100644 --- a/qcsrc/common/vehicles/vehicle/raptor.qc +++ b/qcsrc/common/vehicles/vehicle/raptor.qc @@ -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; diff --git a/qcsrc/common/vehicles/vehicle/raptor_weapons.qc b/qcsrc/common/vehicles/vehicle/raptor_weapons.qc index 92c647624..175dbd099 100644 --- a/qcsrc/common/vehicles/vehicle/raptor_weapons.qc +++ b/qcsrc/common/vehicles/vehicle/raptor_weapons.qc @@ -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; diff --git a/qcsrc/common/vehicles/vehicle/spiderbot.qc b/qcsrc/common/vehicles/vehicle/spiderbot.qc index 0004667cd..edb2a4758 100644 --- a/qcsrc/common/vehicles/vehicle/spiderbot.qc +++ b/qcsrc/common/vehicles/vehicle/spiderbot.qc @@ -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; diff --git a/qcsrc/common/vehicles/vehicle/spiderbot_weapons.qc b/qcsrc/common/vehicles/vehicle/spiderbot_weapons.qc index 7a657961d..257eac801 100644 --- a/qcsrc/common/vehicles/vehicle/spiderbot_weapons.qc +++ b/qcsrc/common/vehicles/vehicle/spiderbot_weapons.qc @@ -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(); } diff --git a/qcsrc/common/weapons/weapon/arc.qc b/qcsrc/common/weapons/weapon/arc.qc index 2a12c4564..ba36d8fc9 100644 --- a/qcsrc/common/weapons/weapon/arc.qc +++ b/qcsrc/common/weapons/weapon/arc.qc @@ -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 diff --git a/qcsrc/common/weapons/weapon/devastator.qc b/qcsrc/common/weapons/weapon/devastator.qc index d714acab4..0272e424c 100644 --- a/qcsrc/common/weapons/weapon/devastator.qc +++ b/qcsrc/common/weapons/weapon/devastator.qc @@ -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); diff --git a/qcsrc/common/weapons/weapon/electro.qc b/qcsrc/common/weapons/weapon/electro.qc index d766e6a87..3e93644fb 100644 --- a/qcsrc/common/weapons/weapon/electro.qc +++ b/qcsrc/common/weapons/weapon/electro.qc @@ -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; diff --git a/qcsrc/common/weapons/weapon/fireball.qc b/qcsrc/common/weapons/weapon/fireball.qc index f39ad474a..50119a687 100644 --- a/qcsrc/common/weapons/weapon/fireball.qc +++ b/qcsrc/common/weapons/weapon/fireball.qc @@ -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) diff --git a/qcsrc/common/weapons/weapon/hook.qc b/qcsrc/common/weapons/weapon/hook.qc index e2884ff79..d76095ec8 100644 --- a/qcsrc/common/weapons/weapon/hook.qc +++ b/qcsrc/common/weapons/weapon/hook.qc @@ -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); diff --git a/qcsrc/common/weapons/weapon/machinegun.qc b/qcsrc/common/weapons/weapon/machinegun.qc index c17d07d65..f220752b3 100644 --- a/qcsrc/common/weapons/weapon/machinegun.qc +++ b/qcsrc/common/weapons/weapon/machinegun.qc @@ -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); diff --git a/qcsrc/common/weapons/weapon/minelayer.qc b/qcsrc/common/weapons/weapon/minelayer.qc index f9c43f62d..e5c43f3a4 100644 --- a/qcsrc/common/weapons/weapon/minelayer.qc +++ b/qcsrc/common/weapons/weapon/minelayer.qc @@ -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(); diff --git a/qcsrc/common/weapons/weapon/porto.qc b/qcsrc/common/weapons/weapon/porto.qc index 580a5bece..56b2759ec 100644 --- a/qcsrc/common/weapons/weapon/porto.qc +++ b/qcsrc/common/weapons/weapon/porto.qc @@ -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); diff --git a/qcsrc/common/weapons/weapon/rifle.qc b/qcsrc/common/weapons/weapon/rifle.qc index 1f79e59f6..526ba0e20 100644 --- a/qcsrc/common/weapons/weapon/rifle.qc +++ b/qcsrc/common/weapons/weapon/rifle.qc @@ -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) { diff --git a/qcsrc/common/weapons/weapon/seeker.qc b/qcsrc/common/weapons/weapon/seeker.qc index 98fe8c8f7..a25e928cb 100644 --- a/qcsrc/common/weapons/weapon/seeker.qc +++ b/qcsrc/common/weapons/weapon/seeker.qc @@ -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 diff --git a/qcsrc/common/weapons/weapon/shotgun.qc b/qcsrc/common/weapons/weapon/shotgun.qc index 928ec4bef..dba351eb6 100644 --- a/qcsrc/common/weapons/weapon/shotgun.qc +++ b/qcsrc/common/weapons/weapon/shotgun.qc @@ -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)) { diff --git a/qcsrc/lib/warpzone/common.qc b/qcsrc/lib/warpzone/common.qc index 080c6310b..5a9b2abf9 100644 --- a/qcsrc/lib/warpzone/common.qc +++ b/qcsrc/lib/warpzone/common.qc @@ -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; diff --git a/qcsrc/lib/warpzone/server.qc b/qcsrc/lib/warpzone/server.qc index 927375043..22aaba862 100644 --- a/qcsrc/lib/warpzone/server.qc +++ b/qcsrc/lib/warpzone/server.qc @@ -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"); } } diff --git a/qcsrc/menu/menu.qc b/qcsrc/menu/menu.qc index 22ab7047c..1c7ed0386 100644 --- a/qcsrc/menu/menu.qc +++ b/qcsrc/menu/menu.qc @@ -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); diff --git a/qcsrc/server/anticheat.qc b/qcsrc/server/anticheat.qc index 877d41657..865010ff5 100644 --- a/qcsrc/server/anticheat.qc +++ b/qcsrc/server/anticheat.qc @@ -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); /* diff --git a/qcsrc/server/bot/aim.qc b/qcsrc/server/bot/aim.qc index 069265937..79f0a2758 100644 --- a/qcsrc/server/bot/aim.qc +++ b/qcsrc/server/bot/aim.qc @@ -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"); diff --git a/qcsrc/server/steerlib.qc b/qcsrc/server/steerlib.qc index ae850618d..7e05e7c75 100644 --- a/qcsrc/server/steerlib.qc +++ b/qcsrc/server/steerlib.qc @@ -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; diff --git a/qcsrc/server/weapons/tracing.qc b/qcsrc/server/weapons/tracing.qc index 01a23c1a5..facf13f20 100644 --- a/qcsrc/server/weapons/tracing.qc +++ b/qcsrc/server/weapons/tracing.qc @@ -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;