Curation round 20: player update, costumes and render, Missing No., the last actives and cards, familiars, Pin, the Frail, Wormwood and the Heretic, Dross to Gehenna, effects and the devil room purchase, champion colours, the quit path, save fields, shared vector helpers
This commit is contained in:
1 parent
ee863e70e6
commit
8dbeb1bc4a
168 files changed
+15682
-2399
No files matched your search
+68
-3
@@ -831,8 +831,73 @@ bool PathFinder::HasPathToPos(const Vector& position, bool isIgnorePoop)
|
||||
return false;
|
||||
}
|
||||
|
||||
// 007e8010
|
||||
void PathFinder::SimulatePlayerMovement(const Vector&, float)
|
||||
// 007e8010 Moves its owner as a player walks with that input, in two half steps: the input (capped at 1, without its
|
||||
// vertical part for a falling grounded owner) scales with speed into the move direction and the way it faces, the
|
||||
// velocity across it fades, it accelerates up to speed * 4.41 and is damped, more slowly while the slippery countdown
|
||||
// lasts. A falling grounded owner keeps falling instead of being damped vertically.
|
||||
void PathFinder::SimulatePlayerMovement(const Vector& input, float speed)
|
||||
{
|
||||
reconstruction_missing("PathFinder::SimulatePlayerMovement 007e8010");
|
||||
constexpr int SLIPPERY_COUNTDOWN = 60;
|
||||
constexpr float INPUT_SPEED_SHARE = 0.25f;
|
||||
constexpr float FALL_PULL = 0.225f;
|
||||
constexpr float MAX_SPEED_PER_SPEED = 4.41f;
|
||||
constexpr float PUSH_DRY = -0.2f;
|
||||
constexpr float PUSH_SLIPPERY = 0.5f;
|
||||
constexpr float DRAG_DRY = 0.775f;
|
||||
constexpr float DRAG_SLIPPERY = 0.96f;
|
||||
constexpr float KEEP_DRY = 0.8f;
|
||||
constexpr float ACCEL_BASE = 3;
|
||||
constexpr float ACCEL_SCALE = 0.4f;
|
||||
constexpr float ACCEL_SLIPPERY_SHARE = 0.25f;
|
||||
auto lerp = [](float from, float to, float t) {
|
||||
return from + (to - from) * t;
|
||||
};
|
||||
|
||||
bool isFalling = entity->HasEntityFlags(FLAG_APPLY_GRAVITY) && entity->entityGridCollisionClass == GRIDCOLL_GROUND;
|
||||
Vector walk = vector_make(input.x, isFalling ? 0 : input.y);
|
||||
float length = vector_length(walk);
|
||||
if (length > 1 && length > 0) walk = vector_make(input.x * (1 / length), walk.y * (1 / length));
|
||||
float scale = speed * INPUT_SPEED_SHARE + (1 - INPUT_SPEED_SHARE);
|
||||
moveDirection = vector_make(scale * walk.x, scale * walk.y);
|
||||
|
||||
if (std::fabs(moveDirection.x) > std::fabs(moveDirection.y))
|
||||
direction = moveDirection.x >= 0 ? PATH_DIRECTION_RIGHT : PATH_DIRECTION_LEFT;
|
||||
else if (moveDirection.y < 0) direction = PATH_DIRECTION_UP;
|
||||
else direction = moveDirection.y > 0 ? PATH_DIRECTION_DOWN : PATH_DIRECTION_NONE;
|
||||
|
||||
if (entity->HasEntityFlags(FLAG_SLIPPERY_PHYSICS)) moveCountdown = SLIPPERY_COUNTDOWN;
|
||||
else moveCountdown = std::max(moveCountdown - 1, 0);
|
||||
float slippery = entity->HasEntityFlags(FLAG_SLOW) ? 0 : (float)moveCountdown / SLIPPERY_COUNTDOWN;
|
||||
float pushShare = lerp(PUSH_DRY, PUSH_SLIPPERY, slippery);
|
||||
float damping = std::sqrt(lerp(DRAG_DRY, DRAG_SLIPPERY, slippery));
|
||||
float maxSpeed = speed * MAX_SPEED_PER_SPEED;
|
||||
Vector half = vector_scale(entity->velocity, 0.5f);
|
||||
|
||||
for (int step = 0; step < 2; step++)
|
||||
{
|
||||
bool isMoving = moveDirection.x != 0 || moveDirection.y != 0;
|
||||
if (isMoving && !isFalling)
|
||||
{
|
||||
float along = half.y * moveDirection.y + half.x * moveDirection.x;
|
||||
Vector kept = vector_make(along * moveDirection.x, along * moveDirection.y);
|
||||
float keep = std::sqrt(lerp(KEEP_DRY, 1, slippery));
|
||||
half = vector_make((half.x - kept.x) * keep + kept.x, (half.y - kept.y) * keep + kept.y);
|
||||
}
|
||||
Vector before = half;
|
||||
|
||||
float push = pushShare * (half.y * moveDirection.y + half.x * moveDirection.x);
|
||||
float accel = ((push > 0 ? push : 0) / speed + ACCEL_BASE) * ACCEL_SCALE;
|
||||
accel = (accel * ACCEL_SLIPPERY_SHARE - accel) * slippery + accel;
|
||||
half = vector_make(half.x + moveDirection.x * 0.5f * accel, half.y + moveDirection.y * 0.5f * accel);
|
||||
|
||||
float lengthSquared = half.x * half.x + half.y * half.y;
|
||||
if (slippery > 0 && lengthSquared > maxSpeed * maxSpeed)
|
||||
{
|
||||
float moved = std::sqrt(lengthSquared);
|
||||
if (moved > 0) half = vector_scale(half, vector_length(before) / moved);
|
||||
}
|
||||
half.x *= damping;
|
||||
half.y = isFalling ? half.y + FALL_PULL : half.y * damping;
|
||||
}
|
||||
entity->velocity = vector_make(half.x + half.x, half.y + half.y);
|
||||
}
|
||||
Reference in new issue
Block a user