+#include "waypoints.qh"
+#include "../_all.qh"
+
+#include "bot.qh"
+#include "navigation.qh"
+
+#include "../antilag.qh"
+
+#include "../../common/constants.qh"
+
+#include "../../warpzonelib/util_server.qh"
+
// create a new spawnfunc_waypoint and automatically link it to other waypoints, and link
// them back to it as well
// (suitable for spawnfunc_waypoint editor)
{
if(!(f & WAYPOINTFLAG_GENERATED))
{
- dprint("Killed a waypoint that was stuck in solid at ", vtos(w.origin), "\n");
+ LOG_TRACE("Killed a waypoint that was stuck in solid at ", vtos(w.origin), "\n");
remove(w);
return world;
}
{
if(autocvar_developer)
{
- print("A generated waypoint is stuck in solid at ", vtos(w.origin), "\n");
+ LOG_INFO("A generated waypoint is stuck in solid at ", vtos(w.origin), "\n");
backtrace("Waypoint stuck");
}
}
{
m1 = w.mins;
m2 = w.maxs;
- setmodel(w, "models/runematch/rune.mdl"); w.effects = EF_LOWPRECISION;
+ setmodel(w, MDL_WAYPOINT); w.effects = EF_LOWPRECISION;
setsize(w, m1, m2);
if (w.wpflags & WAYPOINTFLAG_ITEM)
w.colormod = '1 0 0';
// (precompile a list of all reachable waypoints from this spawnfunc_waypoint)
// (SLOW!)
void waypoint_think()
-{
+{SELFPARAM();
entity e;
vector sv, sm1, sm2, ev, em1, em2, dv;
navigation_testtracewalk = 0;
if (!self.wpisbox)
{
- tracebox(sv - PL_MIN_z * '0 0 1', PL_MIN, PL_MAX, sv, false, self);
+ tracebox(sv - PL_MIN.z * '0 0 1', PL_MIN, PL_MAX, sv, false, self);
if (!trace_startsolid)
{
//dprint("sv deviation", vtos(trace_endpos - sv), "\n");
}
if (!e.wpisbox)
{
- tracebox(ev - PL_MIN_z * '0 0 1', PL_MIN, PL_MAX, ev, false, e);
+ tracebox(ev - PL_MIN.z * '0 0 1', PL_MIN, PL_MAX, ev, false, e);
if (!trace_startsolid)
{
//dprint("ev deviation", vtos(trace_endpos - ev), "\n");
vector m1, m2;
m1 = wp.mins;
m2 = wp.maxs;
- setmodel(wp, "models/runematch/rune.mdl"); wp.effects = EF_LOWPRECISION;
+ setmodel(wp, MDL_WAYPOINT); wp.effects = EF_LOWPRECISION;
setsize(wp, m1, m2);
if (wp.wpflags & WAYPOINTFLAG_ITEM)
wp.colormod = '1 0 0';
}
// spawnfunc_waypoint map entity
-void spawnfunc_waypoint()
+spawnfunc(waypoint)
{
setorigin(self, self.origin);
// schedule a relink after other waypoints have had a chance to spawn
if (file < 0)
{
- dprint("waypoint links load from ");
- dprint(filename);
- dprint(" failed\n");
+ LOG_TRACE("waypoint links load from ");
+ LOG_TRACE(filename);
+ LOG_TRACE(" failed\n");
return false;
}
if(!found)
{
- dprint("waypoint_load_links: couldn't find 'from' waypoint at ", vtos(wp_from.origin),"\n");
+ LOG_TRACE("waypoint_load_links: couldn't find 'from' waypoint at ", vtos(wp_from.origin),"\n");
continue;
}
if(!found)
{
- dprint("waypoint_load_links: couldn't find 'to' waypoint at ", vtos(wp_to.origin),"\n");
+ LOG_TRACE("waypoint_load_links: couldn't find 'to' waypoint at ", vtos(wp_to.origin),"\n");
continue;
}
fclose(file);
- dprint("loaded ");
- dprint(ftos(c));
- dprint(" waypoint links from maps/");
- dprint(mapname);
- dprint(".waypoints.cache\n");
+ LOG_TRACE("loaded ");
+ LOG_TRACE(ftos(c));
+ LOG_TRACE(" waypoint links from maps/");
+ LOG_TRACE(mapname);
+ LOG_TRACE(".waypoints.cache\n");
botframe_cachedwaypointlinks = true;
return true;
if (file < 0)
{
- dprint("waypoint links load from ");
- dprint(filename);
- dprint(" failed\n");
+ LOG_TRACE("waypoint links load from ");
+ LOG_TRACE(filename);
+ LOG_TRACE(" failed\n");
return;
}
if(!found)
{
- print(strcat("NOTICE: Can not find waypoint at ", vtos(wp_from_pos), ". Path skipped\n"));
+ LOG_INFO(strcat("NOTICE: Can not find waypoint at ", vtos(wp_from_pos), ". Path skipped\n"));
continue;
}
}
if(!found)
{
- print(strcat("NOTICE: Can not find waypoint at ", vtos(wp_to_pos), ". Path skipped\n"));
+ LOG_INFO(strcat("NOTICE: Can not find waypoint at ", vtos(wp_to_pos), ". Path skipped\n"));
continue;
}
fclose(file);
- dprint("loaded ");
- dprint(ftos(c));
- dprint(" waypoint links from maps/");
- dprint(mapname);
- dprint(".waypoints.hardwired\n");
+ LOG_TRACE("loaded ");
+ LOG_TRACE(ftos(c));
+ LOG_TRACE(" waypoint links from maps/");
+ LOG_TRACE(mapname);
+ LOG_TRACE(".waypoints.hardwired\n");
}
entity waypoint_get_link(entity w, float i)
file = fopen(filename, FILE_WRITE);
if (file < 0)
{
- print("waypoint links save to ");
- print(filename);
- print(" failed\n");
+ LOG_INFO("waypoint links save to ");
+ LOG_INFO(filename);
+ LOG_INFO(" failed\n");
}
c = 0;
w = findchain(classname, "waypoint");
fclose(file);
botframe_cachedwaypointlinks = true;
- print("saved ");
- print(ftos(c));
- print(" waypoints links to maps/");
- print(mapname);
- print(".waypoints.cache\n");
+ LOG_INFO("saved ");
+ LOG_INFO(ftos(c));
+ LOG_INFO(" waypoints links to maps/");
+ LOG_INFO(mapname);
+ LOG_INFO(".waypoints.cache\n");
}
// save waypoints to gamedir/data/maps/mapname.waypoints
cwb = cwb + 1;
}
fclose(file);
- dprint("loaded ");
- dprint(ftos(cwp));
- dprint(" waypoints and ");
- dprint(ftos(cwb));
- dprint(" wayboxes from maps/");
- dprint(mapname);
- dprint(".waypoints\n");
+ LOG_TRACE("loaded ");
+ LOG_TRACE(ftos(cwp));
+ LOG_TRACE(" waypoints and ");
+ LOG_TRACE(ftos(cwb));
+ LOG_TRACE(" wayboxes from maps/");
+ LOG_TRACE(mapname);
+ LOG_TRACE(".waypoints\n");
}
else
{
- dprint("waypoint load from ");
- dprint(filename);
- dprint(" failed\n");
+ LOG_TRACE("waypoint load from ");
+ LOG_TRACE(filename);
+ LOG_TRACE(" failed\n");
}
return cwp + cwb;
}
vector waypoint_fixorigin(vector position)
{
- tracebox(position + '0 0 1' * (1 - PL_MIN_z), PL_MIN, PL_MAX, position + '0 0 -512', MOVE_NOMONSTERS, world);
+ tracebox(position + '0 0 1' * (1 - PL_MIN.z), PL_MIN, PL_MAX, position + '0 0 -512', MOVE_NOMONSTERS, world);
if(trace_fraction < 1)
position = trace_endpos;
//traceline(position, position + '0 0 -512', MOVE_NOMONSTERS, world);
}
entity waypoint_spawnpersonal(vector position)
-{
+{SELFPARAM();
entity w;
// drop the waypoint to a proper location:
w = find(w, classname, "waypoint");
}
- waypoint_schedulerelink(p.fld = waypoint_spawn(v, v, f));
+ waypoint_schedulerelink(p.(fld) = waypoint_spawn(v, v, f));
return 1;
}
if(navigation_waypoint_will_link(w.origin, porg, p, walkfromwp, 1050))
{
bestdist = d;
- p.fld = w;
+ p.(fld) = w;
}
}
w = find(w, classname, "waypoint");
}
if(bestdist < maxdist)
{
- print("update chain to new nearest WP ", etos(p.fld), "\n");
+ LOG_INFO("update chain to new nearest WP ", etos(p.(fld)), "\n");
return 0;
}
// we know maxdist < 2100
// so wp -> porg is still valid
// all is good
- p.fld = wp;
+ p.(fld) = wp;
return 0;
}
setorigin(p, save);
if(w)
{
- p.fld = w;
+ p.(fld) = w;
return 0;
}
}
tmax = t;
}
- print("spawning a waypoint for connecting to ", etos(wp), "\n");
+ LOG_INFO("spawning a waypoint for connecting to ", etos(wp), "\n");
botframe_autowaypoints_createwp(o, p, fld, 0);
return 1;
}
.entity botframe_autowaypoints_lastwp0, botframe_autowaypoints_lastwp1;
void botframe_autowaypoints_fix(entity p, float walkfromwp, .entity fld)
{
- float r;
- r = botframe_autowaypoints_fix_from(p, walkfromwp, p.fld, fld);
+ float r = botframe_autowaypoints_fix_from(p, walkfromwp, p.(fld), fld);
if(r != -1)
return;
r = botframe_autowaypoints_fix_from(p, walkfromwp, world, fld);
if(r != -1)
return;
- print("emergency: got no good nearby WP to build a link from, starting a new chain\n");
+ LOG_INFO("emergency: got no good nearby WP to build a link from, starting a new chain\n");
if(!botframe_autowaypoints_fixdown(p.origin))
return; // shouldn't happen, caught above
botframe_autowaypoints_createwp(trace_endpos, p, fld, WAYPOINTFLAG_PROTECTED);
{
if (!(w.wpflags & (WAYPOINTFLAG_USEFUL | WAYPOINTFLAG_DEAD_END)))
{
- printf("Removed a waypoint at %v. Try again for more!\n", w.origin);
+ LOG_INFOF("Removed a waypoint at %v. Try again for more!\n", w.origin);
te_explosion(w.origin);
waypoint_remove(w);
break;