Actions

SCHG How-to

Fix bug in ARZ Boss arrow's platform behavior

From Sonic Retro

(Original guide by MoDule)

(Additional step by redhotsonic)

In Sonic 2 there is a bug in ARZ's Boss. The arrows it shoots that act as platforms can temporarily cause the walking in air glitch if the player is fast enough and walks over the edge of the arrow.

This guide will show how to fix this bug.

Fixing the bug

Locate the label loc_30CCC. It should look something like this:

loc_30CCC:
	tst.w	objoff_30(a0)	; has timer been set?
	bne.s	+		; if yes, branch

	move.w	#$1B,d1
	move.w	#1,d2
	move.w	#2,d3
	move.w	x_pos(a0),d4
	bsr.w	JmpTo8_PlatformObject

	btst	#3,status(a0)	; is Main character standing on the arrow?
	beq.s	return_30D02	; if not, branch
	move.w	#$1F,objoff_30(a0)	; set timer
+
	subi.w	#1,objoff_30(a0)	; decrement timer
	bne.s	return_30D02
	; make arrow fall when timer runs out
	move.b	#6,objoff_2A(a0)

return_30D02:
	rts

Now move the following block to the top, under the first label:

	move.w	#$1B,d1
	move.w	#1,d2
	move.w	#2,d3
	move.w	x_pos(a0),d4
	bsr.w	JmpTo8_PlatformObject

Now Sonic can walk off the arrows properly.

Optional next step

Sonic will use his balancing animation when standing on an arrow. If this is undesirable, this next part will show how to change this behavior.

Locate the label loc_30BC8. It should look something like this:

loc_30BC8:
	move.l	#Obj89_MapUnc_30D68,mappings(a0)
	move.w	#make_art_tile(ArtTile_ArtNem_ARZBoss,0,0),art_tile(a0)
	ori.b	#4,render_flags(a0)
	move.b	#-$70,mainspr_width(a0)
	[...]

Although that last line seems to already set a width, it doesn't. Adding this underneath

	move.b	#$10,width_pixels(a0)

seems to work well.

The bug explained

The first part of the bug comes from the arrow object running its platform checks only once. The reason why the check is only run once is because the arrow's platform routine checks if the countdown timer is set first. If it is it skips the code that checks if Sonic is standing on the arrow and initializes the timer. By skipping any further platform checks, Sonic's on-object bit never gets cleared, which causes the walking in air bug.

The second part, where Sonic uses his balancing animation no matter how far he is from the arrow's edge comes from the arrow object not assigning a value to its width_pixels. Now when Sonic's object checks for his distance to the object's edge it will think he's always right at the edge or beyond thus triggering his balancing animation.


Additional step

You've fixed the two bugs in the ARZ boss now, but there is still TWO more bugs in existence. It's actually very similar to the balancing bug on the arrows, except his time, on the poles itself. Noticed that when you jump on top of the poles, Sonic does his balancing act all the time (unless you're hogging the side of the screen)? Also, if you jump and land on the pole, you actually fall though and land on the floor (unless again, you're hogging the side of the screen). Well, I'm about to show you how to fix that, and it's very easy.

Locate the label loc_304D4. This is all the information stored for Eggman like his collision property and his hit counter, etc. But locate the width_pixels(a1) line.

loc_304D4:
	[...] ;a lot of coding above this, but look further below
	move.l	#Obj89_MapUnc_30D68,mappings(a1)
	ori.b	#4,render_flags(a1)
	move.w	#$3E0,art_tile(a1)
	move.b	#$10,width_pixels(a1) ; This is the bit we're about to edit
	move.b	#4,priority(a1)
	move.w	#$2A50,x_pos(a1)
	[...]

At the moment, it is set to 10. Set it to 1E instead, so you have this:

loc_304D4:
	[...] ;a lot of coding above this, but look further below
	move.l	#Obj89_MapUnc_30D68,mappings(a1)
	ori.b	#4,render_flags(a1)
	move.w	#$3E0,art_tile(a1)
	move.b	#$1E,width_pixels(a1) ; Fix's sonic balancing bug on top of polls
	move.b	#4,priority(a1)
	move.w	#$2A50,x_pos(a1)
	[...]

Now, Sonic won't do his balancing act unless on the very edge of the pole. Same with jumping, he will now land and stay on the pole unless you jumped on the very edge.


Additional bug explained

I'm not totally sure why he does it, but I can take a guess. In MoDule's fix for the arrow balancing bug, adding 10 to the width fixes the arrows, so my only guess is that this command that's already set to 10 are originally for the arrows, but it actually effects the poles. Making it 1E set's the width longer (obviously), so he won't trigger his balancing act until near the edge, which is what we want.

See Also

There is another unrelated flaw in this boss' design. Check it out here.

SCHG How-To Guide: Sonic the Hedgehog 2 (16-bit)
Fixing Bugs
Fix Demo Playback | Fix a Race Condition with Pattern Load Cues | Fix Super Sonic Bugs | Use Correct Height When Roll Jumping | Fix Jump Height Bug When Exiting Water | Fix Spin Dash Code and Add Spin Dash Speeds | Fix Screen Boundary Spin Dash Bug | Correct Drowning Bugs | Fix Camera Y Position for Tails | Fix Tails Subanimation Error | Fix Tails' Respawn Speeds | Fix Accidental Deletion of Scattered Rings | Fix Ring Timers | Fix Rexon Crash | Fix Monitor Collision Bug | Fix EHZ Deformation Bug | Correct CPZ Boss Attack Behavior | Fix Bug in ARZ Boss Arrow's Platform Behavior | Fix ARZ Boss Walking on Air Glitch | Fix ARZ Boss Sprite Behavior | Fix Multiple CNZ Boss Bugs | Fix HTZ Background Scrolling Mountains | Fix OOZ Launcher Speed Up Glitch | Fix DEZ Giant Mech Collision Glitch | Fix Boss Deconstruction Behavior | Fix Speed Bugs
Design Choices
Remove the Air Speed Cap | Disable Floor Collision While Dying | Modify Super Sonic Transformation Methods & Behavior | Enable/Disable Tails in Certain Levels | Collide with Water After Being Hurt | Retain Rings When Returning at a Star Post | Improve the Fade In\Fade Out Progression Routines | Fix Scattered Rings' Underwater Physics | Insert LZ Water Ripple Effect | Restore Lost CPZ Boss Feature | Prevent SCZ Tornado Spin Dash Death | Improve ObjectMove Subroutines | Port S3K Rings Manager | Port S3K Object Manager | Port S3K Priority Manager | Edit Level Order with ASM‎ | Alter Ring Requirements in Special Stages | Make Special Stage Characters Use Normal DPLCs | Speed Up Ring Loss Process | Add beta spindash to Sonic 2 | Change spike behaviour in Sonic 2
Adding Features
Create Insta-kill and High Jump Monitors | Create Clone and Special Stage Monitors | Port Knuckles
Sound Features
Port Sonic 1 Sound Driver | Port Sonic 2 Clone Driver | Port Sonic 3 Sound Driver | Expand the Music Index to Start at $00 (Sonic 2 Clone Driver Version)
Extending the Game
Extend the Level Index Past $10 | Extend the Level Select | Extend Water Tables | Add Extra Characters | Free Up 2 Universal SSTs