]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/bot/default/havocbot/havocbot.qc
Bot AI: make bots with low movement skill slow down when they deviate too much from...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / bot / default / havocbot / havocbot.qc
index f5ba20c8a41b1acbe04a1368748eb8cbede98d30..94499c2eb53bedc3ddfc6de34de24a806acb3787 100644 (file)
@@ -779,7 +779,9 @@ void havocbot_movetogoal(entity this)
        {
                if (vdist(this.origin - this.goalcurrent_prev.origin, <, 50)
                        && navigation_goalrating_timeout_can_be_anticipated(this))
+               {
                        navigation_goalrating_timeout_force(this);
+               }
        }
 
        bool goalcurrent_can_be_removed = false;
@@ -879,7 +881,8 @@ void havocbot_movetogoal(entity this)
 
        diff = destorg - this.origin;
 
-       if (this.goalcurrent == this.goalentity && time < this.goalentity_lock_timeout && vdist(diff, <, 10))
+       if (time < this.bot_stop_moving_timeout
+               || (this.goalcurrent == this.goalentity && time < this.goalentity_lock_timeout && vdist(diff, <, 10)))
        {
                // stop if the locked goal has been reached
                destorg = this.origin;
@@ -961,8 +964,16 @@ void havocbot_movetogoal(entity this)
                        {
                                if (vlen2(flat_diff) < vlen2(offset))
                                {
-                                       actual_destorg.x = destorg.x;
-                                       actual_destorg.y = destorg.y;
+                                       if (this.goalcurrent.wpflags & WAYPOINTFLAG_JUMP && this.goalstack01)
+                                       {
+                                               // oblique warpzones need a jump otherwise bots gets stuck
+                                               PHYS_INPUT_BUTTON_JUMP(this) = true;
+                                       }
+                                       else
+                                       {
+                                               actual_destorg.x = destorg.x;
+                                               actual_destorg.y = destorg.y;
+                                       }
                                }
                        }
                        else if (vdist(flat_diff, <, 32) && diff.z < -16) // destination is under the bot
@@ -1055,6 +1066,12 @@ void havocbot_movetogoal(entity this)
                        // Check for water/slime/lava and dangerous edges
                        // (only when the bot is on the ground or jumping intentionally)
 
+                       if (skill + this.bot_moveskill <= 3 && time > this.bot_stop_moving_timeout
+                               && current_speed > maxspeed * 0.9 && fabs(deviation.y) > 70)
+                       {
+                               this.bot_stop_moving_timeout = time + 0.4 + random() * 0.2;
+                       }
+
                        offset = (vdist(this.velocity, >, 32) ? this.velocity * 0.2 : v_forward * 32);
                        vector dst_ahead = this.origin + this.view_ofs + offset;
                        vector dst_down = dst_ahead - '0 0 3000';
@@ -1179,7 +1196,12 @@ void havocbot_movetogoal(entity this)
        }
 
        if (!this.bot_aimdir_executed)
-               bot_aimdir(this, dir, -1);
+       {
+               if (time < this.bot_stop_moving_timeout)
+                       bot_aimdir(this, normalize(this.goalcurrent.origin - this.origin), -1);
+               else
+                       bot_aimdir(this, dir, -1);
+       }
 
        if (!ladder_zdir)
        {
@@ -1187,6 +1209,7 @@ void havocbot_movetogoal(entity this)
                dir = normalize(dir + dodge);
        }
 
+       makevectors(this.v_angle);
        //dir = this.bot_dodgevector;
        //if (this.bot_dodgevector_jumpbutton)
        //      PHYS_INPUT_BUTTON_JUMP(this) = true;
@@ -1402,7 +1425,7 @@ void havocbot_chooseweapon(entity this, .entity weaponentity)
        // Should it do a weapon combo?
        float af, ct, combo_time, combo;
 
-       af = ATTACK_FINISHED(this, 0);
+       af = ATTACK_FINISHED(this, weaponentity);
        ct = autocvar_bot_ai_weapon_combo_threshold;
 
        // Bots with no skill will be 4 times more slower than "godlike" bots when doing weapon combos