Skip top collision on input , not action state. 4.1.5 platformer (solved)

mouse spirit

Well-known member
Ive tried to do this and i felt like i almost had it. When on ground and holding down, skip top collision.My kneel is in my idle state down angles, and my sword down angles.So you see, i cant do it based on my state. It does work that way though. Just not what i need to happen.

Below isnt all my code but i boild it down to this and didnt put any other code with it.. This is now the whole code to just to figure it out. Then i can add my code back in.

Hold down asm
Code:
LDA Object_vulnerability,x
ORA #÷ 10000000
STA Object_vulnerability,x
Heres what im using to do this. But i imagine because my state is actually not skipping top collision,maybe its conflicting? Or i am off on what to do.

To be clear. Above is the code and its on a hold down input.



But heres the whole thing as i normally have it, with kneeling and such .The rest of it works fine and may look like an amatuer did it.


Code:
LDA isPaused
BEQ +
RTS
+

LDA Object_physics_byte,x
    AND #%00000001 ;; is it on the ground?
    BNE +
     JMP end7

    +
 LDA gameHandler
 AND #%00100000
 BEQ++
 RTS
 ++
 



LDX player1_object

GetCurrentActionType player1_object
CMP #$03 ;; attack
BEQ +
CMP #$01
BEQ +
LDA Object_physics_byte,x
AND #%00000001 ;; is it on ground
BEQ +
ChangeObjectState #$00, #$04
JMP +
+
LDA Object_vulnerability,x
ORA #%10000000
STA Object_vulnerability,x
 


LDA Object_movement,x
AND #%00000111
CMP #%00000110 ;; facing left?
BNE ++ 
FaceDirection player1_object, FACE_DOWN_LEFT
JMP+
++
CMP #%00000010 ;;facing right?
BNE +
FaceDirection player1_object, FACE_DOWN_RIGHT
+

end7:



RTS
My guess about it being like this? Its changing states directly before it does the code above. So it might work,not work,work,not work. But as i said. Now i am testing with only 3 lines of code.
 

dale_coop

Moderator
Staff member
I think the "crouch" state is already implemented, by default, for the platform module in the 4.1.5.

Yo need to use the Action Step 5 for that, set the "skip top collision", assign your crouch animation type... and it should work natively (without assigning any script in the Input Editor), if I remember well.
 

mouse spirit

Well-known member
Thanks for your inaight dale.Well my crouch animations are in my idle state and sword states. Not a Crouch state because of the way i had to to things. So i cant do it by state, can i do it on hold input?.
 

dale_coop

Moderator
Staff member
Oh...then, your code should work
But, I think your issue is caused bu the Extra Controls Script (in project settings > scripts settings). That script override some states, checking if the player is on the air, or on ladder or on the ground and force setting states.

Around line 68 of that script, you will find:
Code:
	 LDA gamepad
	AND #%00100000 ; if down is pressed
	BEQ notDucking
	 ChangeObjectState #$5, #$04
	 JMP skipMainGameExtraInputControl

I'd suggest to comment out those 5 lines, it might help for what you want to do.
 

mouse spirit

Well-known member
Well i tried that to no avail. I see what you meant. I commented all that out. Went as far to comment out any state changes in the extra read code and i just put those three lines about vulnerability in my hold down input.
I think it may have to do with somewhere else. I use vulnerability fine for other things but never skiptopcollosion successfully. I will try harder and thanks again, in a normal case im sure that would help.it did help me narrow it down more also.

Lastly, i tried putting the 3 line code on Hold Select, which should not conflict with anything. Maybe its that the actions states flag tick overides all this? And as i said, using the state version of this works. So skiptopcollision works fine just not from me doing code.i tried it in alot of spots just in case.

Another thought.My standing idle animation only works when i hold up. Maybe this is because when im idle pressing nothing its constantly resetting to state 0(idle). I will look into this.

Edit: Used a fix you posted for the idle animation.I still have my problem though.
 

dale_coop

Moderator
Staff member
Your hold down script contains only that ?

Code:
	LDA Object_vulnerability,x
	ORA #%10000000
	STA Object_vulnerability,x

If not, could you share the full script?
 

mouse spirit

Well-known member
Yes here's my normal hold down


Code:
LDA isPaused
BEQ +
RTS
+

LDA Object_physics_byte,x
    AND #%00000001 ;; is it on the ground?
    BNE +
     JMP end7

    +
 LDA gameHandler
 AND #%00100000
 BEQ++
 RTS
 ++
 



LDX player1_object

GetCurrentActionType player1_object
CMP #$03 ;; attack
BEQ +
CMP #$01
BEQ +
LDA Object_physics_byte,x
AND #%00000001 ;; is it on ground
BEQ +
ChangeObjectState #$00, #$04
JMP +
+
LDA Object_vulnerability,x
ORA #%10000000
STA Object_vulnerability,x
 


LDA Object_movement,x
AND #%00000111
CMP #%00000110 ;; facing left?
BNE ++ 
FaceDirection player1_object, FACE_DOWN_LEFT
JMP+
++
CMP #%00000010 ;;facing right?
BNE +
FaceDirection player1_object, FACE_DOWN_RIGHT
+

end7:



RTS



But i eventually erased all of that and only tried this as to eliminate any conlflicts in that script.

Code:
LDA Object_vulnerability,x
ORA #%10000000
STA Object_vulnerability,x

To further eliminate conflicts, i actually put it on the select button.Non of these ideas worked for me.
Also in my extra read code, i commented out all conflicts there when trying to do this.
 

dale_coop

Moderator
Staff member
Instead of only:
Code:
	LDA Object_vulnerability,x
	ORA #%10000000
	STA Object_vulnerability,x

You could try that:
Code:
	LDA Object_vulnerability,x
	ORA #%10000000
	STA Object_vulnerability,x

	LDA Object_state_flags,x
	AND #%10111111
	STA Object_state_flags,x
 

mouse spirit

Well-known member
works great with the select button! Thanks dale_coop ! it wont undo itself unless i change state, and i seem to have conflicts with my other stuff as stated but i can handle all that now. Really wonderful.
But a question,Why does this new work and not the 3 line code i had before?
 

dale_coop

Moderator
Staff member
To undo you will have to make a Down Release script, with the opposite code:
Code:
	LDA Object_vulnerability,x
	AND #%01111111	;; removing the "skip top collision"
	STA Object_vulnerability,x
	
	LDA Object_state_flags,x
	AND #%10111111
	STA Object_state_flags,x
 

mouse spirit

Well-known member
Understood, im on my way! sorry i edit my posts alot, i try to make them better or ask the better question after i already type sometimes.
 

mouse spirit

Well-known member
So its working greaat, got rid of conflicts. Really awesome. But is it possible to skiptopcollision twice? I ask because when this works, it makes my hitbox very verrry small, and it is originally very tall.like imagine a meter,now imagine 1/4 or 1/5 of that.
 

dale_coop

Moderator
Staff member
No I think it's the code that do the calculation of the half bounding box that is incorrect (natively in NESmaker) :p
Could you share a screenshot of your Player's bounding box... I will try to reproduce and fix the incorrect script.
 

mouse spirit

Well-known member
Ofcourse.

asergaerg-1.png

Sounds like work but also sounds like a good lil patch for 4.1.5. Unless it's case specific tailored to my needs. Of which i apologize for this also.
 

dale_coop

Moderator
Staff member
Here's how to fix the "skip top collision" calculated bounding box:

Modify the script assigned to the "Handle Object Collision" element in your "Project Settings > Script Settings", find the subroutine named "GetSelfCollisionBox:" (around line 470 and something). A few lines down, you will find this block of code:
Code:
	LDA Object_vulnerability,x
	AND #%10000000
	BEQ noDuckingBit
	LDA Object_bottom
	SEC 
	SBC Object_top
	STA temp
	LDA Object_y_hi,x
	CLC
	ADC temp
	JMP gotSelfTop

Replace all that block with the fixed one:
Code:
	LDA Object_vulnerability,x
	AND #%10000000
	BEQ noDuckingBit
	LDA Object_bottom,x
	SEC 
	SBC Object_top,x
	LSR
	STA temp
	LDA Object_y_hi,x
	CLC
	ADC Object_top,x
	CLC
	ADC temp
	JMP gotSelfTop



Also, now search for the subroutine named "GetOtherCollisionBox:" (around line 500 and something) and a few lines down, you will find that block of code:
Code:
	LDA Object_vulnerability,x
	AND #%10000000
	BEQ noDuckingBit_other
	LDA Object_bottom
	SEC 
	SBC Object_top
	STA temp
	LDA Object_y_hi,x
	CLC
	ADC temp
	JMP gotSelfTop_other

Replace with that fixed one:
Code:
	LDA Object_vulnerability,x
	AND #%10000000
	BEQ noDuckingBit_other
	LDA Object_bottom,x
	SEC 
	SBC Object_top,x
	LSR
	STA temp
	LDA Object_y_hi,x
	CLC
	ADC Object_top,x
	CLC
	ADC temp
	JMP gotSelfTop_other

Now, if you haven't made any mistake while replacing the code... it should work really better ;) The crouch / "skip top collision" should be correctly calculated (half of your bounding box).

If not... could you share your modified script? I will check.
 
Top Bottom