Curation round 16: Mom's Knife and the bone club, sin minibosses and death rewards, slots and beggars, NPC rendering and twelve bosses, alt path visuals, the Forgotten's flight and tainted HUDs, Sheol and the Cathedral to the credits, familiars and transformations
This commit is contained in:
1 parent
76c594f9a0
commit
e9de039d0f
151 files changed
+14996
-5208
No files matched your search
+109
-8
@@ -1,5 +1,6 @@
|
||||
#include "homing_laser.h"
|
||||
#include "boss_ai.h"
|
||||
#include "entity_familiar.h"
|
||||
#include "entity_laser.h"
|
||||
#include "entity_player.h"
|
||||
#include "entity_tear.h"
|
||||
@@ -16,6 +17,15 @@ constexpr float SMOOTHING_FULL_LENGTH = 200;
|
||||
constexpr float PLAYER_CUT_DISTANCE_SQUARED = 100;
|
||||
constexpr uint32_t PLAYER_CUT_FIRST_SAMPLE = 2;
|
||||
constexpr float GRID_HALF_CELL = GRID_CELL_SIZE / 2;
|
||||
constexpr float OBSTACLE_MARGIN = 20;
|
||||
|
||||
// A hunting path: 40 long steps turned 0.3 toward the nearest target, up to 25 points, smoothed at 0.4. A path shorter
|
||||
// than 0.1 does not hunt.
|
||||
constexpr float HUNT_STEP = 40;
|
||||
constexpr float HUNT_TURN = 0.3f;
|
||||
constexpr size_t HUNT_MAX_POINTS = 25;
|
||||
constexpr float HUNT_TENSION = 0.4f;
|
||||
constexpr float HUNT_MIN_LENGTH_SQUARED = 0.01f;
|
||||
|
||||
// A point on the cubic curve from one bezier point to the next, t from 0 to 1.
|
||||
static Vector bezier_evaluate(const BezierPoint& from, const BezierPoint& to, float t)
|
||||
@@ -101,8 +111,63 @@ LineCheck room_line_check(const Vector& from, const Vector& to, int gridCollisio
|
||||
return {progress < 1 ? position : to, progress >= 1};
|
||||
}
|
||||
|
||||
// The entities a homing path bends toward: vulnerable enemies (of another type than the source for that path type),
|
||||
// a versus rival's punching bag, and the players too for a path that hits them.
|
||||
static std::vector<Entity*> homing_targets_get(BezierPathType pathType, Entity* source)
|
||||
{
|
||||
std::vector<Entity*> targets;
|
||||
for (Entity* entity : g_game->room->entityList.updateEL)
|
||||
{
|
||||
bool isTarget = entity->IsVulnerableEnemy(nullptr) && !entity->HasEntityFlags(FLAG_FRIENDLY | FLAG_NO_TARGET) &&
|
||||
entity != source && !(pathType == BEZIER_PATH_OTHER_TYPES && entity->type == source->type);
|
||||
bool isRivalBag = g_game->deathmatchManager.is_active() && entity->type == ENTITY_FAMILIAR &&
|
||||
entity->variant == Entity_Familiar::PUNCHING_BAG &&
|
||||
!entity->IsDescendantOf(source->spawnerEntity);
|
||||
if (isTarget || isRivalBag) targets.push_back(entity);
|
||||
if (pathType == BEZIER_PATH_WITH_PLAYERS && entity->type == ENTITY_PLAYER && entity != source)
|
||||
targets.push_back(entity);
|
||||
}
|
||||
return targets;
|
||||
}
|
||||
|
||||
// A path that hunts its way from its origin through the room: 40 long steps, each turned toward the nearest target
|
||||
// (more so the more it already faces it), until it leaves the room or has 25 points.
|
||||
static void homing_hunt(HomingLaser& path, const std::vector<Entity*>& targets)
|
||||
{
|
||||
Vector heading = vector_sub(path.bezier.back().point, path.bezier.front().point);
|
||||
if (vector_length_squared(heading) < HUNT_MIN_LENGTH_SQUARED) return;
|
||||
|
||||
path.bezier.pop_back();
|
||||
while (!targets.empty())
|
||||
{
|
||||
Vector last = path.bezier.back().point;
|
||||
Entity* nearest = nullptr;
|
||||
float best = INFINITY;
|
||||
for (Entity* target : targets)
|
||||
{
|
||||
float distance = vector_length_squared(vector_sub(last, target->pos));
|
||||
if (distance >= best) continue;
|
||||
nearest = target;
|
||||
best = distance;
|
||||
}
|
||||
if (!nearest) break;
|
||||
|
||||
Vector toward = vector_normalized(vector_sub(nearest->pos, last));
|
||||
float facing = (vector_dot(vector_normalized(heading), toward) + 1) * BEZIER_HALF;
|
||||
size_t count = path.bezier.size();
|
||||
if (count > 1) heading = vector_sub(path.bezier[count - 1].point, path.bezier[count - 2].point);
|
||||
heading = vector_normalized(vector_add(vector_normalized(heading), vector_scale(toward, HUNT_TURN * facing)));
|
||||
|
||||
Vector next = vector_add(last, vector_scale(heading, HUNT_STEP));
|
||||
path.bezier.push_back({next, {}, {}});
|
||||
if (!g_game->room->IsPositionInRoom(next, 0) || path.bezier.size() >= HUNT_MAX_POINTS) break;
|
||||
}
|
||||
path.compute_bezier_handles(HUNT_TENSION);
|
||||
}
|
||||
|
||||
// 0099c790 Lays out the path's bezier points: a straight one from the origin to the end unless some are already
|
||||
// there. The homing paths and Eye of the Occult's bend are not reconstructed yet.
|
||||
// there, then for a path that hits players one hunting its targets. Eye of the Occult's bend and the homing and
|
||||
// other types' bends toward their targets are not reconstructed yet.
|
||||
void HomingLaser::build_bezier_path(BezierPathType pathType, Entity* source)
|
||||
{
|
||||
if (bezier.empty())
|
||||
@@ -112,11 +177,14 @@ void HomingLaser::build_bezier_path(BezierPathType pathType, Entity* source)
|
||||
bezier.push_back({endPoint, middle, endPoint});
|
||||
}
|
||||
|
||||
std::vector<Entity*> targets;
|
||||
if (pathType != BEZIER_PATH_STRAIGHT) targets = homing_targets_get(pathType, source);
|
||||
Entity_Laser* laser = owner && owner->type == ENTITY_LASER ? static_cast<Entity_Laser*>(owner) : nullptr;
|
||||
if (laser && laser->tearFlags[TEAR_OCCULT])
|
||||
reconstruction_missing("HomingLaser::build_bezier_path 0099c790: Eye of the Occult's bend");
|
||||
if (pathType != BEZIER_PATH_STRAIGHT && source)
|
||||
if (pathType == BEZIER_PATH_HOMING || pathType == BEZIER_PATH_OTHER_TYPES)
|
||||
reconstruction_missing("HomingLaser::build_bezier_path 0099c790: a homing path");
|
||||
if (pathType == BEZIER_PATH_WITH_PLAYERS && bezier.size() == 2) homing_hunt(*this, targets);
|
||||
}
|
||||
|
||||
// 0099e360 Samples the bezier path evenly along its length, then eases the kept samples toward them: a ring all at
|
||||
@@ -301,10 +369,32 @@ void HomingLaser::compute_axis_bezier_handles()
|
||||
reconstruction_missing("HomingLaser::compute_axis_bezier_handles 0099dca0");
|
||||
}
|
||||
|
||||
// 0099e160
|
||||
void HomingLaser::compute_bezier_handles(float)
|
||||
// 0099e160 Smooths the path: each point's handles lie along the line from its neighbours, scaled by the tension
|
||||
// (halved between two neighbours). A path ending where it started (three points or more) wraps around.
|
||||
void HomingLaser::compute_bezier_handles(float tension)
|
||||
{
|
||||
reconstruction_missing("HomingLaser::compute_bezier_handles 0099e160");
|
||||
if (bezier.empty()) return;
|
||||
|
||||
size_t last = bezier.size() - 1;
|
||||
bool isClosed = vector_length_squared(vector_sub(bezier[last].point, bezier[0].point)) < HUNT_MIN_LENGTH_SQUARED &&
|
||||
bezier.size() >= 3;
|
||||
for (size_t i = 0; i <= last; i++)
|
||||
{
|
||||
Vector previous{};
|
||||
Vector next{};
|
||||
if (isClosed && i == 0) previous = vector_sub(bezier[0].point, bezier[last - 1].point);
|
||||
else
|
||||
{
|
||||
if (isClosed && i == last) next = vector_sub(bezier[1].point, bezier[i].point);
|
||||
if (i != 0) previous = vector_sub(bezier[i].point, bezier[i - 1].point);
|
||||
}
|
||||
if (i < last) next = vector_sub(bezier[i + 1].point, bezier[i].point);
|
||||
|
||||
Vector handle = vector_scale(vector_add(previous, next), tension);
|
||||
if (isClosed || (i != 0 && i < last)) handle = vector_scale(handle, BEZIER_HALF);
|
||||
bezier[i].handleIn = vector_sub(bezier[i].point, handle);
|
||||
bezier[i].handleOut = vector_add(bezier[i].point, handle);
|
||||
}
|
||||
}
|
||||
|
||||
// 0099ec00
|
||||
@@ -325,10 +415,21 @@ void HomingLaser::build_wiggle_bezier()
|
||||
reconstruction_missing("HomingLaser::build_wiggle_bezier 0099fed0");
|
||||
}
|
||||
|
||||
// 009a0c50
|
||||
void HomingLaser::truncate_samples_at_obstacle(const Vector&)
|
||||
// 009a0c50 Cuts the path at the first segment past the first that a wall or obstacle stops, the stop taking the
|
||||
// place of the segment's start.
|
||||
void HomingLaser::truncate_samples_at_obstacle(const Vector& offset)
|
||||
{
|
||||
reconstruction_missing("HomingLaser::truncate_samples_at_obstacle 009a0c50");
|
||||
for (size_t i = 1; i + 1 < samples.size(); i++)
|
||||
{
|
||||
Vector start = samples[i];
|
||||
Vector segment = vector_sub(samples[i + 1], start);
|
||||
Vector stop = Entity_Laser::CalculateEndPoint(start, vector_normalized(segment), offset, nullptr, OBSTACLE_MARGIN);
|
||||
if (vector_length_squared(vector_sub(start, stop)) >= vector_length_squared(segment)) continue;
|
||||
|
||||
samples[i] = stop;
|
||||
samples.resize(i + 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 009a0fa0
|
||||
|
||||
Reference in new issue
Block a user