Actions

SCHG How-to

Difference between revisions of "Add a Homing Attack in Sonic 3 and Knuckles"

From Sonic Retro

Line 20: Line 20:
 
;loc_119F6:
 
;loc_119F6:
 
Sonic_InstaShield:
 
Sonic_InstaShield:
btst #Status_Shield,status_secondary(a0) ; does Sonic have an S2 shield (The Elementals were already filtered out at this point)?
+
                btst #Status_Shield,status_secondary(a0) ; does Sonic have an S2 shield (The Elementals were already filtered out at this point)?
 
+
                bne.w locret_11A14 ; if yes, branch
bne.w locret_11A14 ; if yes, branch
+
                btst #Status_FireShield,status_secondary(a0) ; does Sonic have a Homing Attack?
 
+
                move.b #0,(Shield+anim).w
btst #Status_FireShield,status_secondary(a0) ; does Sonic have a Homing Attack?
+
                move.b #1,double_jump_flag(a0)
 
+
                move.w $650.d0
move.b #0,(Shield+anim).w
+
                btst #Status_Facing,status(a0) ; is Sonic facing left?
 
+
                beq.s loc_11958 ; if not, branch
move.b #1,double_jump_flag(a0)
+
                neg.w d0 ; reverse speed value, moving Sonic left
 
 
move.w $650.d0
 
 
 
btst #Status_Facing,status(a0) ; is Sonic facing left?
 
 
 
beq.s loc_11958 ; if not, branch
 
 
 
neg.w d0 ; reverse speed value, moving Sonic left
 
  
 
loc_11958:
 
loc_11958:
  
move.w d0,x_vel(a0) ; apply velocity...
+
                move.w d0,x_vel(a0) ; apply velocity...
 
+
                move.w d0,ground_vel(a0) ; ... both ground and air
move.w d0,ground_vel(a0) ; ... both ground and air
+
                move.w #0.y_vel(a0) ; kill y-velocity
 
+
                move.w .$2000,(H_scroll_frame_offset).w
move.w #0.y_vel(a0) ; kill y-velocity
+
                bsr.w Reset_Player_Position_Array
 
+
                move.w '-$4A,d0; play homing-attack sound
move.w .$2000,(H_scroll_frame_offset).w
+
                jmp (Play_Sound_2).l
 
 
bsr.w Reset_Player_Position_Array
 
 
 
move.w '-$4A,d0; play homing-attack sound
 
 
 
jmp (Play_Sound_2).l
 
  
 
; ---------------------------------------------------------------------------
 
; ---------------------------------------------------------------------------
Line 72: Line 58:
 
Sonic_FireShield:
 
Sonic_FireShield:
  
btst #Status_Invincible,status_secondary(a0) ; first, does Sonic have invincibility?
+
                btst #Status_Invincible,status_secondary(a0) ; first, does Sonic have invincibility?
 
+
                bne.w locret_11A14 ; if yes, branch
bne.w locret_11A14 ; if yes, branch
+
                btst #Status_FireShield,status_secondary(a0) ; does Sonic have a Fire Shield?
 
+
                beq.s Sonic_LightningShield ; if not, branch
btst #Status_FireShield,status_secondary(a0) ; does Sonic have a Fire Shield?
+
                move.b #1,(Shield+anim).w
 
+
                move.b #1,double_jump_flag(a0)
beq.s Sonic_LightningShield ; if not, branch
+
                move.w #$800,d0
 
+
                btst #Status_Facing,status(a0) ; is Sonic facing left?
move.b #1,(Shield+anim).w
+
                beq.s loc_8CB09 ; if not, branch
 
+
                neg.w d0 ; reverse speed value, moving Sonic left
move.b #1,double_jump_flag(a0)
 
 
 
move.w #$800,d0
 
 
 
btst #Status_Facing,status(a0) ; is Sonic facing left?
 
 
 
beq.s loc_8CB09 ; if not, branch
 
 
 
neg.w d0 ; reverse speed value, moving Sonic left
 
  
 
loc_8CB09:
 
loc_8CB09:
  
move.w d0,x_vel(a0) ; apply velocity...
+
                move.w d0,x_vel(a0) ; apply velocity...
 
+
                move.w d0,ground_vel(a0) ; ...both ground and air
move.w d0,ground_vel(a0) ; ...both ground and air
+
                move.w #0,y_vel(a0) ; kill y-velocity
 
+
                move.w #$2000,(H_scroll_frame_offset).w
move.w #0,y_vel(a0) ; kill y-velocity
+
                bsr.w Reset_Player_Position_Array
 
+
                move.w #$43,d0 ; play Fire Shield attack sound
move.w #$2000,(H_scroll_frame_offset).w
+
                jmp (Play_Sound_2).l
 
 
bsr.w Reset_Player_Position_Array
 
 
 
move.w #$43,d0 ; play Fire Shield attack sound
 
 
 
jmp (Play_Sound_2).l
 
  
 
; ---------------------------------------------------------------------------
 
; ---------------------------------------------------------------------------

Revision as of 17:38, 26 January 2021

(Original guide by Sonic Pro1)


first you must have a code editor and the dissambly: sonic 3 & knuckles


I recommend context

well you should go to sonic3k.asm


Exemple-1-to-homing-attack.PNG

then go to ; loc_119F6: Sonic_InstaShield:

and sticks


loc_119F6

Sonic_InstaShield:

               btst #Status_Shield,status_secondary(a0) ; does Sonic have an S2 shield (The Elementals were already filtered out at this point)?
               bne.w locret_11A14 ; if yes, branch
               btst #Status_FireShield,status_secondary(a0) ; does Sonic have a Homing Attack?
               move.b #0,(Shield+anim).w
               move.b #1,double_jump_flag(a0)
               move.w $650.d0
               btst #Status_Facing,status(a0) ; is Sonic facing left?
               beq.s loc_11958 ; if not, branch
               neg.w d0 ; reverse speed value, moving Sonic left

loc_11958:

               move.w d0,x_vel(a0) ; apply velocity...
               move.w d0,ground_vel(a0) ; ... both ground and air
               move.w #0.y_vel(a0) ; kill y-velocity
               move.w .$2000,(H_scroll_frame_offset).w
               bsr.w Reset_Player_Position_Array
               move.w '-$4A,d0; play homing-attack sound
               jmp (Play_Sound_2).l
---------------------------------------------------------------------------

And go higher where this is:

---------------------------------------------------------------------------;

loc_1192C:

Sonic_FireShield:


and replace that with this:


loc_1192C

Sonic_FireShield:

               btst	#Status_Invincible,status_secondary(a0)	; first, does Sonic have invincibility?
               bne.w	locret_11A14				; if yes, branch
               btst	#Status_FireShield,status_secondary(a0)	; does Sonic have a Fire Shield?
               beq.s	Sonic_LightningShield			; if not, branch
               move.b	#1,(Shield+anim).w
               move.b	#1,double_jump_flag(a0)
               move.w	#$800,d0
               btst	#Status_Facing,status(a0)		; is Sonic facing left?
               beq.s	loc_8CB09				; if not, branch
               neg.w	d0					; reverse speed value, moving Sonic left

loc_8CB09:

               move.w	d0,x_vel(a0)		; apply velocity...
               move.w	d0,ground_vel(a0)	; ...both ground and air
               move.w	#0,y_vel(a0)		; kill y-velocity
               move.w	#$2000,(H_scroll_frame_offset).w
               bsr.w	Reset_Player_Position_Array
               move.w	#$43,d0			; play Fire Shield attack sound
               jmp	(Play_Sound_2).l
---------------------------------------------------------------------------


ready you already have a semi-homing attack in sonic 3 I hope you have fun and that you are happy