X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fbot%2Fhavocbot%2Fhavocbot.qc;h=e7f59bc8ec26f967848d193acb1ae55498b1e8ff;hb=7b9c511da12ae85661563a1c8b803360447ba377;hp=f6c0348d28065517ff5865f0a5a21e8a3f27704a;hpb=6a611fb362129440369cb09a590023d6292102e9;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/bot/havocbot/havocbot.qc b/qcsrc/server/bot/havocbot/havocbot.qc index f6c0348d2..e7f59bc8e 100644 --- a/qcsrc/server/bot/havocbot/havocbot.qc +++ b/qcsrc/server/bot/havocbot/havocbot.qc @@ -41,41 +41,30 @@ void havocbot_ai(entity this) // TODO: tracewalk() should take care of this job (better path finding under water) // if we don't have a goal and we're under water look for a waypoint near the "shore" and push it if(IS_DEAD(this)) - if(this.goalcurrent==NULL) - if(this.waterlevel==WATERLEVEL_SWIMMING || (this.aistatus & AI_STATUS_OUT_WATER)) + if(!this.goalcurrent) + if(this.waterlevel == WATERLEVEL_SWIMMING || (this.aistatus & AI_STATUS_OUT_WATER)) { // Look for the closest waypoint out of water - entity newgoal, head; - float bestdistance, distance; - - newgoal = NULL; - bestdistance = 10000; - for (head = findchain(classname, "waypoint"); head; head = head.chain) + entity newgoal = NULL; + FOREACH_ENTITY_CLASS("waypoint", vdist(it.origin - this.origin, <=, 10000), { - distance = vlen(head.origin - this.origin); - if(distance>10000) - continue; - - if(head.origin.z < this.origin.z) + if(it.origin.z < this.origin.z) continue; - if(head.origin.z - this.origin.z - this.view_ofs.z > 100) + if(it.origin.z - this.origin.z - this.view_ofs.z > 100) continue; - if (pointcontents(head.origin + head.maxs + '0 0 1') != CONTENT_EMPTY) + if (pointcontents(it.origin + it.maxs + '0 0 1') != CONTENT_EMPTY) continue; - traceline(this.origin + this.view_ofs , head.origin, true, head); + traceline(this.origin + this.view_ofs, ((it.absmin + it.absmax) * 0.5), true, this); - if(trace_fraction<1) + if(trace_fraction < 1) continue; - if(distance1000) + if(trace_fraction < 1) continue; - traceline(this.origin + this.view_ofs , ( ( head.absmin + head.absmax ) * 0.5 ), true, NULL); - - if(trace_fraction<1) - continue; - - if(distance>bestdistance) - { - newgoal = head; - bestdistance = distance; - } - } + if(!newgoal || vlen2(it.origin - this.origin) > vlen2(newgoal.origin - this.origin)) + newgoal = it; + }); if(newgoal) { @@ -1233,15 +1212,11 @@ float havocbot_moveto(entity this, vector pos) this.aistatus |= AI_STATUS_WAYPOINT_PERSONAL_LINKING; // if pos is inside a teleport, then let's mark it as teleport waypoint - entity head; - for(head = NULL; (head = find(head, classname, "trigger_teleport")); ) + FOREACH_ENTITY_CLASS("trigger_teleport", WarpZoneLib_BoxTouchesBrush(pos, pos, it, NULL), { - if(WarpZoneLib_BoxTouchesBrush(pos, pos, head, NULL)) - { - wp.wpflags |= WAYPOINTFLAG_TELEPORT; - this.lastteleporttime = 0; - } - } + wp.wpflags |= WAYPOINTFLAG_TELEPORT; + this.lastteleporttime = 0; + }); /* if(wp.wpflags & WAYPOINTFLAG_TELEPORT)