| 421 | static ConsoleVariable<bool> cvar_pathing_collider_npc("/pathing_collider_npc", true); |
| 422 | int lastGeneratePathTries = 0; |
| 423 | list_t* generatePath(int x1, int y1, int x2, int y2, Entity* my, Entity* target, GeneratePathTypes pathingType, bool lavaIsPassable) |
| 424 | { |
| 425 | if ( *cvar_pathing_debug ) |
| 426 | { |
| 427 | pathtime = std::chrono::high_resolution_clock::now(); |
| 428 | if ( updatedOnTick != ticks ) |
| 429 | { |
| 430 | DebugStats.gui1 = starttime; |
| 431 | DebugStats.gui2 = {}; |
| 432 | starttime = std::chrono::high_resolution_clock::now(); |
| 433 | updatedOnTick = ticks; |
| 434 | } |
| 435 | } |
| 436 | if (!my) |
| 437 | { |
| 438 | if ( *cvar_pathing_debug ) |
| 439 | { |
| 440 | auto now = std::chrono::high_resolution_clock::now(); |
| 441 | ms = std::chrono::duration_cast<std::chrono::microseconds>(now - pathtime); |
| 442 | DebugStats.gui2 = DebugStats.gui2 + ms; |
| 443 | } |
| 444 | lastGeneratePathTries = 0; |
| 445 | return NULL; |
| 446 | } |
| 447 | |
| 448 | x1 = std::min(std::max(0, x1), (int)map.width - 1); |
| 449 | y1 = std::min(std::max(0, y1), (int)map.height - 1); |
| 450 | x2 = std::min(std::max(0, x2), (int)map.width - 1); |
| 451 | y2 = std::min(std::max(0, y2), (int)map.height - 1); |
| 452 | |
| 453 | // get levitation status |
| 454 | bool levitating = false; |
| 455 | Stat* stats = my->getStats(); |
| 456 | if ( stats ) |
| 457 | { |
| 458 | levitating = isLevitating(stats); |
| 459 | } |
| 460 | if ( my ) |
| 461 | { |
| 462 | if ( my->behavior == &actItem || my->behavior == &actArrowTrap || my->behavior == &actBoulderTrap ) |
| 463 | { |
| 464 | levitating = true; |
| 465 | } |
| 466 | } |
| 467 | |
| 468 | // for boulders falling and checking if a player can reach the ladder. |
| 469 | bool playerCheckPathToExit = (my && my->behavior == &actPlayer |
| 470 | && target && (target->behavior == &actLadder || target->behavior == &actPortal)); |
| 471 | bool playerCheckAchievement = (my && my->behavior == &actPlayer |
| 472 | && target && (target->behavior == &actBomb || target->behavior == &actPlayerLimb || target->behavior == &actItem || target->behavior == &actSwitch)); |
| 473 | |
| 474 | int* pathMap = (int*) calloc(map.width * map.height, sizeof(int)); |
| 475 | int pathMapType = GateGraph::GATE_GRAPH_GROUNDED; |
| 476 | bool waterWalking = my && my->isWaterWalking(); |
| 477 | bool lavaWalking = my && my->isLavaWalking(); |
| 478 | if ( !loading ) |
| 479 | { |
| 480 | if ( levitating || playerCheckPathToExit || waterWalking || lavaWalking ) |
no test coverage detected