SRB2 Message Board  

Go Back   SRB2 Message Board > Archived > SRB2 Forum Archives > Bug Reports (2.1.X)

Thread Tools Search this Thread
Old 02-25-2018   #1
Default NiGHTS' position should be reset when touching Drone (edit: finished fix posted)

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

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

Spoiler: Irrelevant stuff
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)

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)

Test 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 by Digiku; 03-12-2018 at 11:54 AM. Reason: Fix #3
Digiku is offline  
Old 02-25-2018   #2
Ritz's Avatar

Ritz is offline  
Old 02-25-2018   #3

: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:

Edit 2: More substantial fix here:

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,

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 by Digiku; 03-12-2018 at 11:53 AM. Reason: Patch attempt #3
Digiku is offline  
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 01:00 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.