setsize(wp, m1, m2);
wp.effects = EF_LOWPRECISION;
if (wp.wpflags & WAYPOINTFLAG_ITEM)
- wp.colormod = '1 0 0';
+ wp.colormod = '1 0 0'; // red
else if (wp.wpflags & WAYPOINTFLAG_GENERATED)
- wp.colormod = '1 1 0';
- else if (wp.wpflags & WAYPOINTFLAG_NORELINK)
+ wp.colormod = '1 1 0'; // yellow
+ else if (wp.wpflags & WAYPOINTFLAG_SUPPORT)
+ wp.colormod = '0 1 0'; // green
+ else if (wp.wpflags & WAYPOINTFLAG_CUSTOM_JP)
wp.colormod = '1 0.5 0'; // orange
+ else if (wp.wpflags & WAYPOINTFLAG_TELEPORT)
+ wp.colormod = '1 0.5 0'; // orange
+ else if (wp.wpflags & WAYPOINTFLAG_LADDER)
+ wp.colormod = '1 0.5 0'; // orange
+ else if (wp.wpflags & WAYPOINTFLAG_JUMP)
+ wp.colormod = '1 0.5 0'; // orange
+ else if (wp.wpflags & WAYPOINTFLAG_CROUCH)
+ wp.colormod = '0 1 1'; // cyan
else if (waypoint_has_hardwiredlinks(wp))
- wp.colormod = '0.5 0 1'; // violet
+ wp.colormod = '0.5 0 1'; // purple
else
wp.colormod = '1 1 1';
}
wp.model = "";
}
+string waypoint_get_type_name(entity wp)
+{
+ if (wp.wpflags & WAYPOINTFLAG_ITEM) return "^1Item waypoint";
+ else if (wp.wpflags & WAYPOINTFLAG_CROUCH) return "^5Crouch waypoint";
+ else if (wp.wpflags & WAYPOINTFLAG_JUMP) return "^xf80Jump waypoint";
+ else if (wp.wpflags & WAYPOINTFLAG_SUPPORT) return "^2Support waypoint";
+ else if (waypoint_has_hardwiredlinks(wp)) return "^x80fHardwired waypoint";
+ else if (wp.wpflags & WAYPOINTFLAG_LADDER) return "^3Ladder waypoint";
+ else if (wp.wpflags & WAYPOINTFLAG_TELEPORT)
+ {
+ if (!wp.wpisbox) return "^3Warpzone waypoint";
+ else if (wp.wpflags & WAYPOINTFLAG_CUSTOM_JP) return "^3Custom jumppad waypoint";
+ else
+ {
+ IL_EACH(g_jumppads, boxesoverlap(wp.absmin, wp.absmax, it.absmin, it.absmax),
+ { return "^3Jumppad waypoint"; });
+ return "^3Teleport waypoint";
+ }
+ }
+
+ return "^7Waypoint";
+}
+
entity waypoint_get(vector m1, vector m2)
{
if (m1 == m2)
return NULL;
}
+.float createdtime;
entity waypoint_spawn(vector m1, vector m2, float f)
{
if(!(f & (WAYPOINTFLAG_PERSONAL | WAYPOINTFLAG_GENERATED)) && m1 == m2)
// spawn only one destination waypoint for teleports teleporting player to the exact same spot
// otherwise links loaded from file would be applied only to the first destination
// waypoint since link format doesn't specify waypoint entities but just positions
- if((f & WAYPOINTFLAG_GENERATED) && !(f & (WAYPOINTFLAG_NORELINK | WAYPOINTFLAG_PERSONAL)) && m1 == m2)
+ if((f & WAYPOINTFLAG_GENERATED) && !(f & (WPFLAGMASK_NORELINK | WAYPOINTFLAG_PERSONAL)) && m1 == m2)
{
IL_EACH(g_waypoints, boxesoverlap(m1, m2, it.absmin, it.absmax),
{
w.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
w.wpflags = f;
w.solid = SOLID_TRIGGER;
+ w.createdtime = time;
setorigin(w, (m1 + m2) * 0.5);
setsize(w, m1 - w.origin, m2 - w.origin);
if (w.size)
if(!w.wpisbox)
{
- setsize(w, PL_MIN_CONST - '1 1 0', PL_MAX_CONST + '1 1 0');
+ if (f & WAYPOINTFLAG_CROUCH)
+ setsize(w, PL_CROUCH_MIN_CONST - '1 1 0', PL_CROUCH_MAX_CONST + '1 1 0');
+ else
+ setsize(w, PL_MIN_CONST - '1 1 0', PL_MAX_CONST + '1 1 0');
if(!move_out_of_solid(w))
{
if(!(f & WAYPOINTFLAG_GENERATED))
bool start_wp_is_spawned;
vector start_wp_origin;
+bool start_wp_is_hardwired;
+bool start_wp_is_support;
-void waypoint_clear_start_wp(entity pl, bool warn)
+void waypoint_clear_start_wp_globals(entity pl, bool warn)
{
start_wp_is_spawned = false;
start_wp_origin = '0 0 0';
pl.wp_locked = NULL;
+ start_wp_is_hardwired = false;
+ start_wp_is_support = false;
if (warn)
LOG_INFO("^xf80Start waypoint has been cleared.\n");
}
-void waypoint_spawn_fromeditor(entity pl, bool at_crosshair, bool is_jump_wp)
+void crosshair_trace_waypoints(entity pl);
+void waypoint_start_hardwiredlink(entity pl)
+{
+ entity wp = pl.nearestwaypoint;
+ if ((!start_wp_is_spawned || start_wp_is_hardwired) && wp && !(wp.wpflags & WPFLAGMASK_NORELINK))
+ {
+ start_wp_is_hardwired = true;
+ start_wp_is_spawned = true;
+ start_wp_origin = wp.origin;
+ pl.wp_locked = wp;
+ LOG_INFOF("^x80fNearest waypoint %s marked as hardwired link origin.\n", vtos(wp.origin));
+ }
+ else
+ start_wp_is_hardwired = false;
+}
+
+void waypoint_spawn_fromeditor(entity pl, bool at_crosshair, bool is_jump_wp, bool is_crouch_wp, bool is_support_wp)
{
if (WAYPOINT_VERSION < waypoint_version_loaded)
{
vector org = pl.origin;
if (at_crosshair)
{
- crosshair_trace(pl);
- org = trace_endpos - eZ * PL_MIN_CONST.z;
- IL_EACH(g_jumppads, boxesoverlap(org + PL_MIN_CONST, org + PL_MAX_CONST, it.absmin, it.absmax),
+ crosshair_trace_waypoints(pl);
+ org = trace_endpos;
+ if (!trace_ent)
+ org.z -= PL_MIN_CONST.z;
+ if (!(start_wp_is_hardwired || start_wp_is_support))
+ IL_EACH(g_jumppads, boxesoverlap(org + PL_MIN_CONST, org + PL_MAX_CONST, it.absmin, it.absmax),
+ {
+ jp = it;
+ break;
+ });
+ if (!jp && !start_wp_is_spawned && trace_ent)
{
- jp = it;
- break;
- });
+ if (trace_ent.wpflags & (WAYPOINTFLAG_JUMP))
+ is_jump_wp = true;
+ else if (trace_ent.wpflags & (WAYPOINTFLAG_SUPPORT))
+ is_support_wp = true;
+ }
}
- if (jp || is_jump_wp)
+ if (jp || is_jump_wp || is_support_wp)
{
if (start_wp_is_spawned)
start_wp_is_spawned = false;
ctf_flags = 2;
int wp_num = ctf_flags;
- if(!PHYS_INPUT_BUTTON_CROUCH(pl) && !at_crosshair && !is_jump_wp)
+ if(!PHYS_INPUT_BUTTON_CROUCH(pl) && !at_crosshair && !is_jump_wp && !is_support_wp)
{
// snap waypoint to item's origin if close enough
IL_EACH(g_items, true,
vector start_org = '0 0 0';
if (start_wp_is_spawned)
{
- LOG_INFO("^xf80Spawning destination waypoint...\n");
+ if (!start_wp_is_hardwired)
+ LOG_INFO("^xf80Spawning destination waypoint...\n");
start_org = start_wp_origin;
}
if (jp)
{
e = NULL;
- IL_EACH(g_waypoints, it.wpflags & WAYPOINTFLAG_NORELINK
+ IL_EACH(g_waypoints, it.wpflags & WPFLAGMASK_NORELINK
&& boxesoverlap(org + PL_MIN_CONST, org + PL_MAX_CONST, it.absmin, it.absmax),
{
e = it; break;
});
if (!e)
- e = waypoint_spawn(jp.absmin - PL_MAX_CONST + '1 1 1', jp.absmax - PL_MIN_CONST + '-1 -1 -1', WAYPOINTFLAG_TELEPORT | WAYPOINTFLAG_NORELINK);
+ e = waypoint_spawn(jp.absmin - PL_MAX_CONST + '1 1 1', jp.absmax - PL_MIN_CONST + '-1 -1 -1', WAYPOINTFLAG_TELEPORT);
if (!pl.wp_locked)
pl.wp_locked = e;
}
- else if (is_jump_wp)
+ else if (is_jump_wp || is_support_wp)
{
+ int type_flag = (is_jump_wp) ? WAYPOINTFLAG_JUMP : WAYPOINTFLAG_SUPPORT;
+
entity wp_found = waypoint_get(org, org);
- if (wp_found && !(wp_found.wpflags & WAYPOINTFLAG_JUMP))
+ if (wp_found && !(wp_found.wpflags & type_flag))
{
- LOG_INFO("Error: can't spawn a jump waypoint over an existent waypoint of a different type\n");
+ LOG_INFOF("Error: can't spawn a %s waypoint over an existent waypoint of a different type\n", (is_jump_wp) ? "Jump" : "Support");
return;
}
- e = waypoint_spawn(org, org, WAYPOINTFLAG_JUMP | WAYPOINTFLAG_NORELINK);
+ e = waypoint_spawn(org, org, type_flag);
if (!pl.wp_locked)
pl.wp_locked = e;
}
else
- e = waypoint_spawn(org, org, 0);
+ e = waypoint_spawn(org, org, (is_crouch_wp) ? WAYPOINTFLAG_CROUCH : 0);
if(!e)
{
LOG_INFOF("Couldn't spawn waypoint at %v\n", org);
if (start_wp_is_spawned)
- waypoint_clear_start_wp(pl, true);
+ waypoint_clear_start_wp_globals(pl, true);
return;
}
entity start_wp = NULL;
if (start_wp_is_spawned)
{
- IL_EACH(g_waypoints, it.wpflags & WAYPOINTFLAG_NORELINK
+ IL_EACH(g_waypoints, (start_wp_is_hardwired || it.wpflags & WPFLAGMASK_NORELINK)
&& boxesoverlap(start_org, start_org, it.absmin, it.absmax),
{
start_wp = it; break;
{
// should not happen
LOG_INFOF("Couldn't find start waypoint at %v\n", start_org);
- waypoint_clear_start_wp(pl, true);
+ waypoint_clear_start_wp_globals(pl, true);
return;
}
- waypoint_addlink(start_wp, e);
+ if (start_wp_is_hardwired)
+ {
+ if (waypoint_is_hardwiredlink(start_wp, e))
+ {
+ waypoint_unmark_hardwiredlink(start_wp, e);
+ waypoint_removelink(start_wp, e);
+ string s = strcat(vtos(start_wp.origin), "*", vtos(e.origin));
+ LOG_INFOF("^x80fRemoved hardwired link %s.\n", s);
+ }
+ else
+ {
+ if (e.createdtime == time)
+ {
+ LOG_INFO("Error: hardwired links can be created only between 2 existing (and unconnected) waypoints.\n");
+ waypoint_remove(e);
+ waypoint_clear_start_wp_globals(pl, true);
+ waypoint_spawn_fromeditor(pl, at_crosshair, is_jump_wp, is_crouch_wp, is_support_wp);
+ return;
+ }
+ if (start_wp == e)
+ {
+ LOG_INFO("Error: start and destination waypoints coincide.\n");
+ waypoint_clear_start_wp_globals(pl, true);
+ return;
+ }
+ if (waypoint_islinked(start_wp, e))
+ {
+ LOG_INFO("Error: waypoints are already linked.\n");
+ waypoint_clear_start_wp_globals(pl, true);
+ return;
+ }
+ waypoint_addlink(start_wp, e);
+ waypoint_mark_hardwiredlink(start_wp, e);
+ string s = strcat(vtos(start_wp.origin), "*", vtos(e.origin));
+ LOG_INFOF("^x80fAdded hardwired link %s.\n", s);
+ }
+ }
+ else
+ {
+ if (start_wp_is_support)
+ {
+ if (e.SUPPORT_WP)
+ {
+ LOG_INFOF("Waypoint %v has already a support waypoint, delete it first.\n", e.origin);
+ waypoint_clear_start_wp_globals(pl, true);
+ return;
+ }
+ // clear all links to e
+ IL_EACH(g_waypoints, it != e,
+ {
+ if (waypoint_islinked(it, e) && !waypoint_is_hardwiredlink(it, e))
+ waypoint_removelink(it, e);
+ });
+ }
+ waypoint_addlink(start_wp, e);
+ }
}
- if (!(jp || is_jump_wp))
+ if (!(jp || is_jump_wp || is_support_wp || start_wp_is_hardwired))
waypoint_schedulerelink(e);
- bprint(strcat("Waypoint spawned at ", vtos(e.origin), "\n"));
+
+ string wp_type_str = waypoint_get_type_name(e);
+
+ bprint(strcat(wp_type_str, "^7 spawned at ", vtos(e.origin), "\n"));
if (start_wp_is_spawned)
{
pl.wp_locked = NULL;
- waypoint_schedulerelink(start_wp);
+ if (!start_wp_is_hardwired)
+ waypoint_schedulerelink(start_wp);
if (start_wp.wpflags & WAYPOINTFLAG_TELEPORT)
{
if (start_wp.wp00_original == start_wp.wp00)
goto add_wp;
}
}
- if (jp || is_jump_wp)
+ if (jp || is_jump_wp || is_support_wp)
{
if (!start_wp_is_spawned)
{
// the next one created by the user will be the destination waypoint
start_wp_is_spawned = true;
start_wp_origin = initial_origin;
+ if (is_support_wp)
+ start_wp_is_support = true;
}
}
else if (start_wp_is_spawned)
{
- waypoint_clear_start_wp(pl, false);
+ waypoint_clear_start_wp_globals(pl, false);
}
}
{
IL_EACH(g_waypoints, it != wp,
{
+ if (it.SUPPORT_WP == wp)
+ {
+ it.SUPPORT_WP = NULL;
+ waypoint_schedulerelink(it); // restore incoming links
+ }
if (waypoint_islinked(it, wp))
{
if (waypoint_is_hardwiredlink(it, wp))
if (e.wpflags & WAYPOINTFLAG_GENERATED)
{
if (start_wp_is_spawned)
- waypoint_clear_start_wp(pl, true);
+ waypoint_clear_start_wp_globals(pl, true);
return;
}
if (waypoint_has_hardwiredlinks(e))
{
- LOG_INFO("^1Warning: ^7Removal of hardwired waypoints is not allowed in the editor. Please remove links from/to this waypoint (", vtos(e.origin), ") by hand from maps/", mapname, ".waypoints.hardwired\n");
+ LOG_INFO("Can't remove a waypoint with hardwired links, remove links with \"wpeditor hardwire\" first\n");
return;
}
}
bprint(strcat("Waypoint removed at ", vtos(e.origin), "\n"));
+ te_explosion(e.origin);
waypoint_remove(e);
if (sym && wp_sym)
}
if (start_wp_is_spawned)
- waypoint_clear_start_wp(pl, true);
+ waypoint_clear_start_wp_globals(pl, true);
}
void waypoint_removelink(entity from, entity to)
{
- if (from == to || (from.wpflags & WAYPOINTFLAG_NORELINK && !(from.wpflags & WAYPOINTFLAG_JUMP)))
+ if (from == to || (from.wpflags & WPFLAGMASK_NORELINK && !(from.wpflags & (WAYPOINTFLAG_JUMP | WAYPOINTFLAG_SUPPORT))))
return;
entity fromwp31_prev = from.wp31;
return dist / (autocvar_sv_maxspeed * 1.25);
return dist / autocvar_sv_maxspeed;
}
+
float waypoint_getlinearcost_underwater(float dist)
{
// NOTE: underwater speed factor is hardcoded in the engine too, see SV_WaterMove
return dist / (autocvar_sv_maxspeed * 0.7);
}
+float waypoint_getlinearcost_crouched(float dist)
+{
+ return dist / (autocvar_sv_maxspeed * 0.5);
+}
+
float waypoint_gettravelcost(vector from, vector to, entity from_ent, entity to_ent)
{
bool submerged_from = navigation_check_submerged_state(from_ent, from);
if (submerged_from && submerged_to)
return waypoint_getlinearcost_underwater(vlen(to - from));
+ if (from_ent.wpflags & WAYPOINTFLAG_CROUCH && to_ent.wpflags & WAYPOINTFLAG_CROUCH)
+ return waypoint_getlinearcost_crouched(vlen(to - from));
+
float c = waypoint_getlinearcost(vlen(to - from));
float height = from.z - to.z;
if(height > jumpheight_vec.z && autocvar_sv_gravity > 0)
{
- float height_cost;
+ float height_cost; // fall cost
if (boolean(from_ent.wpflags & WAYPOINTFLAG_JUMP))
height_cost = jumpheight_time + sqrt((height + jumpheight_vec.z) / (autocvar_sv_gravity / 2));
else
c = height_cost;
}
+ // consider half path underwater
if (submerged_from || submerged_to)
return (c + waypoint_getlinearcost_underwater(vlen(to - from))) / 2;
+
+ // consider half path crouched
+ if (from_ent.wpflags & WAYPOINTFLAG_CROUCH || to_ent.wpflags & WAYPOINTFLAG_CROUCH)
+ return (c + waypoint_getlinearcost_crouched(vlen(to - from))) / 2;
+
return c;
}
{
if (from == to || waypoint_islinked(from, to))
return;
- if (c == -1 && (from.wpflags & WAYPOINTFLAG_NORELINK) && !(from.wpflags & WAYPOINTFLAG_JUMP))
+ if (c == -1 && (from.wpflags & WPFLAGMASK_NORELINK) && !(from.wpflags & (WAYPOINTFLAG_JUMP | WAYPOINTFLAG_SUPPORT)))
return;
if(c == -1)
void waypoint_addlink(entity from, entity to)
{
- if ((from.wpflags & WAYPOINTFLAG_NORELINK) && !(from.wpflags & (WAYPOINTFLAG_JUMP)))
+ if ((from.wpflags & WPFLAGMASK_NORELINK) && !(from.wpflags & (WAYPOINTFLAG_JUMP | WAYPOINTFLAG_SUPPORT)))
waypoint_addlink_for_custom_jumppad(from, to);
else
waypoint_addlink_customcost(from, to, -1);
+
+ if (from.wpflags & WAYPOINTFLAG_SUPPORT)
+ to.SUPPORT_WP = from;
}
// relink this spawnfunc_waypoint
{
if (boxesoverlap(this.absmin, this.absmax, it.absmin, it.absmax))
{
- waypoint_addlink(this, it);
- waypoint_addlink(it, this);
+ if (!(this.wpflags & WPFLAGMASK_NORELINK))
+ waypoint_addlink(this, it);
+ if (!(it.wpflags & WPFLAGMASK_NORELINK))
+ waypoint_addlink(it, this);
}
else
{
dv = ev - sv;
dv.z = 0;
- if(vdist(dv, >=, 1050)) // max search distance in XY
+ int maxdist = 1050;
+ vector m1 = PL_MIN_CONST;
+ vector m2 = PL_MAX_CONST;
+
+ if (this.wpflags & WAYPOINTFLAG_CROUCH || it.wpflags & WAYPOINTFLAG_CROUCH)
+ {
+ m1 = PL_CROUCH_MIN_CONST;
+ m2 = PL_CROUCH_MAX_CONST;
+ // links from crouch wp to normal wp (and viceversa) are very short to avoid creating many links
+ // that would be wasted due to rough travel cost calculation (the longer link is, the higher cost is)
+ // links from crouch wp to crouch wp can be as long as normal links
+ if (!(this.wpflags & WAYPOINTFLAG_CROUCH && it.wpflags & WAYPOINTFLAG_CROUCH))
+ maxdist = 100;
+ }
+
+ if (vdist(dv, >=, maxdist)) // max search distance in XY
{
++relink_lengthculled;
continue;
//traceline(this.origin, it.origin, false, NULL);
//if (trace_fraction == 1)
- if (this.wpisbox || this.wpflags & WAYPOINTFLAG_JUMP)
+ if (this.wpisbox || this.wpflags & (WAYPOINTFLAG_JUMP | WAYPOINTFLAG_SUPPORT) // forbid outgoing links
+ || it.SUPPORT_WP) // forbid incoming links
+ {
relink_walkculled += 0.5;
+ }
else
{
- if (tracewalk(this, sv, PL_MIN_CONST, PL_MAX_CONST, ev2, ev2_height, MOVE_NOMONSTERS))
+ if (tracewalk(this, sv, m1, m2, ev2, ev2_height, MOVE_NOMONSTERS))
waypoint_addlink(this, it);
else
relink_walkculled += 0.5;
}
- if (it.wpisbox || it.wpflags & WAYPOINTFLAG_JUMP)
+ // reverse direction
+ if (it.wpisbox || it.wpflags & (WAYPOINTFLAG_JUMP | WAYPOINTFLAG_SUPPORT) // forbid incoming links
+ || this.SUPPORT_WP) // forbid outgoing links
+ {
relink_walkculled += 0.5;
+ }
else
{
- if (tracewalk(this, ev, PL_MIN_CONST, PL_MAX_CONST, sv2, sv2_height, MOVE_NOMONSTERS))
+ if (tracewalk(this, ev, m1, m2, sv2, sv2_height, MOVE_NOMONSTERS))
waypoint_addlink(it, this);
else
relink_walkculled += 0.5;
wp.enemy = NULL;
if (!(wp.wpflags & WAYPOINTFLAG_PERSONAL))
wp.owner = NULL;
- if (!(wp.wpflags & WAYPOINTFLAG_NORELINK))
+ if (!(wp.wpflags & WPFLAGMASK_NORELINK))
waypoint_clearlinks(wp);
// schedule an actual relink on next frame
setthink(wp, waypoint_think);
return true;
}
-
-void waypoint_remove_hardwiredlinks()
-{
- IL_EACH(g_waypoints, waypoint_has_hardwiredlinks(it),
- {
- if (it.wphw00) { waypoint_removelink(it, it.wphw00); it.wphw00 = NULL; }
- if (it.wphw01) { waypoint_removelink(it, it.wphw01); it.wphw01 = NULL; }
- if (it.wphw02) { waypoint_removelink(it, it.wphw02); it.wphw02 = NULL; }
- if (it.wphw03) { waypoint_removelink(it, it.wphw03); it.wphw03 = NULL; }
- if (it.wphw04) { waypoint_removelink(it, it.wphw04); it.wphw04 = NULL; }
- if (it.wphw05) { waypoint_removelink(it, it.wphw05); it.wphw05 = NULL; }
- if (it.wphw06) { waypoint_removelink(it, it.wphw06); it.wphw06 = NULL; }
- if (it.wphw07) { waypoint_removelink(it, it.wphw07); it.wphw07 = NULL; }
- waypoint_setupmodel(it);
- });
-}
-
void waypoint_load_hardwiredlinks()
{
string s;
if(!found)
{
- LOG_INFO("NOTICE: Can not find origin waypoint for the hardwired link ", s, ". Path skipped");
+ s = strcat(((is_special) ? "special link " : "hardwired link "), s);
+ LOG_INFO("NOTICE: Can not find origin waypoint of the ", s, ". Path skipped");
continue;
}
}
if(!found)
{
- LOG_INFO("NOTICE: Can not find destination waypoint for the hardwired link ", s, ". Path skipped");
+ s = strcat(((is_special) ? "special link " : "hardwired link "), s);
+ LOG_INFO("NOTICE: Can not find destination waypoint of the ", s, ". Path skipped");
continue;
}
{
waypoint_addlink(wp_from, wp_to);
waypoint_mark_hardwiredlink(wp_from, wp_to);
- } else if (wp_from.wpflags & WAYPOINTFLAG_NORELINK
- && (wp_from.wpflags & WAYPOINTFLAG_JUMP || (wp_from.wpisbox && wp_from.wpflags & WAYPOINTFLAG_TELEPORT)))
+ } else if (wp_from.wpflags & WPFLAGMASK_NORELINK
+ && (wp_from.wpflags & (WAYPOINTFLAG_JUMP | WAYPOINTFLAG_SUPPORT)
+ || (wp_from.wpisbox && wp_from.wpflags & WAYPOINTFLAG_TELEPORT)))
{
waypoint_addlink(wp_from, wp_to);
}
string gt_ext = GET_GAMETYPE_EXTENSION();
string filename = sprintf("maps/%s.waypoints.hardwired", strcat(mapname, gt_ext));
- int file = fopen(filename, FILE_READ);
-
- if (gt_ext != "" && file < 0)
+ int file = fopen(filename, FILE_WRITE);
+ if (file < 0)
{
- // if race waypoint file doesn't exist load the default one
- filename = sprintf("maps/%s.waypoints.hardwired", mapname);
- file = fopen(filename, FILE_READ);
+ LOG_TRACE("waypoint hardwired links ", filename, " creation failed");
+ return;
}
- if (file < 0)
+ // write hardwired links to file
+ int count = 0;
+ fputs(file, "// HARDWIRED LINKS\n");
+ IL_EACH(g_waypoints, waypoint_has_hardwiredlinks(it),
{
- filename = sprintf("maps/%s.waypoints.hardwired", strcat(mapname, gt_ext));
- file = fopen(filename, FILE_WRITE);
- if (file < 0)
- {
- LOG_TRACE("waypoint hardwired links ", filename, " creation failed");
- return;
- }
- fputs(file, "// HARDWIRED LINKS\n\n");
- fclose(file);
- fopen(filename, FILE_READ);
- if (file < 0)
+ for (int j = 0; j < 32; ++j)
{
- LOG_TRACE("waypoint hardwired links load from ", filename, " failed");
- return;
+ entity link = waypoint_get_link(it, j);
+ if (waypoint_is_hardwiredlink(it, link))
+ {
+ // NOTE: vtos rounds vector components to 1 decimal place
+ string s = strcat(vtos(it.origin), "*", vtos(link.origin), "\n");
+ fputs(file, s);
+ ++count;
+ }
}
- }
-
- int buf = buf_create();
- string s;
- int pos = 0;
-
- // read comments and hardwired links from file to buf, they won't be changed
- while ((s = fgets(file)))
- {
- // special links start with *, so old xonotic versions don't load them
- if (substring(s, 0, 1) == "*")
- break;
- bufstr_add(buf, s, false);
- ++pos;
- }
- fclose(file);
+ });
- // read links to buf
- bool special_link_found = false;
- IL_EACH(g_waypoints, it.wpflags & (WAYPOINTFLAG_JUMP | WAYPOINTFLAG_CUSTOM_JP),
+ // write special links to file
+ int count2 = 0;
+ fputs(file, "\n// SPECIAL LINKS\n");
+ IL_EACH(g_waypoints, it.wpflags & (WAYPOINTFLAG_JUMP | WAYPOINTFLAG_SUPPORT | WAYPOINTFLAG_CUSTOM_JP),
{
for (int j = 0; j < 32; ++j)
{
entity link = waypoint_get_link(it, j);
if (link)
{
- if (!special_link_found)
- {
- special_link_found = true;
- if (pos == 0 || substring(bufstr_get(buf, pos - 1), 0, 16) != "// SPECIAL LINKS")
- {
- bufstr_add(buf, "// SPECIAL LINKS (saved in the waypoint editor, comments added hereby won't be preserved)", false);
- }
- }
// NOTE: vtos rounds vector components to 1 decimal place
- string s = strcat("*", vtos(it.origin), "*", vtos(link.origin));
- bufstr_add(buf, s, false);
+ string s = strcat("*", vtos(it.origin), "*", vtos(link.origin), "\n");
+ fputs(file, s);
+ ++count2;
}
}
});
- // write buf to file
- gt_ext = GET_GAMETYPE_EXTENSION();
- filename = sprintf("maps/%s.waypoints.hardwired", strcat(mapname, gt_ext));
- file = fopen(filename, FILE_WRITE);
- if (file < 0)
- {
- LOG_INFOF("waypoint hardwired link save to %s failed", filename);
- return;
- }
- int n = buf_getsize(buf);
- for (int i = 0; i < n; ++i)
- {
- fputs(file, (strcat(bufstr_get(buf, i), "\n")));
- }
- buf_del(buf);
fclose(file);
- LOG_INFOF("saved hardwired waypoint links to %s", filename);
+ LOG_INFOF("saved %d hardwired links and %d special links to %s", count, count2, filename);
}
// Save all waypoint links to a file
void waypoint_save_links()
{
- // temporarily remove hardwired links so they don't get saved among normal links
- waypoint_remove_hardwiredlinks();
-
string gt_ext = GET_GAMETYPE_EXTENSION();
string filename = sprintf("maps/%s.waypoints.cache", strcat(mapname, gt_ext));
fputs(file, strcat("//", "WAYPOINT_TIME ", waypoint_time, "\n"));
int c = 0;
- IL_EACH(g_waypoints, !(it.wpflags & (WAYPOINTFLAG_JUMP | WAYPOINTFLAG_CUSTOM_JP)),
+ IL_EACH(g_waypoints, !(it.wpflags & (WAYPOINTFLAG_JUMP | WAYPOINTFLAG_SUPPORT | WAYPOINTFLAG_CUSTOM_JP)),
{
for(int j = 0; j < 32; ++j)
{
entity link = waypoint_get_link(it, j);
- if(link)
+ if (link && !waypoint_is_hardwiredlink(it, link))
{
// NOTE: vtos rounds vector components to 1 decimal place
string s = strcat(vtos(it.origin), "*", vtos(link.origin), "\n");
botframe_cachedwaypointlinks = true;
LOG_INFOF("saved %d waypoint links to %s", c, filename);
-
- waypoint_load_hardwiredlinks();
}
// save waypoints to gamedir/data/maps/mapname.waypoints
float waypoint_loadall()
{
string s;
- float file, cwp, cwb, fl;
+ int file, cwp, cwb, fl;
vector m1, m2;
cwp = 0;
cwb = 0;
if (!s)
break;
fl = stof(s);
+ if (fl & WAYPOINTFLAG_NORELINK__DEPRECATED)
+ fl &= ~WAYPOINTFLAG_NORELINK__DEPRECATED;
waypoint_spawn(m1, m2, fl);
if (m1 == m2)
cwp = cwp + 1;
{
entity w;
entity dw;
- w = waypoint_spawn(org1, org2, WAYPOINTFLAG_GENERATED | teleport_flag | WAYPOINTFLAG_NORELINK);
+ w = waypoint_spawn(org1, org2, WAYPOINTFLAG_GENERATED | teleport_flag);
dw = waypoint_spawn(destination1, destination2, WAYPOINTFLAG_GENERATED);
// one way link to the destination
w.wp00_original = dw;
if (!(wp1 && wp2))
return;
- if (waypoint_is_hardwiredlink(wp1, wp2))
+ if (waypoint_is_hardwiredlink(wp1, wp2) || wp1.wpflags & (WAYPOINTFLAG_JUMP | WAYPOINTFLAG_SUPPORT | WAYPOINTFLAG_CUSTOM_JP))
te_beam(NULL, wp1.origin, wp2.origin);
else if (display_type == 1)
te_lightning2(NULL, wp1.origin, wp2.origin);
setsize(it, '-16 -16 -16', '16 16 16');
});
- crosshair_trace(pl);
+ WarpZone_crosshair_trace(pl);
IL_EACH(g_waypoints, true, {
it.solid = SOLID_TRIGGER;
if (!it.wpisbox)
setsize(it, '0 0 0', '0 0 0');
});
+
if (trace_ent.classname != "waypoint")
trace_ent = NULL;
+ else if (!trace_ent.wpisbox)
+ trace_endpos = trace_ent.origin;
}
void botframe_showwaypointlinks()
wp = trace_ent;
if (wp != it.wp_aimed)
{
- str = sprintf("\necho ^2WP info^7: entity: %d, flags: %d, origin: '%s'\n", etof(wp), wp.wpflags, vtos(wp.origin));
+ string wp_type_str = waypoint_get_type_name(wp);
+ str = sprintf("\necho Entity %d: %s^7, flags: %d, origin: %s\n", etof(wp), wp_type_str, wp.wpflags, vtos(wp.origin));
if (wp.wpisbox)
- str = strcat(str, sprintf("echo \" absmin: '%s', absmax: '%s'\"\n", vtos(wp.absmin), vtos(wp.absmax)));
+ str = strcat(str, sprintf("echo \" absmin: %s, absmax: %s\"\n", vtos(wp.absmin), vtos(wp.absmax)));
stuffcmd(it, str);
- str = sprintf("entity: %d\nflags: %d\norigin: \'%s\'", etof(wp), wp.wpflags, vtos(wp.origin));
+ str = sprintf("Entity %d: %s^7\nflags: %d\norigin: %s", etof(wp), wp_type_str, wp.wpflags, vtos(wp.origin));
if (wp.wpisbox)
- str = strcat(str, sprintf(" \nabsmin: '%s'\nabsmax: '%s'", vtos(wp.absmin), vtos(wp.absmax)));
+ str = strcat(str, sprintf(" \nabsmin: %s\nabsmax: %s", vtos(wp.absmin), vtos(wp.absmax)));
debug_text_3d(wp.origin, str, 0, 7, '0 0 0');
}
}
}
float bestdist = maxdist;
- IL_EACH(g_waypoints, it != wp && !(it.wpflags & WAYPOINTFLAG_NORELINK),
+ IL_EACH(g_waypoints, it != wp && !(it.wpflags & WPFLAGMASK_NORELINK),
{
float d = vlen(wp.origin - it.origin) + vlen(it.origin - porg);
if(d < bestdist)
}
// automatically create missing waypoints
-.entity botframe_autowaypoints_lastwp0, botframe_autowaypoints_lastwp1;
void botframe_autowaypoints_fix(entity p, float walkfromwp, .entity fld)
{
float r = botframe_autowaypoints_fix_from(p, walkfromwp, p.(fld), fld);
});
}
+//.entity botframe_autowaypoints_lastwp0;
+.entity botframe_autowaypoints_lastwp1;
void botframe_autowaypoints()
{
FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it) && !IS_DEAD(it), {