]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into mand1nga/pathfinding-optimizations
authormand1nga <mand1nga@xonotic.org>
Sat, 13 Aug 2011 03:51:05 +0000 (00:51 -0300)
committermand1nga <mand1nga@xonotic.org>
Sat, 13 Aug 2011 03:51:05 +0000 (00:51 -0300)
Conflicts:
qcsrc/server/bot/navigation.qc

1  2 
qcsrc/server/bot/navigation.qc

index ee1d60ffa4422c989d23d8400e9a7225e1b7a79a,ebaf210b3c493855e071ee409de9efdf34d7c233..2d66b021327e116231d567c989b2f77c7728d388
@@@ -641,19 -641,18 +641,22 @@@ void navigation_markroutes_inverted(ent
  void navigation_routerating(entity e, float f, float rangebias)
  {
        entity nwp;
+       vector o;
        if (!e)
                return;
  
 +      if(e.blacklisted)
 +              return;
 +
+       o = (e.absmin + e.absmax) * 0.5;
++
        //print("routerating ", etos(e), " = ", ftos(f), " - ", ftos(rangebias), "\n");
  
        // Evaluate path using jetpack
        if(g_jetpack)
        if(self.items & IT_JETPACK)
        if(autocvar_bot_ai_navigation_jetpack)
-       if(vlen(self.origin - e.origin) > autocvar_bot_ai_navigation_jetpack_mindistance)
+       if(vlen(self.origin - o) > autocvar_bot_ai_navigation_jetpack_mindistance)
        {
                vector pointa, pointb;
  
                pointa = trace_endpos - '0 0 1';
  
                // Point B
-               traceline(e.origin, e.origin + '0 0 65535', MOVE_NORMAL, e);
+               traceline(o, o + '0 0 65535', MOVE_NORMAL, e);
                pointb = trace_endpos - '0 0 1';
  
                // Can I see these two points from the sky?
        }
        else
        {
 +              float search;
 +
 +              search = TRUE;
 +
 +              if(e.flags & FL_ITEM)
 +              {
 +                      if not(e.flags & FL_WEAPON)
 +                      if(e.nearestwaypoint)
 +                              search = FALSE;
 +              }
 +              else if (e.flags & FL_WEAPON)
 +              {
 +                      if(e.classname != "droppedweapon")
 +                      if(e.nearestwaypoint)
 +                              search = FALSE;
 +              }
 +
 +              if(search)
                if (time > e.nearestwaypointtimeout)
                {
                        nwp = navigation_findnearestwaypoint(e, TRUE);
                        if(nwp)
                                e.nearestwaypoint = nwp;
                        else
 +                      {
                                dprint("FAILED to find a nearest waypoint to '", e.classname, "' #", etos(e), "\n");
  
 +                              if(e.flags & FL_ITEM)
 +                                      e.blacklisted = TRUE;
 +                              else if (e.flags & FL_WEAPON)
 +                              {
 +                                      if(e.classname != "droppedweapon")
 +                                              e.blacklisted = TRUE;
 +                              }
 +
 +                              if(e.blacklisted)
 +                              {
 +                                      dprint("The entity '", e.classname, "' is going to be excluded from path finding during this match\n");
 +                                      return;
 +                              }
 +                      }
 +
                        // TODO: Cleaner solution, probably handling this timeout from ctf.qc
                        if(e.classname=="item_flag_team")
                                e.nearestwaypointtimeout = time + 2;
        {
                //te_wizspike(nwp.wpnearestpoint);
        //      dprint(e.classname, " ", ftos(f), "/(1+", ftos((nwp.wpcost + vlen(e.origin - nwp.wpnearestpoint))), "/", ftos(rangebias), ") = ");
-               f = f * rangebias / (rangebias + (nwp.wpcost + vlen(e.origin - nwp.wpnearestpoint)));
+               f = f * rangebias / (rangebias + (nwp.wpcost + vlen(o - nwp.wpnearestpoint)));
                //dprint("considering ", e.classname, " (with rating ", ftos(f), ")\n");
                //dprint(ftos(f));
                if (navigation_bestrating < f)
@@@ -838,7 -803,7 +841,7 @@@ float navigation_routetogoal(entity e, 
                return TRUE;
  
        // if it can reach the goal there is nothing more to do
-       if (tracewalk(self, startposition, PL_MIN, PL_MAX, e.origin, bot_navigation_movemode))
+       if (tracewalk(self, startposition, PL_MIN, PL_MAX, (e.absmin + e.absmax) * 0.5, bot_navigation_movemode))
                return TRUE;
  
        // see if there are waypoints describing a path to the item
@@@ -964,7 -929,7 +967,7 @@@ void navigation_goalrating_end(
  void botframe_updatedangerousobjects(float maxupdate)
  {
        local entity head, bot_dodgelist;
-       local vector m1, m2, v;
+       local vector m1, m2, v, o;
        local float c, d, danger;
        c = 0;
        bot_dodgelist = findchainfloat(bot_dodge, TRUE);
                        v_x = bound(m1_x, v_x, m2_x);
                        v_y = bound(m1_y, v_y, m2_y);
                        v_z = bound(m1_z, v_z, m2_z);
-                       d = head.bot_dodgerating - vlen(head.origin - v);
+                       o = (head.absmin + head.absmax) * 0.5;
+                       d = head.bot_dodgerating - vlen(o - v);
                        if (d > 0)
                        {
-                               traceline(head.origin, v, TRUE, world);
+                               traceline(o, v, TRUE, world);
                                if (trace_fraction == 1)
                                        danger = danger + d;
                        }
@@@ -1141,7 -1107,7 +1145,7 @@@ void debugnodestatus(vector position, f
  void debuggoalstack()
  {
        local entity goal;
-       local vector org;
+       local vector org, go;
  
        if(self.goalcounter==0)goal=self.goalcurrent;
        else if(self.goalcounter==1)goal=self.goalstack01;
                org = self.lastposition;
  
  
-       te_lightning2(world, org, goal.origin);
-       self.lastposition = goal.origin;
+       go = ( goal.absmin + goal.absmax ) * 0.5;
+       te_lightning2(world, org, go);
+       self.lastposition = go;
  
        self.goalcounter++;
  }