Working on script to make 'skip top collision' work with tiles.

Hey guys, I am working on some modifications to make the 'skip top collision' work with tiles as well.
This would let the player/enemies that have a ducking animation pass under tiles while ducked but collide with them while standing.
I almost have it working, but I am having a bit of a glitch I am having trouble cleaning up.
Of course, when I get this working, I plan to share how to do it all.

I have attached a gif of the problem I am having.


So, the player can pass under objects while in the ducked/crouched state with no issue. The problem occurs if the player stands back up while they are under the object.
What I want to happen, is to prevent the player from transitioning back to their idle state if their top collision points are colliding with a tile.

Pseudocode:
(In extra contol reads, where I have the rest of my code that forces states)

Should we transition to idle state?
=Are we in crouched or slide state?
==Yes:
===Is there a tile above the crouched player?
====Yes:
=====Force the player into the crouched position, they can move L/R but not stand up.
====No:
=====Transition to idle
==No:
===Transition to idle

How I am trying to do this, is to use a bit of code from a tile collision macro, CheckForVertical Ejection.
I copy/pasted it and changed subroutine call to push the player down to change the players object state to crouched:
Code:
notDoingAnything:
    LDA gamepad
    AND #%11110000 ;We ARE doing something, so skip change to idle and wait for next check.
    BEQ +
    JMP skipMainGameExtraInputControl
  +:
    GetCurrentActionType player1_object  ; check current state
    BEQ skipMainGameExtraInputControl   ; if already 0, don't change it again.
    
    ;; If we were shooting dont interrupt
    LDA temp
    CMP #$05
    BEQ skipMainGameExtraInputControl
    
    ;; If we are ducking, check if we are in a tunnel, if so, force crouch.
    LDA temp
    CMP #$03
    BNE ++
    
    ;; Check if in tunnel
    LDA #$00
    STA tile_solidity
    LDA Object_x_hi,x
    CLC
    ADC Object_left,x
    STA tileX
    LDA #$00
    BCC +
    LDA #$01
  +:

    STA tempCol
    LDA yHold_hi
    CLC
    ADC Object_top,x
    STA tileY
    JSR GetTileAtPosition
    JSR DetermineCollisionTable
    STA collisionPoint0 ;; comment this out?
    JSR CheckForCollision
    LDA tile_solidity
    AND #%00000001
    BEQ +
    
    ChangeObjectState #$03, #$04
    JMP skipMainGameExtraInputControl
  +:
 ++: 
    ChangeObjectState #$00, #$04

    
skipMainGameExtraInputControl:  
    
    RTS

However, this doesn't seem to be working :\ The player can still stand up while under the tiles.
 

Mugi

Member
you could try and put checks into the input script itself, something along the lines of

LDX player1_object
LDA collisionPoint0
CMP <put the collision ID of the tile you're colliding with here (for normal solid 01)>
BEQ forcePlayerToStayCrouched

might work with just collision point 0 but for extra accuracy you want to do this for both, collisionPoint0 and collisionPoint1

you also have to keep in mind that collisionchecks are a loop through an object array, and you cannot load a collisionPoint0,x to specify it's only to deal with player, so a further sanitizing of this depending on situational use is
most likely needed. This is just the basic idea of it.

this could propably work when embeded into the tile code itself too, and could actually be a better place for it, assuming you dont really have monsters that frequently hit the ceiling, the only time when the collisions apply, would be when the player does.

i use this way of doing collision checks in a tile code to create the accuracy checks for my wall climb, and since the enemies basically never collide with those tiles, it works fairly well.
 
Top Bottom