]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/bot/default/havocbot/havocbot.qc
Fix issues with the waypoint spawned by the moveto command
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / bot / default / havocbot / havocbot.qc
index bed2919051e70ba6b63a8d2b4c105d5434a62390..a8e10194ef96debb1107ce0e37aba05ae84fc00c 100644 (file)
@@ -31,6 +31,8 @@ void havocbot_ai(entity this)
        if(this.draggedby)
                return;
 
+       this.bot_aimdir_executed = false;
+
        if(bot_execute_commands(this))
                return;
 
@@ -106,8 +108,6 @@ void havocbot_ai(entity this)
        havocbot_aim(this);
        lag_update(this);
 
-       this.bot_aimdir_executed = false;
-
        if (this.bot_aimtarg)
        {
                this.aistatus |= AI_STATUS_ATTACKING;
@@ -794,8 +794,26 @@ void havocbot_movetogoal(entity this)
                        // don't remove if not visible
                        if (checkpvs(this.origin + this.view_ofs, this.goalcurrent))
                        {
-                               navigation_goalrating_timeout_force(this);
-                               return;
+                               if (IS_DEAD(this.goalcurrent))
+                               {
+                                       IL_EACH(g_items, it.enemy == this.goalcurrent && Item_IsLoot(it),
+                                       {
+                                               if (vdist(it.origin - this.goalcurrent.death_origin, <, 50))
+                                               {
+                                                       navigation_clearroute(this);
+                                                       navigation_pushroute(this, it);
+                                                       // loot can't be immediately rated since it isn't on ground yet
+                                                       // it will be rated after a second when on ground, meanwhile head to it
+                                                       navigation_goalrating_timeout_expire(this, 1);
+                                                       return;
+                                               }
+                                       });
+                               }
+                               if (!Item_IsLoot(this.goalcurrent))
+                               {
+                                       navigation_goalrating_timeout_force(this);
+                                       return;
+                               }
                        }
                }
                else if (!(STAT(FROZEN, this.goalentity)) && this.bot_tracewalk_time < time)
@@ -1585,7 +1603,7 @@ float havocbot_moveto(entity this, vector pos)
                {
                        // Step 5: Waypoint reached
                        LOG_TRACE(this.netname, "'s personal waypoint reached");
-                       delete(this.havocbot_personal_waypoint);
+                       waypoint_remove(this.havocbot_personal_waypoint);
                        this.aistatus &= ~AI_STATUS_WAYPOINT_PERSONAL_REACHED;
                        return CMD_STATUS_FINISHED;
                }