Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
movenode.qc File Reference
Include dependency graph for movenode.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void a_think (entity this)
vector pathlib_flynode (entity this, vector start, vector end, float doedge)
vector pathlib_swimnode (entity this, vector start, vector end, float doedge)
vector pathlib_walknode (entity this, vector start, vector end, float doedge)
vector pathlib_wateroutnode (entity this, vector start, vector end, float doedge)

Variables

vector pos1
vector pos2

Function Documentation

◆ a_think()

void a_think ( entity this)

Definition at line 79 of file movenode.qc.

80{
81 te_lightning1(this,this.origin, this.pos1);
82 if(this.cnt < time)
83 delete(this);
84 else
85 this.nextthink = time + 0.2;
86}
float cnt
Definition powerups.qc:24
float time
float nextthink
vector origin
vector pos1
Definition subs.qh:50

References cnt, entity(), nextthink, origin, pos1, and time.

Referenced by pathlib_walknode().

◆ pathlib_flynode()

vector pathlib_flynode ( entity this,
vector start,
vector end,
float doedge )

Definition at line 65 of file movenode.qc.

66{
68
69 end.x = fsnap(end.x, pathlib_gridsize);
70 end.y = fsnap(end.y, pathlib_gridsize);
71
72 tracebox(start, movenode_boxmin,movenode_boxmax, end, MOVE_WORLDONLY, this);
73 if(trace_fraction == 1)
75
76 return end;
77}
float MOVE_WORLDONLY
float trace_fraction
ERASEABLE float fsnap(float val, float fsize)
Definition math.qh:54
bool pathlib_movenode_goodnode
Definition pathlib.qh:75
float pathlib_gridsize
Definition pathlib.qh:50
vector movenode_boxmin
Definition pathlib.qh:74
vector movenode_boxmax
Definition pathlib.qh:73

References entity(), fsnap(), MOVE_WORLDONLY, movenode_boxmax, movenode_boxmin, pathlib_gridsize, pathlib_movenode_goodnode, trace_fraction, and vector.

◆ pathlib_swimnode()

vector pathlib_swimnode ( entity this,
vector start,
vector end,
float doedge )

Definition at line 45 of file movenode.qc.

46{
48
49 if(pointcontents(start) != CONTENT_WATER)
50 return end;
51
52 end.x = fsnap(end.x, pathlib_gridsize);
53 end.y = fsnap(end.y, pathlib_gridsize);
54
55 if(pointcontents(end) == CONTENT_EMPTY)
56 return pathlib_wateroutnode(this, start, end, doedge);
57
58 tracebox(start, movenode_boxmin,movenode_boxmax, end, MOVE_WORLDONLY, this);
59 if(trace_fraction == 1)
61
62 return end;
63}
const float CONTENT_WATER
const float CONTENT_EMPTY
vector pathlib_wateroutnode(entity this, vector start, vector end, float doedge)
Definition movenode.qc:11

References CONTENT_EMPTY, CONTENT_WATER, entity(), fsnap(), MOVE_WORLDONLY, movenode_boxmax, movenode_boxmin, pathlib_gridsize, pathlib_movenode_goodnode, pathlib_wateroutnode(), trace_fraction, and vector.

Referenced by pathlib_astar(), and pathlib_makenode_adaptive().

◆ pathlib_walknode()

vector pathlib_walknode ( entity this,
vector start,
vector end,
float doedge )

Definition at line 88 of file movenode.qc.

89{
90 vector point;
91
92 LOG_DEBUG("Walking node from ", vtos(start), " to ", vtos(end));
93
95
96 end.x = fsnap(end.x,pathlib_gridsize);
97 end.y = fsnap(end.y,pathlib_gridsize);
98 start.x = fsnap(start.x,pathlib_gridsize);
99 start.y = fsnap(start.y,pathlib_gridsize);
100
101 // Find the floor
102 traceline(start + movenode_stepup, start - movenode_maxdrop, MOVE_WORLDONLY, this);
103 if(trace_fraction == 1.0)
104 {
105 entity a = spawn();
106 setthink(a, a_think);
107 a.nextthink = time;
108 setorigin(a, start + movenode_stepup);
109 a.pos1 = trace_endpos;
110 //start - movenode_maxdrop
111 a.cnt = time + 10;
112
113 LOG_TRACE("I cant walk on air!");
114 return trace_endpos;
115 }
116
117 start = trace_endpos;
118
119 // Find the direcion, without Z
120 vector s = start;
121 vector e = end;
122 //e_z = 0; s_z = 0;
123 vector direction = normalize(e - s);
124
125 float distance = vlen(start - end);
126 int steps = rint(distance / movenode_stepsize);
127
128 vector last_point = start;
129 for(int i = 1; i < steps; ++i)
130 {
131 point = last_point + (direction * movenode_stepsize);
132 traceline(point + movenode_stepup,point - movenode_maxdrop,MOVE_WORLDONLY,this);
133 if(trace_fraction == 1.0)
134 return trace_endpos;
135
136 last_point = trace_endpos;
137 }
138
139 point = last_point + (direction * movenode_stepsize);
140 point.x = fsnap(point.x,pathlib_gridsize);
141 point.y = fsnap(point.y,pathlib_gridsize);
142
143 //dprint("end_x: ",ftos(end_x), " end_y: ",ftos(end_y),"\n");
144 //dprint("point_x:",ftos(point_x)," point_y:",ftos(point_y),"\n\n");
145
146 traceline(point + movenode_stepup, point - movenode_maxdrop,MOVE_WORLDONLY,this);
147 if(trace_fraction == 1.0)
148 return trace_endpos;
149
150 last_point = trace_endpos;
151
152 tracebox(start + movenode_boxup, movenode_boxmin,movenode_boxmax, last_point + movenode_boxup, MOVE_WORLDONLY, this);
153 if(trace_fraction != 1.0)
154 return trace_endpos;
155
157 return last_point;
158}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
vector trace_endpos
#define spawn
#define LOG_TRACE(...)
Definition log.qh:76
#define LOG_DEBUG(...)
Definition log.qh:80
float vlen(vector v)
string vtos(vector v)
float rint(float f)
vector normalize(vector v)
void a_think(entity this)
Definition movenode.qc:79
vector movenode_boxup
Definition pathlib.qh:72
vector movenode_maxdrop
Definition pathlib.qh:71
vector movenode_stepup
Definition pathlib.qh:70
float movenode_stepsize
Definition pathlib.qh:69
#define setthink(e, f)
vector
Definition self.qh:92

References a_think(), entity(), fsnap(), LOG_DEBUG, LOG_TRACE, MOVE_WORLDONLY, movenode_boxmax, movenode_boxmin, movenode_boxup, movenode_maxdrop, movenode_stepsize, movenode_stepup, normalize(), pathlib_gridsize, pathlib_movenode_goodnode, rint(), setthink, spawn, time, trace_endpos, trace_fraction, vector, vlen(), and vtos().

Referenced by buildpath_nodefilter_moveskip(), pathlib_astar(), pathlib_close_node(), and pathlib_makenode_adaptive().

◆ pathlib_wateroutnode()

vector pathlib_wateroutnode ( entity this,
vector start,
vector end,
float doedge )

Definition at line 11 of file movenode.qc.

12{
13 vector surface;
14
16
17 end.x = fsnap(end.x, pathlib_gridsize);
18 end.y = fsnap(end.y, pathlib_gridsize);
19
20 traceline(end + ('0 0 0.25' * pathlib_gridsize),end - ('0 0 1' * pathlib_gridsize),MOVE_WORLDONLY,this);
21 end = trace_endpos;
22
23 if (!(pointcontents(end - '0 0 1') == CONTENT_SOLID))
24 return end;
25
26 for(surface = start ; surface.z < (end.z + 32); ++surface.z)
27 {
28 if(pointcontents(surface) == CONTENT_EMPTY)
29 break;
30 }
31
32 if(pointcontents(surface + '0 0 1') != CONTENT_EMPTY)
33 return end;
34
35 tracebox(start + '0 0 64', movenode_boxmin,movenode_boxmax, end + '0 0 64', MOVE_WORLDONLY, this);
36 if(trace_fraction == 1)
38
39 if(fabs(surface.z - end.z) > 32)
41
42 return end;
43}
const float CONTENT_SOLID
float fabs(float f)

References CONTENT_EMPTY, CONTENT_SOLID, entity(), fabs(), fsnap(), MOVE_WORLDONLY, movenode_boxmax, movenode_boxmin, pathlib_gridsize, pathlib_movenode_goodnode, trace_endpos, trace_fraction, and vector.

Referenced by pathlib_swimnode().

Variable Documentation

◆ pos1

vector pos1

Definition at line 9 of file movenode.qc.

◆ pos2

vector pos2

Definition at line 9 of file movenode.qc.