]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Optimize a few checks
authorterencehill <piuntn@gmail.com>
Mon, 5 Jun 2017 13:05:28 +0000 (15:05 +0200)
committerterencehill <piuntn@gmail.com>
Mon, 5 Jun 2017 13:05:28 +0000 (15:05 +0200)
qcsrc/common/triggers/trigger/jumppads.qc
qcsrc/server/bot/default/havocbot/havocbot.qc
qcsrc/server/bot/default/navigation.qc

index c6c60ba7d330557bd95366bec5f3872b0149d1b4..cc71897b18cc1890bab9cb460167b2731cbe0821 100644 (file)
@@ -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))
                                {
index c533071b029871e9b4c1436b6a0f406061cd005e..e2bd68e4bc4308a0bbc9e8a5592510550a2612ea 100644 (file)
@@ -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
index c93e826152ab68501d345e0f66901175690c8d6a..dd242e6def46e47efe3c66bf1ea959f0d07e5c53 100644 (file)
@@ -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))
                {