Curation round 23 (code only): the Mods menu and HUD pieces, Dogma and the Beast, Visage, Hornfel and other bosses, enemies and Entity_NPC branches, player revivals and missing methods, the player's frame, familiars, lasers, weapons and bombs, shared constants folded (115 duplicates, 385 gaps)
This commit is contained in:
1 parent
b9405bfb31
commit
11c71fe041
208 files changed
+20487
-5741
No files matched your search
@@ -39,6 +39,35 @@ static bool is_config_walking(const EntityConfig_Entity* config)
|
||||
return grid == "ground" || (grid.empty() && config->gridCollisionPoints >= 1);
|
||||
}
|
||||
|
||||
// 00823d10 Where a walking enemy can stand: the position itself when it reaches the player, else the first cell
|
||||
// centre off the walls that does, spiralling out from it for 15 rings, else the position.
|
||||
static Vector reachable_position_find(Room& room, Vector position)
|
||||
{
|
||||
constexpr int SPIRAL_RINGS = 16;
|
||||
if (is_reachable_from_player(room, {.position = position})) return position;
|
||||
|
||||
int column = (int)((position.x - GRID_ORIGIN_X) / GRID_CELL_SIZE + 0.5f);
|
||||
int row = (int)((position.y - GRID_ORIGIN_Y) / GRID_CELL_SIZE + 0.5f);
|
||||
int stepX = 0;
|
||||
int stepY = -1;
|
||||
for (int length = 1; length < SPIRAL_RINGS;)
|
||||
{
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
column += stepX;
|
||||
row += stepY;
|
||||
if (column <= 0 || row <= 0 || column >= room.gridWidth - 1 || row >= room.gridHeight - 1) continue;
|
||||
Vector cell = room.GetGridPosition(room.GetGridIndexByTile(column, row));
|
||||
if (is_reachable_from_player(room, {.position = cell})) return cell;
|
||||
}
|
||||
int turned = -stepY;
|
||||
stepY = stepX;
|
||||
stepX = turned;
|
||||
if (stepX == 0) length++;
|
||||
}
|
||||
return position;
|
||||
}
|
||||
|
||||
// 00705480 Turns an entity into one of its weaker forms from entities2.xml, drawn by weight on the room's decoration
|
||||
// seed: an enemy keeps its health share and champion and is counted with the ambush, a flying one turning into a walker
|
||||
// is moved where the players can reach. A grid form replaces it on its cell with a poof. A friendly entity, one a
|
||||
@@ -97,7 +126,7 @@ bool game_enemy_devolve(Entity& entity, Entity** outEntity)
|
||||
bool isWalking = is_config_walking(g_manager->entityConfig.GetEntity(type, variant, form.subtype));
|
||||
if (isFlying && isWalking && !is_reachable_from_player(room, {.position = entity.pos}))
|
||||
{
|
||||
reconstruction_missing("Game::DevolveEnemy 00705480: Room::find_reachable_position 00823d10");
|
||||
entity.pos = reachable_position_find(room, entity.pos);
|
||||
entity.velocity = {};
|
||||
}
|
||||
auto* devolved = static_cast<Entity_NPC*>(g_game->Spawn({.position = entity.pos,
|
||||
|
||||
Reference in new issue
Block a user