From: terencehill Date: Mon, 5 Jun 2017 13:05:28 +0000 (+0200) Subject: Optimize a few checks X-Git-Tag: xonotic-v0.8.5~2378^2~143 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=bed936bd935a8363fb38a620666c030dcb83ef92;p=xonotic%2Fxonotic-data.pk3dir.git Optimize a few checks --- diff --git a/qcsrc/common/triggers/trigger/jumppads.qc b/qcsrc/common/triggers/trigger/jumppads.qc index c6c60ba7d..cc71897b1 100644 --- a/qcsrc/common/triggers/trigger/jumppads.qc +++ b/qcsrc/common/triggers/trigger/jumppads.qc @@ -353,7 +353,7 @@ void trigger_push_findtarget(entity this) new_org = org + ofs; e.velocity = trigger_push_calculatevelocity(new_org, t, this.height); vel = e.velocity; - if(vlen(vec2(e.velocity)) < autocvar_sv_maxspeed) + if (vdist(vec2(e.velocity), <, autocvar_sv_maxspeed)) e.velocity = autocvar_sv_maxspeed * flatdir; if (trigger_push_testorigin(e, t, this, new_org) && (!valid_best_target || trace_endpos.z > best_target.z + 50)) { @@ -365,7 +365,7 @@ void trigger_push_findtarget(entity this) new_org = org - ofs; e.velocity = trigger_push_calculatevelocity(new_org, t, this.height); vel = e.velocity; - if(vlen(vec2(e.velocity)) < autocvar_sv_maxspeed) + if (vdist(vec2(e.velocity), <, autocvar_sv_maxspeed)) e.velocity = autocvar_sv_maxspeed * flatdir; if (trigger_push_testorigin(e, t, this, new_org) && (!valid_best_target || trace_endpos.z > best_target.z + 50)) { diff --git a/qcsrc/server/bot/default/havocbot/havocbot.qc b/qcsrc/server/bot/default/havocbot/havocbot.qc index c533071b0..e2bd68e4b 100644 --- a/qcsrc/server/bot/default/havocbot/havocbot.qc +++ b/qcsrc/server/bot/default/havocbot/havocbot.qc @@ -311,7 +311,7 @@ void havocbot_bunnyhop(entity this, vector dir) // Run only to visible goals if(IS_ONGROUND(this)) - if(vlen(this.velocity - eZ * this.velocity.z) >= autocvar_sv_maxspeed) // if -really- running + if(vdist(vec2(this.velocity), >=, autocvar_sv_maxspeed)) // if -really- running if(checkpvs(this.origin + this.view_ofs, this.goalcurrent)) { this.bot_lastseengoal = this.goalcurrent; @@ -773,8 +773,8 @@ void havocbot_movetogoal(entity this) //if (this.bot_dodgevector_time < time) { - // this.bot_dodgevector_time = time + cvar("bot_ai_dodgeupdateinterval"); - // this.bot_dodgevector_jumpbutton = 1; + //this.bot_dodgevector_time = time + cvar("bot_ai_dodgeupdateinterval"); + //this.bot_dodgevector_jumpbutton = 1; evadeobstacle = '0 0 0'; evadelava = '0 0 0'; @@ -784,7 +784,7 @@ void havocbot_movetogoal(entity this) { if(this.waterlevel>WATERLEVEL_SWIMMING) { - // flatdir_z = 1; + //flatdir_z = 1; this.aistatus |= AI_STATUS_OUT_WATER; } else diff --git a/qcsrc/server/bot/default/navigation.qc b/qcsrc/server/bot/default/navigation.qc index c93e82615..dd242e6de 100644 --- a/qcsrc/server/bot/default/navigation.qc +++ b/qcsrc/server/bot/default/navigation.qc @@ -1088,7 +1088,7 @@ void navigation_poptouchedgoals(entity this) // Loose goal touching check when running if(this.aistatus & AI_STATUS_RUNNING) if(this.goalcurrent.classname=="waypoint") - if(vlen(this.velocity - eZ * this.velocity.z) >= autocvar_sv_maxspeed) // if -really- running + if(vdist(vec2(this.velocity), >=, autocvar_sv_maxspeed)) // if -really- running { if(vdist(this.origin - this.goalcurrent.origin, <, 150)) {