duckfist / MM2Random

Mega Man 2 Randomizer
31 stars 7 forks source link

Mitigate bubble man boss room glitches #141

Closed duckfist closed 5 years ago

duckfist commented 6 years ago

It's too easy to accidentally zip out of the room upon defeating the boss - this is due to some glitch with the water mechanics, where the water becomes "solid" if there's too much lag when the boss fight ends, and if you're facing left when this happens, you can zip out of the room and die before the win is counted and end up in a glitched version of wily 4.

Possible mitigations:

BrooklynS commented 6 years ago

I've been noodling around with this one for the past few days and got it with both crash and bubble in bubble's room.

After narrowing things down, it seems whatever modifications were to FA10 - FAE0 can cause this to happen, coming from mm2rng_prepatch.ips. When I swap this block out with original MM, I haven't gotten the zip or fallen through the floor.

I'm not familiar enough to know what this block of data is for, but it seems to affect some of the collisions in the room? (Filling it with junk lets me and bubble man walk into the boss door).

duckfist commented 6 years ago

Looks like FA1x-FAEx is a table of sprites/objects used in Bubble Man stage. These bytes were changed in the prepatch when I removed sprites related to the "Angler" enemies, using the editor Visine. If I didn't explicitly screw this up, perhaps the editor induced some unexpected artifacts when I removed these objects and saved it.

The sequence at FA10 is the screen number that the object appears in. Note that "09" is the room with the first angler, "0E", is the screen with the 2nd angler. "15" is the boss room. You were able to mess with the boss room door because the two sprites representing it are listed here; notice the two "15" values. Keep in mind that Wily 4 begins after Bubble, which is why there are screens past "15".

The sequences at FA50 and FA90 are the X and Y positions of the objects, I think.

The sequence at FAD0 is the object type. Here are some of the relevant object types occurring around here:

11 - Angler "Palette Activator" 02 - Shrink (spawner) 0F - Angler (weak spot, the "lure") 10 - Angler body? 2F - Boss Door

Something I did notice, though, is that the objects are unsorted - at FA10 (screen numbers) in vanilla, enemies are listed in order from left-to-right for each screen throughout the stage. In the prepatch, this number jumps around a bit. I recall the Visine readme suggesting to resort the objects if things are added and deleted - perhaps me forgetting to resort objects can cause this issue? Or maybe removing one of these objects relating to the Angler causes it?

The first thing I'd try is resorting the objects. I'm not quite ready to dive deeper yet, so feel free to take a crack at it. Good job finding this clue.

BrooklynS commented 6 years ago

Your analysis is spot on, it's Room, X/Ys, then object id.

So it looks like the change was to delete the angler stuff and shift everything up. The weird part is that after the delete and shift there was some duplication of the Wily info. Rooms 16 - 26 are duplicated, with one Room 16 getting replaced with an FF but having the same X/Y and object value as original.

But, even after manually clearing out the Wily duplicates and sorting by Room#, I still was able to get the zip. But since this was manual editing, I could have made some mistakes in updating the block so could be inconclusive.

However, I reverted to the vanilla block, and FF'd the 09 & 0E (FA10 - FA19) rooms and their associated X/Y and object numbers (since we're trying to delete all the angler related stuff). So instead of deleting and shifting, I just FFd the angler stuff out and left everything in their vanilla spots. Didn't see angler the angler palate shifting in those rooms, so that seemed to at least delete the angler.

So far with this change, after about 50 tries, no zip. This bug is tricky though, because I could go like 20 times and not zip, and then hit it a bunch of times in a row.

I'll keep digging around. I dunno enough about the object processing to know if FFing those guys is legitimate, especially if game is looking for something sorted. Boss doors still seemed to work fine, but I haven't looked at Wily4 to see if it had any effect yet.

I'd also want to know if maybe there's something looking at those specific addresses. Seems like a delete and shift should work here, but who knows?

BrooklynS commented 6 years ago

Alright, I spent some more time digging. Learned a bit more about objects and collision checking in the process, but still don't have a good answer why the delete and shift didn't work.

I tried editing that level using a RM2 level editor, and it produced the exact same output you had from Visine. When deleting and saving, it just overwrites the old data and puts an FF as room number at the end of the list which I guess kind of makes sense.

After digging some more, something about the boss door in that room ends up somehow causing the zip to happen. Eliminating just the boss door (FFing the 15's) eliminated the zip. But that's not a good fix since you'd still want the boss door object around to keep boss and you from going into it. Something happens to the objects when the boss dies. I ended up seeing some weirdness around like the object "being alive" flags ($140 - $15F), which gets propagated to another set of addresses and gets hard to follow, so I'm not exactly sure.

Long story short, I've got a potential fix. I don't know the "why" behind it, which is a little unsettling. But the workaround I found was to just maintain the layout of the of the old objects in memory. I took the 10 spots where the angler related data were, and filled them with useless stuff. In the iteration I tested most heavily, I put 10 objects at Room 0, X 0, Y 0, Type 0E [looks like a bubble?]. At this spot, you can't even see them. With that change, I did about 100 tries with no zip or fall through floor. Wily4 objects were all still good too.

So with that said, just let me know if you want me to do anything else. I can kick up a PR with a new ips, or leave it for you to fix later, or whatever.

Are there any other issues on the backlog you wouldn't mind me taking a stab at?

duckfist commented 5 years ago

Sort of fixed it by speeding up the fanfare sequence. 79133a099c5d1bb304d5ab751169a0adda948fcf