NiGHTS' position should be reset when touching Drone (edit: finished fix posted)

Status
Not open for further replies.

Digiku

Member
Retired Staff
Edit 3: See post #3 for fix number 3, I'm pretty much done with it.

This bug has been around since forever, still in 2.1, but NiGHTS' position should really be reset to the Drone's position when touching the Drone in order to make time attacks consistent, end-of-level presentation, to name two things.

Illustration of the bug

Expected: NiGHTS Sonic spawns at Ideya Drone's coordinates

lYw0CR4.gif


Actual: NiGHTS Sonic spawns at player's coordinates upon touching Drone hitbox

o2AWfU1.gif


One way that the bug reared its ugly head: MobjCollide Lua hook doesn't fire predictably when the player is at the edge of the Drone's hitbox. Which is weird because the player still transforms, but *shrug* (edit: might be my own code because I prevent continuous calls here -- MobjCollide does fire, but not when I'm expecting it.)

Expected: "Trans NewMare" message shows immediately when touching Drone (this happens usually)

6FlEZSr.gif


Actual: "Trans NewMare" message only shows after sinking into Drone's position for a few seconds (this happens pretty often from an upward angle, speeding fast)

J2EQXjr.gif


Test WAD: http://digimarco.freepgs.com/SRB2/test_nights-ideyapos.wad

I think that problem would be solved if NiGHTS' position was reset, but that's just my opinion. I'd really like to not ThinkFrame my way out of detecting new mares -- but regardless of Lua, it's just cleaner from a gameplay perspective to set NiGHTS' position.
 
Last edited:
:V Post edited for clarity; it helps to have a GIF of the actual behavior in question.

Edit: I did an initial patch attempt. View it here:

It "works" but it's not perfect. I'll leave this here, hoping it's a start for someone else to pick up the work.

The value is knowing where the fix should live:
  1. Player touches Drone in P_TouchSpecial. player->drone is set.
  2. P_NiGHTSMovement catches player->drone and calls new function P_MoveNiGHTSToDrone to do the position correction.
  3. P_MoveNiGHTSToDrone corrects player->mo->x/y/z to player->drone-->x/y/z. When coordinates match, player->drone is set to NULL to end the correction.
Current issues:
  • The Z variation is a lot less with this fix, but still exists. When Drone's Thing Z is 0:
    • Sonic-to-NiGHTS corrects Z to ~10 when walking into Drone, and ~20 when jumping from above Drone.
    • NiGHTS-to-NiGHTS corrects Z to ~60 both when flying from the side and from above the Drone. Versus pre-fix, where Z would be ~120 from above.
  • Currently, the correction is immediate without using momx/momy/momz to transition, because I can't figure out how to do that gracefully. I copied the position code from P_DoNiGHTSCapsule which also sucks the player into the Egg Capsule.

So I don't know if my approach is the best fix, but the good news is at least flying is consistent:

ia2v5mw.gif


GDYX2hf.gif


Edit 2: More substantial fix here: https://github.com/STJr/SRB2/compare/master...mazmazz:nights-dronepos

Positioning works consistently now. I decided to spawn NiGHTS on floor because some stages (SS1 notably) are designed for that -- but it's always consistent, that's what matters.

I had to de-couple the Drone hitbox from the bouncing NiGHTS sprite -- they're two separate mobjs now. Message me on discord if you want to know why.

Still needs momentum moving to the fixed position -- or not, if laziness is a-okay! Looks good to me as-is.
Edit 3: Fix #3 posted, https://github.com/STJr/SRB2/compare/master...mazmazz:nights-dronepos

I'm pretty much done -- I decoupled all the Drone visual elements from the hitbox, so it's made of MT_NIGHTSDRONE, MT_NIGHTSGOAL, MT_NIGHTSDRONESPARKLE, and MT_NIGHTSDRONEMAN.

MT_NIGHTSDRONE is always invisible and has no gravity, so its collision is constant. The other three's visibility are toggled as appropriate.

The player's position is corrected during its thinker. A player->drone flag triggers the position correction in P_MoveNiGHTSToDrone and prevents P_NiGHTSMovement from running (which causes player's X/Y position to bug out if run.)

Come to think of it, you could remove player->drone and P_MoveNiGHTSToDrone by just creating a new flag PF_NIGHTSERIZE and checking it before P_NiGHTSMovement. If it's there, unflag it and return early. That way, player's position can be set directly in P_TouchSpecialMobj without needing a new function, as I attempted here.

But: if you wanted momentum, you'll need the separate function. I decided I liked the direct player positioning however.
 
Last edited:
Status
Not open for further replies.

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top