Making knuckles break walls S2

Discussion in 'Discussion and Q&A Archive' started by Pacca, Oct 14, 2014.

Thread Status:
Not open for further replies.
  1. Pacca

    Pacca Having an online identity crisis since 2019 Member

    Joined:
    Jul 5, 2014
    Messages:
    1,175
    Location:
    Limbo
    Im using the leftover S1 breakable wall object in S2 (xenowhirl), and have knuckles as a character, so naturally, I want him to punch through walls. I can't get it to work right though. CLownacy suggestted the below code:

    loc_15DAE:
        lea    (MainCharacter).w,a1 ; a1=character
        cmpi.b    #$D1,(a1)    ; is player Knuckles?
        beq.s    .knux        ; if so, he doesn't need to be checked for rolling
        cmpi.b    #2,anim(a1)
        bne.s    return_15DAC
    .knux:
        move.w    objoff_30(a0),d0
        bpl.s    loc_15DC2
        neg.w    d0

    But it doesn't work right, only sometimes.
     
  2. Clownacy

    Clownacy Retired Staff lolololo Member

    Joined:
    Aug 15, 2014
    Messages:
    1,020
    Here's the fix. Under loc_15DC2, change the first two lines to this:

    Code:
    	cmpi.b	#$D1,(a1)	; is player Knuckles?
    	beq.s	.knux		; if so, he doesn't need to be checked for speed, either
    	cmpi.w	#$480,d0	; is player's speed $480 or higher?
    	blo.s	return_15DAC	; if not, branch
    
     
  3. Pacca

    Pacca Having an online identity crisis since 2019 Member

    Joined:
    Jul 5, 2014
    Messages:
    1,175
    Location:
    Limbo
    Um, now the game freezes when knuckles touches a wall...

    It only freezes when playing as knuckles, but still, gamebreaking...

    Edit: I managed to fix it, you had a logic error which caused a loop, the beq.s should not point to .knux

    Edit2: How rude of me! It works! Thank you so much :3
     
    Last edited by a moderator: Oct 15, 2014
  4. Clownacy

    Clownacy Retired Staff lolololo Member

    Joined:
    Aug 15, 2014
    Messages:
    1,020
    Oops. Yeah, like before, that code snippet is supposed to end with a .knux label. Weird that you got it to build. I've had loc_ labels invalidate the closest of .labels by being between the label and the branch.
     
    Last edited by a moderator: Oct 15, 2014
Thread Status:
Not open for further replies.