Curation round 25 (code only): the ultra horsemen and the Beast's background, the Scourge and Polty, the player's last gaps with the frame gate removed, game core, debug and daily, local co-op and player-controlled enemies, TMTRAINER, local versus, the vanilla Lua API, the special-daily fix, shared constants folded (60 duplicates, 10 offline gaps)
This commit is contained in:
1 parent
534339a496
commit
5c89798773
280 files changed
+14904
-5309
No files matched your search
+110
-43
@@ -595,63 +595,78 @@ static int line_cell_collision(Room& room, int column, int row)
|
||||
return path >= GRID_PATH_SOLID ? COLLISION_SOLID : COLLISION_NONE;
|
||||
}
|
||||
|
||||
// Whether a blast stops at a cell: walls (but an unlocked lock or a door) and solid blocks.
|
||||
static bool line_cell_is_blast_wall(Room& room, int cellIndex)
|
||||
// Whether a blast stops at a cell: walls (but an unlocked lock, a door, or a wall when walls are ignored) and solid
|
||||
// blocks. With crushables ignored, a grid entity that can be crushed or walked stops it too.
|
||||
static bool line_cell_is_blast_wall(Room& room, int cellIndex, const LineQuery& check)
|
||||
{
|
||||
uint32_t collision = room.GetGridCollision(cellIndex);
|
||||
bool isKnown = cellIndex >= 0 && cellIndex < ROOM_GRID_CELLS;
|
||||
GridEntity* grid = isKnown ? room.gridEntities[cellIndex] : nullptr;
|
||||
if (collision == COLLISION_NONE) return false;
|
||||
if (!grid) return collision == COLLISION_WALL;
|
||||
if (grid->type == GRID_ROCKB) return true;
|
||||
if (collision != COLLISION_NONE && grid->type == GRID_ROCKB) return true;
|
||||
if (grid->type == GRID_LOCK && g_game->playerManager.AnyoneHasTrinket(TRINKET_BROKEN_PADLOCK)) return false;
|
||||
return grid->type != GRID_DOOR && collision == COLLISION_WALL;
|
||||
|
||||
bool isPassable = grid->type == GRID_DOOR || (grid->type == GRID_WALL && check.isIgnoreWalls);
|
||||
if (!isPassable && collision == COLLISION_WALL) return true;
|
||||
return check.isIgnoreCrushable && (grid->IsEasyCrushableOrWalkable() || grid->IsDangerousCrushableOrWalkable());
|
||||
}
|
||||
|
||||
// Whether a band corner's collision lets a line through: with crushables ignored, a grid entity in the grid that can
|
||||
// be crushed or walked does.
|
||||
static bool line_corner_is_crushable(Room& room, int column, int row, const LineQuery& check)
|
||||
{
|
||||
bool isInside = column >= 0 && column < room.gridWidth && row >= 0 && row < room.gridHeight;
|
||||
int gridIndex = isInside ? row * room.gridWidth + column : -1;
|
||||
if (!check.isIgnoreCrushable || gridIndex < 0 || gridIndex >= ROOM_GRID_CELLS) return false;
|
||||
|
||||
GridEntity* grid = room.gridEntities[gridIndex];
|
||||
return grid && (grid->IsEasyCrushableOrWalkable() || grid->IsDangerousCrushableOrWalkable());
|
||||
}
|
||||
|
||||
// 007f0df0 Whether a line from start to end is clear, walked in steps of 10: mode 0 checks a 10 wide band for grid
|
||||
// collision and for more than 8 cells walked past their grid path threshold, mode 1 the same on the line's own cells,
|
||||
// mode 2 the line's own cells for what stops a blast, mode 3 the band for shots (which fly over pits). Crushable
|
||||
// rocks and the stop position are left to come.
|
||||
bool room_check_line(const Vector& start, const Vector& end, int mode, int gridPathThreshold)
|
||||
// mode 2 the line's own cells for what stops a blast, mode 3 the band for shots (which fly over pits), and any other
|
||||
// mode nothing. The stop position, when asked, gets the step before the line was blocked, or the end.
|
||||
bool room_check_line(const LineQuery& check)
|
||||
{
|
||||
|
||||
Room& room = *g_game->room;
|
||||
Vector step = vector_sub(start, end);
|
||||
auto stop = [&](const Vector& position, bool isClear) {
|
||||
if (check.stopPosition) *check.stopPosition = position;
|
||||
return isClear;
|
||||
};
|
||||
Vector step = vector_sub(check.start, check.end);
|
||||
float length = vector_length(step);
|
||||
if (length <= 0) return true;
|
||||
if (length <= 0) return stop(check.end, true);
|
||||
|
||||
step = vector_scale(step, LINE_STEP / length);
|
||||
auto cellOf = [](float value, float origin) {
|
||||
return (int)((value - origin) / GRID_CELL_SIZE + HALF);
|
||||
};
|
||||
int startColumn = cellOf(start.x, GRID_ORIGIN_X);
|
||||
int startRow = cellOf(start.y, GRID_ORIGIN_Y);
|
||||
int startColumn = cellOf(check.start.x, GRID_ORIGIN_X);
|
||||
int startRow = cellOf(check.start.y, GRID_ORIGIN_Y);
|
||||
bool isStartInside =
|
||||
startColumn >= 0 && startColumn < room.gridWidth && startRow >= 0 && startRow < room.gridHeight;
|
||||
int startIndex = isStartInside ? room.gridWidth * startRow + startColumn : -1;
|
||||
|
||||
int blocked = 0;
|
||||
Vector at = start;
|
||||
Vector at = check.start;
|
||||
for (float walked = 0; walked < length; walked += LINE_STEP)
|
||||
{
|
||||
at = vector_sub(at, step);
|
||||
if (mode == LINE_MODE_EXPLOSION)
|
||||
Vector before = vector_add(at, step);
|
||||
if (check.mode != LINE_MODE_GROUND && check.mode != LINE_MODE_PROJECTILE)
|
||||
{
|
||||
int column = cellOf(at.x, GRID_ORIGIN_X);
|
||||
int row = cellOf(at.y, GRID_ORIGIN_Y);
|
||||
bool isInside = column >= 0 && column < room.gridWidth && row >= 0 && row < room.gridHeight;
|
||||
int cellIndex = isInside ? row * room.gridWidth + column : -1;
|
||||
if (line_cell_is_blast_wall(room, cellIndex)) return false;
|
||||
continue;
|
||||
}
|
||||
if (mode == LINE_MODE_CELL)
|
||||
{
|
||||
int column = cellOf(at.x, GRID_ORIGIN_X);
|
||||
int row = cellOf(at.y, GRID_ORIGIN_Y);
|
||||
bool isInside = column >= 0 && column < room.gridWidth && row >= 0 && row < room.gridHeight;
|
||||
int cellIndex = isInside ? row * room.gridWidth + column : -1;
|
||||
if (room.GetGridCollision(cellIndex) != COLLISION_NONE) return false;
|
||||
if (cellIndex != startIndex && cellIndex >= 0 && room.GetGridPath(cellIndex) > gridPathThreshold) blocked++;
|
||||
if (check.mode == LINE_MODE_EXPLOSION && line_cell_is_blast_wall(room, cellIndex, check))
|
||||
return stop(before, false);
|
||||
if (check.mode != LINE_MODE_CELL) continue;
|
||||
|
||||
if (room.GetGridCollision(cellIndex) != COLLISION_NONE) return stop(before, false);
|
||||
if (cellIndex != startIndex && cellIndex >= 0 && room.GetGridPath(cellIndex) > check.gridPathThreshold)
|
||||
blocked++;
|
||||
continue;
|
||||
}
|
||||
for (const LineCorner& corner : LINE_CORNERS)
|
||||
@@ -659,17 +674,22 @@ bool room_check_line(const Vector& start, const Vector& end, int mode, int gridP
|
||||
int column = cellOf(at.x + corner.x, GRID_ORIGIN_X);
|
||||
int row = cellOf(at.y + corner.y, GRID_ORIGIN_Y);
|
||||
int collision = line_cell_collision(room, column, row);
|
||||
if (mode == LINE_MODE_PROJECTILE && collision == COLLISION_PIT) continue;
|
||||
if (collision != COLLISION_NONE) return false;
|
||||
if (check.mode == LINE_MODE_PROJECTILE && collision == COLLISION_PIT) continue;
|
||||
if (collision != COLLISION_NONE)
|
||||
{
|
||||
if (line_corner_is_crushable(room, column, row, check)) continue;
|
||||
return stop(before, false);
|
||||
}
|
||||
|
||||
bool isInside = column >= 0 && column < room.gridWidth && row >= 0 && row < room.gridHeight;
|
||||
int cornerIndex = isInside ? row * room.gridWidth + column : -1;
|
||||
if (cornerIndex == startIndex) continue;
|
||||
int path = cornerIndex >= 0 ? room.GetGridPath(cornerIndex) : 0;
|
||||
if (mode == LINE_MODE_GROUND && path > gridPathThreshold) blocked++;
|
||||
if (check.mode == LINE_MODE_GROUND && path > check.gridPathThreshold) blocked++;
|
||||
}
|
||||
}
|
||||
return blocked <= LINE_BLOCKED_MAX;
|
||||
if (blocked > LINE_BLOCKED_MAX) return stop(vector_add(at, step), false);
|
||||
return stop(check.end, true);
|
||||
}
|
||||
|
||||
// The suppression the console sets so its next spawned NPC is not rolled a champion (the original's 00c71670).
|
||||
@@ -2222,8 +2242,7 @@ bool Entity_NPC::TakeDamage(float damage, uint64_t damageFlags, const EntityRef&
|
||||
Entity_Player* player =
|
||||
attacker && attacker->type == ENTITY_PLAYER ? static_cast<Entity_Player*>(attacker) : game_nearest_player(pos);
|
||||
if (damageFlags & DAMAGE_SPAWN_FLY) player->AddBlueFlies(1, player->pos, this);
|
||||
if (!player->proceduralItems.empty())
|
||||
reconstruction_missing("Entity_NPC::TakeDamage 006d60a0: the attacker's on-hit procedural items");
|
||||
glitched_items_hit_trigger(*player, *this, CONDITION_ENEMY_HIT);
|
||||
return isHurt;
|
||||
}
|
||||
|
||||
@@ -2461,7 +2480,7 @@ Vector Entity_NPC::CalcTargetPosition(float distanceLimit)
|
||||
g_game->frameCount % CONFUSION_RETARGET_FRAMES != 0);
|
||||
if (!isKept)
|
||||
{
|
||||
float angle = random_unit() * RANDOM_HALF_TURN;
|
||||
float angle = random_unit() * PI_ROUGH;
|
||||
angle += angle;
|
||||
float scaleFirst = random_unit();
|
||||
float distance = random_unit() * scaleFirst * CONFUSION_WANDER;
|
||||
@@ -3119,18 +3138,32 @@ Vector Entity_NPC::GetControllerMovementInput(float deadzone)
|
||||
return controller_input_finish(input, deadzone);
|
||||
}
|
||||
|
||||
// 006d9050 Keeps the controlling player's last movement, or none without one.
|
||||
void Entity_NPC::UpdateControllerMovement(bool)
|
||||
// 006d9050 Keeps the controlling player's shooting input as its movement, the last one held unless forced to take
|
||||
// any (none included), or none without a player.
|
||||
void Entity_NPC::UpdateControllerMovement(bool isForceUpdate)
|
||||
{
|
||||
if (controllerID == -1)
|
||||
{
|
||||
controllerMovement = {};
|
||||
return;
|
||||
}
|
||||
reconstruction_missing("Entity_NPC::UpdateControllerMovement 006d9050");
|
||||
|
||||
Vector input = GetControllerMovementInput(MOVEMENT_DEADZONE);
|
||||
if (isForceUpdate || !vector_is_zero(input)) controllerMovement = input;
|
||||
}
|
||||
|
||||
// The rest of Entity_NPC is not reconstructed yet.
|
||||
// 006d9320 Steers it by the controlling player's walking input: the input times the acceleration and its speed
|
||||
// multiplier added to its velocity under a friction its multiplier eases, capped at a top speed.
|
||||
void Entity_NPC::apply_controller_movement(float acceleration, float drag, float maxSpeed)
|
||||
{
|
||||
float scaledDrag = drag;
|
||||
if (speedMultiplier != 1) scaledDrag = drag / (speedMultiplier + drag - speedMultiplier * drag);
|
||||
|
||||
Vector input = GetControllerInput(0);
|
||||
velocity = vector_add(vector_scale(input, acceleration * speedMultiplier), vector_scale(velocity, scaledDrag));
|
||||
float speed = vector_length(velocity);
|
||||
if (speed > maxSpeed && speed > 0) velocity = vector_scale(velocity, maxSpeed / speed);
|
||||
}
|
||||
|
||||
// 006d9440 Thrown: a poop pile flies at the throw's velocity from 20 pixels up at the throw's height, stops being kept
|
||||
// across rooms, gets the thrown flag (colliding with everything when a player threw it) and splats when fast. Other
|
||||
@@ -3330,11 +3363,38 @@ void Entity_NPC::TransferControl(Entity_NPC* target)
|
||||
controllerID = -1;
|
||||
}
|
||||
|
||||
// 006d8b20 The aim target a controlled NPC steers. Without a controller and none shown yet, there is nothing to do.
|
||||
void Entity_NPC::SpawnControlTarget(int inputMode, float)
|
||||
// 006d8b20 Shows the aim target a controlled NPC steers, turned by rotation, for two frames more: an aim target that
|
||||
// is no effect goes first. A new one (1000.30, never timing out, tinted red) appears only on the input its mode
|
||||
// watches (shooting, walking or none).
|
||||
void Entity_NPC::SpawnControlTarget(int inputMode, float rotation)
|
||||
{
|
||||
if (!aimTargetEffect && controllerID == -1 && inputMode <= 1) return;
|
||||
reconstruction_missing("Entity_NPC::SpawnControlTarget 006d8b20");
|
||||
Entity* target = aimTargetEffect;
|
||||
if (target && target->type != ENTITY_EFFECT)
|
||||
{
|
||||
target->Remove();
|
||||
aimTargetEffect = nullptr;
|
||||
target = nullptr;
|
||||
}
|
||||
|
||||
if (!target)
|
||||
{
|
||||
if (inputMode == CONTROL_INPUT_SHOOT && vector_is_zero(GetControllerMovementInput(0))) return;
|
||||
if (inputMode == CONTROL_INPUT_WALK && vector_is_zero(GetControllerInput(0))) return;
|
||||
|
||||
auto* spawned = static_cast<Entity_Effect*>(g_game->Spawn(
|
||||
{.position = pos, .spawner = this, .type = ENTITY_EFFECT, .variant = EFFECT_TARGET, .seed = Random()}));
|
||||
spawned->timeout = 0;
|
||||
spawned->lifespan = 0;
|
||||
spawned->Update();
|
||||
spawned->sprite.color = CONTROL_TARGET_COLOR;
|
||||
aimTargetEffect = spawned;
|
||||
target = spawned;
|
||||
}
|
||||
|
||||
auto& effect = static_cast<Entity_Effect&>(*target);
|
||||
effect.rotation = rotation;
|
||||
effect.varData[1] = CONTROL_TARGET_FRAMES;
|
||||
effect.varData[2] = (uint32_t)inputMode;
|
||||
}
|
||||
|
||||
// 006d8d30 Where its aim target stands, or its own position without one.
|
||||
@@ -3343,10 +3403,17 @@ Vector Entity_NPC::GetAimTargetPosition()
|
||||
return aimTargetEffect ? aimTargetEffect->pos : pos;
|
||||
}
|
||||
|
||||
// 006d8d80
|
||||
// 006d8d80 Whether the controlling player lets its aim target be: no input on the one its mode watches (always for
|
||||
// the mode watching none, the shooting input for an aim target that is no effect). Never without an aim target.
|
||||
bool Entity_NPC::is_controller_input_idle()
|
||||
{
|
||||
reconstruction_missing("Entity_NPC::is_controller_input_idle 006d8d80");
|
||||
Entity* target = aimTargetEffect;
|
||||
if (!target) return false;
|
||||
|
||||
int mode = target->type == ENTITY_EFFECT ? (int)static_cast<Entity_Effect*>(target)->varData[2] : CONTROL_INPUT_SHOOT;
|
||||
if (mode == CONTROL_INPUT_SHOOT) return vector_is_zero(GetControllerMovementInput(MOVEMENT_DEADZONE));
|
||||
if (mode == CONTROL_INPUT_WALK) return vector_is_zero(GetControllerInput(MOVEMENT_DEADZONE));
|
||||
return mode == CONTROL_INPUT_NONE;
|
||||
}
|
||||
|
||||
// 006d8e40 A controlled NPC's charge bar at value between start and end, hidden when full if asked.
|
||||
|
||||
Reference in new issue
Block a user