[4.1.5] Switch Players Action State From Jumping Once Player Touches Ground

Post Reply
User avatar
Vonwoah
Posts: 7
Joined: Wed Oct 30, 2019 9:02 am
Location: United States
Contact:

[4.1.5] Switch Players Action State From Jumping Once Player Touches Ground

Post by Vonwoah » Thu Nov 07, 2019 3:07 pm

Version 4.1.5
Starting Module: BASE_ScrollingPlatformer.MOD

EDIT: Turns out the previous script was unnecessary. If you are running 4.1.5 and use the Scrolling Platform module, the fix can be applied to ModuleScripts/MainScripts/ScrollingPlatformer/ExtraControllReadCode.asm

Code: Select all

ExtraInputControl:
    
	;; Change player to standing/idle state once touching ground
	LDX player1_object
	LDA Object_physics_byte,x
	AND #%00000001 ;; is on ground
	BEQ +
	GetCurrentActionType player1_object
	CMP #$03 ;; jumping state
	BNE +
	ChangeObjectState #$00, #$04 ;; idle state
	+
	
	RTS
Last edited by Vonwoah on Sun Nov 10, 2019 7:27 am, edited 1 time in total.
User avatar
Mugi
Posts: 741
Joined: Thu Dec 27, 2018 8:30 pm

Re: [4.1.5] Switch Players Action State From Jumping Once Player Touches Ground

Post by Mugi » Thu Nov 07, 2019 3:28 pm

you can simply check against the object physics byte to see if the player is in the air or not by doing

LDA Object_physics_byte,x
AND #%00000001 ; if is in air

and change the actionstate back to idle from the jump script itself if the condition is not met.
i think nesmaker's engine does this by default in the extra controller script that runs after every input, but if my memory serves me right it had some issues with the default configuration it came with.
a lot of people experienced broken input actions/animation states when the version containing this script was added to the engine and there's some old threads in the forum archive about dealing with it.
"what are you up to?" "Oh, not much... just... Parallaxing"
- Raftronaut
User avatar
Vonwoah
Posts: 7
Joined: Wed Oct 30, 2019 9:02 am
Location: United States
Contact:

Re: [4.1.5] Switch Players Action State From Jumping Once Player Touches Ground

Post by Vonwoah » Sat Nov 09, 2019 1:38 pm

Mugi wrote:
Thu Nov 07, 2019 3:28 pm
a lot of people experienced broken input actions/animation states when the version containing this script was added to the engine and there's some old threads in the forum archive about dealing with it
I've seen a number of threads involving broken animation states, and I haven't seen any fixes for jumping in 4_1_5. Do you know where I might find this? I've tried every jump script out there, and even wrote my own from scratch and still can't get the jump action state to end when the player touches the ground. This is because my command to test for ground overrides my jump animation. If it's in the jump script, this all executes once with a press of a button. It don't know how to conditionally check for the jump animation to stop after pressing A jump + player jumps + idle animation when touching ground. This logic is in my test script, but it's overriding my jump values because I can only test for air or ground with a press of a button. I'm trying to figure out how to end it without a timer and landing on the ground.

This is the current state of the 4_1_5 scrollingPlatformer. Below is my rewritten jump script that is still broken. I've tested with a blank project and do see that the ending of jump actions do not end. I've been trying to fix this for weeks, so any help is appreciated.

Code: Select all

;; THIS CODE IS FOR JUMPING.
LDX player1_object

;; Our jump
LDA Object_physics_byte,x
AND #$00000100
BEQ +
	ChangeObjectState #$02, #$04
	
	;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	;;; set the vertical speed to a negative number to make it "jump".	
	LDA #$00
	SEC
    SBC #JUMP_SPEED_LO
    STA Object_v_speed_lo,x
    LDA #$00
    SEC
    SBC #JUMP_SPEED_HI
    STA Object_v_speed_hi,x	
	BEQ noJump
+
	
;; this just overrides above on button press because the player starts out on the ground
;; hmmmmmm
	LDA Object_physics_byte,x
	AND #$00000001 ;;
	BEQ noJump
	ChangeObjectState #$00, #$04
	+
	
noJump:
	;; no way to determine after object jump, to change to state #$00 when touching ground
	;; since everything is determined by a single press of a button
	RTS
User avatar
dale_coop
Posts: 4376
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: [4.1.5] Switch Players Action State From Jumping Once Player Touches Ground

Post by dale_coop » Sat Nov 09, 2019 8:19 pm

The issue comes not from your jump script... but from the Handle Extra Controls script...(my guess) ;)
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
User avatar
Vonwoah
Posts: 7
Joined: Wed Oct 30, 2019 9:02 am
Location: United States
Contact:

Re: [4.1.5] Switch Players Action State From Jumping Once Player Touches Ground

Post by Vonwoah » Sun Nov 10, 2019 7:20 am

Thank you Mugi and Dale.

Turns out it was the Handle Extra Control script! Previously I was looking here and I zeroed it out to just return RTS. This is exactly what I needed, control to modify the action after input. I applied this code to ExtraControllReadCode.asm. From my previous tests, I remember the 4.1.5 scrollingPlatform module doesn't take care of changing the players state to idle when touching the ground. If anyone else has this problem.

Code: Select all

ExtraInputControl:
    
	;; Change player to standing/idle state once touching ground
	LDX player1_object
	LDA Object_physics_byte,x
	AND #%00000001 ;; is on ground
	BEQ +
	GetCurrentActionType player1_object
	CMP #$03 ;; jumping state
	BNE +
	ChangeObjectState #$00, #$04 ;; idle state
	+
	
	RTS
Thank you! Thank you! Thank you!
Post Reply