]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Optimize code by adding 2 checks
authorterencehill <piuntn@gmail.com>
Sat, 19 May 2018 11:59:13 +0000 (13:59 +0200)
committerterencehill <piuntn@gmail.com>
Sat, 19 May 2018 11:59:13 +0000 (13:59 +0200)
qcsrc/server/bot/default/havocbot/havocbot.qc

index 9d4ef6336104b2d3c6006ddc07b66ad08b5c91e5..5fb9e728adb5b585743b8a3a22b85325f11e0e96 100644 (file)
@@ -1079,11 +1079,15 @@ void havocbot_movetogoal(entity this)
                }
 
                dodge = havocbot_dodge(this);
-               dodge = dodge * bound(0,0.5+(skill+this.bot_dodgeskill)*0.1,1);
+               if (dodge)
+                       dodge *= bound(0, 0.5 + (skill + this.bot_dodgeskill) * 0.1, 1);
                evadelava = evadelava * bound(1,3-(skill+this.bot_dodgeskill),3); //Noobs fear lava a lot and take more distance from it
-               traceline(this.origin, ( ( this.enemy.absmin + this.enemy.absmax ) * 0.5 ), true, NULL);
-               if(IS_PLAYER(trace_ent))
-                       dir = dir * bound(0,(skill+this.bot_dodgeskill)/7,1);
+               if (this.enemy)
+               {
+                       traceline(this.origin, (this.enemy.absmin + this.enemy.absmax) * 0.5, true, NULL);
+                       if (IS_PLAYER(trace_ent))
+                               dir = dir * bound(0, (skill + this.bot_dodgeskill) / 7, 1);
+               }
 
                dir = normalize(dir + dodge + evadeobstacle + evadelava);
        //      this.bot_dodgevector = dir;