37 vec3_t mins, maxs, start, stop;
42 VectorAdd(ent->s.origin, ent->mins, mins);
43 VectorAdd(ent->s.origin, ent->maxs, maxs);
48 start[2] = mins[2] - 1;
49 for (x = 0 ; x <= 1 ; x++)
50 for (y = 0 ; y <= 1 ; y++) {
51 start[0] = x ? maxs[0] : mins[0];
52 start[1] = y ? maxs[1] : mins[1];
53 if (
gi.pointcontents(start) != CONTENTS_SOLID)
68 start[0] = stop[0] = (mins[0] + maxs[0]) * 0.5;
69 start[1] = stop[1] = (mins[1] + maxs[1]) * 0.5;
73 if (trace.fraction == 1.0)
75 mid = bottom = trace.endpos[2];
78 for (x = 0 ; x <= 1 ; x++)
79 for (y = 0 ; y <= 1 ; y++) {
80 start[0] = stop[0] = x ? maxs[0] : mins[0];
81 start[1] = stop[1] = y ? maxs[1] : mins[1];
85 if (trace.fraction != 1.0 && trace.endpos[2] > bottom)
86 bottom = trace.endpos[2];
87 if (trace.fraction == 1.0 || mid - trace.endpos[2] >
STEPSIZE)
111 vec3_t oldorg, neworg, end;
119 VectorCopy(ent->s.origin, oldorg);
120 VectorAdd(ent->s.origin, move, neworg);
125 for (i = 0 ; i < 2 ; i++) {
126 VectorAdd(ent->s.origin, move, neworg);
127 if (i == 0 && ent->enemy) {
128 if (!ent->goalentity)
129 ent->goalentity = ent->enemy;
130 dz = ent->s.origin[2] - ent->goalentity->s.origin[2];
131 if (ent->goalentity->client) {
134 if (!((ent->flags &
FL_SWIM) && (ent->waterlevel < 2)))
148 trace =
gi.trace(ent->s.origin, ent->mins, ent->maxs, neworg, ent, MASK_MONSTERSOLID);
151 if (ent->flags &
FL_FLY) {
152 if (!ent->waterlevel) {
153 test[0] = trace.endpos[0];
154 test[1] = trace.endpos[1];
155 test[2] = trace.endpos[2] + ent->mins[2] + 1;
156 contents =
gi.pointcontents(test);
157 if (contents & MASK_WATER)
164 if (ent->waterlevel < 2) {
165 test[0] = trace.endpos[0];
166 test[1] = trace.endpos[1];
167 test[2] = trace.endpos[2] + ent->mins[2] + 1;
168 contents =
gi.pointcontents(test);
169 if (!(contents & MASK_WATER))
174 if (trace.fraction == 1) {
175 VectorCopy(trace.endpos, ent->s.origin);
191 if (!(ent->monsterinfo.aiflags &
AI_NOSTEP))
196 neworg[2] += stepsize;
197 VectorCopy(neworg, end);
198 end[2] -= stepsize * 2;
200 trace =
gi.trace(neworg, ent->mins, ent->maxs, end, ent, MASK_MONSTERSOLID);
205 if (trace.startsolid) {
206 neworg[2] -= stepsize;
207 trace =
gi.trace(neworg, ent->mins, ent->maxs, end, ent, MASK_MONSTERSOLID);
208 if (trace.allsolid || trace.startsolid)
214 if (ent->waterlevel == 0) {
215 test[0] = trace.endpos[0];
216 test[1] = trace.endpos[1];
217 test[2] = trace.endpos[2] + ent->mins[2] + 1;
218 contents =
gi.pointcontents(test);
220 if (contents & MASK_WATER)
224 if (trace.fraction == 1) {
227 VectorAdd(ent->s.origin, move, ent->s.origin);
232 ent->groundentity = NULL;
240 VectorCopy(trace.endpos, ent->s.origin);
252 VectorCopy(oldorg, ent->s.origin);
259 ent->groundentity = trace.ent;
260 ent->groundentity_linkcount = trace.ent->linkcount;
286 current = anglemod(ent->s.angles[YAW]);
287 ideal = ent->ideal_yaw;
289 if (current == ideal)
292 move = ideal - current;
293 speed = ent->yaw_speed;
294 if (ideal > current) {
309 ent->s.angles[YAW] = anglemod(current + move);
324 vec3_t move, oldorigin;
327 ent->ideal_yaw = yaw;
330 yaw = yaw * M_PI * 2 / 360;
331 move[0] = cos(yaw) * dist;
332 move[1] = sin(yaw) * dist;
335 VectorCopy(ent->s.origin, oldorigin);
337 delta = ent->s.angles[YAW] - ent->ideal_yaw;
338 if (delta > 45 && delta < 315) {
340 VectorCopy(oldorigin, ent->s.origin);
373 float deltax, deltay;
375 float tdir, olddir, turnaround;
381 olddir = anglemod((
int)(actor->ideal_yaw / 45) * 45);
382 turnaround = anglemod(olddir - 180);
384 deltax = enemy->s.origin[0] - actor->s.origin[0];
385 deltay = enemy->s.origin[1] - actor->s.origin[1];
388 else if (deltax < -10)
394 else if (deltay > 10)
402 tdir = d[2] == 90 ? 45 : 315;
404 tdir = d[2] == 90 ? 135 : 215;
411 if (((rand() & 3) & 1) || fabsf(deltay) > fabsf(deltax)) {
417 if (d[1] !=
DI_NODIR && d[1] != turnaround
421 if (d[2] !=
DI_NODIR && d[2] != turnaround
431 for (tdir = 0 ; tdir <= 315 ; tdir += 45)
435 for (tdir = 315 ; tdir >= 0 ; tdir -= 45)
443 actor->ideal_yaw = olddir;
462 for (i = 0 ; i < 3 ; i++) {
463 if (goal->absmin[i] > ent->absmax[i] + dist)
465 if (goal->absmax[i] < ent->absmin[i] - dist)
481 goal = ent->goalentity;
483 if (!ent->groundentity && !(ent->flags & (
FL_FLY |
FL_SWIM)))
507 if (!ent->groundentity && !(ent->flags & (
FL_FLY |
FL_SWIM)))
510 yaw = yaw * M_PI * 2 / 360;
512 move[0] = cos(yaw) * dist;
513 move[1] = sin(yaw) * dist;