Megaman Style slide/dash code issue

I am trying to make a megaman style slide/dash action script, and it almost works just right!

I am having trouble determining the player's facing direction however.

Here is what I have so far:

Code:
;; MODIFIED FROM DEFAULT JUMP SCRIPT

;; Get player object
;; Check if in air, and skip if so.
LDX player1_object
LDA Object_status,x
AND #%00000100
BEQ +

;; Check facing direction
LDA Object_movement,x
AND #%00000111 ;only keep the last 3 bits
CMP #$00000110 ;facing right
BEQ slideRight
JMP slideLeft

slideRight:
;FACE_RIGHT		= #%00000010
LDA #$00
SEC
ADC #$03  
STA Object_h_speed_hi,x

slideLeft:
;FACE_LEFT		= #%00000110
;; Store 250 in accumulator and assign it to object's speed
LDA #$00
SEC
SBC #$03  
STA Object_h_speed_hi,x

ChangeObjectState #$07, #$02 ;Set the object's animation state (my dash action is 7)
;PlaySound #SFX_PLAYER_JUMP
+
RTS

This code will dash, but it will only go left. My check for player's facing direction doesn't seem to work.
Also, if this code helps you in any way feel free to use it!
 

dale_coop

Moderator
Staff member
A small corrected script:
Code:
;; MODIFIED FROM DEFAULT JUMP SCRIPT

;; Get player object
;; Check if in air, and skip if so.
	LDX player1_object
	LDA Object_status,x
	AND #%00000100
	BEQ +

	;; Check facing direction
	LDA Object_movement,x
	AND #%00000111 ;only keep the last 3 bits
	CMP #%00000010 ;FACE_RIGHT		= #%00000010
	BEQ slideRight
	JMP slideLeft

slideRight:
	;FACE_RIGHT		= #%00000010
	LDA #$00
	ADC #$06
	STA Object_h_speed_hi,x
	JMP continueSliding

slideLeft:
	;FACE_LEFT		= #%00000110
	;; Store 250 in accumulator and assign it to object's speed
	LDA #$00
	SBC #$06
	STA Object_h_speed_hi,x

continueSliding:
	ChangeObjectState #$07, #$02 ;Set the object's animation state (my dash action is 7)
	;PlaySound #SFX_PLAYER_JUMP
+
	RTS
 

digitalbooty

New member
I used the corrected code, mine only dashes left, too. I've assigned it to press "Down" on the d-pad. Should I put this code elsewhere?
 

dale_coop

Moderator
Staff member
You can’t assign it to “down” because the script will not know which direction your player want to go.
You need to assign it to “left” and to “right”.
And in your case it you want the player to dash only if press “down” at the same time, you might modify the script to check the gamepad, maybe something like that:

Code:
;; MODIFIED FROM DEFAULT JUMP SCRIPT

;; Get player object
;; Check if in air, and skip if so.
	LDX player1_object
	LDA Object_status,x
	AND #%00000100
	BEQ +
	
	LDA gamepad
	CMP #%00100000  ;;check if “down” is press too
	BNE +

	;; Check facing direction
	LDA Object_movement,x
	AND #%00000111 ;only keep the last 3 bits
	CMP #%00000010 ;FACE_RIGHT		= #%00000010
	BEQ slideRight
	JMP slideLeft

slideRight:
	;FACE_RIGHT		= #%00000010
	LDA #$00
	ADC #$06
	STA Object_h_speed_hi,x
	JMP continueSliding

slideLeft:
	;FACE_LEFT		= #%00000110
	;; Store 250 in accumulator and assign it to object's speed
	LDA #$00
	SBC #$06
	STA Object_h_speed_hi,x

continueSliding:
	ChangeObjectState #$07, #$02 ;Set the object's animation state (my dash action is 7)
	;PlaySound #SFX_PLAYER_JUMP
+
	RTS
 
So then you would make 2 new scripts dash.asm and stopdash.asm? And then place this in the input scripts and the assign them to the left dash right dash? But what if you want the dash to happen when you press A button and left or right? Where do you change the code for that to happen

Cheers
 

rimoJO

Member
Doesn't seem to work for me. I have the corrected LR+B set as L+B and R+B in the Input Editor, and it doesn't work.
 

WillElm

New member
I assigned this script to Left and Right presses, but I don't have any results. I wonder if something in the extra control read script could be interfering, or maybe my regular left and right presses are overtaking it?

What exactly is happening in the slideRight and slideLeft labels? Is it adding and subtracting velocity to and from your current speed?

I want to be able to dash by holding B and pressing left or right. I think I'm missing what the SBC and ADC in slideLeft and slideRight are accomplishing.
 

axbakk

Member
A small corrected script:
Code:
;; MODIFIED FROM DEFAULT JUMP SCRIPT

;; Get player object
;; Check if in air, and skip if so.
    LDX player1_object
    LDA Object_status,x
    AND #%00000100
    BEQ +

    ;; Check facing direction
    LDA Object_movement,x
    AND #%00000111 ;only keep the last 3 bits
    CMP #%00000010 ;FACE_RIGHT        = #%00000010
    BEQ slideRight
    JMP slideLeft

slideRight:
    ;FACE_RIGHT        = #%00000010
    LDA #$00
    ADC #$06
    STA Object_h_speed_hi,x
    JMP continueSliding

slideLeft:
    ;FACE_LEFT        = #%00000110
    ;; Store 250 in accumulator and assign it to object's speed
    LDA #$00
    SBC #$06
    STA Object_h_speed_hi,x

continueSliding:
    ChangeObjectState #$07, #$02 ;Set the object's animation state (my dash action is 7)
    ;PlaySound #SFX_PLAYER_JUMP
+
    RTS

Just tried this in 4.1.5 and it does nothing. Maybe i am doing something wrong?

assigned this script to PRESS "B" in input scripts.
And my players action step 7 got the dash animation and top collision skip..

Something more i have to do to make it work or is this script not working in my version? if so, does anyone have a script that will work for me in 4.1.5?

Cheers // Axbakk
 

Vanessalaups

New member
Every time I try to reply to a PM, I get an error message. Ive tried it from 3 different computers and it doesnt let me reply to anyone. People probably think I am being rude by ignoring them Help
 

force73

Member
Just tried this in 4.1.5 and it does nothing. Maybe i am doing something wrong?

assigned this script to PRESS "B" in input scripts.
And my players action step 7 got the dash animation and top collision skip..

Something more i have to do to make it work or is this script not working in my version? if so, does anyone have a script that will work for me in 4.1.5?

Cheers // Axbakk
Hey axbakk,

were you able to get it to work? Have the same problem right now and don't know, how to fix it. Everytime I press the button the script is assigned, the Player got reseted to the last checkpoint (I have a game with 1 screen = 1 level).
 

abenjack

New member
Hi guys, this code doesn't work in nesmaker 4.5.9. There's a patch or workaround to fix it for the last version of nesmaker?
Thanks in advance
 
Top Bottom