]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Bot AI: fix bots ignoring loot if thrown by killed players they were directly chasing
authorterencehill <piuntn@gmail.com>
Fri, 23 Nov 2018 15:48:43 +0000 (16:48 +0100)
committerterencehill <piuntn@gmail.com>
Fri, 23 Nov 2018 17:05:25 +0000 (18:05 +0100)
qcsrc/server/bot/default/havocbot/havocbot.qc

index bed2919051e70ba6b63a8d2b4c105d5434a62390..bb6c15c528546b3b92863d621751eeaa1a9ec84f 100644 (file)
@@ -794,8 +794,26 @@ void havocbot_movetogoal(entity this)
                        // don't remove if not visible
                        if (checkpvs(this.origin + this.view_ofs, this.goalcurrent))
                        {
                        // 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)
                        }
                }
                else if (!(STAT(FROZEN, this.goalentity)) && this.bot_tracewalk_time < time)