Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
expandnode.qc
Go to the documentation of this file.
1
#include "
expandnode.qh
"
2
3
#include <
server/pathlib/pathlib.qh
>
4
#include <
server/pathlib/utility.qh
>
5
6
/*
7
vector plib_points2[8];
8
vector plib_points[8];
9
float plib_fvals[8];
10
11
float pathlib_expandnode_starf(entity node, vector start, vector goal)
12
{
13
float fc;
14
15
vector where = node.origin;
16
17
vector f = PLIB_FORWARD * pathlib_gridsize;
18
vector r = PLIB_RIGHT * pathlib_gridsize;
19
20
// Forward
21
plib_points[0] = where + f;
22
23
// Back
24
plib_points[1] = where - f;
25
26
// Right
27
plib_points[2] = where + r;
28
29
// Left
30
plib_points[3] = where - r;
31
32
// Forward-right
33
plib_points[4] = where + f + r;
34
35
// Forward-left
36
plib_points[5] = where + f - r;
37
38
// Back-right
39
plib_points[6] = where - f + r;
40
41
// Back-left
42
plib_points[7] = where - f - r;
43
44
for(int i=0;i < 8; ++i)
45
{
46
vector t = plib_points[i];
47
fc = pathlib_heuristic(t,goal) + pathlib_cost(node, t, pathlib_gridsize);
48
plib_fvals[i] = fc;
49
50
}
51
52
fc = plib_fvals[0];
53
plib_points2[0] = plib_points[0];
54
vector bp = plib_points[0];
55
int fc2 = 0;
56
for(int i = 0; i < 8; ++i)
57
{
58
bool c = false;
59
entity nap = pathlib_nodeatpoint(plib_points[i]);
60
if(nap)
61
{
62
if(nap.owner == openlist)
63
c = true;
64
}
65
else
66
c = true;
67
68
if(c)
69
if(plib_fvals[i] < fc)
70
{
71
bp = plib_points[i];
72
fc = plib_fvals[i];
73
plib_points2[fc2] = plib_points[i];
74
++fc2;
75
}
76
77
//nap = pathlib_nodeatpoint(plib_points[i]);
78
//if(nap)
79
//if not nap.owner == closedlist)
80
//{
81
//}
82
}
83
84
pathlib_makenode(node, start, bp, goal, pathlib_gridsize);
85
86
for(int i = 0; i < 3; ++i)
87
{
88
pathlib_makenode(node, start, plib_points2[i], goal, pathlib_gridsize);
89
}
90
91
return pathlib_open_cnt;
92
}
93
*/
94
95
float
pathlib_expandnode_star
(
entity
node,
vector
start,
vector
goal)
96
{
97
vector
point;
98
99
vector
where = node.origin;
100
101
vector
f =
PLIB_FORWARD
*
pathlib_gridsize
;
102
vector
r =
PLIB_RIGHT
*
pathlib_gridsize
;
103
104
if
(node.pathlib_node_edgeflags ==
pathlib_node_edgeflag_unknown
)
105
node.pathlib_node_edgeflags =
tile_check_plus2
(node, node.origin);
106
107
if
(node.pathlib_node_edgeflags ==
pathlib_node_edgeflag_none
)
108
{
109
LOG_TRACE
(
"Node at "
,
vtos
(node.origin),
" not expanable"
);
110
return
pathlib_open_cnt
;
111
}
112
113
// Forward
114
if
(node.pathlib_node_edgeflags &
pathlib_node_edgeflag_forward
)
115
{
116
point = where + f;
117
pathlib_makenode
(node, start, point, goal,
pathlib_movecost
);
118
}
119
120
// Back
121
if
(node.pathlib_node_edgeflags &
pathlib_node_edgeflag_back
)
122
{
123
point = where - f;
124
pathlib_makenode
(node, start, point, goal,
pathlib_movecost
);
125
}
126
127
// Right
128
if
(node.pathlib_node_edgeflags &
pathlib_node_edgeflag_right
)
129
{
130
point = where + r;
131
pathlib_makenode
(node, start, point, goal,
pathlib_movecost
);
132
}
133
134
// Left
135
if
(node.pathlib_node_edgeflags &
pathlib_node_edgeflag_left
)
136
{
137
point = where - r;
138
pathlib_makenode
(node, start, point, goal,
pathlib_movecost
);
139
140
}
141
142
// Forward-right
143
if
(node.pathlib_node_edgeflags &
pathlib_node_edgeflag_forwardright
)
144
{
145
point = where + f + r;
146
pathlib_makenode
(node, start, point, goal,
pathlib_movecost_diag
);
147
}
148
149
// Forward-left
150
if
(node.pathlib_node_edgeflags &
pathlib_node_edgeflag_forwardleft
)
151
{
152
point = where + f - r;
153
pathlib_makenode
(node, start, point, goal,
pathlib_movecost_diag
);
154
155
}
156
157
// Back-right
158
if
(node.pathlib_node_edgeflags &
pathlib_node_edgeflag_backright
)
159
{
160
point = where - f + r;
161
pathlib_makenode
(node, start, point, goal,
pathlib_movecost_diag
);
162
}
163
164
// Back-left
165
if
(node.pathlib_node_edgeflags &
pathlib_node_edgeflag_backleft
)
166
{
167
point = where - f - r;
168
pathlib_makenode
(node, start, point, goal,
pathlib_movecost_diag
);
169
}
170
171
return
pathlib_open_cnt
;
172
}
173
174
/*
175
float pathlib_expandnode_octagon(entity node, vector start, vector goal)
176
{
177
vector point;
178
179
vector where = node.origin;
180
181
vector f = PLIB_FORWARD * pathlib_gridsize;
182
vector r = PLIB_RIGHT * pathlib_gridsize;
183
184
// Forward
185
point = where + f;
186
pathlib_makenode(node, start, point, goal, pathlib_movecost);
187
188
// Back
189
point = where - f;
190
pathlib_makenode(node, start, point, goal, pathlib_movecost);
191
192
// Right
193
point = where + r;
194
pathlib_makenode(node, start, point, goal, pathlib_movecost);
195
196
// Left
197
point = where - r;
198
pathlib_makenode(node, start, point, goal, pathlib_movecost);
199
200
f = PLIB_FORWARD * pathlib_gridsize * 0.5;
201
r = PLIB_RIGHT * pathlib_gridsize * 0.5;
202
203
// Forward-right
204
point = where + f + r;
205
pathlib_makenode(node, start, point, goal, pathlib_movecost);
206
207
// Forward-left
208
point = where + f - r;
209
pathlib_makenode(node, start, point, goal, pathlib_movecost);
210
211
// Back-right
212
point = where - f + r;
213
pathlib_makenode(node, start, point, goal, pathlib_movecost);
214
215
// Back-left
216
point = where - f - r;
217
pathlib_makenode(node, start, point, goal, pathlib_movecost);
218
219
return pathlib_open_cnt;
220
}
221
*/
222
223
float
pathlib_expandnode_box
(
entity
node,
vector
start,
vector
goal)
224
{
225
vector
v;
226
227
for
(v.z = node.origin.z -
pathlib_gridsize
; v.z <= node.origin.z +
pathlib_gridsize
; v.z +=
pathlib_gridsize
)
228
for
(v.y = node.origin.y -
pathlib_gridsize
; v.y <= node.origin.y +
pathlib_gridsize
; v.y +=
pathlib_gridsize
)
229
for
(v.x = node.origin.x -
pathlib_gridsize
; v.x <= node.origin.x +
pathlib_gridsize
; v.x +=
pathlib_gridsize
)
230
{
231
//if(vlen(v - node.origin))
232
pathlib_makenode
(node,start,v,goal,
pathlib_movecost
);
233
}
234
235
return
pathlib_open_cnt
;
236
}
entity
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
pathlib_expandnode_star
float pathlib_expandnode_star(entity node, vector start, vector goal)
Definition
expandnode.qc:95
pathlib_expandnode_box
float pathlib_expandnode_box(entity node, vector start, vector goal)
Definition
expandnode.qc:223
expandnode.qh
LOG_TRACE
#define LOG_TRACE(...)
Definition
log.qh:76
vtos
string vtos(vector v)
pathlib.qh
pathlib_node_edgeflag_forwardright
const float pathlib_node_edgeflag_forwardright
Definition
pathlib.qh:38
pathlib_movecost_diag
float pathlib_movecost_diag
Definition
pathlib.qh:52
PLIB_FORWARD
const vector PLIB_FORWARD
Definition
pathlib.qh:13
pathlib_node_edgeflag_backright
const float pathlib_node_edgeflag_backright
Definition
pathlib.qh:36
pathlib_node_edgeflag_forward
const float pathlib_node_edgeflag_forward
Definition
pathlib.qh:33
pathlib_node_edgeflag_left
const float pathlib_node_edgeflag_left
Definition
pathlib.qh:31
pathlib_makenode
var bool pathlib_makenode(entity parent, vector start, vector to, vector goal, float cost)
pathlib_node_edgeflag_forwardleft
const float pathlib_node_edgeflag_forwardleft
Definition
pathlib.qh:37
pathlib_open_cnt
float pathlib_open_cnt
Definition
pathlib.qh:42
pathlib_node_edgeflag_right
const float pathlib_node_edgeflag_right
Definition
pathlib.qh:32
pathlib_node_edgeflag_unknown
const float pathlib_node_edgeflag_unknown
Definition
pathlib.qh:30
pathlib_node_edgeflag_backleft
const float pathlib_node_edgeflag_backleft
Definition
pathlib.qh:35
PLIB_RIGHT
const vector PLIB_RIGHT
Definition
pathlib.qh:15
pathlib_node_edgeflag_back
const float pathlib_node_edgeflag_back
Definition
pathlib.qh:34
pathlib_node_edgeflag_none
const float pathlib_node_edgeflag_none
Definition
pathlib.qh:39
pathlib_movecost
float pathlib_movecost
Definition
pathlib.qh:51
pathlib_gridsize
float pathlib_gridsize
Definition
pathlib.qh:50
vector
vector
Definition
self.qh:92
tile_check_plus2
float tile_check_plus2(entity this, vector where)
Definition
utility.qc:112
utility.qh
server
pathlib
expandnode.qc
Generated on
for Xonotic QuakeC by
1.14.0