Trouble with metroidvania tutorial movement

AllDarnDavey

Active member
Yeah, there's a post about this problem on the facebook group as well... it isn't just the metroidvania core either. If you roll the dpad... start pressing right, roll to right & up together, then to just up... you keep moving right. The button release doesn't trigger properly if you add a second dpad direction before releasing.

I took a peek at the input code and couldn't make much heads or tails of it. Hopefully we get a patch or somebody figures out a fix.
 

crazygrouptrio

Active member
I really hope someone finds a fix for this, I've spent literally hours on this issue alone (even trying to force 4.15 code back in since it did not have this issue) and still nothing. :x
 

AllDarnDavey

Active member
I might be going crazy here but I was looking into doHandleInputScripts and I don't think NESmaker actually uses it?! First there are two very similar scripts, doHandleInputScripts.asm and doHandleInputReads.asm, the first one is usually the one assigned in modules... but nothing I've tried makes any difference, so I tried breaking the script on purpose, not difference, then I assigned the blank.asm to Handle Input Scripts in NESmaker script settings, and it didn't change a thing. Game should've been uncontrollable, but it wasn't, NESmaker isn't using that file at all.

You do still have to assign input scripts into the input editor, and I checked gamestates assignments and stuff do work, so it's getting and interpreting that data somewhere, but not using that file it isn't. So not only do I have no idea how to fix this, I don't even know where to look to fix the code, because the file I thought was being used isn't.
 

AllDarnDavey

Active member
I figured it out, well I didn't fix it, I figured out where the code handling these input states is... doHandleInputReads.asm is the file it uses, regardless of what you assign in your script settings.
 

AllDarnDavey

Active member
Okay, I think I'm getting closer to tracking this down. changeActionToStop.asm is not checking that we've stop holding the direction we started, but just that the dpad isn't being pressed, so if you roll the dpad, it may trigger a release right, but it doesn't change the action state because you're still pressing a dpad button.
 

AllDarnDavey

Active member
Alright finally got a fix.
First you're gonna need to add a new input script that filters out up and down holds when changing from walking to stop animations for side platformers. Assign it for release left & release right, I named it "changeActionToStopLR.asm", code below:
Code:
    TXA
    STA temp ;; assumes the object we want to move is in x.
    ;;; It is possible that we are pressing multiple directions, and let go of one of them.
    ;;; If this happens, we would have our behavior change to stop, even though we'd continue to move.
    ;;; What we need to do is check to see if the relevant dpad buttons are pressed.  If any buttons
    ;;; are pressed that would counter the change to a stop action upon release, we need to skip the
    ;;; change to stop action.  
    GetActionStep temp
    CMP #$07
    BNE +notHurt
        RTS
    +notHurt
    LDA controllerNumber_hold
    BNE weAreCheckingCOntroller2
        ;; we are checking controller 1.
        LDA gamepad
        AND #%11000000
        BEQ changeToStop_NoDpadPressed
            RTS
        weAreCheckingCOntroller2:
        LDA gamepad2
        AND #%11000000
        BEQ changeToStop_NoDpadPressed
            RTS
    changeToStop_NoDpadPressed:
        ChangeActionStep temp, #$00 ;; assumes that "walk" is in action 1
        ;arg0 = what object?
        ;arg1 = what behavior?
    RTS

You'll also need a new version of the oStopMoving.asm script, give it a name like "oStopMovingPlatformer.asm" assign it under script settings>Behaviors>Stop Moving, give it this code:
Code:
oStopMoving:
	LDX arg0_hold
	LDA Object_direction,x
	AND #%01001111
	STA Object_direction,x

	RTS

These are meant for side on platformers with gravity, not overhead style, so your mileage may very with other modules, the only minor issue I've found so far is ladders are a bit more tricky to climb. Ladders still work, they're just require a little more precise alignment and timing.
 
Not sure if anyone had that issue with the above scripts from AllDarnDavey, but for my game, if I was running Left or Right(holding L or R dpad), and then I would press Down (still holding L or R dpad), it would stop the player object correctly, but if I then released the DOWN button, it goes back to moving in L/R direction but it is in playerobject state 0, which is Idle/standing. so it's not giving me it's running animation.

To work around that, I created a small input script that I named "FromDowntoMoving.asm" that I assigned to RELEASE of DOWN BUTTON :

Code:
    TXA
    STA temp ;; assumes the object we want to move is in x.
 GetActionStep temp
    CMP #$07
    BNE +notHurt
        RTS
    +notHurt
	CMP #$02 ;; the state of your jump animation
	BNE +notJumping
		RTS
	+notJumping
        
		
		LDA gamepad
		AND #%11000000 ; checking for A button
		BNE +LRpressed
			; L or R were not pressed, do stuff here then JMP to end
			JMP +donewithLRButtons
		+LRpressed
		; L or R are pressed, do some stuff here...
		ChangeActionStep temp, #$01 ;; assumes that "walk" is in action 1 ;arg0 = what object? ;arg1 = what behavior?
+donewithLRButtons

    RTS

Note that I've not implemented any crouch feature or any other scripts to my down button, not sure if that would conflict with anything else.
Seems to work for what I need in my game though.
and, thanks AllDarnDavey for the code above.
 

mouse spirit

Well-known member
Alldarn, i am in 4.1.5 and have an issue when i jump and attack and then hold down,when i hit the ground i am still in jumping animation until i press left or right or release down.

I am trying to duck after melee in the air.Even if i wait after attacking,it never goes to duck unless i hit the ground first,then hold down.(or press left/right or release down.)

Is this a similar issue?
 

AllDarnDavey

Active member
mouse spirit said:
Alldarn, i am in 4.1.5 and have an issue when i jump and attack and then hold down,when i hit the ground i am still in jumping animation until i press left or right or release down.

I am trying to duck after melee in the air.Even if i wait after attacking,it never goes to duck unless i hit the ground first,then hold down.(or press left/right or release down.)

Is this a similar issue?
It's been a long time since I've touched 4.1.5 at all, but it sounds similar. I do remember a bunch of issues especially with jump through platforms and ladders sometimes.
 

Yan

Member
This is kinda related so I'm posting here. When landing while holding up or down my character would be in his running animation instead of his idle.

That's because of "doHandlePhysics_PlatformBase" (line 655) being like this:
Code:
LDA gamepad
AND #%11110000

To fix that just change it to this:
Code:
LDA gamepad
AND #%11000000
 
Top Bottom