Curation round 13: grid entities, more enemies, Caves, boss helpers and five bosses, chests and costumes, curses and alt stages, the Lua API
This commit is contained in:
1 parent
f8ce24fc6c
commit
8ae02a8422
160 files changed
+16231
-1689
No files matched your search
+37
-9
@@ -43,7 +43,7 @@ constexpr float EVADE_REACH_RANGE = 450;
|
||||
constexpr float EVADE_REACH_SHARE = 3;
|
||||
constexpr float EVADE_FLATTEN = 0.5f;
|
||||
constexpr float EVADE_MARGIN = 100;
|
||||
constexpr int EVADE_BAR_STEP = 10;
|
||||
constexpr float EVADE_BAR_STEP = 10;
|
||||
constexpr float EVADE_GRID_TOP = 120;
|
||||
constexpr float EVADE_SPOT_RANGE_SQUARED = 40000;
|
||||
constexpr float EVADE_PATH_SPEED = 1.079f;
|
||||
@@ -53,6 +53,8 @@ constexpr float EVADE_PATH_SPEED = 1.079f;
|
||||
constexpr uint32_t GRID_PATH_BAND = 1000;
|
||||
constexpr uint32_t GRID_PATH_PIT = 3000;
|
||||
constexpr int GRID_PATH_IMPASSABLE = 950;
|
||||
constexpr int GRID_PATH_SOLID_CELL = 1000;
|
||||
constexpr int GRID_PATH_POOP_CELL = 1500;
|
||||
constexpr int GRID_PATH_SLOWING_MAX = 949;
|
||||
constexpr int CRUSH_COST_EASY = 1;
|
||||
constexpr int CRUSH_COST_DANGEROUS = 800;
|
||||
@@ -117,7 +119,7 @@ void PathFinder::Reset()
|
||||
isPathFound = false;
|
||||
gridPathTarget = {};
|
||||
evadeMovementCountdown = 0;
|
||||
stuckFrames = 0;
|
||||
evadeBar = 0;
|
||||
evadeDistance = 0;
|
||||
visitedGridIndices.clear();
|
||||
direction = PATH_DIRECTION_NONE;
|
||||
@@ -434,18 +436,19 @@ static void evade_spot_try(PathFinder& finder, const Vector& targetPos, const Ve
|
||||
}
|
||||
|
||||
float bar = reach / EVADE_REACH_SHARE + distance + EVADE_MARGIN + finder.evadeDistance;
|
||||
bar -= (float)finder.stuckFrames;
|
||||
bar -= finder.evadeBar;
|
||||
if (bar <= vector_length(vector_sub(targetPos, center)))
|
||||
{
|
||||
finder.movementTarget = center;
|
||||
if (finder.evadeDistance < EVADE_WIDE) finder.evadeDistance *= 0.5f;
|
||||
}
|
||||
finder.stuckFrames += EVADE_BAR_STEP;
|
||||
finder.evadeBar += EVADE_BAR_STEP;
|
||||
}
|
||||
|
||||
// 007e4940 Flees targetPos: within 250 of it (170 out of its walking sight) it keeps evading for 3 more checks of
|
||||
// every 14 frames, pushing away and seeking a cell to run to that lies well away from the target, and it wanders
|
||||
// once the evasion runs out. A friendly owner paths to its target instead. stuckFrames holds the bar a spot must clear.
|
||||
// once the evasion runs out. A friendly owner paths to its target instead. evadeBar lowers the bar each candidate
|
||||
// spot must clear.
|
||||
void PathFinder::EvadeTarget(const Vector& targetPos, StatusMode mode)
|
||||
{
|
||||
if (mode == STATUS_OBEYED && is_entity_friendly())
|
||||
@@ -470,7 +473,7 @@ void PathFinder::EvadeTarget(const Vector& targetPos, StatusMode mode)
|
||||
if (is_evade_check_frame(*entity, EVADE_FORGET_FRAMES)) visitedGridIndices.clear();
|
||||
if (evadeMovementCountdown < 1)
|
||||
{
|
||||
stuckFrames = 0;
|
||||
evadeBar = 0;
|
||||
evadeDistance *= EVADE_DECAY;
|
||||
MoveRandomly(STATUS_IGNORED);
|
||||
entity->friction *= EVADE_DECAY;
|
||||
@@ -568,10 +571,35 @@ void PathFinder::update_chase_movement()
|
||||
reconstruction_missing("PathFinder::update_chase_movement 007e6b90");
|
||||
}
|
||||
|
||||
// 007e7070
|
||||
bool PathFinder::HasPathToPos(const Vector&, bool)
|
||||
// 007e7070 Whether the owner can walk to a position: a flood from its cell over the walkable cells (and poop, when
|
||||
// asked) reaches the owner's cell within half the room's cells. An owner standing in a solid cell cannot.
|
||||
bool PathFinder::HasPathToPos(const Vector& position, bool isIgnorePoop)
|
||||
{
|
||||
reconstruction_missing("PathFinder::HasPathToPos 007e7070");
|
||||
Room& room = *g_game->room;
|
||||
int start = room.GetGridIndex(entity->pos);
|
||||
if (start >= 0 && room.gridPaths[start] == GRID_PATH_SOLID_CELL) return false;
|
||||
|
||||
std::array<int, PATH_GRID_CELLS> costs = room.gridPaths;
|
||||
std::queue<PathNode> open;
|
||||
open.push({room.GetGridIndex(position), 0});
|
||||
while (!open.empty())
|
||||
{
|
||||
PathNode node = open.front();
|
||||
if (node.cost >= room.gridWidth * room.gridHeight / 2) return false;
|
||||
open.pop();
|
||||
|
||||
for (int next : grid_neighbors_get(room, node.gridIndex))
|
||||
{
|
||||
if (next < 0) continue;
|
||||
bool isWalkable = costs[next] >= 0 && costs[next] < GRID_PATH_IMPASSABLE;
|
||||
if (!isWalkable && !(isIgnorePoop && costs[next] == GRID_PATH_POOP_CELL)) continue;
|
||||
|
||||
costs[next] = -(node.cost + 1);
|
||||
if (next == start) return true;
|
||||
open.push({next, node.cost + 1});
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// 007e8010
|
||||
|
||||
Reference in new issue
Block a user