| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
#include "../qcommon/q_shared.h" |
| 33 |
#include "l_log.h" |
| 34 |
#include "l_memory.h" |
| 35 |
#include "l_script.h" |
| 36 |
#include "l_libvar.h" |
| 37 |
#include "l_precomp.h" |
| 38 |
#include "l_struct.h" |
| 39 |
#include "aasfile.h" |
| 40 |
#include "botlib.h" |
| 41 |
#include "be_aas.h" |
| 42 |
#include "be_aas_funcs.h" |
| 43 |
#include "be_aas_def.h" |
| 44 |
|
| 45 |
extern int Sys_MilliSeconds(void); |
| 46 |
|
| 47 |
|
| 48 |
extern botlib_import_t botimport; |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
#define AAS_MAX_REACHABILITYSIZE 65536 |
| 55 |
|
| 56 |
#define REACHABILITYAREASPERCYCLE 15 |
| 57 |
|
| 58 |
#define INSIDEUNITS 2 |
| 59 |
#define INSIDEUNITS_WALKEND 5 |
| 60 |
#define INSIDEUNITS_WALKSTART 0.1 |
| 61 |
#define INSIDEUNITS_WATERJUMP 15 |
| 62 |
|
| 63 |
#define AREA_WEAPONJUMP 8192 //valid area to weapon jump to |
| 64 |
|
| 65 |
int reach_swim; |
| 66 |
int reach_equalfloor; |
| 67 |
int reach_step; |
| 68 |
int reach_walk; |
| 69 |
int reach_barrier; |
| 70 |
int reach_waterjump; |
| 71 |
int reach_walkoffledge; |
| 72 |
int reach_jump; |
| 73 |
int reach_ladder; |
| 74 |
int reach_teleport; |
| 75 |
int reach_elevator; |
| 76 |
int reach_funcbob; |
| 77 |
int reach_grapple; |
| 78 |
int reach_doublejump; |
| 79 |
int reach_rampjump; |
| 80 |
int reach_strafejump; |
| 81 |
int reach_rocketjump; |
| 82 |
int reach_bfgjump; |
| 83 |
int reach_jumppad; |
| 84 |
|
| 85 |
int calcgrapplereach; |
| 86 |
|
| 87 |
typedef struct aas_lreachability_s |
| 88 |
{ |
| 89 |
int areanum; |
| 90 |
int facenum; |
| 91 |
int edgenum; |
| 92 |
vec3_t start; |
| 93 |
vec3_t end; |
| 94 |
int traveltype; |
| 95 |
unsigned short int traveltime; |
| 96 |
|
| 97 |
struct aas_lreachability_s *next; |
| 98 |
} aas_lreachability_t; |
| 99 |
|
| 100 |
aas_lreachability_t *reachabilityheap; |
| 101 |
aas_lreachability_t *nextreachability; |
| 102 |
aas_lreachability_t **areareachability; |
| 103 |
int numlreachabilities; |
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
float AAS_FaceArea(aas_face_t *face) |
| 113 |
{ |
| 114 |
int i, edgenum, side; |
| 115 |
float total; |
| 116 |
vec_t *v; |
| 117 |
vec3_t d1, d2, cross; |
| 118 |
aas_edge_t *edge; |
| 119 |
|
| 120 |
edgenum = aasworld.edgeindex[face->firstedge]; |
| 121 |
side = edgenum < 0; |
| 122 |
edge = &aasworld.edges[abs(edgenum)]; |
| 123 |
v = aasworld.vertexes[edge->v[side]]; |
| 124 |
|
| 125 |
total = 0; |
| 126 |
for (i = 1; i < face->numedges - 1; i++) |
| 127 |
{ |
| 128 |
edgenum = aasworld.edgeindex[face->firstedge + i]; |
| 129 |
side = edgenum < 0; |
| 130 |
edge = &aasworld.edges[abs(edgenum)]; |
| 131 |
VectorSubtract(aasworld.vertexes[edge->v[side]], v, d1); |
| 132 |
VectorSubtract(aasworld.vertexes[edge->v[!side]], v, d2); |
| 133 |
CrossProduct(d1, d2, cross); |
| 134 |
total += 0.5 * VectorLength(cross); |
| 135 |
} |
| 136 |
return total; |
| 137 |
} |
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
float AAS_AreaVolume(int areanum) |
| 146 |
{ |
| 147 |
int i, edgenum, facenum, side; |
| 148 |
vec_t d, a, volume; |
| 149 |
vec3_t corner; |
| 150 |
aas_plane_t *plane; |
| 151 |
aas_edge_t *edge; |
| 152 |
aas_face_t *face; |
| 153 |
aas_area_t *area; |
| 154 |
|
| 155 |
area = &aasworld.areas[areanum]; |
| 156 |
facenum = aasworld.faceindex[area->firstface]; |
| 157 |
face = &aasworld.faces[abs(facenum)]; |
| 158 |
edgenum = aasworld.edgeindex[face->firstedge]; |
| 159 |
edge = &aasworld.edges[abs(edgenum)]; |
| 160 |
|
| 161 |
VectorCopy(aasworld.vertexes[edge->v[0]], corner); |
| 162 |
|
| 163 |
|
| 164 |
volume = 0; |
| 165 |
for (i = 0; i < area->numfaces; i++) |
| 166 |
{ |
| 167 |
facenum = abs(aasworld.faceindex[area->firstface + i]); |
| 168 |
face = &aasworld.faces[facenum]; |
| 169 |
side = face->backarea != areanum; |
| 170 |
plane = &aasworld.planes[face->planenum ^ side]; |
| 171 |
d = -(DotProduct (corner, plane->normal) - plane->dist); |
| 172 |
a = AAS_FaceArea(face); |
| 173 |
volume += d * a; |
| 174 |
} |
| 175 |
|
| 176 |
volume /= 3; |
| 177 |
return volume; |
| 178 |
} |
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
int AAS_BestReachableLinkArea(aas_link_t *areas) |
| 186 |
{ |
| 187 |
aas_link_t *link; |
| 188 |
|
| 189 |
for (link = areas; link; link = link->next_area) |
| 190 |
{ |
| 191 |
if (AAS_AreaGrounded(link->areanum) || AAS_AreaSwim(link->areanum)) |
| 192 |
{ |
| 193 |
return link->areanum; |
| 194 |
} |
| 195 |
} |
| 196 |
|
| 197 |
for (link = areas; link; link = link->next_area) |
| 198 |
{ |
| 199 |
if (link->areanum) return link->areanum; |
| 200 |
|
| 201 |
|
| 202 |
if (AAS_AreaReachability(link->areanum)) |
| 203 |
return link->areanum; |
| 204 |
} |
| 205 |
return 0; |
| 206 |
} |
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
int AAS_GetJumpPadInfo(int ent, vec3_t areastart, vec3_t absmins, vec3_t absmaxs, vec3_t velocity) |
| 214 |
{ |
| 215 |
int modelnum, ent2; |
| 216 |
float speed, height, gravity, time, dist, forward; |
| 217 |
vec3_t origin, angles, teststart, ent2origin; |
| 218 |
aas_trace_t trace; |
| 219 |
char model[MAX_EPAIRKEY]; |
| 220 |
char target[MAX_EPAIRKEY], targetname[MAX_EPAIRKEY]; |
| 221 |
|
| 222 |
|
| 223 |
AAS_FloatForBSPEpairKey(ent, "speed", &speed); |
| 224 |
if (!speed) speed = 1000; |
| 225 |
VectorClear(angles); |
| 226 |
|
| 227 |
AAS_ValueForBSPEpairKey(ent, "model", model, MAX_EPAIRKEY); |
| 228 |
if (model[0]) modelnum = atoi(model+1); |
| 229 |
else modelnum = 0; |
| 230 |
AAS_BSPModelMinsMaxsOrigin(modelnum, angles, absmins, absmaxs, origin); |
| 231 |
VectorAdd(origin, absmins, absmins); |
| 232 |
VectorAdd(origin, absmaxs, absmaxs); |
| 233 |
VectorAdd(absmins, absmaxs, origin); |
| 234 |
VectorScale (origin, 0.5, origin); |
| 235 |
|
| 236 |
|
| 237 |
VectorCopy(origin, teststart); |
| 238 |
teststart[2] += 64; |
| 239 |
trace = AAS_TraceClientBBox(teststart, origin, PRESENCE_CROUCH, -1); |
| 240 |
if (trace.startsolid) |
| 241 |
{ |
| 242 |
botimport.Print(PRT_MESSAGE, "trigger_push start solid\n"); |
| 243 |
VectorCopy(origin, areastart); |
| 244 |
} |
| 245 |
else |
| 246 |
{ |
| 247 |
VectorCopy(trace.endpos, areastart); |
| 248 |
} |
| 249 |
areastart[2] += 0.125; |
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
AAS_ValueForBSPEpairKey(ent, "target", target, MAX_EPAIRKEY); |
| 254 |
for (ent2 = AAS_NextBSPEntity(0); ent2; ent2 = AAS_NextBSPEntity(ent2)) |
| 255 |
{ |
| 256 |
if (!AAS_ValueForBSPEpairKey(ent2, "targetname", targetname, MAX_EPAIRKEY)) continue; |
| 257 |
if (!strcmp(targetname, target)) break; |
| 258 |
} |
| 259 |
if (!ent2) |
| 260 |
{ |
| 261 |
botimport.Print(PRT_MESSAGE, "trigger_push without target entity %s\n", target); |
| 262 |
return qfalse; |
| 263 |
} |
| 264 |
AAS_VectorForBSPEpairKey(ent2, "origin", ent2origin); |
| 265 |
|
| 266 |
height = ent2origin[2] - origin[2]; |
| 267 |
gravity = aassettings.phys_gravity; |
| 268 |
time = sqrt( height / ( 0.5 * gravity ) ); |
| 269 |
if (!time) |
| 270 |
{ |
| 271 |
botimport.Print(PRT_MESSAGE, "trigger_push without time\n"); |
| 272 |
return qfalse; |
| 273 |
} |
| 274 |
|
| 275 |
VectorSubtract ( ent2origin, origin, velocity); |
| 276 |
dist = VectorNormalize( velocity); |
| 277 |
forward = dist / time; |
| 278 |
|
| 279 |
forward *= 1.1f; |
| 280 |
VectorScale(velocity, forward, velocity); |
| 281 |
velocity[2] = time * gravity; |
| 282 |
return qtrue; |
| 283 |
} |
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
int AAS_BestReachableFromJumpPadArea(vec3_t origin, vec3_t mins, vec3_t maxs) |
| 291 |
{ |
| 292 |
int ent, bot_visualizejumppads, bestareanum; |
| 293 |
float volume, bestareavolume; |
| 294 |
vec3_t areastart, cmdmove, bboxmins, bboxmaxs; |
| 295 |
vec3_t absmins, absmaxs, velocity; |
| 296 |
aas_clientmove_t move; |
| 297 |
aas_link_t *areas, *link; |
| 298 |
char classname[MAX_EPAIRKEY]; |
| 299 |
|
| 300 |
#ifdef BSPC |
| 301 |
bot_visualizejumppads = 0; |
| 302 |
#else |
| 303 |
bot_visualizejumppads = LibVarValue("bot_visualizejumppads", "0"); |
| 304 |
#endif |
| 305 |
VectorAdd(origin, mins, bboxmins); |
| 306 |
VectorAdd(origin, maxs, bboxmaxs); |
| 307 |
for (ent = AAS_NextBSPEntity(0); ent; ent = AAS_NextBSPEntity(ent)) |
| 308 |
{ |
| 309 |
if (!AAS_ValueForBSPEpairKey(ent, "classname", classname, MAX_EPAIRKEY)) continue; |
| 310 |
if (strcmp(classname, "trigger_push")) continue; |
| 311 |
|
| 312 |
if (!AAS_GetJumpPadInfo(ent, areastart, absmins, absmaxs, velocity)) continue; |
| 313 |
|
| 314 |
areas = AAS_LinkEntityClientBBox(absmins, absmaxs, -1, PRESENCE_CROUCH); |
| 315 |
for (link = areas; link; link = link->next_area) |
| 316 |
{ |
| 317 |
if (AAS_AreaJumpPad(link->areanum)) break; |
| 318 |
} |
| 319 |
if (!link) |
| 320 |
{ |
| 321 |
botimport.Print(PRT_MESSAGE, "trigger_push not in any jump pad area\n"); |
| 322 |
AAS_UnlinkFromAreas(areas); |
| 323 |
continue; |
| 324 |
} |
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
VectorSet(cmdmove, 0, 0, 0); |
| 329 |
Com_Memset(&move, 0, sizeof(aas_clientmove_t)); |
| 330 |
AAS_ClientMovementHitBBox(&move, -1, areastart, PRESENCE_NORMAL, qfalse, |
| 331 |
velocity, cmdmove, 0, 30, 0.1f, bboxmins, bboxmaxs, bot_visualizejumppads); |
| 332 |
if (move.frames < 30) |
| 333 |
{ |
| 334 |
bestareanum = 0; |
| 335 |
bestareavolume = 0; |
| 336 |
for (link = areas; link; link = link->next_area) |
| 337 |
{ |
| 338 |
if (!AAS_AreaJumpPad(link->areanum)) continue; |
| 339 |
volume = AAS_AreaVolume(link->areanum); |
| 340 |
if (volume >= bestareavolume) |
| 341 |
{ |
| 342 |
bestareanum = link->areanum; |
| 343 |
bestareavolume = volume; |
| 344 |
} |
| 345 |
} |
| 346 |
AAS_UnlinkFromAreas(areas); |
| 347 |
return bestareanum; |
| 348 |
} |
| 349 |
AAS_UnlinkFromAreas(areas); |
| 350 |
} |
| 351 |
return 0; |
| 352 |
} |
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
int AAS_BestReachableArea(vec3_t origin, vec3_t mins, vec3_t maxs, vec3_t goalorigin) |
| 360 |
{ |
| 361 |
int areanum, i, j, k, l; |
| 362 |
aas_link_t *areas; |
| 363 |
vec3_t absmins, absmaxs; |
| 364 |
|
| 365 |
vec3_t start, end; |
| 366 |
aas_trace_t trace; |
| 367 |
|
| 368 |
if (!aasworld.loaded) |
| 369 |
{ |
| 370 |
botimport.Print(PRT_ERROR, "AAS_BestReachableArea: aas not loaded\n"); |
| 371 |
return 0; |
| 372 |
} |
| 373 |
|
| 374 |
VectorCopy(origin, start); |
| 375 |
areanum = AAS_PointAreaNum(start); |
| 376 |
|
| 377 |
for (i = 0; i < 5 && !areanum; i++) |
| 378 |
{ |
| 379 |
for (j = 0; j < 5 && !areanum; j++) |
| 380 |
{ |
| 381 |
for (k = -1; k <= 1 && !areanum; k++) |
| 382 |
{ |
| 383 |
for (l = -1; l <= 1 && !areanum; l++) |
| 384 |
{ |
| 385 |
VectorCopy(origin, start); |
| 386 |
start[0] += (float) j * 4 * k; |
| 387 |
start[1] += (float) j * 4 * l; |
| 388 |
start[2] += (float) i * 4; |
| 389 |
areanum = AAS_PointAreaNum(start); |
| 390 |
} |
| 391 |
} |
| 392 |
} |
| 393 |
} |
| 394 |
|
| 395 |
if (areanum) |
| 396 |
{ |
| 397 |
|
| 398 |
VectorCopy(start, end); |
| 399 |
start[2] += 0.25; |
| 400 |
end[2] -= 50; |
| 401 |
trace = AAS_TraceClientBBox(start, end, PRESENCE_CROUCH, -1); |
| 402 |
if (!trace.startsolid) |
| 403 |
{ |
| 404 |
areanum = AAS_PointAreaNum(trace.endpos); |
| 405 |
VectorCopy(trace.endpos, goalorigin); |
| 406 |
|
| 407 |
|
| 408 |
|
| 409 |
|
| 410 |
if (areanum) return areanum; |
| 411 |
} |
| 412 |
else |
| 413 |
{ |
| 414 |
|
| 415 |
|
| 416 |
|
| 417 |
#if 0 |
| 418 |
if (AAS_PointAreaNum(start)) |
| 419 |
{ |
| 420 |
Log_Write("point %f %f %f in area %d but trace startsolid", start[0], start[1], start[2], areanum); |
| 421 |
AAS_DrawPermanentCross(start, 4, LINECOLOR_RED); |
| 422 |
} |
| 423 |
botimport.Print(PRT_MESSAGE, "AAS_BestReachableArea: start solid\n"); |
| 424 |
#endif |
| 425 |
VectorCopy(start, goalorigin); |
| 426 |
return areanum; |
| 427 |
} |
| 428 |
} |
| 429 |
|
| 430 |
|
| 431 |
|
| 432 |
|
| 433 |
VectorCopy(origin, goalorigin); |
| 434 |
|
| 435 |
VectorAdd(origin, mins, absmins); |
| 436 |
VectorAdd(origin, maxs, absmaxs); |
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
areas = AAS_LinkEntityClientBBox(absmins, absmaxs, -1, PRESENCE_CROUCH); |
| 442 |
|
| 443 |
areanum = AAS_BestReachableLinkArea(areas); |
| 444 |
|
| 445 |
AAS_UnlinkFromAreas(areas); |
| 446 |
|
| 447 |
return areanum; |
| 448 |
} |
| 449 |
|
| 450 |
|
| 451 |
|
| 452 |
|
| 453 |
|
| 454 |
|
| 455 |
void AAS_SetupReachabilityHeap(void) |
| 456 |
{ |
| 457 |
int i; |
| 458 |
|
| 459 |
reachabilityheap = (aas_lreachability_t *) GetClearedMemory( |
| 460 |
AAS_MAX_REACHABILITYSIZE * sizeof(aas_lreachability_t)); |
| 461 |
for (i = 0; i < AAS_MAX_REACHABILITYSIZE-1; i++) |
| 462 |
{ |
| 463 |
reachabilityheap[i].next = &reachabilityheap[i+1]; |
| 464 |
} |
| 465 |
reachabilityheap[AAS_MAX_REACHABILITYSIZE-1].next = NULL; |
| 466 |
nextreachability = reachabilityheap; |
| 467 |
numlreachabilities = 0; |
| 468 |
} |
| 469 |
|
| 470 |
|
| 471 |
|
| 472 |
|
| 473 |
|
| 474 |
|
| 475 |
void AAS_ShutDownReachabilityHeap(void) |
| 476 |
{ |
| 477 |
FreeMemory(reachabilityheap); |
| 478 |
numlreachabilities = 0; |
| 479 |
} |
| 480 |
|
| 481 |
|
| 482 |
|
| 483 |
|
| 484 |
|
| 485 |
|
| 486 |
|
| 487 |
aas_lreachability_t *AAS_AllocReachability(void) |
| 488 |
{ |
| 489 |
aas_lreachability_t *r; |
| 490 |
|
| 491 |
if (!nextreachability) return NULL; |
| 492 |
|
| 493 |
if (!nextreachability->next) AAS_Error("AAS_MAX_REACHABILITYSIZE\n"); |
| 494 |
|
| 495 |
r = nextreachability; |
| 496 |
nextreachability = nextreachability->next; |
| 497 |
numlreachabilities++; |
| 498 |
return r; |
| 499 |
} |
| 500 |
|
| 501 |
|
| 502 |
|
| 503 |
|
| 504 |
|
| 505 |
|
| 506 |
|
| 507 |
void AAS_FreeReachability(aas_lreachability_t *lreach) |
| 508 |
{ |
| 509 |
Com_Memset(lreach, 0, sizeof(aas_lreachability_t)); |
| 510 |
|
| 511 |
lreach->next = nextreachability; |
| 512 |
nextreachability = lreach; |
| 513 |
numlreachabilities--; |
| 514 |
} |
| 515 |
|
| 516 |
|
| 517 |
|
| 518 |
|
| 519 |
|
| 520 |
|
| 521 |
|
| 522 |
int AAS_AreaReachability(int areanum) |
| 523 |
{ |
| 524 |
if (areanum < 0 || areanum >= aasworld.numareas) |
| 525 |
{ |
| 526 |
AAS_Error("AAS_AreaReachability: areanum %d out of range\n", areanum); |
| 527 |
return 0; |
| 528 |
} |
| 529 |
return aasworld.areasettings[areanum].numreachableareas; |
| 530 |
} |
| 531 |
|
| 532 |
|
| 533 |
|
| 534 |
|
| 535 |
|
| 536 |
|
| 537 |
|
| 538 |
float AAS_AreaGroundFaceArea(int areanum) |
| 539 |
{ |
| 540 |
int i; |
| 541 |
float total; |
| 542 |
aas_area_t *area; |
| 543 |
aas_face_t *face; |
| 544 |
|
| 545 |
total = 0; |
| 546 |
area = &aasworld.areas[areanum]; |
| 547 |
for (i = 0; i < area->numfaces; i++) |
| 548 |
{ |
| 549 |
face = &aasworld.faces[abs(aasworld.faceindex[area->firstface + i])]; |
| 550 |
if (!(face->faceflags & FACE_GROUND)) continue; |
| 551 |
|
| 552 |
total += AAS_FaceArea(face); |
| 553 |
} |
| 554 |
return total; |
| 555 |
} |
| 556 |
|
| 557 |
|
| 558 |
|
| 559 |
|
| 560 |
|
| 561 |
|
| 562 |
|
| 563 |
void AAS_FaceCenter(int facenum, vec3_t center) |
| 564 |
{ |
| 565 |
int i; |
| 566 |
float scale; |
| 567 |
aas_face_t *face; |
| 568 |
aas_edge_t *edge; |
| 569 |
|
| 570 |
face = &aasworld.faces[facenum]; |
| 571 |
|
| 572 |
VectorClear(center); |
| 573 |
for (i = 0; i < face->numedges; i++) |
| 574 |
{ |
| 575 |
edge = &aasworld.edges[abs(aasworld.edgeindex[face->firstedge + i])]; |
| 576 |
VectorAdd(center, aasworld.vertexes[edge->v[0]], center); |
| 577 |
VectorAdd(center, aasworld.vertexes[edge->v[1]], center); |
| 578 |
} |
| 579 |
scale = 0.5 / face->numedges; |
| 580 |
VectorScale(center, scale, center); |
| 581 |
} |
| 582 |
|
| 583 |
|
| 584 |
|
| 585 |
|
| 586 |
|
| 587 |
|
| 588 |
|
| 589 |
|
| 590 |
int AAS_FallDamageDistance(void) |
| 591 |
{ |
| 592 |
float maxzvelocity, gravity, t; |
| 593 |
|
| 594 |
maxzvelocity = sqrt(30 * 10000); |
| 595 |
gravity = aassettings.phys_gravity; |
| 596 |
t = maxzvelocity / gravity; |
| 597 |
return 0.5 * gravity * t * t; |
| 598 |
} |
| 599 |
|
| 600 |
|
| 601 |
|
| 602 |
|
| 603 |
|
| 604 |
|
| 605 |
|
| 606 |
|
| 607 |
|
| 608 |
float AAS_FallDelta(float distance) |
| 609 |
{ |
| 610 |
float t, delta, gravity; |
| 611 |
|
| 612 |
gravity = aassettings.phys_gravity; |
| 613 |
t = sqrt(fabs(distance) * 2 / gravity); |
| 614 |
delta = t * gravity; |
| 615 |
return delta * delta * 0.0001; |
| 616 |
} |
| 617 |
|
| 618 |
|
| 619 |
|
| 620 |
|
| 621 |
|
| 622 |
|
| 623 |
float AAS_MaxJumpHeight(float phys_jumpvel) |
| 624 |
{ |
| 625 |
float phys_gravity; |
| 626 |
|
| 627 |
phys_gravity = aassettings.phys_gravity; |
| 628 |
|
| 629 |
return 0.5 * phys_gravity * (phys_jumpvel / phys_gravity) * (phys_jumpvel / phys_gravity); |
| 630 |
} |
| 631 |
|
| 632 |
|
| 633 |
|
| 634 |
|
| 635 |
|
| 636 |
|
| 637 |
|
| 638 |
float AAS_MaxJumpDistance(float phys_jumpvel) |
| 639 |
{ |
| 640 |
float phys_gravity, phys_maxvelocity, t; |
| 641 |
|
| 642 |
phys_gravity = aassettings.phys_gravity; |
| 643 |
phys_maxvelocity = aassettings.phys_maxvelocity; |
| 644 |
|
| 645 |
t = sqrt(aassettings.rs_maxjumpfallheight / (0.5 * phys_gravity)); |
| 646 |
|
| 647 |
return phys_maxvelocity * (t + phys_jumpvel / phys_gravity); |
| 648 |
} |
| 649 |
|
| 650 |
|
| 651 |
|
| 652 |
|
| 653 |
|
| 654 |
|
| 655 |
|
| 656 |
int AAS_AreaCrouch(int areanum) |
| 657 |
{ |
| 658 |
if (!(aasworld.areasettings[areanum].presencetype & PRESENCE_NORMAL)) return qtrue; |
| 659 |
else return qfalse; |
| 660 |
} |
| 661 |
|
| 662 |
|
| 663 |
|
| 664 |
|
| 665 |
|
| 666 |
|
| 667 |
|
| 668 |
int AAS_AreaSwim(int areanum) |
| 669 |
{ |
| 670 |
if (aasworld.areasettings[areanum].areaflags & AREA_LIQUID) return qtrue; |
| 671 |
else return qfalse; |
| 672 |
} |
| 673 |
|
| 674 |
|
| 675 |
|
| 676 |
|
| 677 |
|
| 678 |
|
| 679 |
|
| 680 |
int AAS_AreaLiquid(int areanum) |
| 681 |
{ |
| 682 |
if (aasworld.areasettings[areanum].areaflags & AREA_LIQUID) return qtrue; |
| 683 |
else return qfalse; |
| 684 |
} |
| 685 |
|
| 686 |
|
| 687 |
|
| 688 |
|
| 689 |
|
| 690 |
|
| 691 |
int AAS_AreaLava(int areanum) |
| 692 |
{ |
| 693 |
return (aasworld.areasettings[areanum].contents & AREACONTENTS_LAVA); |
| 694 |
} |
| 695 |
|
| 696 |
|
| 697 |
|
| 698 |
|
| 699 |
|
| 700 |
|
| 701 |
int AAS_AreaSlime(int areanum) |
| 702 |
{ |
| 703 |
return (aasworld.areasettings[areanum].contents & AREACONTENTS_SLIME); |
| 704 |
} |
| 705 |
|
| 706 |
|
| 707 |
|
| 708 |
|
| 709 |
|
| 710 |
|
| 711 |
|
| 712 |
int AAS_AreaGrounded(int areanum) |
| 713 |
{ |
| 714 |
return (aasworld.areasettings[areanum].areaflags & AREA_GROUNDED); |
| 715 |
} |
| 716 |
|
| 717 |
|
| 718 |
|
| 719 |
|
| 720 |
|
| 721 |
|
| 722 |
|
| 723 |
int AAS_AreaLadder(int areanum) |
| 724 |
{ |
| 725 |
return (aasworld.areasettings[areanum].areaflags & AREA_LADDER); |
| 726 |
} |
| 727 |
|
| 728 |
|
| 729 |
|
| 730 |
|
| 731 |
|
| 732 |
|
| 733 |
int AAS_AreaJumpPad(int areanum) |
| 734 |
{ |
| 735 |
return (aasworld.areasettings[areanum].contents & AREACONTENTS_JUMPPAD); |
| 736 |
} |
| 737 |
|
| 738 |
|
| 739 |
|
| 740 |
|
| 741 |
|
| 742 |
|
| 743 |
int AAS_AreaTeleporter(int areanum) |
| 744 |
{ |
| 745 |
return (aasworld.areasettings[areanum].contents & AREACONTENTS_TELEPORTER); |
| 746 |
} |
| 747 |
|
| 748 |
|
| 749 |
|
| 750 |
|
| 751 |
|
| 752 |
|
| 753 |
int AAS_AreaClusterPortal(int areanum) |
| 754 |
{ |
| 755 |
return (aasworld.areasettings[areanum].contents & AREACONTENTS_CLUSTERPORTAL); |
| 756 |
} |
| 757 |
|
| 758 |
|
| 759 |
|
| 760 |
|
| 761 |
|
| 762 |
|
| 763 |
int AAS_AreaDoNotEnter(int areanum) |
| 764 |
{ |
| 765 |
return (aasworld.areasettings[areanum].contents & AREACONTENTS_DONOTENTER); |
| 766 |
} |
| 767 |
|
| 768 |
|
| 769 |
|
| 770 |
|
| 771 |
|
| 772 |
|
| 773 |
|
| 774 |
unsigned short int AAS_BarrierJumpTravelTime(void) |
| 775 |
{ |
| 776 |
return aassettings.phys_jumpvel / (aassettings.phys_gravity * 0.1); |
| 777 |
} |
| 778 |
|
| 779 |
|
| 780 |
|
| 781 |
|
| 782 |
|
| 783 |
|
| 784 |
|
| 785 |
qboolean AAS_ReachabilityExists(int area1num, int area2num) |
| 786 |
{ |
| 787 |
aas_lreachability_t *r; |
| 788 |
|
| 789 |
for (r = areareachability[area1num]; r; r = r->next) |
| 790 |
{ |
| 791 |
if (r->areanum == area2num) return qtrue; |
| 792 |
} |
| 793 |
return qfalse; |
| 794 |
} |
| 795 |
|
| 796 |
|
| 797 |
|
| 798 |
|
| 799 |
|
| 800 |
|
| 801 |
|
| 802 |
|
| 803 |
int AAS_NearbySolidOrGap(vec3_t start, vec3_t end) |
| 804 |
{ |
| 805 |
vec3_t dir, testpoint; |
| 806 |
int areanum; |
| 807 |
|
| 808 |
VectorSubtract(end, start, dir); |
| 809 |
dir[2] = 0; |
| 810 |
VectorNormalize(dir); |
| 811 |
VectorMA(end, 48, dir, testpoint); |
| 812 |
|
| 813 |
areanum = AAS_PointAreaNum(testpoint); |
| 814 |
if (!areanum) |
| 815 |
{ |
| 816 |
testpoint[2] += 16; |
| 817 |
areanum = AAS_PointAreaNum(testpoint); |
| 818 |
if (!areanum) return qtrue; |
| 819 |
} |
| 820 |
VectorMA(end, 64, dir, testpoint); |
| 821 |
areanum = AAS_PointAreaNum(testpoint); |
| 822 |
if (areanum) |
| 823 |
{ |
| 824 |
if (!AAS_AreaSwim(areanum) && !AAS_AreaGrounded(areanum)) return qtrue; |
| 825 |
} |
| 826 |
return qfalse; |
| 827 |
} |
| 828 |
|
| 829 |
|
| 830 |
|
| 831 |
|
| 832 |
|
| 833 |
|
| 834 |
|
| 835 |
int AAS_Reachability_Swim(int area1num, int area2num) |
| 836 |
{ |
| 837 |
int i, j, face1num, face2num, side1; |
| 838 |
aas_area_t *area1, *area2; |
| 839 |
aas_lreachability_t *lreach; |
| 840 |
aas_face_t *face1; |
| 841 |
aas_plane_t *plane; |
| 842 |
vec3_t start; |
| 843 |
|
| 844 |
if (!AAS_AreaSwim(area1num) || !AAS_AreaSwim(area2num)) return qfalse; |
| 845 |
|
| 846 |
if (!(aasworld.areasettings[area2num].presencetype & PRESENCE_NORMAL)) return qfalse; |
| 847 |
|
| 848 |
area1 = &aasworld.areas[area1num]; |
| 849 |
area2 = &aasworld.areas[area2num]; |
| 850 |
|
| 851 |
|
| 852 |
for (i = 0; i < 3; i++) |
| 853 |
{ |
| 854 |
if (area1->mins[i] > area2->maxs[i] + 10) return qfalse; |
| 855 |
if (area1->maxs[i] < area2->mins[i] - 10) return qfalse; |
| 856 |
} |
| 857 |
|
| 858 |
for (i = 0; i < area1->numfaces; i++) |
| 859 |
{ |
| 860 |
face1num = aasworld.faceindex[area1->firstface + i]; |
| 861 |
side1 = face1num < 0; |
| 862 |
face1num = abs(face1num); |
| 863 |
|
| 864 |
for (j = 0; j < area2->numfaces; j++) |
| 865 |
{ |
| 866 |
face2num = abs(aasworld.faceindex[area2->firstface + j]); |
| 867 |
|
| 868 |
if (face1num == face2num) |
| 869 |
{ |
| 870 |
AAS_FaceCenter(face1num, start); |
| 871 |
|
| 872 |
if (AAS_PointContents(start) & (CONTENTS_LAVA|CONTENTS_SLIME|CONTENTS_WATER)) |
| 873 |
{ |
| 874 |
|
| 875 |
face1 = &aasworld.faces[face1num]; |
| 876 |
|
| 877 |
lreach = AAS_AllocReachability(); |
| 878 |
if (!lreach) return qfalse; |
| 879 |
lreach->areanum = area2num; |
| 880 |
lreach->facenum = face1num; |
| 881 |
lreach->edgenum = 0; |
| 882 |
VectorCopy(start, lreach->start); |
| 883 |
plane = &aasworld.planes[face1->planenum ^ side1]; |
| 884 |
VectorMA(lreach->start, -INSIDEUNITS, plane->normal, lreach->end); |
| 885 |
lreach->traveltype = TRAVEL_SWIM; |
| 886 |
lreach->traveltime = 1; |
| 887 |
|
| 888 |
if (AAS_AreaVolume(area2num) < 800) |
| 889 |
lreach->traveltime += 200; |
| 890 |
|
| 891 |
|
| 892 |
lreach->next = areareachability[area1num]; |
| 893 |
areareachability[area1num] = lreach; |
| 894 |
reach_swim++; |
| 895 |
return qtrue; |
| 896 |
} |
| 897 |
} |
| 898 |
} |
| 899 |
} |
| 900 |
return qfalse; |
| 901 |
} |
| 902 |
|
| 903 |
|
| 904 |
|
| 905 |
|
| 906 |
|
| 907 |
|
| 908 |
|
| 909 |
|
| 910 |
int AAS_Reachability_EqualFloorHeight(int area1num, int area2num) |
| 911 |
{ |
| 912 |
int i, j, edgenum, edgenum1, edgenum2, foundreach, side; |
| 913 |
float height, bestheight, length, bestlength; |
| 914 |
vec3_t dir, start, end, normal, invgravity, gravitydirection = {0, 0, -1}; |
| 915 |
vec3_t edgevec; |
| 916 |
aas_area_t *area1, *area2; |
| 917 |
aas_face_t *face1, *face2; |
| 918 |
aas_edge_t *edge; |
| 919 |
aas_plane_t *plane2; |
| 920 |
aas_lreachability_t lr, *lreach; |
| 921 |
|
| 922 |
if (!AAS_AreaGrounded(area1num) || !AAS_AreaGrounded(area2num)) return qfalse; |
| 923 |
|
| 924 |
area1 = &aasworld.areas[area1num]; |
| 925 |
area2 = &aasworld.areas[area2num]; |
| 926 |
|
| 927 |
for (i = 0; i < 2; i++) |
| 928 |
{ |
| 929 |
if (area1->mins[i] > area2->maxs[i] + 10) return qfalse; |
| 930 |
if (area1->maxs[i] < area2->mins[i] - 10) return qfalse; |
| 931 |
} |
| 932 |
|
| 933 |
if (area2->mins[2] > area1->maxs[2]) return qfalse; |
| 934 |
|
| 935 |
VectorCopy(gravitydirection, invgravity); |
| 936 |
VectorInverse(invgravity); |
| 937 |
|
| 938 |
bestheight = 99999; |
| 939 |
bestlength = 0; |
| 940 |
foundreach = qfalse; |
| 941 |
Com_Memset(&lr, 0, sizeof(aas_lreachability_t)); |
| 942 |
|
| 943 |
|
| 944 |
|
| 945 |
for (i = 0; i < area1->numfaces; i++) |
| 946 |
{ |
| 947 |
face1 = &aasworld.faces[abs(aasworld.faceindex[area1->firstface + i])]; |
| 948 |
if (!(face1->faceflags & FACE_GROUND)) continue; |
| 949 |
|
| 950 |
for (j = 0; j < area2->numfaces; j++) |
| 951 |
{ |
| 952 |
face2 = &aasworld.faces[abs(aasworld.faceindex[area2->firstface + j])]; |
| 953 |
if (!(face2->faceflags & FACE_GROUND)) continue; |
| 954 |
|
| 955 |
for (edgenum1 = 0; edgenum1 < face1->numedges; edgenum1++) |
| 956 |
{ |
| 957 |
for (edgenum2 = 0; edgenum2 < face2->numedges; edgenum2++) |
| 958 |
{ |
| 959 |
if (abs(aasworld.edgeindex[face1->firstedge + edgenum1]) != |
| 960 |
abs(aasworld.edgeindex[face2->firstedge + edgenum2])) |
| 961 |
continue; |
| 962 |
edgenum = aasworld.edgeindex[face1->firstedge + edgenum1]; |
| 963 |
side = edgenum < 0; |
| 964 |
edge = &aasworld.edges[abs(edgenum)]; |
| 965 |
|
| 966 |
VectorSubtract(aasworld.vertexes[edge->v[1]], |
| 967 |
aasworld.vertexes[edge->v[0]], dir); |
| 968 |
length = VectorLength(dir); |
| 969 |
|
| 970 |
VectorAdd(aasworld.vertexes[edge->v[0]], |
| 971 |
aasworld.vertexes[edge->v[1]], start); |
| 972 |
VectorScale(start, 0.5, start); |
| 973 |
VectorCopy(start, end); |
| 974 |
|
| 975 |
|
| 976 |
|
| 977 |
|
| 978 |
VectorSubtract(aasworld.vertexes[edge->v[side]], |
| 979 |
aasworld.vertexes[edge->v[!side]], edgevec); |
| 980 |
plane2 = &aasworld.planes[face2->planenum]; |
| 981 |
CrossProduct(edgevec, plane2->normal, normal); |
| 982 |
VectorNormalize(normal); |
| 983 |
|
| 984 |
|
| 985 |
VectorMA(end, INSIDEUNITS_WALKEND, normal, end); |
| 986 |
VectorMA(start, INSIDEUNITS_WALKSTART, normal, start); |
| 987 |
end[2] += 0.125; |
| 988 |
|
| 989 |
height = DotProduct(invgravity, start); |
| 990 |
|
| 991 |
|
| 992 |
|
| 993 |
|
| 994 |
|
| 995 |
|
| 996 |
if (height < bestheight || |
| 997 |
(height < bestheight + 1 && length > bestlength)) |
| 998 |
{ |
| 999 |
bestheight = height; |
| 1000 |
bestlength = length; |
| 1001 |
|
| 1002 |
lr.areanum = area2num; |
| 1003 |
lr.facenum = 0; |
| 1004 |
lr.edgenum = edgenum; |
| 1005 |
VectorCopy(start, lr.start); |
| 1006 |
VectorCopy(end, lr.end); |
| 1007 |
lr.traveltype = TRAVEL_WALK; |
| 1008 |
lr.traveltime = 1; |
| 1009 |
foundreach = qtrue; |
| 1010 |
} |
| 1011 |
} |
| 1012 |
} |
| 1013 |
} |
| 1014 |
} |
| 1015 |
if (foundreach) |
| 1016 |
{ |
| 1017 |
|
| 1018 |
lreach = AAS_AllocReachability(); |
| 1019 |
if (!lreach) return qfalse; |
| 1020 |
lreach->areanum = lr.areanum; |
| 1021 |
lreach->facenum = lr.facenum; |
| 1022 |
lreach->edgenum = lr.edgenum; |
| 1023 |
VectorCopy(lr.start, lreach->start); |
| 1024 |
VectorCopy(lr.end, lreach->end); |
| 1025 |
lreach->traveltype = lr.traveltype; |
| 1026 |
lreach->traveltime = lr.traveltime; |
| 1027 |
lreach->next = areareachability[area1num]; |
| 1028 |
areareachability[area1num] = lreach; |
| 1029 |
|
| 1030 |
if (!AAS_AreaCrouch(area1num) && AAS_AreaCrouch(area2num)) |
| 1031 |
{ |
| 1032 |
lreach->traveltime += aassettings.rs_startcrouch; |
| 1033 |
} |
| 1034 |
|
| 1035 |
|
| 1036 |
|
| 1037 |
|
| 1038 |
|
| 1039 |
|
| 1040 |
|
| 1041 |
|
| 1042 |
|
| 1043 |
|
| 1044 |
reach_equalfloor++; |
| 1045 |
return qtrue; |
| 1046 |
} |
| 1047 |
return qfalse; |
| 1048 |
} |
| 1049 |
|
| 1050 |
|
| 1051 |
|
| 1052 |
|
| 1053 |
|
| 1054 |
|
| 1055 |
|
| 1056 |
int AAS_Reachability_Step_Barrier_WaterJump_WalkOffLedge(int area1num, int area2num) |
| 1057 |
{ |
| 1058 |
int i, j, k, l, edge1num, edge2num, areas[10], numareas; |
| 1059 |
int ground_bestarea2groundedgenum, ground_foundreach; |
| 1060 |
int water_bestarea2groundedgenum, water_foundreach; |
| 1061 |
int side1, area1swim, faceside1, groundface1num; |
| 1062 |
float dist, dist1, dist2, diff, ortdot; |
| 1063 |
|
| 1064 |
float x1, x2, x3, x4, y1, y2, y3, y4, tmp, y; |
| 1065 |
float length, ground_bestlength, water_bestlength, ground_bestdist, water_bestdist; |
| 1066 |
vec3_t v1, v2, v3, v4, tmpv, p1area1, p1area2, p2area1, p2area2; |
| 1067 |
vec3_t normal, ort, edgevec, start, end, dir; |
| 1068 |
vec3_t ground_beststart = {0, 0, 0}, ground_bestend = {0, 0, 0}, ground_bestnormal = {0, 0, 0}; |
| 1069 |
vec3_t water_beststart = {0, 0, 0}, water_bestend = {0, 0, 0}, water_bestnormal = {0, 0, 0}; |
| 1070 |
vec3_t invgravity = {0, 0, 1}; |
| 1071 |
vec3_t testpoint; |
| 1072 |
aas_plane_t *plane; |
| 1073 |
aas_area_t *area1, *area2; |
| 1074 |
aas_face_t *groundface1, *groundface2; |
| 1075 |
aas_edge_t *edge1, *edge2; |
| 1076 |
aas_lreachability_t *lreach; |
| 1077 |
aas_trace_t trace; |
| 1078 |
|
| 1079 |
|
| 1080 |
if (!AAS_AreaGrounded(area1num) && !AAS_AreaSwim(area1num)) return qfalse; |
| 1081 |
|
| 1082 |
if (!AAS_AreaGrounded(area2num) && !AAS_AreaSwim(area2num)) return qfalse; |
| 1083 |
|
| 1084 |
area1 = &aasworld.areas[area1num]; |
| 1085 |
area2 = &aasworld.areas[area2num]; |
| 1086 |
|
| 1087 |
area1swim = AAS_AreaSwim(area1num); |
| 1088 |
|
| 1089 |
for (i = 0; i < 2; i++) |
| 1090 |
{ |
| 1091 |
if (area1->mins[i] > area2->maxs[i] + 10) return qfalse; |
| 1092 |
if (area1->maxs[i] < area2->mins[i] - 10) return qfalse; |
| 1093 |
} |
| 1094 |
|
| 1095 |
ground_foundreach = qfalse; |
| 1096 |
ground_bestdist = 99999; |
| 1097 |
ground_bestlength = 0; |
| 1098 |
ground_bestarea2groundedgenum = 0; |
| 1099 |
|
| 1100 |
water_foundreach = qfalse; |
| 1101 |
water_bestdist = 99999; |
| 1102 |
water_bestlength = 0; |
| 1103 |
water_bestarea2groundedgenum = 0; |
| 1104 |
|
| 1105 |
for (i = 0; i < area1->numfaces; i++) |
| 1106 |
{ |
| 1107 |
groundface1num = aasworld.faceindex[area1->firstface + i]; |
| 1108 |
faceside1 = groundface1num < 0; |
| 1109 |
groundface1 = &aasworld.faces[abs(groundface1num)]; |
| 1110 |
|
| 1111 |
if (!(groundface1->faceflags & FACE_GROUND)) |
| 1112 |
{ |
| 1113 |
|
| 1114 |
if (area1swim) |
| 1115 |
{ |
| 1116 |
|
| 1117 |
plane = &aasworld.planes[groundface1->planenum ^ (!faceside1)]; |
| 1118 |
if (DotProduct(plane->normal, invgravity) < 0.7) continue; |
| 1119 |
} |
| 1120 |
else |
| 1121 |
{ |
| 1122 |
|
| 1123 |
continue; |
| 1124 |
} |
| 1125 |
} |
| 1126 |
|
| 1127 |
for (k = 0; k < groundface1->numedges; k++) |
| 1128 |
{ |
| 1129 |
edge1num = aasworld.edgeindex[groundface1->firstedge + k]; |
| 1130 |
side1 = (edge1num < 0); |
| 1131 |
|
| 1132 |
|
| 1133 |
|
| 1134 |
if (!(groundface1->faceflags & FACE_GROUND)) side1 = (side1 == faceside1); |
| 1135 |
edge1num = abs(edge1num); |
| 1136 |
edge1 = &aasworld.edges[edge1num]; |
| 1137 |
|
| 1138 |
VectorCopy(aasworld.vertexes[edge1->v[!side1]], v1); |
| 1139 |
VectorCopy(aasworld.vertexes[edge1->v[side1]], v2); |
| 1140 |
|
| 1141 |
|
| 1142 |
|
| 1143 |
VectorSubtract(v2, v1, edgevec); |
| 1144 |
CrossProduct(edgevec, invgravity, normal); |
| 1145 |
VectorNormalize(normal); |
| 1146 |
dist = DotProduct(normal, v1); |
| 1147 |
|
| 1148 |
for (j = 0; j < area2->numfaces; j++) |
| 1149 |
{ |
| 1150 |
groundface2 = &aasworld.faces[abs(aasworld.faceindex[area2->firstface + j])]; |
| 1151 |
|
| 1152 |
if (!(groundface2->faceflags & FACE_GROUND)) continue; |
| 1153 |
|
| 1154 |
for (l = 0; l < groundface2->numedges; l++) |
| 1155 |
{ |
| 1156 |
edge2num = abs(aasworld.edgeindex[groundface2->firstedge + l]); |
| 1157 |
edge2 = &aasworld.edges[edge2num]; |
| 1158 |
|
| 1159 |
VectorCopy(aasworld.vertexes[edge2->v[0]], v3); |
| 1160 |
VectorCopy(aasworld.vertexes[edge2->v[1]], v4); |
| 1161 |
|
| 1162 |
|
| 1163 |
diff = DotProduct(normal, v3) - dist; |
| 1164 |
if (diff < -0.1 || diff > 0.1) continue; |
| 1165 |
diff = DotProduct(normal, v4) - dist; |
| 1166 |
if (diff < -0.1 || diff > 0.1) continue; |
| 1167 |
|
| 1168 |
|
| 1169 |
|
| 1170 |
|
| 1171 |
|
| 1172 |
CrossProduct(invgravity, normal, ort); |
| 1173 |
|
| 1174 |
ortdot = DotProduct(ort, ort); |
| 1175 |
|
| 1176 |
|
| 1177 |
y1 = v1[2]; |
| 1178 |
y2 = v2[2]; |
| 1179 |
y3 = v3[2]; |
| 1180 |
y4 = v4[2]; |
| 1181 |
|
| 1182 |
x1 = DotProduct(v1, ort) / ortdot; |
| 1183 |
x2 = DotProduct(v2, ort) / ortdot; |
| 1184 |
x3 = DotProduct(v3, ort) / ortdot; |
| 1185 |
x4 = DotProduct(v4, ort) / ortdot; |
| 1186 |
|
| 1187 |
if (x1 > x2) |
| 1188 |
{ |
| 1189 |
tmp = x1; x1 = x2; x2 = tmp; |
| 1190 |
tmp = y1; y1 = y2; y2 = tmp; |
| 1191 |
VectorCopy(v1, tmpv); VectorCopy(v2, v1); VectorCopy(tmpv, v2); |
| 1192 |
} |
| 1193 |
if (x3 > x4) |
| 1194 |
{ |
| 1195 |
tmp = x3; x3 = x4; x4 = tmp; |
| 1196 |
tmp = y3; y3 = y4; y4 = tmp; |
| 1197 |
VectorCopy(v3, tmpv); VectorCopy(v4, v3); VectorCopy(tmpv, v4); |
| 1198 |
} |
| 1199 |
|
| 1200 |
if (x2 <= x3 || x4 <= x1) |
| 1201 |
{ |
| 1202 |
|
| 1203 |
continue; |
| 1204 |
} |
| 1205 |
|
| 1206 |
if ((x1 - 0.5 < x3 && x4 < x2 + 0.5) && |
| 1207 |
(x3 - 0.5 < x1 && x2 < x4 + 0.5)) |
| 1208 |
{ |
| 1209 |
dist1 = y3 - y1; |
| 1210 |
dist2 = y4 - y2; |
| 1211 |
VectorCopy(v1, p1area1); |
| 1212 |
VectorCopy(v2, p2area1); |
| 1213 |
VectorCopy(v3, p1area2); |
| 1214 |
VectorCopy(v4, p2area2); |
| 1215 |
} |
| 1216 |
else |
| 1217 |
{ |
| 1218 |
|
| 1219 |
if (x1 > x3 - 0.1 && x1 < x3 + 0.1) |
| 1220 |
{ |
| 1221 |
dist1 = y3 - y1; |
| 1222 |
VectorCopy(v1, p1area1); |
| 1223 |
VectorCopy(v3, p1area2); |
| 1224 |
} |
| 1225 |
else if (x1 < x3) |
| 1226 |
{ |
| 1227 |
y = y1 + (x3 - x1) * (y2 - y1) / (x2 - x1); |
| 1228 |
dist1 = y3 - y; |
| 1229 |
VectorCopy(v3, p1area1); |
| 1230 |
p1area1[2] = y; |
| 1231 |
VectorCopy(v3, p1area2); |
| 1232 |
} |
| 1233 |
else |
| 1234 |
{ |
| 1235 |
y = y3 + (x1 - x3) * (y4 - y3) / (x4 - x3); |
| 1236 |
dist1 = y - y1; |
| 1237 |
VectorCopy(v1, p1area1); |
| 1238 |
VectorCopy(v1, p1area2); |
| 1239 |
p1area2[2] = y; |
| 1240 |
} |
| 1241 |
|
| 1242 |
if (x2 > x4 - 0.1 && x2 < x4 + 0.1) |
| 1243 |
{ |
| 1244 |
dist2 = y4 - y2; |
| 1245 |
VectorCopy(v2, p2area1); |
| 1246 |
VectorCopy(v4, p2area2); |
| 1247 |
} |
| 1248 |
else if (x2 < x4) |
| 1249 |
{ |
| 1250 |
y = y3 + (x2 - x3) * (y4 - y3) / (x4 - x3); |
| 1251 |
dist2 = y - y2; |
| 1252 |
VectorCopy(v2, p2area1); |
| 1253 |
VectorCopy(v2, p2area2); |
| 1254 |
p2area2[2] = y; |
| 1255 |
} |
| 1256 |
else |
| 1257 |
{ |
| 1258 |
y = y1 + (x4 - x1) * (y2 - y1) / (x2 - x1); |
| 1259 |
dist2 = y4 - y; |
| 1260 |
VectorCopy(v4, p2area1); |
| 1261 |
p2area1[2] = y; |
| 1262 |
VectorCopy(v4, p2area2); |
| 1263 |
} |
| 1264 |
} |
| 1265 |
|
| 1266 |
|
| 1267 |
if (dist1 > dist2 - 1 && dist1 < dist2 + 1) |
| 1268 |
{ |
| 1269 |
dist = dist1; |
| 1270 |
VectorAdd(p1area1, p2area1, start); |
| 1271 |
VectorScale(start, 0.5, start); |
| 1272 |
VectorAdd(p1area2, p2area2, end); |
| 1273 |
VectorScale(end, 0.5, end); |
| 1274 |
} |
| 1275 |
else if (dist1 < dist2) |
| 1276 |
{ |
| 1277 |
dist = dist1; |
| 1278 |
VectorCopy(p1area1, start); |
| 1279 |
VectorCopy(p1area2, end); |
| 1280 |
} |
| 1281 |
else |
| 1282 |
{ |
| 1283 |
dist = dist2; |
| 1284 |
VectorCopy(p2area1, start); |
| 1285 |
VectorCopy(p2area2, end); |
| 1286 |
} |
| 1287 |
|
| 1288 |
VectorSubtract(p2area2, p1area2, dir); |
| 1289 |
length = VectorLength(dir); |
| 1290 |
|
| 1291 |
if (groundface1->faceflags & FACE_GROUND) |
| 1292 |
{ |
| 1293 |
|
| 1294 |
if (dist < ground_bestdist || |
| 1295 |
|
| 1296 |
|
| 1297 |
(dist < ground_bestdist + 1 && length > ground_bestlength)) |
| 1298 |
{ |
| 1299 |
ground_bestdist = dist; |
| 1300 |
ground_bestlength = length; |
| 1301 |
ground_foundreach = qtrue; |
| 1302 |
ground_bestarea2groundedgenum = edge1num; |
| 1303 |
|
| 1304 |
VectorCopy(start, ground_beststart); |
| 1305 |
|
| 1306 |
VectorCopy(normal, ground_bestnormal); |
| 1307 |
|
| 1308 |
VectorCopy(end, ground_bestend); |
| 1309 |
} |
| 1310 |
} |
| 1311 |
else |
| 1312 |
{ |
| 1313 |
|
| 1314 |
if (dist < water_bestdist || |
| 1315 |
|
| 1316 |
|
| 1317 |
(dist < water_bestdist + 1 && length > water_bestlength)) |
| 1318 |
{ |
| 1319 |
water_bestdist = dist; |
| 1320 |
water_bestlength = length; |
| 1321 |
water_foundreach = qtrue; |
| 1322 |
water_bestarea2groundedgenum = edge1num; |
| 1323 |
|
| 1324 |
VectorCopy(start, water_beststart); |
| 1325 |
|
| 1326 |
VectorCopy(normal, water_bestnormal); |
| 1327 |
|
| 1328 |
VectorCopy(end, water_bestend); |
| 1329 |
} |
| 1330 |
} |
| 1331 |
} |
| 1332 |
} |
| 1333 |
} |
| 1334 |
} |
| 1335 |
|
| 1336 |
|
| 1337 |
|
| 1338 |
|
| 1339 |
|
| 1340 |
|
| 1341 |
|
| 1342 |
|
| 1343 |
|
| 1344 |
|
| 1345 |
|
| 1346 |
|
| 1347 |
|
| 1348 |
|
| 1349 |
|
| 1350 |
|
| 1351 |
|
| 1352 |
|
| 1353 |
|
| 1354 |
if (ground_foundreach) |
| 1355 |
{ |
| 1356 |
|
| 1357 |
|
| 1358 |
if (ground_bestdist >= 0 && ground_bestdist < aassettings.phys_maxstep) |
| 1359 |
{ |
| 1360 |
|
| 1361 |
lreach = AAS_AllocReachability(); |
| 1362 |
if (!lreach) return qfalse; |
| 1363 |
lreach->areanum = area2num; |
| 1364 |
lreach->facenum = 0; |
| 1365 |
lreach->edgenum = ground_bestarea2groundedgenum; |
| 1366 |
VectorMA(ground_beststart, INSIDEUNITS_WALKSTART, ground_bestnormal, lreach->start); |
| 1367 |
VectorMA(ground_bestend, INSIDEUNITS_WALKEND, ground_bestnormal, lreach->end); |
| 1368 |
lreach->traveltype = TRAVEL_WALK; |
| 1369 |
lreach->traveltime = 0; |
| 1370 |
|
| 1371 |
if (!AAS_AreaCrouch(area1num) && AAS_AreaCrouch(area2num)) |
| 1372 |
{ |
| 1373 |
lreach->traveltime += aassettings.rs_startcrouch; |
| 1374 |
} |
| 1375 |
lreach->next = areareachability[area1num]; |
| 1376 |
areareachability[area1num] = lreach; |
| 1377 |
|
| 1378 |
|
| 1379 |
|
| 1380 |
|
| 1381 |
|
| 1382 |
|
| 1383 |
|
| 1384 |
|
| 1385 |
|
| 1386 |
|
| 1387 |
reach_step++; |
| 1388 |
return qtrue; |
| 1389 |
} |
| 1390 |
} |
| 1391 |
|
| 1392 |
|
| 1393 |
|
| 1394 |
|
| 1395 |
|
| 1396 |
|
| 1397 |
|
| 1398 |
|
| 1399 |
|
| 1400 |
|
| 1401 |
|
| 1402 |
|
| 1403 |
|
| 1404 |
|
| 1405 |
|
| 1406 |
|
| 1407 |
|
| 1408 |
|
| 1409 |
|
| 1410 |
if (water_foundreach) |
| 1411 |
{ |
| 1412 |
|
| 1413 |
VectorMA(water_bestend, -INSIDEUNITS, water_bestnormal, testpoint); |
| 1414 |
|
| 1415 |
testpoint[2] -= aassettings.phys_maxwaterjump; |
| 1416 |
|
| 1417 |
if (aasworld.areasettings[AAS_PointAreaNum(testpoint)].areaflags & AREA_LIQUID) |
| 1418 |
{ |
| 1419 |
|
| 1420 |
|
| 1421 |
if (water_bestdist < aassettings.phys_maxwaterjump + 24) |
| 1422 |
{ |
| 1423 |
|
| 1424 |
if ((aasworld.areasettings[area1num].presencetype & PRESENCE_NORMAL) && |
| 1425 |
(aasworld.areasettings[area2num].presencetype & PRESENCE_NORMAL)) |
| 1426 |
{ |
| 1427 |
|
| 1428 |
lreach = AAS_AllocReachability(); |
| 1429 |
if (!lreach) return qfalse; |
| 1430 |
lreach->areanum = area2num; |
| 1431 |
lreach->facenum = 0; |
| 1432 |
lreach->edgenum = water_bestarea2groundedgenum; |
| 1433 |
VectorCopy(water_beststart, lreach->start); |
| 1434 |
VectorMA(water_bestend, INSIDEUNITS_WATERJUMP, water_bestnormal, lreach->end); |
| 1435 |
lreach->traveltype = TRAVEL_WATERJUMP; |
| 1436 |
lreach->traveltime = aassettings.rs_waterjump; |
| 1437 |
lreach->next = areareachability[area1num]; |
| 1438 |
areareachability[area1num] = lreach; |
| 1439 |
|
| 1440 |
reach_waterjump++; |
| 1441 |
return qtrue; |
| 1442 |
} |
| 1443 |
} |
| 1444 |
} |
| 1445 |
} |
| 1446 |
|
| 1447 |
|
| 1448 |
|
| 1449 |
|
| 1450 |
|
| 1451 |
|
| 1452 |
|
| 1453 |
|
| 1454 |
|
| 1455 |
|
| 1456 |
|
| 1457 |
|
| 1458 |
|
| 1459 |
|
| 1460 |
|
| 1461 |
|
| 1462 |
|
| 1463 |
|
| 1464 |
if (ground_foundreach) |
| 1465 |
{ |
| 1466 |
|
| 1467 |
if (ground_bestdist > 0 && ground_bestdist < aassettings.phys_maxbarrier) |
| 1468 |
{ |
| 1469 |
|
| 1470 |
if (!water_foundreach || (ground_bestdist - water_bestdist < 16)) |
| 1471 |
{ |
| 1472 |
|
| 1473 |
if (!AAS_AreaCrouch(area1num) && !AAS_AreaCrouch(area2num)) |
| 1474 |
{ |
| 1475 |
|
| 1476 |
lreach = AAS_AllocReachability(); |
| 1477 |
if (!lreach) return qfalse; |
| 1478 |
lreach->areanum = area2num; |
| 1479 |
lreach->facenum = 0; |
| 1480 |
lreach->edgenum = ground_bestarea2groundedgenum; |
| 1481 |
VectorMA(ground_beststart, INSIDEUNITS_WALKSTART, ground_bestnormal, lreach->start); |
| 1482 |
VectorMA(ground_bestend, INSIDEUNITS_WALKEND, ground_bestnormal, lreach->end); |
| 1483 |
lreach->traveltype = TRAVEL_BARRIERJUMP; |
| 1484 |
lreach->traveltime = aassettings.rs_barrierjump; |
| 1485 |
lreach->next = areareachability[area1num]; |
| 1486 |
areareachability[area1num] = lreach; |
| 1487 |
|
| 1488 |
reach_barrier++; |
| 1489 |
return qtrue; |
| 1490 |
} |
| 1491 |
} |
| 1492 |
} |
| 1493 |
} |
| 1494 |
|
| 1495 |
|
| 1496 |
|
| 1497 |
|
| 1498 |
|
| 1499 |
|
| 1500 |
|
| 1501 |
|
| 1502 |
|
| 1503 |
|
| 1504 |
|
| 1505 |
|
| 1506 |
|
| 1507 |
|
| 1508 |
|
| 1509 |
|
| 1510 |
|
| 1511 |
|
| 1512 |
|
| 1513 |
|
| 1514 |
|
| 1515 |
|
| 1516 |
if (ground_foundreach) |
| 1517 |
{ |
| 1518 |
if (ground_bestdist < 0) |
| 1519 |
{ |
| 1520 |
if (ground_bestdist > -aassettings.phys_maxstep) |
| 1521 |
{ |
| 1522 |
|
| 1523 |
lreach = AAS_AllocReachability(); |
| 1524 |
if (!lreach) return qfalse; |
| 1525 |
lreach->areanum = area2num; |
| 1526 |
lreach->facenum = 0; |
| 1527 |
lreach->edgenum = ground_bestarea2groundedgenum; |
| 1528 |
VectorMA(ground_beststart, INSIDEUNITS_WALKSTART, ground_bestnormal, lreach->start); |
| 1529 |
VectorMA(ground_bestend, INSIDEUNITS_WALKEND, ground_bestnormal, lreach->end); |
| 1530 |
lreach->traveltype = TRAVEL_WALK; |
| 1531 |
lreach->traveltime = 1; |
| 1532 |
lreach->next = areareachability[area1num]; |
| 1533 |
areareachability[area1num] = lreach; |
| 1534 |
|
| 1535 |
reach_walk++; |
| 1536 |
return qtrue; |
| 1537 |
} |
| 1538 |
|
| 1539 |
if (!aassettings.rs_maxfallheight || fabs(ground_bestdist) < aassettings.rs_maxfallheight) { |
| 1540 |
|
| 1541 |
VectorMA(ground_bestend, INSIDEUNITS, ground_bestnormal, ground_bestend); |
| 1542 |
VectorCopy(ground_bestend, start); |
| 1543 |
start[2] = ground_beststart[2]; |
| 1544 |
VectorCopy(ground_bestend, end); |
| 1545 |
end[2] += 4; |
| 1546 |
trace = AAS_TraceClientBBox(start, end, PRESENCE_NORMAL, -1); |
| 1547 |
|
| 1548 |
if (!trace.startsolid && trace.fraction >= 1.0) |
| 1549 |
{ |
| 1550 |
|
| 1551 |
trace.endpos[2] += 1; |
| 1552 |
if (AAS_PointAreaNum(trace.endpos) == area2num) |
| 1553 |
{ |
| 1554 |
|
| 1555 |
numareas = AAS_TraceAreas(start, end, areas, NULL, ARRAY_LEN(areas)); |
| 1556 |
for (i = 0; i < numareas; i++) |
| 1557 |
if (AAS_AreaClusterPortal(areas[i])) |
| 1558 |
break; |
| 1559 |
if (i >= numareas) |
| 1560 |
{ |
| 1561 |
|
| 1562 |
lreach = AAS_AllocReachability(); |
| 1563 |
if (!lreach) return qfalse; |
| 1564 |
lreach->areanum = area2num; |
| 1565 |
lreach->facenum = 0; |
| 1566 |
lreach->edgenum = ground_bestarea2groundedgenum; |
| 1567 |
VectorCopy(ground_beststart, lreach->start); |
| 1568 |
VectorCopy(ground_bestend, lreach->end); |
| 1569 |
lreach->traveltype = TRAVEL_WALKOFFLEDGE; |
| 1570 |
lreach->traveltime = aassettings.rs_startwalkoffledge + fabs(ground_bestdist) * 50 / aassettings.phys_gravity; |
| 1571 |
|
| 1572 |
if (!AAS_AreaSwim(area2num) && !AAS_AreaJumpPad(area2num)) |
| 1573 |
{ |
| 1574 |
if (AAS_FallDelta(ground_bestdist) > aassettings.phys_falldelta5) |
| 1575 |
{ |
| 1576 |
lreach->traveltime += aassettings.rs_falldamage5; |
| 1577 |
} |
| 1578 |
if (AAS_FallDelta(ground_bestdist) > aassettings.phys_falldelta10) |
| 1579 |
{ |
| 1580 |
lreach->traveltime += aassettings.rs_falldamage10; |
| 1581 |
} |
| 1582 |
} |
| 1583 |
lreach->next = areareachability[area1num]; |
| 1584 |
areareachability[area1num] = lreach; |
| 1585 |
|
| 1586 |
reach_walkoffledge++; |
| 1587 |
|
| 1588 |
|
| 1589 |
|
| 1590 |
return qtrue; |
| 1591 |
} |
| 1592 |
} |
| 1593 |
} |
| 1594 |
} |
| 1595 |
} |
| 1596 |
} |
| 1597 |
return qfalse; |
| 1598 |
} |
| 1599 |
|
| 1600 |
|
| 1601 |
|
| 1602 |
|
| 1603 |
|
| 1604 |
|
| 1605 |
|
| 1606 |
float VectorDistance(vec3_t v1, vec3_t v2) |
| 1607 |
{ |
| 1608 |
vec3_t dir; |
| 1609 |
|
| 1610 |
VectorSubtract(v2, v1, dir); |
| 1611 |
return VectorLength(dir); |
| 1612 |
} |
| 1613 |
|
| 1614 |
|
| 1615 |
|
| 1616 |
|
| 1617 |
|
| 1618 |
|
| 1619 |
|
| 1620 |
int VectorBetweenVectors(vec3_t v, vec3_t v1, vec3_t v2) |
| 1621 |
{ |
| 1622 |
vec3_t dir1, dir2; |
| 1623 |
|
| 1624 |
VectorSubtract(v, v1, dir1); |
| 1625 |
VectorSubtract(v, v2, dir2); |
| 1626 |
return (DotProduct(dir1, dir2) <= 0); |
| 1627 |
} |
| 1628 |
|
| 1629 |
|
| 1630 |
|
| 1631 |
|
| 1632 |
|
| 1633 |
|
| 1634 |
|
| 1635 |
void VectorMiddle(vec3_t v1, vec3_t v2, vec3_t middle) |
| 1636 |
{ |
| 1637 |
VectorAdd(v1, v2, middle); |
| 1638 |
VectorScale(middle, 0.5, middle); |
| 1639 |
} |
| 1640 |
|
| 1641 |
|
| 1642 |
|
| 1643 |
|
| 1644 |
|
| 1645 |
|
| 1646 |
|
| 1647 |
|
| 1648 |
|
| 1649 |
|
| 1650 |
|
| 1651 |
|
| 1652 |
|
| 1653 |
|
| 1654 |
|
| 1655 |
|
| 1656 |
|
| 1657 |
|
| 1658 |
|
| 1659 |
|
| 1660 |
|
| 1661 |
|
| 1662 |
|
| 1663 |
|
| 1664 |
|
| 1665 |
|
| 1666 |
|
| 1667 |
|
| 1668 |
|
| 1669 |
|
| 1670 |
|
| 1671 |
|
| 1672 |
|
| 1673 |
|
| 1674 |
|
| 1675 |
|
| 1676 |
|
| 1677 |
|
| 1678 |
|
| 1679 |
|
| 1680 |
|
| 1681 |
|
| 1682 |
|
| 1683 |
|
| 1684 |
|
| 1685 |
|
| 1686 |
|
| 1687 |
|
| 1688 |
|
| 1689 |
|
| 1690 |
|
| 1691 |
|
| 1692 |
|
| 1693 |
|
| 1694 |
|
| 1695 |
|
| 1696 |
|
| 1697 |
|
| 1698 |
|
| 1699 |
|
| 1700 |
|
| 1701 |
|
| 1702 |
|
| 1703 |
|
| 1704 |
|
| 1705 |
|
| 1706 |
|
| 1707 |
|
| 1708 |
|
| 1709 |
|
| 1710 |
|
| 1711 |
|
| 1712 |
|
| 1713 |
|
| 1714 |
|
| 1715 |
|
| 1716 |
|
| 1717 |
|
| 1718 |
|
| 1719 |
|
| 1720 |
|
| 1721 |
|
| 1722 |
|
| 1723 |
|
| 1724 |
|
| 1725 |
|
| 1726 |
|
| 1727 |
|
| 1728 |
|
| 1729 |
|
| 1730 |
|
| 1731 |
|
| 1732 |
|
| 1733 |
|
| 1734 |
|
| 1735 |
|
| 1736 |
|
| 1737 |
|
| 1738 |
|
| 1739 |
|
| 1740 |
|
| 1741 |
|
| 1742 |
|
| 1743 |
|
| 1744 |
|
| 1745 |
|
| 1746 |
|
| 1747 |
|
| 1748 |
|
| 1749 |
|
| 1750 |
|
| 1751 |
|
| 1752 |
|
| 1753 |
|
| 1754 |
|
| 1755 |
|
| 1756 |
|
| 1757 |
|
| 1758 |
|
| 1759 |
|
| 1760 |
|
| 1761 |
|
| 1762 |
|
| 1763 |
|
| 1764 |
|
| 1765 |
|
| 1766 |
|
| 1767 |
|
| 1768 |
|
| 1769 |
|
| 1770 |
|
| 1771 |
|
| 1772 |
|
| 1773 |
|
| 1774 |
|
| 1775 |
|
| 1776 |
|
| 1777 |
|
| 1778 |
|
| 1779 |
|
| 1780 |
|
| 1781 |
|
| 1782 |
|
| 1783 |
|
| 1784 |
|
| 1785 |
|
| 1786 |
|
| 1787 |
|
| 1788 |
|
| 1789 |
|
| 1790 |
|
| 1791 |
|
| 1792 |
|
| 1793 |
|
| 1794 |
|
| 1795 |
|
| 1796 |
|
| 1797 |
|
| 1798 |
|
| 1799 |
|
| 1800 |
|
| 1801 |
|
| 1802 |
|
| 1803 |
|
| 1804 |
|
| 1805 |
|
| 1806 |
|
| 1807 |
|
| 1808 |
|
| 1809 |
|
| 1810 |
|
| 1811 |
|
| 1812 |
|
| 1813 |
|
| 1814 |
|
| 1815 |
|
| 1816 |
|
| 1817 |
|
| 1818 |
|
| 1819 |
|
| 1820 |
|
| 1821 |
|
| 1822 |
|
| 1823 |
|
| 1824 |
|
| 1825 |
|
| 1826 |
|
| 1827 |
float AAS_ClosestEdgePoints(vec3_t v1, vec3_t v2, vec3_t v3, vec3_t v4, |
| 1828 |
aas_plane_t *plane1, aas_plane_t *plane2, |
| 1829 |
vec3_t beststart1, vec3_t bestend1, |
| 1830 |
vec3_t beststart2, vec3_t bestend2, float bestdist) |
| 1831 |
{ |
| 1832 |
vec3_t dir1, dir2, p1, p2, p3, p4; |
| 1833 |
float a1, a2, b1, b2, dist, dist1, dist2; |
| 1834 |
int founddist; |
| 1835 |
|
| 1836 |
|
| 1837 |
VectorSubtract(v2, v1, dir1); |
| 1838 |
VectorSubtract(v4, v3, dir2); |
| 1839 |
|
| 1840 |
dir1[2] = 0; |
| 1841 |
dir2[2] = 0; |
| 1842 |
|
| 1843 |
|
| 1844 |
|
| 1845 |
|
| 1846 |
|
| 1847 |
|
| 1848 |
if (dir2[0]) |
| 1849 |
{ |
| 1850 |
a2 = dir2[1] / dir2[0]; |
| 1851 |
b2 = v3[1] - a2 * v3[0]; |
| 1852 |
|
| 1853 |
p1[0] = (DotProduct(v1, dir2) - (a2 * dir2[0] + b2 * dir2[1])) / dir2[0]; |
| 1854 |
p1[1] = a2 * p1[0] + b2; |
| 1855 |
|
| 1856 |
p2[0] = (DotProduct(v2, dir2) - (a2 * dir2[0] + b2 * dir2[1])) / dir2[0]; |
| 1857 |
p2[1] = a2 * p2[0] + b2; |
| 1858 |
} |
| 1859 |
else |
| 1860 |
{ |
| 1861 |
|
| 1862 |
p1[0] = v3[0]; |
| 1863 |
p1[1] = v1[1]; |
| 1864 |
|
| 1865 |
p2[0] = v3[0]; |
| 1866 |
p2[1] = v2[1]; |
| 1867 |
} |
| 1868 |
|
| 1869 |
if (dir1[0]) |
| 1870 |
{ |
| 1871 |
|
| 1872 |
a1 = dir1[1] / dir1[0]; |
| 1873 |
b1 = v1[1] - a1 * v1[0]; |
| 1874 |
|
| 1875 |
p3[0] = (DotProduct(v3, dir1) - (a1 * dir1[0] + b1 * dir1[1])) / dir1[0]; |
| 1876 |
p3[1] = a1 * p3[0] + b1; |
| 1877 |
|
| 1878 |
p4[0] = (DotProduct(v4, dir1) - (a1 * dir1[0] + b1 * dir1[1])) / dir1[0]; |
| 1879 |
p4[1] = a1 * p4[0] + b1; |
| 1880 |
} |
| 1881 |
else |
| 1882 |
{ |
| 1883 |
|
| 1884 |
p3[0] = v1[0]; |
| 1885 |
p3[1] = v3[1]; |
| 1886 |
|
| 1887 |
p4[0] = v1[0]; |
| 1888 |
p4[1] = v4[1]; |
| 1889 |
} |
| 1890 |
|
| 1891 |
p1[2] = 0; |
| 1892 |
p2[2] = 0; |
| 1893 |
p3[2] = 0; |
| 1894 |
p4[2] = 0; |
| 1895 |
|
| 1896 |
p1[2] = (plane2->dist - DotProduct(plane2->normal, p1)) / plane2->normal[2]; |
| 1897 |
p2[2] = (plane2->dist - DotProduct(plane2->normal, p2)) / plane2->normal[2]; |
| 1898 |
p3[2] = (plane1->dist - DotProduct(plane1->normal, p3)) / plane1->normal[2]; |
| 1899 |
p4[2] = (plane1->dist - DotProduct(plane1->normal, p4)) / plane1->normal[2]; |
| 1900 |
|
| 1901 |
founddist = qfalse; |
| 1902 |
|
| 1903 |
if (VectorBetweenVectors(p1, v3, v4)) |
| 1904 |
{ |
| 1905 |
dist = VectorDistance(v1, p1); |
| 1906 |
if (dist > bestdist - 0.5 && dist < bestdist + 0.5) |
| 1907 |
{ |
| 1908 |
dist1 = VectorDistance(beststart1, v1); |
| 1909 |
dist2 = VectorDistance(beststart2, v1); |
| 1910 |
if (dist1 > dist2) |
| 1911 |
{ |
| 1912 |
if (dist1 > VectorDistance(beststart1, beststart2)) VectorCopy(v1, beststart2); |
| 1913 |
} |
| 1914 |
else |
| 1915 |
{ |
| 1916 |
if (dist2 > VectorDistance(beststart1, beststart2)) VectorCopy(v1, beststart1); |
| 1917 |
} |
| 1918 |
dist1 = VectorDistance(bestend1, p1); |
| 1919 |
dist2 = VectorDistance(bestend2, p1); |
| 1920 |
if (dist1 > dist2) |
| 1921 |
{ |
| 1922 |
if (dist1 > VectorDistance(bestend1, bestend2)) VectorCopy(p1, bestend2); |
| 1923 |
} |
| 1924 |
else |
| 1925 |
{ |
| 1926 |
if (dist2 > VectorDistance(bestend1, bestend2)) VectorCopy(p1, bestend1); |
| 1927 |
} |
| 1928 |
} |
| 1929 |
else if (dist < bestdist) |
| 1930 |
{ |
| 1931 |
bestdist = dist; |
| 1932 |
VectorCopy(v1, beststart1); |
| 1933 |
VectorCopy(v1, beststart2); |
| 1934 |
VectorCopy(p1, bestend1); |
| 1935 |
VectorCopy(p1, bestend2); |
| 1936 |
} |
| 1937 |
founddist = qtrue; |
| 1938 |
} |
| 1939 |
if (VectorBetweenVectors(p2, v3, v4)) |
| 1940 |
{ |
| 1941 |
dist = VectorDistance(v2, p2); |
| 1942 |
if (dist > bestdist - 0.5 && dist < bestdist + 0.5) |
| 1943 |
{ |
| 1944 |
dist1 = VectorDistance(beststart1, v2); |
| 1945 |
dist2 = VectorDistance(beststart2, v2); |
| 1946 |
if (dist1 > dist2) |
| 1947 |
{ |
| 1948 |
if (dist1 > VectorDistance(beststart1, beststart2)) VectorCopy(v2, beststart2); |
| 1949 |
} |
| 1950 |
else |
| 1951 |
{ |
| 1952 |
if (dist2 > VectorDistance(beststart1, beststart2)) VectorCopy(v2, beststart1); |
| 1953 |
} |
| 1954 |
dist1 = VectorDistance(bestend1, p2); |
| 1955 |
dist2 = VectorDistance(bestend2, p2); |
| 1956 |
if (dist1 > dist2) |
| 1957 |
{ |
| 1958 |
if (dist1 > VectorDistance(bestend1, bestend2)) VectorCopy(p2, bestend2); |
| 1959 |
} |
| 1960 |
else |
| 1961 |
{ |
| 1962 |
if (dist2 > VectorDistance(bestend1, bestend2)) VectorCopy(p2, bestend1); |
| 1963 |
} |
| 1964 |
} |
| 1965 |
else if (dist < bestdist) |
| 1966 |
{ |
| 1967 |
bestdist = dist; |
| 1968 |
VectorCopy(v2, beststart1); |
| 1969 |
VectorCopy(v2, beststart2); |
| 1970 |
VectorCopy(p2, bestend1); |
| 1971 |
VectorCopy(p2, bestend2); |
| 1972 |
} |
| 1973 |
founddist = qtrue; |
| 1974 |
} |
| 1975 |
if (VectorBetweenVectors(p3, v1, v2)) |
| 1976 |
{ |
| 1977 |
dist = VectorDistance(v3, p3); |
| 1978 |
if (dist > bestdist - 0.5 && dist < bestdist + 0.5) |
| 1979 |
{ |
| 1980 |
dist1 = VectorDistance(beststart1, p3); |
| 1981 |
dist2 = VectorDistance(beststart2, p3); |
| 1982 |
if (dist1 > dist2) |
| 1983 |
{ |
| 1984 |
if (dist1 > VectorDistance(beststart1, beststart2)) VectorCopy(p3, beststart2); |
| 1985 |
} |
| 1986 |
else |
| 1987 |
{ |
| 1988 |
if (dist2 > VectorDistance(beststart1, beststart2)) VectorCopy(p3, beststart1); |
| 1989 |
} |
| 1990 |
dist1 = VectorDistance(bestend1, v3); |
| 1991 |
dist2 = VectorDistance(bestend2, v3); |
| 1992 |
if (dist1 > dist2) |
| 1993 |
{ |
| 1994 |
if (dist1 > VectorDistance(bestend1, bestend2)) VectorCopy(v3, bestend2); |
| 1995 |
} |
| 1996 |
else |
| 1997 |
{ |
| 1998 |
if (dist2 > VectorDistance(bestend1, bestend2)) VectorCopy(v3, bestend1); |
| 1999 |
} |
| 2000 |
} |
| 2001 |
else if (dist < bestdist) |
| 2002 |
{ |
| 2003 |
bestdist = dist; |
| 2004 |
VectorCopy(p3, beststart1); |
| 2005 |
VectorCopy(p3, beststart2); |
| 2006 |
VectorCopy(v3, bestend1); |
| 2007 |
VectorCopy(v3, bestend2); |
| 2008 |
} |
| 2009 |
founddist = qtrue; |
| 2010 |
} |
| 2011 |
if (VectorBetweenVectors(p4, v1, v2)) |
| 2012 |
{ |
| 2013 |
dist = VectorDistance(v4, p4); |
| 2014 |
if (dist > bestdist - 0.5 && dist < bestdist + 0.5) |
| 2015 |
{ |
| 2016 |
dist1 = VectorDistance(beststart1, p4); |
| 2017 |
dist2 = VectorDistance(beststart2, p4); |
| 2018 |
if (dist1 > dist2) |
| 2019 |
{ |
| 2020 |
if (dist1 > VectorDistance(beststart1, beststart2)) VectorCopy(p4, beststart2); |
| 2021 |
} |
| 2022 |
else |
| 2023 |
{ |
| 2024 |
if (dist2 > VectorDistance(beststart1, beststart2)) VectorCopy(p4, beststart1); |
| 2025 |
} |
| 2026 |
dist1 = VectorDistance(bestend1, v4); |
| 2027 |
dist2 = VectorDistance(bestend2, v4); |
| 2028 |
if (dist1 > dist2) |
| 2029 |
{ |
| 2030 |
if (dist1 > VectorDistance(bestend1, bestend2)) VectorCopy(v4, bestend2); |
| 2031 |
} |
| 2032 |
else |
| 2033 |
{ |
| 2034 |
if (dist2 > VectorDistance(bestend1, bestend2)) VectorCopy(v4, bestend1); |
| 2035 |
} |
| 2036 |
} |
| 2037 |
else if (dist < bestdist) |
| 2038 |
{ |
| 2039 |
bestdist = dist; |
| 2040 |
VectorCopy(p4, beststart1); |
| 2041 |
VectorCopy(p4, beststart2); |
| 2042 |
VectorCopy(v4, bestend1); |
| 2043 |
VectorCopy(v4, bestend2); |
| 2044 |
} |
| 2045 |
founddist = qtrue; |
| 2046 |
} |
| 2047 |
|
| 2048 |
|
| 2049 |
if (!founddist) |
| 2050 |
{ |
| 2051 |
dist = VectorDistance(v1, v3); |
| 2052 |
if (dist < bestdist) |
| 2053 |
{ |
| 2054 |
bestdist = dist; |
| 2055 |
VectorCopy(v1, beststart1); |
| 2056 |
VectorCopy(v1, beststart2); |
| 2057 |
VectorCopy(v3, bestend1); |
| 2058 |
VectorCopy(v3, bestend2); |
| 2059 |
} |
| 2060 |
dist = VectorDistance(v1, v4); |
| 2061 |
if (dist < bestdist) |
| 2062 |
{ |
| 2063 |
bestdist = dist; |
| 2064 |
VectorCopy(v1, beststart1); |
| 2065 |
VectorCopy(v1, beststart2); |
| 2066 |
VectorCopy(v4, bestend1); |
| 2067 |
VectorCopy(v4, bestend2); |
| 2068 |
} |
| 2069 |
dist = VectorDistance(v2, v3); |
| 2070 |
if (dist < bestdist) |
| 2071 |
{ |
| 2072 |
bestdist = dist; |
| 2073 |
VectorCopy(v2, beststart1); |
| 2074 |
VectorCopy(v2, beststart2); |
| 2075 |
VectorCopy(v3, bestend1); |
| 2076 |
VectorCopy(v3, bestend2); |
| 2077 |
} |
| 2078 |
dist = VectorDistance(v2, v4); |
| 2079 |
if (dist < bestdist) |
| 2080 |
{ |
| 2081 |
bestdist = dist; |
| 2082 |
VectorCopy(v2, beststart1); |
| 2083 |
VectorCopy(v2, beststart2); |
| 2084 |
VectorCopy(v4, bestend1); |
| 2085 |
VectorCopy(v4, bestend2); |
| 2086 |
} |
| 2087 |
} |
| 2088 |
return bestdist; |
| 2089 |
} |
| 2090 |
|
| 2091 |
|
| 2092 |
|
| 2093 |
|
| 2094 |
|
| 2095 |
|
| 2096 |
|
| 2097 |
|
| 2098 |
|
| 2099 |
|
| 2100 |
|
| 2101 |
|
| 2102 |
|
| 2103 |
|
| 2104 |
|
| 2105 |
int AAS_Reachability_Jump(int area1num, int area2num) |
| 2106 |
{ |
| 2107 |
int i, j, k, l, face1num, face2num, edge1num, edge2num, traveltype; |
| 2108 |
int stopevent, areas[10], numareas; |
| 2109 |
float phys_jumpvel, maxjumpdistance, maxjumpheight, height, bestdist, speed; |
| 2110 |
vec_t *v1, *v2, *v3, *v4; |
| 2111 |
vec3_t beststart = {0}, beststart2 = {0}, bestend = {0}, bestend2 = {0}; |
| 2112 |
vec3_t teststart, testend, dir, velocity, cmdmove, up = {0, 0, 1}, sidewards; |
| 2113 |
aas_area_t *area1, *area2; |
| 2114 |
aas_face_t *face1, *face2; |
| 2115 |
aas_edge_t *edge1, *edge2; |
| 2116 |
aas_plane_t *plane1, *plane2, *plane; |
| 2117 |
aas_trace_t trace; |
| 2118 |
aas_clientmove_t move; |
| 2119 |
aas_lreachability_t *lreach; |
| 2120 |
|
| 2121 |
if (!AAS_AreaGrounded(area1num) || !AAS_AreaGrounded(area2num)) return qfalse; |
| 2122 |
|
| 2123 |
if (AAS_AreaCrouch(area1num) || AAS_AreaCrouch(area2num)) return qfalse; |
| 2124 |
|
| 2125 |
area1 = &aasworld.areas[area1num]; |
| 2126 |
area2 = &aasworld.areas[area2num]; |
| 2127 |
|
| 2128 |
phys_jumpvel = aassettings.phys_jumpvel; |
| 2129 |
|
| 2130 |
maxjumpdistance = 2 * AAS_MaxJumpDistance(phys_jumpvel); |
| 2131 |
|
| 2132 |
maxjumpheight = AAS_MaxJumpHeight(phys_jumpvel); |
| 2133 |
|
| 2134 |
|
| 2135 |
for (i = 0; i < 2; i++) |
| 2136 |
{ |
| 2137 |
if (area1->mins[i] > area2->maxs[i] + maxjumpdistance) return qfalse; |
| 2138 |
if (area1->maxs[i] < area2->mins[i] - maxjumpdistance) return qfalse; |
| 2139 |
} |
| 2140 |
|
| 2141 |
if (area2->mins[2] > area1->maxs[2] + maxjumpheight) return qfalse; |
| 2142 |
|
| 2143 |
bestdist = 999999; |
| 2144 |
|
| 2145 |
for (i = 0; i < area1->numfaces; i++) |
| 2146 |
{ |
| 2147 |
face1num = aasworld.faceindex[area1->firstface + i]; |
| 2148 |
face1 = &aasworld.faces[abs(face1num)]; |
| 2149 |
|
| 2150 |
if (!(face1->faceflags & FACE_GROUND)) continue; |
| 2151 |
|
| 2152 |
for (j = 0; j < area2->numfaces; j++) |
| 2153 |
{ |
| 2154 |
face2num = aasworld.faceindex[area2->firstface + j]; |
| 2155 |
face2 = &aasworld.faces[abs(face2num)]; |
| 2156 |
|
| 2157 |
if (!(face2->faceflags & FACE_GROUND)) continue; |
| 2158 |
|
| 2159 |
for (k = 0; k < face1->numedges; k++) |
| 2160 |
{ |
| 2161 |
edge1num = abs(aasworld.edgeindex[face1->firstedge + k]); |
| 2162 |
edge1 = &aasworld.edges[edge1num]; |
| 2163 |
for (l = 0; l < face2->numedges; l++) |
| 2164 |
{ |
| 2165 |
edge2num = abs(aasworld.edgeindex[face2->firstedge + l]); |
| 2166 |
edge2 = &aasworld.edges[edge2num]; |
| 2167 |
|
| 2168 |
v1 = aasworld.vertexes[edge1->v[0]]; |
| 2169 |
v2 = aasworld.vertexes[edge1->v[1]]; |
| 2170 |
v3 = aasworld.vertexes[edge2->v[0]]; |
| 2171 |
v4 = aasworld.vertexes[edge2->v[1]]; |
| 2172 |
|
| 2173 |
plane1 = &aasworld.planes[face1->planenum]; |
| 2174 |
plane2 = &aasworld.planes[face2->planenum]; |
| 2175 |
|
| 2176 |
bestdist = AAS_ClosestEdgePoints(v1, v2, v3, v4, plane1, plane2, |
| 2177 |
beststart, bestend, |
| 2178 |
beststart2, bestend2, bestdist); |
| 2179 |
} |
| 2180 |
} |
| 2181 |
} |
| 2182 |
} |
| 2183 |
VectorMiddle(beststart, beststart2, beststart); |
| 2184 |
VectorMiddle(bestend, bestend2, bestend); |
| 2185 |
if (bestdist > 4 && bestdist < maxjumpdistance) |
| 2186 |
{ |
| 2187 |
|
| 2188 |
|
| 2189 |
if (bestdist <= 48 && fabs(beststart[2] - bestend[2]) < 8) |
| 2190 |
{ |
| 2191 |
speed = 400; |
| 2192 |
traveltype = TRAVEL_WALKOFFLEDGE; |
| 2193 |
} |
| 2194 |
else if (AAS_HorizontalVelocityForJump(0, beststart, bestend, &speed)) |
| 2195 |
{ |
| 2196 |
|
| 2197 |
speed *= 1.2f; |
| 2198 |
traveltype = TRAVEL_WALKOFFLEDGE; |
| 2199 |
} |
| 2200 |
else |
| 2201 |
{ |
| 2202 |
|
| 2203 |
|
| 2204 |
if (!AAS_HorizontalVelocityForJump(phys_jumpvel, beststart, bestend, &speed)) |
| 2205 |
return qfalse; |
| 2206 |
speed *= 1.05f; |
| 2207 |
traveltype = TRAVEL_JUMP; |
| 2208 |
|
| 2209 |
|
| 2210 |
VectorSubtract(bestend, beststart, dir); |
| 2211 |
dir[2] = 0; |
| 2212 |
if (VectorLength(dir) < 10) |
| 2213 |
return qfalse; |
| 2214 |
} |
| 2215 |
|
| 2216 |
VectorSubtract(bestend, beststart, dir); |
| 2217 |
VectorNormalize(dir); |
| 2218 |
VectorMA(beststart, 1, dir, teststart); |
| 2219 |
|
| 2220 |
VectorCopy(teststart, testend); |
| 2221 |
testend[2] -= 100; |
| 2222 |
trace = AAS_TraceClientBBox(teststart, testend, PRESENCE_NORMAL, -1); |
| 2223 |
|
| 2224 |
if (trace.startsolid) |
| 2225 |
return qfalse; |
| 2226 |
if (trace.fraction < 1) |
| 2227 |
{ |
| 2228 |
plane = &aasworld.planes[trace.planenum]; |
| 2229 |
|
| 2230 |
if (DotProduct(plane->normal, up) >= 0.7) |
| 2231 |
{ |
| 2232 |
|
| 2233 |
if (!(AAS_PointContents(trace.endpos) & (CONTENTS_LAVA|CONTENTS_SLIME))) |
| 2234 |
{ |
| 2235 |
if (teststart[2] - trace.endpos[2] <= aassettings.phys_maxbarrier) |
| 2236 |
return qfalse; |
| 2237 |
} |
| 2238 |
} |
| 2239 |
} |
| 2240 |
|
| 2241 |
VectorMA(bestend, -1, dir, teststart); |
| 2242 |
|
| 2243 |
VectorCopy(teststart, testend); |
| 2244 |
testend[2] -= 100; |
| 2245 |
trace = AAS_TraceClientBBox(teststart, testend, PRESENCE_NORMAL, -1); |
| 2246 |
|
| 2247 |
if (trace.startsolid) |
| 2248 |
return qfalse; |
| 2249 |
if (trace.fraction < 1) |
| 2250 |
{ |
| 2251 |
plane = &aasworld.planes[trace.planenum]; |
| 2252 |
|
| 2253 |
if (DotProduct(plane->normal, up) >= 0.7) |
| 2254 |
{ |
| 2255 |
|
| 2256 |
if (!(AAS_PointContents(trace.endpos) & (CONTENTS_LAVA|CONTENTS_SLIME))) |
| 2257 |
{ |
| 2258 |
if (teststart[2] - trace.endpos[2] <= aassettings.phys_maxbarrier) |
| 2259 |
return qfalse; |
| 2260 |
} |
| 2261 |
} |
| 2262 |
} |
| 2263 |
|
| 2264 |
|
| 2265 |
VectorClear(cmdmove); |
| 2266 |
if ((traveltype & TRAVELTYPE_MASK) == TRAVEL_JUMP) |
| 2267 |
cmdmove[2] = aassettings.phys_jumpvel; |
| 2268 |
else |
| 2269 |
cmdmove[2] = 0; |
| 2270 |
|
| 2271 |
VectorSubtract(bestend, beststart, dir); |
| 2272 |
dir[2] = 0; |
| 2273 |
VectorNormalize(dir); |
| 2274 |
CrossProduct(dir, up, sidewards); |
| 2275 |
|
| 2276 |
stopevent = SE_HITGROUND|SE_ENTERWATER|SE_ENTERSLIME|SE_ENTERLAVA|SE_HITGROUNDDAMAGE; |
| 2277 |
if (!AAS_AreaClusterPortal(area1num) && !AAS_AreaClusterPortal(area2num)) |
| 2278 |
stopevent |= SE_TOUCHCLUSTERPORTAL; |
| 2279 |
|
| 2280 |
for (i = 0; i < 3; i++) |
| 2281 |
{ |
| 2282 |
|
| 2283 |
if (i == 1) |
| 2284 |
VectorAdd(testend, sidewards, testend); |
| 2285 |
else if (i == 2) |
| 2286 |
VectorSubtract(bestend, sidewards, testend); |
| 2287 |
else |
| 2288 |
VectorCopy(bestend, testend); |
| 2289 |
VectorSubtract(testend, beststart, dir); |
| 2290 |
dir[2] = 0; |
| 2291 |
VectorNormalize(dir); |
| 2292 |
VectorScale(dir, speed, velocity); |
| 2293 |
|
| 2294 |
AAS_PredictClientMovement(&move, -1, beststart, PRESENCE_NORMAL, qtrue, |
| 2295 |
velocity, cmdmove, 3, 30, 0.1f, |
| 2296 |
stopevent, 0, qfalse); |
| 2297 |
|
| 2298 |
if (move.frames >= 30) |
| 2299 |
return qfalse; |
| 2300 |
|
| 2301 |
if (move.stopevent & (SE_ENTERSLIME|SE_ENTERLAVA)) |
| 2302 |
return qfalse; |
| 2303 |
|
| 2304 |
if (move.stopevent & SE_TOUCHCLUSTERPORTAL) |
| 2305 |
return qfalse; |
| 2306 |
|
| 2307 |
|
| 2308 |
VectorMA(move.endpos, -64, dir, teststart); |
| 2309 |
teststart[2] += 1; |
| 2310 |
numareas = AAS_TraceAreas(move.endpos, teststart, areas, NULL, ARRAY_LEN(areas)); |
| 2311 |
for (j = 0; j < numareas; j++) |
| 2312 |
{ |
| 2313 |
if (areas[j] == area2num) |
| 2314 |
break; |
| 2315 |
} |
| 2316 |
if (j < numareas) |
| 2317 |
break; |
| 2318 |
} |
| 2319 |
if (i >= 3) |
| 2320 |
return qfalse; |
| 2321 |
|
| 2322 |
#ifdef REACH_DEBUG |
| 2323 |
|
| 2324 |
Log_Write("jump reachability between %d and %d\r\n", area1num, area2num); |
| 2325 |
#endif |
| 2326 |
|
| 2327 |
lreach = AAS_AllocReachability(); |
| 2328 |
if (!lreach) return qfalse; |
| 2329 |
lreach->areanum = area2num; |
| 2330 |
lreach->facenum = 0; |
| 2331 |
lreach->edgenum = 0; |
| 2332 |
VectorCopy(beststart, lreach->start); |
| 2333 |
VectorCopy(bestend, lreach->end); |
| 2334 |
lreach->traveltype = traveltype; |
| 2335 |
|
| 2336 |
VectorSubtract(bestend, beststart, dir); |
| 2337 |
height = dir[2]; |
| 2338 |
dir[2] = 0; |
| 2339 |
if ((traveltype & TRAVELTYPE_MASK) == TRAVEL_WALKOFFLEDGE && height > VectorLength(dir)) |
| 2340 |
{ |
| 2341 |
lreach->traveltime = aassettings.rs_startwalkoffledge + height * 50 / aassettings.phys_gravity; |
| 2342 |
} |
| 2343 |
else |
| 2344 |
{ |
| 2345 |
lreach->traveltime = aassettings.rs_startjump + VectorDistance(bestend, beststart) * 240 / aassettings.phys_maxwalkvelocity; |
| 2346 |
} |
| 2347 |
|
| 2348 |
if (!AAS_AreaJumpPad(area2num)) |
| 2349 |
{ |
| 2350 |
if (AAS_FallDelta(beststart[2] - bestend[2]) > aassettings.phys_falldelta5) |
| 2351 |
{ |
| 2352 |
lreach->traveltime += aassettings.rs_falldamage5; |
| 2353 |
} |
| 2354 |
else if (AAS_FallDelta(beststart[2] - bestend[2]) > aassettings.phys_falldelta10) |
| 2355 |
{ |
| 2356 |
lreach->traveltime += aassettings.rs_falldamage10; |
| 2357 |
} |
| 2358 |
} |
| 2359 |
lreach->next = areareachability[area1num]; |
| 2360 |
areareachability[area1num] = lreach; |
| 2361 |
|
| 2362 |
if ((traveltype & TRAVELTYPE_MASK) == TRAVEL_JUMP) |
| 2363 |
reach_jump++; |
| 2364 |
else |
| 2365 |
reach_walkoffledge++; |
| 2366 |
} |
| 2367 |
return qfalse; |
| 2368 |
} |
| 2369 |
|
| 2370 |
|
| 2371 |
|
| 2372 |
|
| 2373 |
|
| 2374 |
|
| 2375 |
|
| 2376 |
int AAS_Reachability_Ladder(int area1num, int area2num) |
| 2377 |
{ |
| 2378 |
int i, j, k, l, edge1num, edge2num, sharededgenum = 0, lowestedgenum = 0; |
| 2379 |
int face1num, face2num, ladderface1num = 0, ladderface2num = 0; |
| 2380 |
int ladderface1vertical, ladderface2vertical, firstv; |
| 2381 |
float face1area, face2area, bestface1area = -9999, bestface2area = -9999; |
| 2382 |
float phys_jumpvel, maxjumpheight; |
| 2383 |
vec3_t area1point, area2point, v1, v2, up = {0, 0, 1}; |
| 2384 |
vec3_t mid, lowestpoint = {0, 0}, start, end, sharededgevec, dir; |
| 2385 |
aas_area_t *area1, *area2; |
| 2386 |
aas_face_t *face1, *face2, *ladderface1 = NULL, *ladderface2 = NULL; |
| 2387 |
aas_plane_t *plane1, *plane2; |
| 2388 |
aas_edge_t *sharededge, *edge1; |
| 2389 |
aas_lreachability_t *lreach; |
| 2390 |
aas_trace_t trace; |
| 2391 |
|
| 2392 |
if (!AAS_AreaLadder(area1num) || !AAS_AreaLadder(area2num)) return qfalse; |
| 2393 |
|
| 2394 |
phys_jumpvel = aassettings.phys_jumpvel; |
| 2395 |
|
| 2396 |
maxjumpheight = AAS_MaxJumpHeight(phys_jumpvel); |
| 2397 |
|
| 2398 |
area1 = &aasworld.areas[area1num]; |
| 2399 |
area2 = &aasworld.areas[area2num]; |
| 2400 |
|
| 2401 |
for (i = 0; i < area1->numfaces; i++) |
| 2402 |
{ |
| 2403 |
face1num = aasworld.faceindex[area1->firstface + i]; |
| 2404 |
face1 = &aasworld.faces[abs(face1num)]; |
| 2405 |
|
| 2406 |
if (!(face1->faceflags & FACE_LADDER)) continue; |
| 2407 |
|
| 2408 |
for (j = 0; j < area2->numfaces; j++) |
| 2409 |
{ |
| 2410 |
face2num = aasworld.faceindex[area2->firstface + j]; |
| 2411 |
face2 = &aasworld.faces[abs(face2num)]; |
| 2412 |
|
| 2413 |
if (!(face2->faceflags & FACE_LADDER)) continue; |
| 2414 |
|
| 2415 |
for (k = 0; k < face1->numedges; k++) |
| 2416 |
{ |
| 2417 |
edge1num = aasworld.edgeindex[face1->firstedge + k]; |
| 2418 |
for (l = 0; l < face2->numedges; l++) |
| 2419 |
{ |
| 2420 |
edge2num = aasworld.edgeindex[face2->firstedge + l]; |
| 2421 |
if (abs(edge1num) == abs(edge2num)) |
| 2422 |
{ |
| 2423 |
|
| 2424 |
face1area = AAS_FaceArea(face1); |
| 2425 |
face2area = AAS_FaceArea(face2); |
| 2426 |
if (face1area > bestface1area && face2area > bestface2area) |
| 2427 |
{ |
| 2428 |
bestface1area = face1area; |
| 2429 |
bestface2area = face2area; |
| 2430 |
ladderface1 = face1; |
| 2431 |
ladderface2 = face2; |
| 2432 |
ladderface1num = face1num; |
| 2433 |
ladderface2num = face2num; |
| 2434 |
sharededgenum = edge1num; |
| 2435 |
} |
| 2436 |
break; |
| 2437 |
} |
| 2438 |
} |
| 2439 |
if (l != face2->numedges) break; |
| 2440 |
} |
| 2441 |
} |
| 2442 |
} |
| 2443 |
|
| 2444 |
if (ladderface1 && ladderface2) |
| 2445 |
{ |
| 2446 |
|
| 2447 |
sharededge = &aasworld.edges[abs(sharededgenum)]; |
| 2448 |
firstv = sharededgenum < 0; |
| 2449 |
|
| 2450 |
VectorCopy(aasworld.vertexes[sharededge->v[firstv]], v1); |
| 2451 |
VectorCopy(aasworld.vertexes[sharededge->v[!firstv]], v2); |
| 2452 |
VectorAdd(v1, v2, area1point); |
| 2453 |
VectorScale(area1point, 0.5, area1point); |
| 2454 |
VectorCopy(area1point, area2point); |
| 2455 |
|
| 2456 |
|
| 2457 |
plane1 = &aasworld.planes[ladderface1->planenum ^ (ladderface1num < 0)]; |
| 2458 |
plane2 = &aasworld.planes[ladderface2->planenum ^ (ladderface2num < 0)]; |
| 2459 |
|
| 2460 |
|
| 2461 |
VectorSubtract(v2, v1, sharededgevec); |
| 2462 |
CrossProduct(plane1->normal, sharededgevec, dir); |
| 2463 |
VectorNormalize(dir); |
| 2464 |
|
| 2465 |
VectorMA(area1point, -32, dir, area1point); |
| 2466 |
VectorMA(area2point, 32, dir, area2point); |
| 2467 |
|
| 2468 |
ladderface1vertical = fabsf(DotProduct(plane1->normal, up)) < 0.1; |
| 2469 |
ladderface2vertical = fabsf(DotProduct(plane2->normal, up)) < 0.1; |
| 2470 |
|
| 2471 |
if (!ladderface1vertical && !ladderface2vertical) return qfalse; |
| 2472 |
|
| 2473 |
if (ladderface1vertical && ladderface2vertical |
| 2474 |
|
| 2475 |
&& DotProduct(plane1->normal, plane2->normal) > 0.7 |
| 2476 |
|
| 2477 |
&& fabsf(DotProduct(sharededgevec, up)) < 0.7) |
| 2478 |
{ |
| 2479 |
|
| 2480 |
lreach = AAS_AllocReachability(); |
| 2481 |
if (!lreach) return qfalse; |
| 2482 |
lreach->areanum = area2num; |
| 2483 |
lreach->facenum = ladderface1num; |
| 2484 |
lreach->edgenum = abs(sharededgenum); |
| 2485 |
VectorCopy(area1point, lreach->start); |
| 2486 |
|
| 2487 |
VectorMA(area2point, -3, plane1->normal, lreach->end); |
| 2488 |
lreach->traveltype = TRAVEL_LADDER; |
| 2489 |
lreach->traveltime = 10; |
| 2490 |
lreach->next = areareachability[area1num]; |
| 2491 |
areareachability[area1num] = lreach; |
| 2492 |
|
| 2493 |
reach_ladder++; |
| 2494 |
|
| 2495 |
lreach = AAS_AllocReachability(); |
| 2496 |
if (!lreach) return qfalse; |
| 2497 |
lreach->areanum = area1num; |
| 2498 |
lreach->facenum = ladderface2num; |
| 2499 |
lreach->edgenum = abs(sharededgenum); |
| 2500 |
VectorCopy(area2point, lreach->start); |
| 2501 |
|
| 2502 |
VectorMA(area1point, -3, plane1->normal, lreach->end); |
| 2503 |
lreach->traveltype = TRAVEL_LADDER; |
| 2504 |
lreach->traveltime = 10; |
| 2505 |
lreach->next = areareachability[area2num]; |
| 2506 |
areareachability[area2num] = lreach; |
| 2507 |
|
| 2508 |
reach_ladder++; |
| 2509 |
|
| 2510 |
return qtrue; |
| 2511 |
} |
| 2512 |
|
| 2513 |
|
| 2514 |
|
| 2515 |
if (ladderface1vertical && (ladderface2->faceflags & FACE_GROUND)) |
| 2516 |
{ |
| 2517 |
|
| 2518 |
lreach = AAS_AllocReachability(); |
| 2519 |
if (!lreach) return qfalse; |
| 2520 |
lreach->areanum = area2num; |
| 2521 |
lreach->facenum = ladderface1num; |
| 2522 |
lreach->edgenum = abs(sharededgenum); |
| 2523 |
VectorCopy(area1point, lreach->start); |
| 2524 |
VectorCopy(area2point, lreach->end); |
| 2525 |
lreach->end[2] += 16; |
| 2526 |
VectorMA(lreach->end, -15, plane1->normal, lreach->end); |
| 2527 |
lreach->traveltype = TRAVEL_LADDER; |
| 2528 |
lreach->traveltime = 10; |
| 2529 |
lreach->next = areareachability[area1num]; |
| 2530 |
areareachability[area1num] = lreach; |
| 2531 |
|
| 2532 |
reach_ladder++; |
| 2533 |
|
| 2534 |
lreach = AAS_AllocReachability(); |
| 2535 |
if (!lreach) return qfalse; |
| 2536 |
lreach->areanum = area1num; |
| 2537 |
lreach->facenum = ladderface2num; |
| 2538 |
lreach->edgenum = abs(sharededgenum); |
| 2539 |
VectorCopy(area2point, lreach->start); |
| 2540 |
VectorCopy(area1point, lreach->end); |
| 2541 |
lreach->traveltype = TRAVEL_WALKOFFLEDGE; |
| 2542 |
lreach->traveltime = 10; |
| 2543 |
lreach->next = areareachability[area2num]; |
| 2544 |
areareachability[area2num] = lreach; |
| 2545 |
|
| 2546 |
reach_walkoffledge++; |
| 2547 |
|
| 2548 |
return qtrue; |
| 2549 |
} |
| 2550 |
|
| 2551 |
if (ladderface1vertical) |
| 2552 |
{ |
| 2553 |
|
| 2554 |
lowestpoint[2] = 99999; |
| 2555 |
for (i = 0; i < ladderface1->numedges; i++) |
| 2556 |
{ |
| 2557 |
edge1num = abs(aasworld.edgeindex[ladderface1->firstedge + i]); |
| 2558 |
edge1 = &aasworld.edges[edge1num]; |
| 2559 |
|
| 2560 |
VectorCopy(aasworld.vertexes[edge1->v[0]], v1); |
| 2561 |
VectorCopy(aasworld.vertexes[edge1->v[1]], v2); |
| 2562 |
|
| 2563 |
VectorAdd(v1, v2, mid); |
| 2564 |
VectorScale(mid, 0.5, mid); |
| 2565 |
|
| 2566 |
if (mid[2] < lowestpoint[2]) |
| 2567 |
{ |
| 2568 |
VectorCopy(mid, lowestpoint); |
| 2569 |
lowestedgenum = edge1num; |
| 2570 |
} |
| 2571 |
} |
| 2572 |
|
| 2573 |
plane1 = &aasworld.planes[ladderface1->planenum]; |
| 2574 |
|
| 2575 |
VectorMA(lowestpoint, 5, plane1->normal, start); |
| 2576 |
VectorCopy(start, end); |
| 2577 |
start[2] += 5; |
| 2578 |
end[2] -= 100; |
| 2579 |
|
| 2580 |
trace = AAS_TraceClientBBox(start, end, PRESENCE_NORMAL, -1); |
| 2581 |
|
| 2582 |
|
| 2583 |
#ifdef REACH_DEBUG |
| 2584 |
if (trace.startsolid) |
| 2585 |
{ |
| 2586 |
Log_Write("trace from area %d started in solid\r\n", area1num); |
| 2587 |
} |
| 2588 |
#endif |
| 2589 |
|
| 2590 |
trace.endpos[2] += 1; |
| 2591 |
area2num = AAS_PointAreaNum(trace.endpos); |
| 2592 |
|
| 2593 |
area2 = &aasworld.areas[area2num]; |
| 2594 |
for (i = 0; i < area2->numfaces; i++) |
| 2595 |
{ |
| 2596 |
face2num = aasworld.faceindex[area2->firstface + i]; |
| 2597 |
face2 = &aasworld.faces[abs(face2num)]; |
| 2598 |
|
| 2599 |
if (face2->faceflags & FACE_LADDER) |
| 2600 |
{ |
| 2601 |
plane2 = &aasworld.planes[face2->planenum]; |
| 2602 |
if (fabsf(DotProduct(plane2->normal, up)) < 0.1) break; |
| 2603 |
} |
| 2604 |
} |
| 2605 |
|
| 2606 |
if (i >= area2->numfaces && area2num != area1num && |
| 2607 |
|
| 2608 |
!AAS_ReachabilityExists(area1num, area2num) && |
| 2609 |
!AAS_ReachabilityExists(area2num, area1num)) |
| 2610 |
{ |
| 2611 |
|
| 2612 |
if (start[2] - trace.endpos[2] < maxjumpheight) |
| 2613 |
{ |
| 2614 |
|
| 2615 |
lreach = AAS_AllocReachability(); |
| 2616 |
if (!lreach) return qfalse; |
| 2617 |
lreach->areanum = area2num; |
| 2618 |
lreach->facenum = ladderface1num; |
| 2619 |
lreach->edgenum = lowestedgenum; |
| 2620 |
VectorCopy(lowestpoint, lreach->start); |
| 2621 |
VectorCopy(trace.endpos, lreach->end); |
| 2622 |
lreach->traveltype = TRAVEL_LADDER; |
| 2623 |
lreach->traveltime = 10; |
| 2624 |
lreach->next = areareachability[area1num]; |
| 2625 |
areareachability[area1num] = lreach; |
| 2626 |
|
| 2627 |
reach_ladder++; |
| 2628 |
|
| 2629 |
lreach = AAS_AllocReachability(); |
| 2630 |
if (!lreach) return qfalse; |
| 2631 |
lreach->areanum = area1num; |
| 2632 |
lreach->facenum = ladderface1num; |
| 2633 |
lreach->edgenum = lowestedgenum; |
| 2634 |
VectorCopy(trace.endpos, lreach->start); |
| 2635 |
|
| 2636 |
VectorMA(lowestpoint, -5, plane1->normal, lreach->end); |
| 2637 |
|
| 2638 |
lreach->end[2] += 10; |
| 2639 |
lreach->traveltype = TRAVEL_JUMP; |
| 2640 |
lreach->traveltime = 10; |
| 2641 |
lreach->next = areareachability[area2num]; |
| 2642 |
areareachability[area2num] = lreach; |
| 2643 |
|
| 2644 |
reach_jump++; |
| 2645 |
|
| 2646 |
return qtrue; |
| 2647 |
#ifdef REACH_DEBUG |
| 2648 |
Log_Write("jump up to ladder reach between %d and %d\r\n", area2num, area1num); |
| 2649 |
#endif |
| 2650 |
} |
| 2651 |
#ifdef REACH_DEBUG |
| 2652 |
else Log_Write("jump too high between area %d and %d\r\n", area2num, area1num); |
| 2653 |
#endif |
| 2654 |
} |
| 2655 |
|
| 2656 |
|
| 2657 |
|
| 2658 |
|
| 2659 |
|
| 2660 |
|
| 2661 |
|
| 2662 |
|
| 2663 |
|
| 2664 |
|
| 2665 |
|
| 2666 |
|
| 2667 |
|
| 2668 |
|
| 2669 |
|
| 2670 |
|
| 2671 |
|
| 2672 |
|
| 2673 |
|
| 2674 |
|
| 2675 |
|
| 2676 |
|
| 2677 |
|
| 2678 |
|
| 2679 |
|
| 2680 |
|
| 2681 |
|
| 2682 |
|
| 2683 |
|
| 2684 |
|
| 2685 |
|
| 2686 |
|
| 2687 |
|
| 2688 |
|
| 2689 |
|
| 2690 |
|
| 2691 |
|
| 2692 |
|
| 2693 |
|
| 2694 |
|
| 2695 |
|
| 2696 |
|
| 2697 |
|
| 2698 |
|
| 2699 |
|
| 2700 |
} |
| 2701 |
} |
| 2702 |
return qfalse; |
| 2703 |
} |
| 2704 |
|
| 2705 |
|
| 2706 |
|
| 2707 |
|
| 2708 |
|
| 2709 |
|
| 2710 |
int AAS_TravelFlagsForTeam(int ent) |
| 2711 |
{ |
| 2712 |
int notteam; |
| 2713 |
|
| 2714 |
if (!AAS_IntForBSPEpairKey(ent, "bot_notteam", ¬team)) |
| 2715 |
return 0; |
| 2716 |
if (notteam == 1) |
| 2717 |
return TRAVELFLAG_NOTTEAM1; |
| 2718 |
if (notteam == 2) |
| 2719 |
return TRAVELFLAG_NOTTEAM2; |
| 2720 |
return 0; |
| 2721 |
} |
| 2722 |
|
| 2723 |
|
| 2724 |
|
| 2725 |
|
| 2726 |
|
| 2727 |
|
| 2728 |
|
| 2729 |
|
| 2730 |
|
| 2731 |
|
| 2732 |
|
| 2733 |
|
| 2734 |
|
| 2735 |
|
| 2736 |
|
| 2737 |
|
| 2738 |
|
| 2739 |
|
| 2740 |
void AAS_Reachability_Teleport(void) |
| 2741 |
{ |
| 2742 |
int area1num, area2num; |
| 2743 |
char target[MAX_EPAIRKEY], targetname[MAX_EPAIRKEY]; |
| 2744 |
char classname[MAX_EPAIRKEY], model[MAX_EPAIRKEY]; |
| 2745 |
int ent, dest; |
| 2746 |
float angle; |
| 2747 |
vec3_t origin, destorigin, mins, maxs, end, angles; |
| 2748 |
vec3_t mid, velocity, cmdmove; |
| 2749 |
aas_lreachability_t *lreach; |
| 2750 |
aas_clientmove_t move; |
| 2751 |
aas_trace_t trace; |
| 2752 |
aas_link_t *areas, *link; |
| 2753 |
|
| 2754 |
for (ent = AAS_NextBSPEntity(0); ent; ent = AAS_NextBSPEntity(ent)) |
| 2755 |
{ |
| 2756 |
if (!AAS_ValueForBSPEpairKey(ent, "classname", classname, MAX_EPAIRKEY)) continue; |
| 2757 |
if (!strcmp(classname, "trigger_multiple")) |
| 2758 |
{ |
| 2759 |
AAS_ValueForBSPEpairKey(ent, "model", model, MAX_EPAIRKEY); |
| 2760 |
|
| 2761 |
botimport.Print(PRT_MESSAGE, "trigger_multiple model = \"%s\"\n", model); |
| 2762 |
|
| 2763 |
VectorClear(angles); |
| 2764 |
AAS_BSPModelMinsMaxsOrigin(atoi(model+1), angles, mins, maxs, origin); |
| 2765 |
|
| 2766 |
if (!AAS_ValueForBSPEpairKey(ent, "target", target, MAX_EPAIRKEY)) |
| 2767 |
{ |
| 2768 |
botimport.Print(PRT_ERROR, "trigger_multiple at %1.0f %1.0f %1.0f without target\n", |
| 2769 |
origin[0], origin[1], origin[2]); |
| 2770 |
continue; |
| 2771 |
} |
| 2772 |
for (dest = AAS_NextBSPEntity(0); dest; dest = AAS_NextBSPEntity(dest)) |
| 2773 |
{ |
| 2774 |
if (!AAS_ValueForBSPEpairKey(dest, "classname", classname, MAX_EPAIRKEY)) continue; |
| 2775 |
if (!strcmp(classname, "target_teleporter")) |
| 2776 |
{ |
| 2777 |
if (!AAS_ValueForBSPEpairKey(dest, "targetname", targetname, MAX_EPAIRKEY)) continue; |
| 2778 |
if (!strcmp(targetname, target)) |
| 2779 |
{ |
| 2780 |
break; |
| 2781 |
} |
| 2782 |
} |
| 2783 |
} |
| 2784 |
if (!dest) |
| 2785 |
{ |
| 2786 |
continue; |
| 2787 |
} |
| 2788 |
if (!AAS_ValueForBSPEpairKey(dest, "target", target, MAX_EPAIRKEY)) |
| 2789 |
{ |
| 2790 |
botimport.Print(PRT_ERROR, "target_teleporter without target\n"); |
| 2791 |
continue; |
| 2792 |
} |
| 2793 |
} |
| 2794 |
else if (!strcmp(classname, "trigger_teleport")) |
| 2795 |
{ |
| 2796 |
AAS_ValueForBSPEpairKey(ent, "model", model, MAX_EPAIRKEY); |
| 2797 |
|
| 2798 |
botimport.Print(PRT_MESSAGE, "trigger_teleport model = \"%s\"\n", model); |
| 2799 |
|
| 2800 |
VectorClear(angles); |
| 2801 |
AAS_BSPModelMinsMaxsOrigin(atoi(model+1), angles, mins, maxs, origin); |
| 2802 |
|
| 2803 |
if (!AAS_ValueForBSPEpairKey(ent, "target", target, MAX_EPAIRKEY)) |
| 2804 |
{ |
| 2805 |
botimport.Print(PRT_ERROR, "trigger_teleport at %1.0f %1.0f %1.0f without target\n", |
| 2806 |
origin[0], origin[1], origin[2]); |
| 2807 |
continue; |
| 2808 |
} |
| 2809 |
} |
| 2810 |
else |
| 2811 |
{ |
| 2812 |
continue; |
| 2813 |
} |
| 2814 |
|
| 2815 |
for (dest = AAS_NextBSPEntity(0); dest; dest = AAS_NextBSPEntity(dest)) |
| 2816 |
{ |
| 2817 |
|
| 2818 |
|
| 2819 |
|
| 2820 |
if (AAS_ValueForBSPEpairKey(dest, "targetname", targetname, MAX_EPAIRKEY)) |
| 2821 |
{ |
| 2822 |
if (!strcmp(targetname, target)) |
| 2823 |
{ |
| 2824 |
break; |
| 2825 |
} |
| 2826 |
} |
| 2827 |
} |
| 2828 |
if (!dest) |
| 2829 |
{ |
| 2830 |
botimport.Print(PRT_ERROR, "teleporter without misc_teleporter_dest (%s)\n", target); |
| 2831 |
continue; |
| 2832 |
} |
| 2833 |
if (!AAS_VectorForBSPEpairKey(dest, "origin", destorigin)) |
| 2834 |
{ |
| 2835 |
botimport.Print(PRT_ERROR, "teleporter destination (%s) without origin\n", target); |
| 2836 |
continue; |
| 2837 |
} |
| 2838 |
|
| 2839 |
area2num = AAS_PointAreaNum(destorigin); |
| 2840 |
|
| 2841 |
if (!AAS_AreaTeleporter(area2num) && !AAS_AreaJumpPad(area2num)) |
| 2842 |
{ |
| 2843 |
VectorCopy(destorigin, end); |
| 2844 |
end[2] -= 64; |
| 2845 |
trace = AAS_TraceClientBBox(destorigin, end, PRESENCE_CROUCH, -1); |
| 2846 |
if (trace.startsolid) |
| 2847 |
{ |
| 2848 |
botimport.Print(PRT_ERROR, "teleporter destination (%s) in solid\n", target); |
| 2849 |
continue; |
| 2850 |
} |
| 2851 |
|
| 2852 |
|
| 2853 |
|
| 2854 |
|
| 2855 |
|
| 2856 |
|
| 2857 |
|
| 2858 |
|
| 2859 |
|
| 2860 |
|
| 2861 |
{ |
| 2862 |
|
| 2863 |
AAS_FloatForBSPEpairKey(dest, "angle", &angle); |
| 2864 |
if (angle) |
| 2865 |
{ |
| 2866 |
VectorSet(angles, 0, angle, 0); |
| 2867 |
AngleVectors(angles, velocity, NULL, NULL); |
| 2868 |
VectorScale(velocity, 400, velocity); |
| 2869 |
} |
| 2870 |
else |
| 2871 |
{ |
| 2872 |
VectorClear(velocity); |
| 2873 |
} |
| 2874 |
VectorClear(cmdmove); |
| 2875 |
AAS_PredictClientMovement(&move, -1, destorigin, PRESENCE_NORMAL, qfalse, |
| 2876 |
velocity, cmdmove, 0, 30, 0.1f, |
| 2877 |
SE_HITGROUND|SE_ENTERWATER|SE_ENTERSLIME| |
| 2878 |
SE_ENTERLAVA|SE_HITGROUNDDAMAGE|SE_TOUCHJUMPPAD|SE_TOUCHTELEPORTER, 0, qfalse); |
| 2879 |
area2num = AAS_PointAreaNum(move.endpos); |
| 2880 |
if (move.stopevent & (SE_ENTERSLIME|SE_ENTERLAVA)) |
| 2881 |
{ |
| 2882 |
botimport.Print(PRT_WARNING, "teleported into slime or lava at dest %s\n", target); |
| 2883 |
} |
| 2884 |
VectorCopy(move.endpos, destorigin); |
| 2885 |
} |
| 2886 |
} |
| 2887 |
|
| 2888 |
|
| 2889 |
|
| 2890 |
|
| 2891 |
VectorAdd(origin, mins, mins); |
| 2892 |
VectorAdd(origin, maxs, maxs); |
| 2893 |
|
| 2894 |
VectorAdd(mins, maxs, mid); |
| 2895 |
VectorScale(mid, 0.5, mid); |
| 2896 |
|
| 2897 |
areas = AAS_LinkEntityClientBBox(mins, maxs, -1, PRESENCE_CROUCH); |
| 2898 |
if (!areas) botimport.Print(PRT_MESSAGE, "trigger_multiple not in any area\n"); |
| 2899 |
|
| 2900 |
for (link = areas; link; link = link->next_area) |
| 2901 |
{ |
| 2902 |
|
| 2903 |
if (!AAS_AreaTeleporter(link->areanum)) continue; |
| 2904 |
|
| 2905 |
area1num = link->areanum; |
| 2906 |
|
| 2907 |
lreach = AAS_AllocReachability(); |
| 2908 |
if (!lreach) break; |
| 2909 |
lreach->areanum = area2num; |
| 2910 |
lreach->facenum = 0; |
| 2911 |
lreach->edgenum = 0; |
| 2912 |
VectorCopy(mid, lreach->start); |
| 2913 |
VectorCopy(destorigin, lreach->end); |
| 2914 |
lreach->traveltype = TRAVEL_TELEPORT; |
| 2915 |
lreach->traveltype |= AAS_TravelFlagsForTeam(ent); |
| 2916 |
lreach->traveltime = aassettings.rs_teleport; |
| 2917 |
lreach->next = areareachability[area1num]; |
| 2918 |
areareachability[area1num] = lreach; |
| 2919 |
|
| 2920 |
reach_teleport++; |
| 2921 |
} |
| 2922 |
|
| 2923 |
AAS_UnlinkFromAreas(areas); |
| 2924 |
} |
| 2925 |
} |
| 2926 |
|
| 2927 |
|
| 2928 |
|
| 2929 |
|
| 2930 |
|
| 2931 |
|
| 2932 |
|
| 2933 |
|
| 2934 |
void AAS_Reachability_Elevator(void) |
| 2935 |
{ |
| 2936 |
int area1num, area2num, modelnum, i, j, k, l, n, p; |
| 2937 |
float lip, height, speed; |
| 2938 |
char model[MAX_EPAIRKEY], classname[MAX_EPAIRKEY]; |
| 2939 |
int ent; |
| 2940 |
vec3_t mins, maxs, origin, angles = {0, 0, 0}; |
| 2941 |
vec3_t pos1, pos2, mids, platbottom, plattop; |
| 2942 |
vec3_t bottomorg, toporg, start, end, dir; |
| 2943 |
vec_t xvals[8], yvals[8], xvals_top[8], yvals_top[8]; |
| 2944 |
aas_lreachability_t *lreach; |
| 2945 |
aas_trace_t trace; |
| 2946 |
|
| 2947 |
#ifdef REACH_DEBUG |
| 2948 |
Log_Write("AAS_Reachability_Elevator\r\n"); |
| 2949 |
#endif |
| 2950 |
for (ent = AAS_NextBSPEntity(0); ent; ent = AAS_NextBSPEntity(ent)) |
| 2951 |
{ |
| 2952 |
if (!AAS_ValueForBSPEpairKey(ent, "classname", classname, MAX_EPAIRKEY)) continue; |
| 2953 |
if (!strcmp(classname, "func_plat")) |
| 2954 |
{ |
| 2955 |
#ifdef REACH_DEBUG |
| 2956 |
Log_Write("found func plat\r\n"); |
| 2957 |
#endif |
| 2958 |
if (!AAS_ValueForBSPEpairKey(ent, "model", model, MAX_EPAIRKEY)) |
| 2959 |
{ |
| 2960 |
botimport.Print(PRT_ERROR, "func_plat without model\n"); |
| 2961 |
continue; |
| 2962 |
} |
| 2963 |
|
| 2964 |
modelnum = atoi(model+1); |
| 2965 |
if (modelnum <= 0) |
| 2966 |
{ |
| 2967 |
botimport.Print(PRT_ERROR, "func_plat with invalid model number\n"); |
| 2968 |
continue; |
| 2969 |
} |
| 2970 |
|
| 2971 |
|
| 2972 |
|
| 2973 |
AAS_BSPModelMinsMaxsOrigin(modelnum, angles, mins, maxs, origin); |
| 2974 |
|
| 2975 |
AAS_VectorForBSPEpairKey(ent, "origin", origin); |
| 2976 |
|
| 2977 |
VectorCopy(origin, pos1); |
| 2978 |
VectorCopy(origin, pos2); |
| 2979 |
|
| 2980 |
AAS_FloatForBSPEpairKey(ent, "lip", &lip); |
| 2981 |
if (!lip) lip = 8; |
| 2982 |
|
| 2983 |
AAS_FloatForBSPEpairKey(ent, "height", &height); |
| 2984 |
if (!height) height = (maxs[2] - mins[2]) - lip; |
| 2985 |
|
| 2986 |
AAS_FloatForBSPEpairKey(ent, "speed", &speed); |
| 2987 |
if (!speed) speed = 200; |
| 2988 |
|
| 2989 |
pos2[2] -= height; |
| 2990 |
|
| 2991 |
|
| 2992 |
VectorAdd(mins, maxs, mids); |
| 2993 |
VectorMA(pos2, 0.5, mids, platbottom); |
| 2994 |
platbottom[2] = maxs[2] - (pos1[2] - pos2[2]) + 2; |
| 2995 |
|
| 2996 |
VectorAdd(mins, maxs, mids); |
| 2997 |
VectorMA(pos2, 0.5, mids, plattop); |
| 2998 |
plattop[2] = maxs[2] + 2; |
| 2999 |
|
| 3000 |
|
| 3001 |
|
| 3002 |
|
| 3003 |
|
| 3004 |
|
| 3005 |
|
| 3006 |
for (i = 0; i < 3; i++) |
| 3007 |
{ |
| 3008 |
mins[i] -= 1; |
| 3009 |
maxs[i] += 1; |
| 3010 |
} |
| 3011 |
|
| 3012 |
|
| 3013 |
|
| 3014 |
VectorAdd(mins, maxs, mids); |
| 3015 |
VectorScale(mids, 0.5, mids); |
| 3016 |
|
| 3017 |
xvals[0] = mins[0]; xvals[1] = mids[0]; xvals[2] = maxs[0]; xvals[3] = mids[0]; |
| 3018 |
yvals[0] = mids[1]; yvals[1] = maxs[1]; yvals[2] = mids[1]; yvals[3] = mins[1]; |
| 3019 |
|
| 3020 |
xvals[4] = mins[0]; xvals[5] = maxs[0]; xvals[6] = maxs[0]; xvals[7] = mins[0]; |
| 3021 |
yvals[4] = maxs[1]; yvals[5] = maxs[1]; yvals[6] = mins[1]; yvals[7] = mins[1]; |
| 3022 |
|
| 3023 |
for (i = 0; i < 9; i++) |
| 3024 |
{ |
| 3025 |
if (i < 8) |
| 3026 |
{ |
| 3027 |
bottomorg[0] = origin[0] + xvals[i]; |
| 3028 |
bottomorg[1] = origin[1] + yvals[i]; |
| 3029 |
bottomorg[2] = platbottom[2] + 16; |
| 3030 |
|
| 3031 |
area1num = AAS_PointAreaNum(bottomorg); |
| 3032 |
for (k = 0; k < 16; k++) |
| 3033 |
{ |
| 3034 |
if (area1num) |
| 3035 |
{ |
| 3036 |
if (AAS_AreaGrounded(area1num) || AAS_AreaSwim(area1num)) break; |
| 3037 |
} |
| 3038 |
bottomorg[2] += 4; |
| 3039 |
area1num = AAS_PointAreaNum(bottomorg); |
| 3040 |
} |
| 3041 |
|
| 3042 |
if (k >= 16) |
| 3043 |
{ |
| 3044 |
continue; |
| 3045 |
} |
| 3046 |
} |
| 3047 |
else |
| 3048 |
{ |
| 3049 |
VectorCopy(plattop, bottomorg); |
| 3050 |
bottomorg[2] += 24; |
| 3051 |
area1num = AAS_PointAreaNum(bottomorg); |
| 3052 |
if (!area1num) continue; |
| 3053 |
VectorCopy(platbottom, bottomorg); |
| 3054 |
bottomorg[2] += 24; |
| 3055 |
} |
| 3056 |
|
| 3057 |
|
| 3058 |
for (n = 0; n < 3; n++) |
| 3059 |
{ |
| 3060 |
for (k = 0; k < 3; k++) |
| 3061 |
{ |
| 3062 |
mins[k] -= 4; |
| 3063 |
maxs[k] += 4; |
| 3064 |
} |
| 3065 |
xvals_top[0] = mins[0]; xvals_top[1] = mids[0]; xvals_top[2] = maxs[0]; xvals_top[3] = mids[0]; |
| 3066 |
yvals_top[0] = mids[1]; yvals_top[1] = maxs[1]; yvals_top[2] = mids[1]; yvals_top[3] = mins[1]; |
| 3067 |
|
| 3068 |
xvals_top[4] = mins[0]; xvals_top[5] = maxs[0]; xvals_top[6] = maxs[0]; xvals_top[7] = mins[0]; |
| 3069 |
yvals_top[4] = maxs[1]; yvals_top[5] = maxs[1]; yvals_top[6] = mins[1]; yvals_top[7] = mins[1]; |
| 3070 |
|
| 3071 |
for (j = 0; j < 8; j++) |
| 3072 |
{ |
| 3073 |
toporg[0] = origin[0] + xvals_top[j]; |
| 3074 |
toporg[1] = origin[1] + yvals_top[j]; |
| 3075 |
toporg[2] = plattop[2] + 16; |
| 3076 |
|
| 3077 |
area2num = AAS_PointAreaNum(toporg); |
| 3078 |
for (l = 0; l < 16; l++) |
| 3079 |
{ |
| 3080 |
if (area2num) |
| 3081 |
{ |
| 3082 |
if (AAS_AreaGrounded(area2num) || AAS_AreaSwim(area2num)) |
| 3083 |
{ |
| 3084 |
VectorCopy(plattop, start); |
| 3085 |
start[2] += 32; |
| 3086 |
VectorCopy(toporg, end); |
| 3087 |
end[2] += 1; |
| 3088 |
trace = AAS_TraceClientBBox(start, end, PRESENCE_CROUCH, -1); |
| 3089 |
if (trace.fraction >= 1) break; |
| 3090 |
} |
| 3091 |
} |
| 3092 |
toporg[2] += 4; |
| 3093 |
area2num = AAS_PointAreaNum(toporg); |
| 3094 |
} |
| 3095 |
|
| 3096 |
if (l >= 16) continue; |
| 3097 |
|
| 3098 |
if (area2num == area1num) continue; |
| 3099 |
|
| 3100 |
if (!AAS_AreaGrounded(area2num)) continue; |
| 3101 |
|
| 3102 |
if (AAS_ReachabilityExists(area1num, area2num)) continue; |
| 3103 |
|
| 3104 |
VectorSubtract(bottomorg, platbottom, dir); |
| 3105 |
VectorNormalize(dir); |
| 3106 |
dir[0] = bottomorg[0] + 24 * dir[0]; |
| 3107 |
dir[1] = bottomorg[1] + 24 * dir[1]; |
| 3108 |
dir[2] = bottomorg[2]; |
| 3109 |
|
| 3110 |
for (p = 0; p < 3; p++) |
| 3111 |
if (dir[p] < origin[p] + mins[p] || dir[p] > origin[p] + maxs[p]) break; |
| 3112 |
if (p >= 3) continue; |
| 3113 |
|
| 3114 |
lreach = AAS_AllocReachability(); |
| 3115 |
if (!lreach) continue; |
| 3116 |
lreach->areanum = area2num; |
| 3117 |
|
| 3118 |
lreach->facenum = modelnum; |
| 3119 |
|
| 3120 |
lreach->edgenum = (int) height; |
| 3121 |
|
| 3122 |
VectorCopy(dir, lreach->start); |
| 3123 |
VectorCopy(toporg, lreach->end); |
| 3124 |
lreach->traveltype = TRAVEL_ELEVATOR; |
| 3125 |
lreach->traveltype |= AAS_TravelFlagsForTeam(ent); |
| 3126 |
lreach->traveltime = aassettings.rs_startelevator + height * 100 / speed; |
| 3127 |
lreach->next = areareachability[area1num]; |
| 3128 |
areareachability[area1num] = lreach; |
| 3129 |
|
| 3130 |
n = 9999; |
| 3131 |
|
| 3132 |
#ifdef REACH_DEBUG |
| 3133 |
Log_Write("elevator reach from %d to %d\r\n", area1num, area2num); |
| 3134 |
#endif |
| 3135 |
|
| 3136 |
reach_elevator++; |
| 3137 |
} |
| 3138 |
} |
| 3139 |
} |
| 3140 |
} |
| 3141 |
} |
| 3142 |
} |
| 3143 |
|
| 3144 |
|
| 3145 |
|
| 3146 |
|
| 3147 |
|
| 3148 |
|
| 3149 |
aas_lreachability_t *AAS_FindFaceReachabilities(vec3_t *facepoints, int numpoints, aas_plane_t *plane, int towardsface) |
| 3150 |
{ |
| 3151 |
int i, j, k, l; |
| 3152 |
int facenum, edgenum, bestfacenum; |
| 3153 |
float *v1, *v2, *v3, *v4; |
| 3154 |
float bestdist, speed, hordist, dist; |
| 3155 |
vec3_t beststart = {0}, beststart2 = {0}, bestend = {0}, bestend2 = {0}, tmp, hordir, testpoint; |
| 3156 |
aas_lreachability_t *lreach, *lreachabilities; |
| 3157 |
aas_area_t *area; |
| 3158 |
aas_face_t *face; |
| 3159 |
aas_edge_t *edge; |
| 3160 |
aas_plane_t *faceplane, *bestfaceplane; |
| 3161 |
|
| 3162 |
|
| 3163 |
lreachabilities = NULL; |
| 3164 |
bestfacenum = 0; |
| 3165 |
bestfaceplane = NULL; |
| 3166 |
|
| 3167 |
for (i = 1; i < aasworld.numareas; i++) |
| 3168 |
{ |
| 3169 |
area = &aasworld.areas[i]; |
| 3170 |
|
| 3171 |
|
| 3172 |
bestdist = 999999; |
| 3173 |
for (j = 0; j < area->numfaces; j++) |
| 3174 |
{ |
| 3175 |
facenum = aasworld.faceindex[area->firstface + j]; |
| 3176 |
face = &aasworld.faces[abs(facenum)]; |
| 3177 |
|
| 3178 |
if (!(face->faceflags & FACE_GROUND)) continue; |
| 3179 |
|
| 3180 |
faceplane = &aasworld.planes[face->planenum]; |
| 3181 |
|
| 3182 |
for (k = 0; k < face->numedges; k++) |
| 3183 |
{ |
| 3184 |
edgenum = abs(aasworld.edgeindex[face->firstedge + k]); |
| 3185 |
edge = &aasworld.edges[edgenum]; |
| 3186 |
|
| 3187 |
v1 = aasworld.vertexes[edge->v[0]]; |
| 3188 |
v2 = aasworld.vertexes[edge->v[1]]; |
| 3189 |
|
| 3190 |
for (l = 0; l < numpoints; l++) |
| 3191 |
{ |
| 3192 |
v3 = facepoints[l]; |
| 3193 |
v4 = facepoints[(l+1) % numpoints]; |
| 3194 |
dist = AAS_ClosestEdgePoints(v1, v2, v3, v4, faceplane, plane, |
| 3195 |
beststart, bestend, |
| 3196 |
beststart2, bestend2, bestdist); |
| 3197 |
if (dist < bestdist) |
| 3198 |
{ |
| 3199 |
bestfacenum = facenum; |
| 3200 |
bestfaceplane = faceplane; |
| 3201 |
bestdist = dist; |
| 3202 |
} |
| 3203 |
} |
| 3204 |
} |
| 3205 |
} |
| 3206 |
|
| 3207 |
if (bestdist > 192) continue; |
| 3208 |
|
| 3209 |
VectorMiddle(beststart, beststart2, beststart); |
| 3210 |
VectorMiddle(bestend, bestend2, bestend); |
| 3211 |
|
| 3212 |
if (!towardsface) |
| 3213 |
{ |
| 3214 |
VectorCopy(beststart, tmp); |
| 3215 |
VectorCopy(bestend, beststart); |
| 3216 |
VectorCopy(tmp, bestend); |
| 3217 |
} |
| 3218 |
|
| 3219 |
VectorSubtract(bestend, beststart, hordir); |
| 3220 |
hordir[2] = 0; |
| 3221 |
hordist = VectorLength(hordir); |
| 3222 |
|
| 3223 |
if (hordist > 2 * AAS_MaxJumpDistance(aassettings.phys_jumpvel)) continue; |
| 3224 |
|
| 3225 |
if (bestend[2] - 32 > beststart[2]) continue; |
| 3226 |
|
| 3227 |
if (bestend[2] < beststart[2] - 128) continue; |
| 3228 |
|
| 3229 |
if (hordist > 32) |
| 3230 |
{ |
| 3231 |
|
| 3232 |
if (!AAS_HorizontalVelocityForJump(0, beststart, bestend, &speed)) continue; |
| 3233 |
} |
| 3234 |
|
| 3235 |
beststart[2] += 1; |
| 3236 |
bestend[2] += 1; |
| 3237 |
|
| 3238 |
if (towardsface) VectorCopy(bestend, testpoint); |
| 3239 |
else VectorCopy(beststart, testpoint); |
| 3240 |
if (bestfaceplane != NULL) |
| 3241 |
testpoint[2] = (bestfaceplane->dist - DotProduct(bestfaceplane->normal, testpoint)) / bestfaceplane->normal[2]; |
| 3242 |
else |
| 3243 |
testpoint[2] = 0; |
| 3244 |
|
| 3245 |
if (!AAS_PointInsideFace(bestfacenum, testpoint, 0.1f)) |
| 3246 |
{ |
| 3247 |
|
| 3248 |
if (bestend[2] - 16 > beststart[2]) continue; |
| 3249 |
} |
| 3250 |
lreach = AAS_AllocReachability(); |
| 3251 |
if (!lreach) return lreachabilities; |
| 3252 |
lreach->areanum = i; |
| 3253 |
lreach->facenum = 0; |
| 3254 |
lreach->edgenum = 0; |
| 3255 |
VectorCopy(beststart, lreach->start); |
| 3256 |
VectorCopy(bestend, lreach->end); |
| 3257 |
lreach->traveltype = 0; |
| 3258 |
lreach->traveltime = 0; |
| 3259 |
lreach->next = lreachabilities; |
| 3260 |
lreachabilities = lreach; |
| 3261 |
#ifndef BSPC |
| 3262 |
if (towardsface) AAS_PermanentLine(lreach->start, lreach->end, 1); |
| 3263 |
else AAS_PermanentLine(lreach->start, lreach->end, 2); |
| 3264 |
#endif |
| 3265 |
} |
| 3266 |
return lreachabilities; |
| 3267 |
} |
| 3268 |
|
| 3269 |
|
| 3270 |
|
| 3271 |
|
| 3272 |
|
| 3273 |
|
| 3274 |
void AAS_Reachability_FuncBobbing(void) |
| 3275 |
{ |
| 3276 |
int ent, spawnflags, modelnum, axis; |
| 3277 |
int i, numareas, areas[10]; |
| 3278 |
char classname[MAX_EPAIRKEY], model[MAX_EPAIRKEY]; |
| 3279 |
vec3_t origin, move_end, move_start, move_start_top, move_end_top; |
| 3280 |
vec3_t mins, maxs, angles = {0, 0, 0}; |
| 3281 |
vec3_t start_edgeverts[4], end_edgeverts[4], mid; |
| 3282 |
vec3_t org, start, end, dir, points[10]; |
| 3283 |
float height; |
| 3284 |
aas_plane_t start_plane, end_plane; |
| 3285 |
aas_lreachability_t *startreach, *endreach, *nextstartreach, *nextendreach, *lreach; |
| 3286 |
aas_lreachability_t *firststartreach, *firstendreach; |
| 3287 |
|
| 3288 |
for (ent = AAS_NextBSPEntity(0); ent; ent = AAS_NextBSPEntity(ent)) |
| 3289 |
{ |
| 3290 |
if (!AAS_ValueForBSPEpairKey(ent, "classname", classname, MAX_EPAIRKEY)) continue; |
| 3291 |
if (strcmp(classname, "func_bobbing")) continue; |
| 3292 |
AAS_FloatForBSPEpairKey(ent, "height", &height); |
| 3293 |
if (!height) height = 32; |
| 3294 |
|
| 3295 |
if (!AAS_ValueForBSPEpairKey(ent, "model", model, MAX_EPAIRKEY)) |
| 3296 |
{ |
| 3297 |
botimport.Print(PRT_ERROR, "func_bobbing without model\n"); |
| 3298 |
continue; |
| 3299 |
} |
| 3300 |
|
| 3301 |
modelnum = atoi(model+1); |
| 3302 |
if (modelnum <= 0) |
| 3303 |
{ |
| 3304 |
botimport.Print(PRT_ERROR, "func_bobbing with invalid model number\n"); |
| 3305 |
continue; |
| 3306 |
} |
| 3307 |
|
| 3308 |
if (!AAS_VectorForBSPEpairKey(ent, "origin", origin)) |
| 3309 |
VectorSet(origin, 0, 0, 0); |
| 3310 |
|
| 3311 |
AAS_BSPModelMinsMaxsOrigin(modelnum, angles, mins, maxs, NULL); |
| 3312 |
|
| 3313 |
VectorAdd(mins, origin, mins); |
| 3314 |
VectorAdd(maxs, origin, maxs); |
| 3315 |
|
| 3316 |
VectorAdd(mins, maxs, mid); |
| 3317 |
VectorScale(mid, 0.5, mid); |
| 3318 |
VectorCopy(mid, origin); |
| 3319 |
|
| 3320 |
VectorCopy(origin, move_end); |
| 3321 |
VectorCopy(origin, move_start); |
| 3322 |
|
| 3323 |
AAS_IntForBSPEpairKey(ent, "spawnflags", &spawnflags); |
| 3324 |
|
| 3325 |
if (spawnflags & 1) axis = 0; |
| 3326 |
else if (spawnflags & 2) axis = 1; |
| 3327 |
else axis = 2; |
| 3328 |
|
| 3329 |
move_start[axis] -= height; |
| 3330 |
move_end[axis] += height; |
| 3331 |
|
| 3332 |
Log_Write("funcbob model %d, start = {%1.1f, %1.1f, %1.1f} end = {%1.1f, %1.1f, %1.1f}\n", |
| 3333 |
modelnum, move_start[0], move_start[1], move_start[2], move_end[0], move_end[1], move_end[2]); |
| 3334 |
|
| 3335 |
#ifndef BSPC |
| 3336 |
|
| 3337 |
|
| 3338 |
|
| 3339 |
|
| 3340 |
#endif |
| 3341 |
|
| 3342 |
for (i = 0; i < 4; i++) |
| 3343 |
{ |
| 3344 |
VectorCopy(move_start, start_edgeverts[i]); |
| 3345 |
start_edgeverts[i][2] += maxs[2] - mid[2]; |
| 3346 |
start_edgeverts[i][2] += 24; |
| 3347 |
} |
| 3348 |
start_edgeverts[0][0] += maxs[0] - mid[0]; |
| 3349 |
start_edgeverts[0][1] += maxs[1] - mid[1]; |
| 3350 |
start_edgeverts[1][0] += maxs[0] - mid[0]; |
| 3351 |
start_edgeverts[1][1] += mins[1] - mid[1]; |
| 3352 |
start_edgeverts[2][0] += mins[0] - mid[0]; |
| 3353 |
start_edgeverts[2][1] += mins[1] - mid[1]; |
| 3354 |
start_edgeverts[3][0] += mins[0] - mid[0]; |
| 3355 |
start_edgeverts[3][1] += maxs[1] - mid[1]; |
| 3356 |
|
| 3357 |
start_plane.dist = start_edgeverts[0][2]; |
| 3358 |
VectorSet(start_plane.normal, 0, 0, 1); |
| 3359 |
|
| 3360 |
for (i = 0; i < 4; i++) |
| 3361 |
{ |
| 3362 |
VectorCopy(move_end, end_edgeverts[i]); |
| 3363 |
end_edgeverts[i][2] += maxs[2] - mid[2]; |
| 3364 |
end_edgeverts[i][2] += 24; |
| 3365 |
} |
| 3366 |
end_edgeverts[0][0] += maxs[0] - mid[0]; |
| 3367 |
end_edgeverts[0][1] += maxs[1] - mid[1]; |
| 3368 |
end_edgeverts[1][0] += maxs[0] - mid[0]; |
| 3369 |
end_edgeverts[1][1] += mins[1] - mid[1]; |
| 3370 |
end_edgeverts[2][0] += mins[0] - mid[0]; |
| 3371 |
end_edgeverts[2][1] += mins[1] - mid[1]; |
| 3372 |
end_edgeverts[3][0] += mins[0] - mid[0]; |
| 3373 |
end_edgeverts[3][1] += maxs[1] - mid[1]; |
| 3374 |
|
| 3375 |
end_plane.dist = end_edgeverts[0][2]; |
| 3376 |
VectorSet(end_plane.normal, 0, 0, 1); |
| 3377 |
|
| 3378 |
#ifndef BSPC |
| 3379 |
#if 0 |
| 3380 |
for (i = 0; i < 4; i++) |
| 3381 |
{ |
| 3382 |
AAS_PermanentLine(start_edgeverts[i], start_edgeverts[(i+1)%4], 1); |
| 3383 |
AAS_PermanentLine(end_edgeverts[i], end_edgeverts[(i+1)%4], 1); |
| 3384 |
} |
| 3385 |
#endif |
| 3386 |
#endif |
| 3387 |
VectorCopy(move_start, move_start_top); |
| 3388 |
move_start_top[2] += maxs[2] - mid[2] + 24; |
| 3389 |
VectorCopy(move_end, move_end_top); |
| 3390 |
move_end_top[2] += maxs[2] - mid[2] + 24; |
| 3391 |
|
| 3392 |
if (!AAS_PointAreaNum(move_start_top)) continue; |
| 3393 |
if (!AAS_PointAreaNum(move_end_top)) continue; |
| 3394 |
|
| 3395 |
for (i = 0; i < 2; i++) |
| 3396 |
{ |
| 3397 |
|
| 3398 |
if (i == 0) |
| 3399 |
{ |
| 3400 |
firststartreach = AAS_FindFaceReachabilities(start_edgeverts, 4, &start_plane, qtrue); |
| 3401 |
firstendreach = AAS_FindFaceReachabilities(end_edgeverts, 4, &end_plane, qfalse); |
| 3402 |
} |
| 3403 |
else |
| 3404 |
{ |
| 3405 |
firststartreach = AAS_FindFaceReachabilities(end_edgeverts, 4, &end_plane, qtrue); |
| 3406 |
firstendreach = AAS_FindFaceReachabilities(start_edgeverts, 4, &start_plane, qfalse); |
| 3407 |
} |
| 3408 |
|
| 3409 |
|
| 3410 |
for (startreach = firststartreach; startreach; startreach = nextstartreach) |
| 3411 |
{ |
| 3412 |
nextstartreach = startreach->next; |
| 3413 |
|
| 3414 |
|
| 3415 |
|
| 3416 |
|
| 3417 |
for (endreach = firstendreach; endreach; endreach = nextendreach) |
| 3418 |
{ |
| 3419 |
nextendreach = endreach->next; |
| 3420 |
|
| 3421 |
|
| 3422 |
|
| 3423 |
|
| 3424 |
Log_Write("funcbob reach from area %d to %d\n", startreach->areanum, endreach->areanum); |
| 3425 |
|
| 3426 |
|
| 3427 |
if (i == 0) VectorCopy(move_start_top, org); |
| 3428 |
else VectorCopy(move_end_top, org); |
| 3429 |
VectorSubtract(startreach->start, org, dir); |
| 3430 |
dir[2] = 0; |
| 3431 |
VectorNormalize(dir); |
| 3432 |
VectorCopy(startreach->start, start); |
| 3433 |
VectorMA(startreach->start, 1, dir, start); |
| 3434 |
start[2] += 1; |
| 3435 |
VectorMA(startreach->start, 16, dir, end); |
| 3436 |
end[2] += 1; |
| 3437 |
|
| 3438 |
numareas = AAS_TraceAreas(start, end, areas, points, 10); |
| 3439 |
if (numareas <= 0) continue; |
| 3440 |
if (numareas > 1) VectorCopy(points[1], startreach->start); |
| 3441 |
else VectorCopy(end, startreach->start); |
| 3442 |
|
| 3443 |
if (!AAS_PointAreaNum(startreach->start)) continue; |
| 3444 |
if (!AAS_PointAreaNum(endreach->end)) continue; |
| 3445 |
|
| 3446 |
lreach = AAS_AllocReachability(); |
| 3447 |
lreach->areanum = endreach->areanum; |
| 3448 |
if (i == 0) lreach->edgenum = ((int)move_start[axis] << 16) | ((int) move_end[axis] & 0x0000ffff); |
| 3449 |
else lreach->edgenum = ((int)move_end[axis] << 16) | ((int) move_start[axis] & 0x0000ffff); |
| 3450 |
lreach->facenum = (spawnflags << 16) | modelnum; |
| 3451 |
VectorCopy(startreach->start, lreach->start); |
| 3452 |
VectorCopy(endreach->end, lreach->end); |
| 3453 |
#ifndef BSPC |
| 3454 |
|
| 3455 |
|
| 3456 |
#endif |
| 3457 |
lreach->traveltype = TRAVEL_FUNCBOB; |
| 3458 |
lreach->traveltype |= AAS_TravelFlagsForTeam(ent); |
| 3459 |
lreach->traveltime = aassettings.rs_funcbob; |
| 3460 |
reach_funcbob++; |
| 3461 |
lreach->next = areareachability[startreach->areanum]; |
| 3462 |
areareachability[startreach->areanum] = lreach; |
| 3463 |
|
| 3464 |
} |
| 3465 |
} |
| 3466 |
for (startreach = firststartreach; startreach; startreach = nextstartreach) |
| 3467 |
{ |
| 3468 |
nextstartreach = startreach->next; |
| 3469 |
AAS_FreeReachability(startreach); |
| 3470 |
} |
| 3471 |
for (endreach = firstendreach; endreach; endreach = nextendreach) |
| 3472 |
{ |
| 3473 |
nextendreach = endreach->next; |
| 3474 |
AAS_FreeReachability(endreach); |
| 3475 |
} |
| 3476 |
|
| 3477 |
if (!(spawnflags & 1) && !(spawnflags & 2)) break; |
| 3478 |
} |
| 3479 |
} |
| 3480 |
} |
| 3481 |
|
| 3482 |
|
| 3483 |
|
| 3484 |
|
| 3485 |
|
| 3486 |
|
| 3487 |
void AAS_Reachability_JumpPad(void) |
| 3488 |
{ |
| 3489 |
int face2num, i, ret, area2num, visualize, ent, bot_visualizejumppads; |
| 3490 |
|
| 3491 |
|
| 3492 |
float speed, zvel; |
| 3493 |
|
| 3494 |
aas_face_t *face2; |
| 3495 |
aas_area_t *area2; |
| 3496 |
aas_lreachability_t *lreach; |
| 3497 |
vec3_t areastart, facecenter, dir, cmdmove; |
| 3498 |
vec3_t velocity, absmins, absmaxs; |
| 3499 |
|
| 3500 |
aas_clientmove_t move; |
| 3501 |
|
| 3502 |
aas_link_t *areas, *link; |
| 3503 |
|
| 3504 |
char classname[MAX_EPAIRKEY]; |
| 3505 |
|
| 3506 |
#ifdef BSPC |
| 3507 |
bot_visualizejumppads = 0; |
| 3508 |
#else |
| 3509 |
bot_visualizejumppads = LibVarValue("bot_visualizejumppads", "0"); |
| 3510 |
#endif |
| 3511 |
for (ent = AAS_NextBSPEntity(0); ent; ent = AAS_NextBSPEntity(ent)) |
| 3512 |
{ |
| 3513 |
if (!AAS_ValueForBSPEpairKey(ent, "classname", classname, MAX_EPAIRKEY)) continue; |
| 3514 |
if (strcmp(classname, "trigger_push")) continue; |
| 3515 |
|
| 3516 |
if (!AAS_GetJumpPadInfo(ent, areastart, absmins, absmaxs, velocity)) continue; |
| 3517 |
|
| 3518 |
|
| 3519 |
|
| 3520 |
|
| 3521 |
|
| 3522 |
|
| 3523 |
|
| 3524 |
|
| 3525 |
|
| 3526 |
|
| 3527 |
|
| 3528 |
|
| 3529 |
|
| 3530 |
|
| 3531 |
|
| 3532 |
|
| 3533 |
|
| 3534 |
|
| 3535 |
|
| 3536 |
|
| 3537 |
|
| 3538 |
|
| 3539 |
|
| 3540 |
|
| 3541 |
|
| 3542 |
|
| 3543 |
|
| 3544 |
|
| 3545 |
|
| 3546 |
|
| 3547 |
|
| 3548 |
|
| 3549 |
|
| 3550 |
|
| 3551 |
|
| 3552 |
|
| 3553 |
|
| 3554 |
|
| 3555 |
|
| 3556 |
|
| 3557 |
|
| 3558 |
|
| 3559 |
|
| 3560 |
|
| 3561 |
|
| 3562 |
|
| 3563 |
|
| 3564 |
|
| 3565 |
|
| 3566 |
|
| 3567 |
|
| 3568 |
|
| 3569 |
|
| 3570 |
|
| 3571 |
|
| 3572 |
|
| 3573 |
|
| 3574 |
|
| 3575 |
|
| 3576 |
|
| 3577 |
|
| 3578 |
|
| 3579 |
|
| 3580 |
|
| 3581 |
|
| 3582 |
|
| 3583 |
|
| 3584 |
|
| 3585 |
|
| 3586 |
|
| 3587 |
|
| 3588 |
areas = AAS_LinkEntityClientBBox(absmins, absmaxs, -1, PRESENCE_CROUCH); |
| 3589 |
|
| 3590 |
|
| 3591 |
|
| 3592 |
|
| 3593 |
|
| 3594 |
|
| 3595 |
|
| 3596 |
|
| 3597 |
|
| 3598 |
for (link = areas; link; link = link->next_area) |
| 3599 |
{ |
| 3600 |
if (AAS_AreaJumpPad(link->areanum)) break; |
| 3601 |
} |
| 3602 |
if (!link) |
| 3603 |
{ |
| 3604 |
botimport.Print(PRT_MESSAGE, "trigger_push not in any jump pad area\n"); |
| 3605 |
AAS_UnlinkFromAreas(areas); |
| 3606 |
continue; |
| 3607 |
} |
| 3608 |
|
| 3609 |
botimport.Print(PRT_MESSAGE, "found a trigger_push with velocity %f %f %f\n", velocity[0], velocity[1], velocity[2]); |
| 3610 |
|
| 3611 |
if (velocity[0] || velocity[1]) |
| 3612 |
{ |
| 3613 |
VectorSet(cmdmove, 0, 0, 0); |
| 3614 |
|
| 3615 |
|
| 3616 |
Com_Memset(&move, 0, sizeof(aas_clientmove_t)); |
| 3617 |
area2num = 0; |
| 3618 |
for (i = 0; i < 20; i++) |
| 3619 |
{ |
| 3620 |
AAS_PredictClientMovement(&move, -1, areastart, PRESENCE_NORMAL, qfalse, |
| 3621 |
velocity, cmdmove, 0, 30, 0.1f, |
| 3622 |
SE_HITGROUND|SE_ENTERWATER|SE_ENTERSLIME| |
| 3623 |
SE_ENTERLAVA|SE_HITGROUNDDAMAGE|SE_TOUCHJUMPPAD|SE_TOUCHTELEPORTER, 0, bot_visualizejumppads); |
| 3624 |
area2num = move.endarea; |
| 3625 |
for (link = areas; link; link = link->next_area) |
| 3626 |
{ |
| 3627 |
if (!AAS_AreaJumpPad(link->areanum)) continue; |
| 3628 |
if (link->areanum == area2num) break; |
| 3629 |
} |
| 3630 |
if (!link) break; |
| 3631 |
VectorCopy(move.endpos, areastart); |
| 3632 |
VectorCopy(move.velocity, velocity); |
| 3633 |
} |
| 3634 |
if (area2num && i < 20) |
| 3635 |
{ |
| 3636 |
for (link = areas; link; link = link->next_area) |
| 3637 |
{ |
| 3638 |
if (!AAS_AreaJumpPad(link->areanum)) continue; |
| 3639 |
if (AAS_ReachabilityExists(link->areanum, area2num)) continue; |
| 3640 |
|
| 3641 |
lreach = AAS_AllocReachability(); |
| 3642 |
if (!lreach) |
| 3643 |
{ |
| 3644 |
AAS_UnlinkFromAreas(areas); |
| 3645 |
return; |
| 3646 |
} |
| 3647 |
lreach->areanum = area2num; |
| 3648 |
|
| 3649 |
lreach->facenum = velocity[2]; |
| 3650 |
|
| 3651 |
lreach->edgenum = sqrt(velocity[0] * velocity[0] + velocity[1] * velocity[1]); |
| 3652 |
VectorCopy(areastart, lreach->start); |
| 3653 |
VectorCopy(move.endpos, lreach->end); |
| 3654 |
lreach->traveltype = TRAVEL_JUMPPAD; |
| 3655 |
lreach->traveltype |= AAS_TravelFlagsForTeam(ent); |
| 3656 |
lreach->traveltime = aassettings.rs_jumppad; |
| 3657 |
lreach->next = areareachability[link->areanum]; |
| 3658 |
areareachability[link->areanum] = lreach; |
| 3659 |
|
| 3660 |
reach_jumppad++; |
| 3661 |
} |
| 3662 |
} |
| 3663 |
} |
| 3664 |
|
| 3665 |
if (fabs(velocity[0]) > 100 || fabs(velocity[1]) > 100) continue; |
| 3666 |
|
| 3667 |
for (area2num = 1; area2num < aasworld.numareas; area2num++) |
| 3668 |
{ |
| 3669 |
visualize = qfalse; |
| 3670 |
|
| 3671 |
|
| 3672 |
|
| 3673 |
|
| 3674 |
|
| 3675 |
|
| 3676 |
|
| 3677 |
|
| 3678 |
|
| 3679 |
|
| 3680 |
|
| 3681 |
|
| 3682 |
|
| 3683 |
|
| 3684 |
for (link = areas; link; link = link->next_area) |
| 3685 |
{ |
| 3686 |
if (AAS_ReachabilityExists(link->areanum, area2num)) break; |
| 3687 |
if (AAS_AreaJumpPad(link->areanum)) |
| 3688 |
{ |
| 3689 |
if (link->areanum == area2num) break; |
| 3690 |
} |
| 3691 |
} |
| 3692 |
if (link) continue; |
| 3693 |
|
| 3694 |
area2 = &aasworld.areas[area2num]; |
| 3695 |
for (i = 0; i < area2->numfaces; i++) |
| 3696 |
{ |
| 3697 |
face2num = aasworld.faceindex[area2->firstface + i]; |
| 3698 |
face2 = &aasworld.faces[abs(face2num)]; |
| 3699 |
|
| 3700 |
if (!(face2->faceflags & FACE_GROUND)) continue; |
| 3701 |
|
| 3702 |
AAS_FaceCenter(face2num, facecenter); |
| 3703 |
|
| 3704 |
if (facecenter[2] < areastart[2]) continue; |
| 3705 |
|
| 3706 |
zvel = velocity[2]; |
| 3707 |
|
| 3708 |
|
| 3709 |
ret = AAS_HorizontalVelocityForJump(zvel, areastart, facecenter, &speed); |
| 3710 |
if (ret && speed < 150) |
| 3711 |
{ |
| 3712 |
|
| 3713 |
VectorSubtract(facecenter, areastart, dir); |
| 3714 |
dir[2] = 0; |
| 3715 |
|
| 3716 |
|
| 3717 |
{ |
| 3718 |
|
| 3719 |
VectorScale(dir, speed, cmdmove); |
| 3720 |
|
| 3721 |
AAS_PredictClientMovement(&move, -1, areastart, PRESENCE_NORMAL, qfalse, |
| 3722 |
velocity, cmdmove, 30, 30, 0.1f, |
| 3723 |
SE_ENTERWATER|SE_ENTERSLIME| |
| 3724 |
SE_ENTERLAVA|SE_HITGROUNDDAMAGE| |
| 3725 |
SE_TOUCHJUMPPAD|SE_TOUCHTELEPORTER|SE_HITGROUNDAREA, area2num, visualize); |
| 3726 |
|
| 3727 |
|
| 3728 |
if (move.frames < 30 && |
| 3729 |
!(move.stopevent & (SE_ENTERSLIME|SE_ENTERLAVA|SE_HITGROUNDDAMAGE)) |
| 3730 |
&& (move.stopevent & (SE_HITGROUNDAREA|SE_TOUCHJUMPPAD|SE_TOUCHTELEPORTER))) |
| 3731 |
{ |
| 3732 |
|
| 3733 |
for (link = areas; link; link = link->next_area) |
| 3734 |
{ |
| 3735 |
if (link->areanum == move.endarea) break; |
| 3736 |
} |
| 3737 |
if (!link) |
| 3738 |
{ |
| 3739 |
for (link = areas; link; link = link->next_area) |
| 3740 |
{ |
| 3741 |
if (!AAS_AreaJumpPad(link->areanum)) continue; |
| 3742 |
if (AAS_ReachabilityExists(link->areanum, area2num)) continue; |
| 3743 |
|
| 3744 |
lreach = AAS_AllocReachability(); |
| 3745 |
if (!lreach) |
| 3746 |
{ |
| 3747 |
AAS_UnlinkFromAreas(areas); |
| 3748 |
return; |
| 3749 |
} |
| 3750 |
lreach->areanum = move.endarea; |
| 3751 |
|
| 3752 |
lreach->facenum = velocity[2]; |
| 3753 |
|
| 3754 |
lreach->edgenum = sqrt(cmdmove[0] * cmdmove[0] + cmdmove[1] * cmdmove[1]); |
| 3755 |
VectorCopy(areastart, lreach->start); |
| 3756 |
VectorCopy(facecenter, lreach->end); |
| 3757 |
lreach->traveltype = TRAVEL_JUMPPAD; |
| 3758 |
lreach->traveltype |= AAS_TravelFlagsForTeam(ent); |
| 3759 |
lreach->traveltime = aassettings.rs_aircontrolledjumppad; |
| 3760 |
lreach->next = areareachability[link->areanum]; |
| 3761 |
areareachability[link->areanum] = lreach; |
| 3762 |
|
| 3763 |
reach_jumppad++; |
| 3764 |
} |
| 3765 |
} |
| 3766 |
} |
| 3767 |
} |
| 3768 |
} |
| 3769 |
} |
| 3770 |
} |
| 3771 |
AAS_UnlinkFromAreas(areas); |
| 3772 |
} |
| 3773 |
} |
| 3774 |
|
| 3775 |
|
| 3776 |
|
| 3777 |
|
| 3778 |
|
| 3779 |
|
| 3780 |
|
| 3781 |
|
| 3782 |
int AAS_Reachability_Grapple(int area1num, int area2num) |
| 3783 |
{ |
| 3784 |
int face2num, i, j, areanum, numareas, areas[20]; |
| 3785 |
float mingrappleangle, z, hordist; |
| 3786 |
bsp_trace_t bsptrace; |
| 3787 |
aas_trace_t trace; |
| 3788 |
aas_face_t *face2; |
| 3789 |
aas_area_t *area1, *area2; |
| 3790 |
aas_lreachability_t *lreach; |
| 3791 |
vec3_t areastart = {0, 0, 0}, facecenter, start, end, dir, down = {0, 0, -1}; |
| 3792 |
vec_t *v; |
| 3793 |
|
| 3794 |
|
| 3795 |
if (!AAS_AreaGrounded(area1num) && !AAS_AreaSwim(area1num)) return qfalse; |
| 3796 |
|
| 3797 |
if (!(AAS_AreaPresenceType(area1num) & PRESENCE_NORMAL)) return qfalse; |
| 3798 |
|
| 3799 |
if (AAS_AreaSwim(area1num)) return qfalse; |
| 3800 |
|
| 3801 |
area1 = &aasworld.areas[area1num]; |
| 3802 |
area2 = &aasworld.areas[area2num]; |
| 3803 |
|
| 3804 |
if (area2->maxs[2] < area1->mins[2]) return qfalse; |
| 3805 |
|
| 3806 |
VectorCopy(aasworld.areas[area1num].center, start); |
| 3807 |
|
| 3808 |
if (!AAS_AreaSwim(area1num)) |
| 3809 |
{ |
| 3810 |
if (!AAS_PointAreaNum(start)) Log_Write("area %d center %f %f %f in solid?\r\n", area1num, |
| 3811 |
start[0], start[1], start[2]); |
| 3812 |
VectorCopy(start, end); |
| 3813 |
end[2] -= 1000; |
| 3814 |
trace = AAS_TraceClientBBox(start, end, PRESENCE_CROUCH, -1); |
| 3815 |
if (trace.startsolid) return qfalse; |
| 3816 |
VectorCopy(trace.endpos, areastart); |
| 3817 |
} |
| 3818 |
else |
| 3819 |
{ |
| 3820 |
if (!(AAS_PointContents(start) & (CONTENTS_LAVA|CONTENTS_SLIME|CONTENTS_WATER))) return qfalse; |
| 3821 |
} |
| 3822 |
|
| 3823 |
|
| 3824 |
|
| 3825 |
for (i = 0; i < area2->numfaces; i++) |
| 3826 |
{ |
| 3827 |
face2num = aasworld.faceindex[area2->firstface + i]; |
| 3828 |
face2 = &aasworld.faces[abs(face2num)]; |
| 3829 |
|
| 3830 |
if (!(face2->faceflags & FACE_SOLID)) continue; |
| 3831 |
|
| 3832 |
v = aasworld.vertexes[aasworld.edges[abs(aasworld.edgeindex[face2->firstedge])].v[0]]; |
| 3833 |
VectorSubtract(v, areastart, dir); |
| 3834 |
|
| 3835 |
if (DotProduct(aasworld.planes[face2->planenum].normal, dir) > 0) continue; |
| 3836 |
|
| 3837 |
AAS_FaceCenter(face2num, facecenter); |
| 3838 |
|
| 3839 |
if (facecenter[2] < areastart[2] + 64) continue; |
| 3840 |
|
| 3841 |
if (DotProduct(aasworld.planes[face2->planenum].normal, down) < 0) continue; |
| 3842 |
|
| 3843 |
VectorSubtract(facecenter, areastart, dir); |
| 3844 |
|
| 3845 |
z = dir[2]; |
| 3846 |
dir[2] = 0; |
| 3847 |
hordist = VectorLength(dir); |
| 3848 |
if (!hordist) continue; |
| 3849 |
|
| 3850 |
if (hordist > 2000) continue; |
| 3851 |
|
| 3852 |
mingrappleangle = 15; |
| 3853 |
if (z / hordist < tan(2 * M_PI * mingrappleangle / 360)) continue; |
| 3854 |
|
| 3855 |
VectorCopy(facecenter, start); |
| 3856 |
VectorMA(facecenter, -500, aasworld.planes[face2->planenum].normal, end); |
| 3857 |
|
| 3858 |
bsptrace = AAS_Trace(start, NULL, NULL, end, 0, CONTENTS_SOLID); |
| 3859 |
|
| 3860 |
if ((bsptrace.surface.flags & SURF_SKY) || (bsptrace.fraction * 500 > 32)) continue; |
| 3861 |
|
| 3862 |
|
| 3863 |
VectorSubtract(facecenter, areastart, dir); |
| 3864 |
VectorNormalize(dir); |
| 3865 |
VectorMA(areastart, 4, dir, start); |
| 3866 |
VectorCopy(bsptrace.endpos, end); |
| 3867 |
trace = AAS_TraceClientBBox(start, end, PRESENCE_NORMAL, -1); |
| 3868 |
VectorSubtract(trace.endpos, facecenter, dir); |
| 3869 |
if (VectorLength(dir) > 24) continue; |
| 3870 |
|
| 3871 |
VectorCopy(trace.endpos, start); |
| 3872 |
VectorCopy(trace.endpos, end); |
| 3873 |
end[2] -= AAS_FallDamageDistance(); |
| 3874 |
trace = AAS_TraceClientBBox(start, end, PRESENCE_NORMAL, -1); |
| 3875 |
if (trace.fraction >= 1) continue; |
| 3876 |
|
| 3877 |
areanum = AAS_PointAreaNum(trace.endpos); |
| 3878 |
|
| 3879 |
if (aasworld.areasettings[areanum].contents & (AREACONTENTS_SLIME|AREACONTENTS_LAVA)) |
| 3880 |
{ |
| 3881 |
continue; |
| 3882 |
} |
| 3883 |
|
| 3884 |
if (areanum == area1num) continue; |
| 3885 |
|
| 3886 |
if (AAS_ReachabilityExists(area1num, areanum)) continue; |
| 3887 |
|
| 3888 |
if (!AAS_AreaGrounded(areanum)) continue; |
| 3889 |
|
| 3890 |
numareas = AAS_TraceAreas(areastart, bsptrace.endpos, areas, NULL, 20); |
| 3891 |
if (numareas >= 20) continue; |
| 3892 |
for (j = 0; j < numareas; j++) |
| 3893 |
{ |
| 3894 |
if (aasworld.areasettings[areas[j]].contents & AREACONTENTS_CLUSTERPORTAL) break; |
| 3895 |
} |
| 3896 |
if (j < numareas) continue; |
| 3897 |
|
| 3898 |
lreach = AAS_AllocReachability(); |
| 3899 |
if (!lreach) return qfalse; |
| 3900 |
lreach->areanum = areanum; |
| 3901 |
lreach->facenum = face2num; |
| 3902 |
lreach->edgenum = 0; |
| 3903 |
VectorCopy(areastart, lreach->start); |
| 3904 |
|
| 3905 |
VectorCopy(bsptrace.endpos, lreach->end); |
| 3906 |
lreach->traveltype = TRAVEL_GRAPPLEHOOK; |
| 3907 |
VectorSubtract(lreach->end, lreach->start, dir); |
| 3908 |
lreach->traveltime = aassettings.rs_startgrapple + VectorLength(dir) * 0.25; |
| 3909 |
lreach->next = areareachability[area1num]; |
| 3910 |
areareachability[area1num] = lreach; |
| 3911 |
|
| 3912 |
reach_grapple++; |
| 3913 |
} |
| 3914 |
|
| 3915 |
return qfalse; |
| 3916 |
} |
| 3917 |
|
| 3918 |
|
| 3919 |
|
| 3920 |
|
| 3921 |
|
| 3922 |
|
| 3923 |
void AAS_SetWeaponJumpAreaFlags(void) |
| 3924 |
{ |
| 3925 |
int ent, i; |
| 3926 |
vec3_t mins = {-15, -15, -15}, maxs = {15, 15, 15}; |
| 3927 |
vec3_t origin; |
| 3928 |
int areanum, weaponjumpareas, spawnflags; |
| 3929 |
char classname[MAX_EPAIRKEY]; |
| 3930 |
|
| 3931 |
weaponjumpareas = 0; |
| 3932 |
for (ent = AAS_NextBSPEntity(0); ent; ent = AAS_NextBSPEntity(ent)) |
| 3933 |
{ |
| 3934 |
if (!AAS_ValueForBSPEpairKey(ent, "classname", classname, MAX_EPAIRKEY)) continue; |
| 3935 |
if ( |
| 3936 |
!strcmp(classname, "item_armor_body") || |
| 3937 |
!strcmp(classname, "item_armor_combat") || |
| 3938 |
!strcmp(classname, "item_health_mega") || |
| 3939 |
!strcmp(classname, "weapon_grenadelauncher") || |
| 3940 |
!strcmp(classname, "weapon_rocketlauncher") || |
| 3941 |
!strcmp(classname, "weapon_lightning") || |
| 3942 |
!strcmp(classname, "weapon_plasmagun") || |
| 3943 |
!strcmp(classname, "weapon_railgun") || |
| 3944 |
!strcmp(classname, "weapon_bfg") || |
| 3945 |
!strcmp(classname, "item_quad") || |
| 3946 |
!strcmp(classname, "item_regen") || |
| 3947 |
!strcmp(classname, "item_invulnerability")) |
| 3948 |
{ |
| 3949 |
if (AAS_VectorForBSPEpairKey(ent, "origin", origin)) |
| 3950 |
{ |
| 3951 |
spawnflags = 0; |
| 3952 |
AAS_IntForBSPEpairKey(ent, "spawnflags", &spawnflags); |
| 3953 |
|
| 3954 |
if (!(spawnflags & 1)) |
| 3955 |
{ |
| 3956 |
if (!AAS_DropToFloor(origin, mins, maxs)) |
| 3957 |
{ |
| 3958 |
botimport.Print(PRT_MESSAGE, "%s in solid at (%1.1f %1.1f %1.1f)\n", |
| 3959 |
classname, origin[0], origin[1], origin[2]); |
| 3960 |
} |
| 3961 |
} |
| 3962 |
|
| 3963 |
areanum = AAS_BestReachableArea(origin, mins, maxs, origin); |
| 3964 |
|
| 3965 |
aasworld.areasettings[areanum].areaflags |= AREA_WEAPONJUMP; |
| 3966 |
|
| 3967 |
|
| 3968 |
|
| 3969 |
|
| 3970 |
weaponjumpareas++; |
| 3971 |
} |
| 3972 |
} |
| 3973 |
} |
| 3974 |
for (i = 1; i < aasworld.numareas; i++) |
| 3975 |
{ |
| 3976 |
if (aasworld.areasettings[i].contents & AREACONTENTS_JUMPPAD) |
| 3977 |
{ |
| 3978 |
aasworld.areasettings[i].areaflags |= AREA_WEAPONJUMP; |
| 3979 |
weaponjumpareas++; |
| 3980 |
} |
| 3981 |
} |
| 3982 |
botimport.Print(PRT_MESSAGE, "%d weapon jump areas\n", weaponjumpareas); |
| 3983 |
} |
| 3984 |
|
| 3985 |
|
| 3986 |
|
| 3987 |
|
| 3988 |
|
| 3989 |
|
| 3990 |
|
| 3991 |
|
| 3992 |
|
| 3993 |
|
| 3994 |
|
| 3995 |
int AAS_Reachability_WeaponJump(int area1num, int area2num) |
| 3996 |
{ |
| 3997 |
int face2num, i, n, ret, visualize; |
| 3998 |
float speed, zvel; |
| 3999 |
|
| 4000 |
aas_face_t *face2; |
| 4001 |
aas_area_t *area1, *area2; |
| 4002 |
aas_lreachability_t *lreach; |
| 4003 |
vec3_t areastart, facecenter, start, end, dir, cmdmove; |
| 4004 |
vec3_t velocity; |
| 4005 |
aas_clientmove_t move; |
| 4006 |
aas_trace_t trace; |
| 4007 |
|
| 4008 |
visualize = qfalse; |
| 4009 |
|
| 4010 |
|
| 4011 |
|
| 4012 |
|
| 4013 |
if (!AAS_AreaGrounded(area1num) || AAS_AreaSwim(area1num)) return qfalse; |
| 4014 |
if (!AAS_AreaGrounded(area2num)) return qfalse; |
| 4015 |
|
| 4016 |
if (!(aasworld.areasettings[area2num].areaflags & AREA_WEAPONJUMP)) return qfalse; |
| 4017 |
|
| 4018 |
area1 = &aasworld.areas[area1num]; |
| 4019 |
area2 = &aasworld.areas[area2num]; |
| 4020 |
|
| 4021 |
if (area2->maxs[2] < area1->mins[2]) return qfalse; |
| 4022 |
|
| 4023 |
VectorCopy(aasworld.areas[area1num].center, start); |
| 4024 |
|
| 4025 |
if (!AAS_PointAreaNum(start)) Log_Write("area %d center %f %f %f in solid?\r\n", area1num, |
| 4026 |
start[0], start[1], start[2]); |
| 4027 |
VectorCopy(start, end); |
| 4028 |
end[2] -= 1000; |
| 4029 |
trace = AAS_TraceClientBBox(start, end, PRESENCE_CROUCH, -1); |
| 4030 |
if (trace.startsolid) return qfalse; |
| 4031 |
VectorCopy(trace.endpos, areastart); |
| 4032 |
|
| 4033 |
|
| 4034 |
|
| 4035 |
for (i = 0; i < area2->numfaces; i++) |
| 4036 |
{ |
| 4037 |
face2num = aasworld.faceindex[area2->firstface + i]; |
| 4038 |
face2 = &aasworld.faces[abs(face2num)]; |
| 4039 |
|
| 4040 |
if (!(face2->faceflags & FACE_GROUND)) continue; |
| 4041 |
|
| 4042 |
AAS_FaceCenter(face2num, facecenter); |
| 4043 |
|
| 4044 |
if (facecenter[2] < areastart[2] + 64) continue; |
| 4045 |
|
| 4046 |
for (n = 0; n < 1; n++) |
| 4047 |
{ |
| 4048 |
|
| 4049 |
if (n) zvel = AAS_BFGJumpZVelocity(areastart); |
| 4050 |
else zvel = AAS_RocketJumpZVelocity(areastart); |
| 4051 |
|
| 4052 |
|
| 4053 |
ret = AAS_HorizontalVelocityForJump(zvel, areastart, facecenter, &speed); |
| 4054 |
if (ret && speed < 300) |
| 4055 |
{ |
| 4056 |
|
| 4057 |
VectorSubtract(facecenter, areastart, dir); |
| 4058 |
dir[2] = 0; |
| 4059 |
|
| 4060 |
|
| 4061 |
{ |
| 4062 |
|
| 4063 |
VectorScale(dir, speed, cmdmove); |
| 4064 |
VectorSet(velocity, 0, 0, zvel); |
| 4065 |
|
| 4066 |
|
| 4067 |
|
| 4068 |
|
| 4069 |
|
| 4070 |
|
| 4071 |
|
| 4072 |
AAS_PredictClientMovement(&move, -1, areastart, PRESENCE_NORMAL, qtrue, |
| 4073 |
velocity, cmdmove, 30, 30, 0.1f, |
| 4074 |
SE_ENTERWATER|SE_ENTERSLIME| |
| 4075 |
SE_ENTERLAVA|SE_HITGROUNDDAMAGE| |
| 4076 |
SE_TOUCHJUMPPAD|SE_HITGROUND|SE_HITGROUNDAREA, area2num, visualize); |
| 4077 |
|
| 4078 |
|
| 4079 |
if (move.frames < 30 && |
| 4080 |
!(move.stopevent & (SE_ENTERSLIME|SE_ENTERLAVA|SE_HITGROUNDDAMAGE)) |
| 4081 |
&& (move.stopevent & (SE_HITGROUNDAREA|SE_TOUCHJUMPPAD))) |
| 4082 |
{ |
| 4083 |
|
| 4084 |
lreach = AAS_AllocReachability(); |
| 4085 |
if (!lreach) return qfalse; |
| 4086 |
lreach->areanum = area2num; |
| 4087 |
lreach->facenum = 0; |
| 4088 |
lreach->edgenum = 0; |
| 4089 |
VectorCopy(areastart, lreach->start); |
| 4090 |
VectorCopy(facecenter, lreach->end); |
| 4091 |
if (n) |
| 4092 |
{ |
| 4093 |
lreach->traveltype = TRAVEL_BFGJUMP; |
| 4094 |
lreach->traveltime = aassettings.rs_bfgjump; |
| 4095 |
} |
| 4096 |
else |
| 4097 |
{ |
| 4098 |
lreach->traveltype = TRAVEL_ROCKETJUMP; |
| 4099 |
lreach->traveltime = aassettings.rs_rocketjump; |
| 4100 |
} |
| 4101 |
lreach->next = areareachability[area1num]; |
| 4102 |
areareachability[area1num] = lreach; |
| 4103 |
|
| 4104 |
reach_rocketjump++; |
| 4105 |
return qtrue; |
| 4106 |
} |
| 4107 |
} |
| 4108 |
} |
| 4109 |
} |
| 4110 |
} |
| 4111 |
|
| 4112 |
return qfalse; |
| 4113 |
} |
| 4114 |
|
| 4115 |
|
| 4116 |
|
| 4117 |
|
| 4118 |
|
| 4119 |
|
| 4120 |
|
| 4121 |
void AAS_Reachability_WalkOffLedge(int areanum) |
| 4122 |
{ |
| 4123 |
int i, j, k, l, m, n, p, areas[10], numareas; |
| 4124 |
int face1num, face2num, face3num, edge1num, edge2num, edge3num; |
| 4125 |
int otherareanum, gap, reachareanum, side; |
| 4126 |
aas_area_t *area, *area2; |
| 4127 |
aas_face_t *face1, *face2, *face3; |
| 4128 |
aas_edge_t *edge; |
| 4129 |
aas_plane_t *plane; |
| 4130 |
vec_t *v1, *v2; |
| 4131 |
vec3_t sharededgevec, mid, dir, testend; |
| 4132 |
aas_lreachability_t *lreach; |
| 4133 |
aas_trace_t trace; |
| 4134 |
|
| 4135 |
if (!AAS_AreaGrounded(areanum) || AAS_AreaSwim(areanum)) return; |
| 4136 |
|
| 4137 |
area = &aasworld.areas[areanum]; |
| 4138 |
|
| 4139 |
for (i = 0; i < area->numfaces; i++) |
| 4140 |
{ |
| 4141 |
face1num = aasworld.faceindex[area->firstface + i]; |
| 4142 |
face1 = &aasworld.faces[abs(face1num)]; |
| 4143 |
|
| 4144 |
if (!(face1->faceflags & FACE_GROUND)) continue; |
| 4145 |
|
| 4146 |
for (k = 0; k < face1->numedges; k++) |
| 4147 |
{ |
| 4148 |
edge1num = aasworld.edgeindex[face1->firstedge + k]; |
| 4149 |
|
| 4150 |
for (j = 0; j < area->numfaces; j++) |
| 4151 |
{ |
| 4152 |
face2num = aasworld.faceindex[area->firstface + j]; |
| 4153 |
face2 = &aasworld.faces[abs(face2num)]; |
| 4154 |
|
| 4155 |
if (face2->faceflags & FACE_GROUND) continue; |
| 4156 |
|
| 4157 |
for (l = 0; l < face2->numedges; l++) |
| 4158 |
{ |
| 4159 |
edge2num = aasworld.edgeindex[face2->firstedge + l]; |
| 4160 |
if (abs(edge1num) == abs(edge2num)) |
| 4161 |
{ |
| 4162 |
|
| 4163 |
if (face2->frontarea == areanum) otherareanum = face2->backarea; |
| 4164 |
else otherareanum = face2->frontarea; |
| 4165 |
|
| 4166 |
area2 = &aasworld.areas[otherareanum]; |
| 4167 |
|
| 4168 |
if (aasworld.areasettings[otherareanum].areaflags & AREA_GROUNDED) |
| 4169 |
{ |
| 4170 |
|
| 4171 |
gap = qfalse; |
| 4172 |
for (n = 0; n < area2->numfaces; n++) |
| 4173 |
{ |
| 4174 |
face3num = aasworld.faceindex[area2->firstface + n]; |
| 4175 |
|
| 4176 |
if (abs(face3num) == abs(face2num)) continue; |
| 4177 |
|
| 4178 |
face3 = &aasworld.faces[abs(face3num)]; |
| 4179 |
|
| 4180 |
for (m = 0; m < face3->numedges; m++) |
| 4181 |
{ |
| 4182 |
edge3num = aasworld.edgeindex[face3->firstedge + m]; |
| 4183 |
|
| 4184 |
if (abs(edge3num) == abs(edge1num)) |
| 4185 |
{ |
| 4186 |
if (!(face3->faceflags & FACE_SOLID)) |
| 4187 |
{ |
| 4188 |
gap = qtrue; |
| 4189 |
break; |
| 4190 |
} |
| 4191 |
|
| 4192 |
if (face3->faceflags & FACE_GROUND) |
| 4193 |
{ |
| 4194 |
gap = qfalse; |
| 4195 |
break; |
| 4196 |
} |
| 4197 |
|
| 4198 |
gap = qtrue; |
| 4199 |
break; |
| 4200 |
} |
| 4201 |
} |
| 4202 |
if (m < face3->numedges) break; |
| 4203 |
} |
| 4204 |
if (!gap) break; |
| 4205 |
} |
| 4206 |
|
| 4207 |
edge = &aasworld.edges[abs(edge1num)]; |
| 4208 |
side = edge1num < 0; |
| 4209 |
|
| 4210 |
v1 = aasworld.vertexes[edge->v[side]]; |
| 4211 |
v2 = aasworld.vertexes[edge->v[!side]]; |
| 4212 |
|
| 4213 |
plane = &aasworld.planes[face1->planenum]; |
| 4214 |
|
| 4215 |
VectorSubtract(v2, v1, sharededgevec); |
| 4216 |
CrossProduct(plane->normal, sharededgevec, dir); |
| 4217 |
VectorNormalize(dir); |
| 4218 |
|
| 4219 |
VectorAdd(v1, v2, mid); |
| 4220 |
VectorScale(mid, 0.5, mid); |
| 4221 |
VectorMA(mid, 8, dir, mid); |
| 4222 |
|
| 4223 |
VectorCopy(mid, testend); |
| 4224 |
testend[2] -= 1000; |
| 4225 |
trace = AAS_TraceClientBBox(mid, testend, PRESENCE_CROUCH, -1); |
| 4226 |
|
| 4227 |
if (trace.startsolid) |
| 4228 |
{ |
| 4229 |
|
| 4230 |
break; |
| 4231 |
} |
| 4232 |
reachareanum = AAS_PointAreaNum(trace.endpos); |
| 4233 |
if (reachareanum == areanum) |
| 4234 |
{ |
| 4235 |
|
| 4236 |
break; |
| 4237 |
} |
| 4238 |
if (AAS_ReachabilityExists(areanum, reachareanum)) |
| 4239 |
{ |
| 4240 |
|
| 4241 |
break; |
| 4242 |
} |
| 4243 |
if (!AAS_AreaGrounded(reachareanum) && !AAS_AreaSwim(reachareanum)) |
| 4244 |
{ |
| 4245 |
|
| 4246 |
break; |
| 4247 |
} |
| 4248 |
|
| 4249 |
if (aasworld.areasettings[reachareanum].contents & (AREACONTENTS_SLIME |
| 4250 |
| AREACONTENTS_LAVA)) |
| 4251 |
{ |
| 4252 |
|
| 4253 |
break; |
| 4254 |
} |
| 4255 |
|
| 4256 |
numareas = AAS_TraceAreas(mid, testend, areas, NULL, ARRAY_LEN(areas)); |
| 4257 |
for (p = 0; p < numareas; p++) |
| 4258 |
if (AAS_AreaClusterPortal(areas[p])) |
| 4259 |
break; |
| 4260 |
if (p < numareas) |
| 4261 |
break; |
| 4262 |
|
| 4263 |
if (aassettings.rs_maxfallheight && fabs(mid[2] - trace.endpos[2]) > aassettings.rs_maxfallheight) |
| 4264 |
break; |
| 4265 |
|
| 4266 |
lreach = AAS_AllocReachability(); |
| 4267 |
if (!lreach) break; |
| 4268 |
lreach->areanum = reachareanum; |
| 4269 |
lreach->facenum = 0; |
| 4270 |
lreach->edgenum = edge1num; |
| 4271 |
VectorCopy(mid, lreach->start); |
| 4272 |
VectorCopy(trace.endpos, lreach->end); |
| 4273 |
lreach->traveltype = TRAVEL_WALKOFFLEDGE; |
| 4274 |
lreach->traveltime = aassettings.rs_startwalkoffledge + fabs(mid[2] - trace.endpos[2]) * 50 / aassettings.phys_gravity; |
| 4275 |
if (!AAS_AreaSwim(reachareanum) && !AAS_AreaJumpPad(reachareanum)) |
| 4276 |
{ |
| 4277 |
if (AAS_FallDelta(mid[2] - trace.endpos[2]) > aassettings.phys_falldelta5) |
| 4278 |
{ |
| 4279 |
lreach->traveltime += aassettings.rs_falldamage5; |
| 4280 |
} |
| 4281 |
else if (AAS_FallDelta(mid[2] - trace.endpos[2]) > aassettings.phys_falldelta10) |
| 4282 |
{ |
| 4283 |
lreach->traveltime += aassettings.rs_falldamage10; |
| 4284 |
} |
| 4285 |
} |
| 4286 |
lreach->next = areareachability[areanum]; |
| 4287 |
areareachability[areanum] = lreach; |
| 4288 |
|
| 4289 |
reach_walkoffledge++; |
| 4290 |
} |
| 4291 |
} |
| 4292 |
} |
| 4293 |
} |
| 4294 |
} |
| 4295 |
} |
| 4296 |
|
| 4297 |
|
| 4298 |
|
| 4299 |
|
| 4300 |
|
| 4301 |
|
| 4302 |
void AAS_StoreReachability(void) |
| 4303 |
{ |
| 4304 |
int i; |
| 4305 |
aas_areasettings_t *areasettings; |
| 4306 |
aas_lreachability_t *lreach; |
| 4307 |
aas_reachability_t *reach; |
| 4308 |
|
| 4309 |
if (aasworld.reachability) FreeMemory(aasworld.reachability); |
| 4310 |
aasworld.reachability = (aas_reachability_t *) GetClearedMemory((numlreachabilities + 10) * sizeof(aas_reachability_t)); |
| 4311 |
aasworld.reachabilitysize = 1; |
| 4312 |
for (i = 0; i < aasworld.numareas; i++) |
| 4313 |
{ |
| 4314 |
areasettings = &aasworld.areasettings[i]; |
| 4315 |
areasettings->firstreachablearea = aasworld.reachabilitysize; |
| 4316 |
areasettings->numreachableareas = 0; |
| 4317 |
for (lreach = areareachability[i]; lreach; lreach = lreach->next) |
| 4318 |
{ |
| 4319 |
reach = &aasworld.reachability[areasettings->firstreachablearea + |
| 4320 |
areasettings->numreachableareas]; |
| 4321 |
reach->areanum = lreach->areanum; |
| 4322 |
reach->facenum = lreach->facenum; |
| 4323 |
reach->edgenum = lreach->edgenum; |
| 4324 |
VectorCopy(lreach->start, reach->start); |
| 4325 |
VectorCopy(lreach->end, reach->end); |
| 4326 |
reach->traveltype = lreach->traveltype; |
| 4327 |
reach->traveltime = lreach->traveltime; |
| 4328 |
|
| 4329 |
areasettings->numreachableareas++; |
| 4330 |
} |
| 4331 |
aasworld.reachabilitysize += areasettings->numreachableareas; |
| 4332 |
} |
| 4333 |
} |
| 4334 |
|
| 4335 |
|
| 4336 |
|
| 4337 |
|
| 4338 |
|
| 4339 |
|
| 4340 |
|
| 4341 |
|
| 4342 |
|
| 4343 |
|
| 4344 |
|
| 4345 |
|
| 4346 |
|
| 4347 |
|
| 4348 |
|
| 4349 |
|
| 4350 |
|
| 4351 |
|
| 4352 |
|
| 4353 |
|
| 4354 |
|
| 4355 |
|
| 4356 |
|
| 4357 |
|
| 4358 |
|
| 4359 |
int AAS_ContinueInitReachability(float time) |
| 4360 |
{ |
| 4361 |
int i, j, todo, start_time; |
| 4362 |
static float framereachability, reachability_delay; |
| 4363 |
static int lastpercentage; |
| 4364 |
|
| 4365 |
if (!aasworld.loaded) return qfalse; |
| 4366 |
|
| 4367 |
if (aasworld.numreachabilityareas >= aasworld.numareas + 2) return qfalse; |
| 4368 |
|
| 4369 |
if (aasworld.numreachabilityareas == 1) |
| 4370 |
{ |
| 4371 |
botimport.Print(PRT_MESSAGE, "calculating reachability...\n"); |
| 4372 |
lastpercentage = 0; |
| 4373 |
framereachability = 2000; |
| 4374 |
reachability_delay = 1000; |
| 4375 |
} |
| 4376 |
|
| 4377 |
todo = aasworld.numreachabilityareas + (int) framereachability; |
| 4378 |
start_time = Sys_MilliSeconds(); |
| 4379 |
|
| 4380 |
for (i = aasworld.numreachabilityareas; i < aasworld.numareas && i < todo; i++) |
| 4381 |
{ |
| 4382 |
aasworld.numreachabilityareas++; |
| 4383 |
|
| 4384 |
if (aasworld.areasettings[i].contents & AREACONTENTS_JUMPPAD) |
| 4385 |
{ |
| 4386 |
continue; |
| 4387 |
} |
| 4388 |
|
| 4389 |
for (j = 1; j < aasworld.numareas; j++) |
| 4390 |
{ |
| 4391 |
if (i == j) continue; |
| 4392 |
|
| 4393 |
if (aasworld.areasettings[i].contents & (AREACONTENTS_TELEPORTER|AREACONTENTS_JUMPPAD)) |
| 4394 |
{ |
| 4395 |
if (!(aasworld.areasettings[j].contents & (AREACONTENTS_TELEPORTER|AREACONTENTS_JUMPPAD))) |
| 4396 |
{ |
| 4397 |
continue; |
| 4398 |
} |
| 4399 |
} |
| 4400 |
|
| 4401 |
if (AAS_ReachabilityExists(i, j)) continue; |
| 4402 |
|
| 4403 |
if (AAS_Reachability_Swim(i, j)) continue; |
| 4404 |
|
| 4405 |
if (AAS_Reachability_EqualFloorHeight(i, j)) continue; |
| 4406 |
|
| 4407 |
if (AAS_Reachability_Step_Barrier_WaterJump_WalkOffLedge(i, j)) continue; |
| 4408 |
|
| 4409 |
if (AAS_Reachability_Ladder(i, j)) continue; |
| 4410 |
|
| 4411 |
if (AAS_Reachability_Jump(i, j)) continue; |
| 4412 |
} |
| 4413 |
|
| 4414 |
if (aasworld.areasettings[i].contents & (AREACONTENTS_TELEPORTER|AREACONTENTS_JUMPPAD)) |
| 4415 |
{ |
| 4416 |
continue; |
| 4417 |
} |
| 4418 |
|
| 4419 |
for (j = 1; j < aasworld.numareas; j++) |
| 4420 |
{ |
| 4421 |
if (i == j) continue; |
| 4422 |
|
| 4423 |
if (AAS_ReachabilityExists(i, j)) continue; |
| 4424 |
|
| 4425 |
if (calcgrapplereach) AAS_Reachability_Grapple(i, j); |
| 4426 |
|
| 4427 |
AAS_Reachability_WeaponJump(i, j); |
| 4428 |
} |
| 4429 |
|
| 4430 |
if (Sys_MilliSeconds() - start_time > (int) reachability_delay) break; |
| 4431 |
|
| 4432 |
if (aasworld.numreachabilityareas * 1000 / aasworld.numareas > lastpercentage) break; |
| 4433 |
} |
| 4434 |
|
| 4435 |
if (aasworld.numreachabilityareas == aasworld.numareas) |
| 4436 |
{ |
| 4437 |
botimport.Print(PRT_MESSAGE, "\r%6.1f%%", (float) 100.0); |
| 4438 |
botimport.Print(PRT_MESSAGE, "\nplease wait while storing reachability...\n"); |
| 4439 |
aasworld.numreachabilityareas++; |
| 4440 |
} |
| 4441 |
|
| 4442 |
else if (aasworld.numreachabilityareas == aasworld.numareas + 1) |
| 4443 |
{ |
| 4444 |
|
| 4445 |
for (i = 1; i < aasworld.numareas; i++) |
| 4446 |
{ |
| 4447 |
|
| 4448 |
if (aasworld.areasettings[i].contents & AREACONTENTS_JUMPPAD) |
| 4449 |
{ |
| 4450 |
continue; |
| 4451 |
} |
| 4452 |
AAS_Reachability_WalkOffLedge(i); |
| 4453 |
} |
| 4454 |
|
| 4455 |
AAS_Reachability_JumpPad(); |
| 4456 |
|
| 4457 |
AAS_Reachability_Teleport(); |
| 4458 |
|
| 4459 |
AAS_Reachability_Elevator(); |
| 4460 |
|
| 4461 |
AAS_Reachability_FuncBobbing(); |
| 4462 |
|
| 4463 |
#ifdef DEBUG |
| 4464 |
botimport.Print(PRT_MESSAGE, "%6d reach swim\n", reach_swim); |
| 4465 |
botimport.Print(PRT_MESSAGE, "%6d reach equal floor\n", reach_equalfloor); |
| 4466 |
botimport.Print(PRT_MESSAGE, "%6d reach step\n", reach_step); |
| 4467 |
botimport.Print(PRT_MESSAGE, "%6d reach barrier\n", reach_barrier); |
| 4468 |
botimport.Print(PRT_MESSAGE, "%6d reach waterjump\n", reach_waterjump); |
| 4469 |
botimport.Print(PRT_MESSAGE, "%6d reach walkoffledge\n", reach_walkoffledge); |
| 4470 |
botimport.Print(PRT_MESSAGE, "%6d reach jump\n", reach_jump); |
| 4471 |
botimport.Print(PRT_MESSAGE, "%6d reach ladder\n", reach_ladder); |
| 4472 |
botimport.Print(PRT_MESSAGE, "%6d reach walk\n", reach_walk); |
| 4473 |
botimport.Print(PRT_MESSAGE, "%6d reach teleport\n", reach_teleport); |
| 4474 |
botimport.Print(PRT_MESSAGE, "%6d reach funcbob\n", reach_funcbob); |
| 4475 |
botimport.Print(PRT_MESSAGE, "%6d reach elevator\n", reach_elevator); |
| 4476 |
botimport.Print(PRT_MESSAGE, "%6d reach grapple\n", reach_grapple); |
| 4477 |
botimport.Print(PRT_MESSAGE, "%6d reach rocketjump\n", reach_rocketjump); |
| 4478 |
botimport.Print(PRT_MESSAGE, "%6d reach jumppad\n", reach_jumppad); |
| 4479 |
#endif |
| 4480 |
|
| 4481 |
|
| 4482 |
AAS_StoreReachability(); |
| 4483 |
|
| 4484 |
AAS_ShutDownReachabilityHeap(); |
| 4485 |
|
| 4486 |
FreeMemory(areareachability); |
| 4487 |
|
| 4488 |
aasworld.numreachabilityareas++; |
| 4489 |
|
| 4490 |
botimport.Print(PRT_MESSAGE, "calculating clusters...\n"); |
| 4491 |
} |
| 4492 |
else |
| 4493 |
{ |
| 4494 |
lastpercentage = aasworld.numreachabilityareas * 1000 / aasworld.numareas; |
| 4495 |
botimport.Print(PRT_MESSAGE, "\r%6.1f%%", (float) lastpercentage / 10); |
| 4496 |
} |
| 4497 |
|
| 4498 |
return qtrue; |
| 4499 |
} |
| 4500 |
|
| 4501 |
|
| 4502 |
|
| 4503 |
|
| 4504 |
|
| 4505 |
|
| 4506 |
void AAS_InitReachability(void) |
| 4507 |
{ |
| 4508 |
if (!aasworld.loaded) return; |
| 4509 |
|
| 4510 |
if (aasworld.reachabilitysize) |
| 4511 |
{ |
| 4512 |
#ifndef BSPC |
| 4513 |
if (!((int)LibVarGetValue("forcereachability"))) |
| 4514 |
{ |
| 4515 |
aasworld.numreachabilityareas = aasworld.numareas + 2; |
| 4516 |
return; |
| 4517 |
} |
| 4518 |
#else |
| 4519 |
aasworld.numreachabilityareas = aasworld.numareas + 2; |
| 4520 |
return; |
| 4521 |
#endif |
| 4522 |
} |
| 4523 |
#ifndef BSPC |
| 4524 |
calcgrapplereach = LibVarGetValue("grapplereach"); |
| 4525 |
#endif |
| 4526 |
aasworld.savefile = qtrue; |
| 4527 |
|
| 4528 |
aasworld.numreachabilityareas = 1; |
| 4529 |
|
| 4530 |
|
| 4531 |
AAS_SetupReachabilityHeap(); |
| 4532 |
|
| 4533 |
areareachability = (aas_lreachability_t **) GetClearedMemory( |
| 4534 |
aasworld.numareas * sizeof(aas_lreachability_t *)); |
| 4535 |
|
| 4536 |
AAS_SetWeaponJumpAreaFlags(); |
| 4537 |
} |