(Solved) 4.5.9 Disable Player inputs

9Panzer

Well-known member
Okay so I've been trying to setup the input scripts to disable player inputs while in certain action states. I figured out that these lines of code in the movement Scripts controlled the Injury inputs:

TXA
STA temp ;; assumes the object we want to move is in x.
GetActionStep temp
CMP #$07
BNE +notHurt
RTS
+notHurt

So I tried doubling it with a different CMP # which I figured out was the Action states.
TXA
STA temp ;; assumes the object we want to move is in x.
GetActionStep temp
CMP #$07
BNE +notHurt
RTS
+notHurt

TXA
STA temp ;; assumes the object we want to move is in x.
GetActionStep temp
CMP #$06
BNE +notHurt
RTS
+notHurt

StartMoving temp, #LEFT
TXA
STA temp ;; assumes the object we want to move is in x.
ChangeFacingDirection temp, #FACE_LEFT

RTS

This worked perfectly, but when I tried adding a 3rd set for CMP #$04 it gives me a "Routines\BASE_4_5\System\Vectors.asm(1): Value out of range."

Any suggestions?
 

AllDarnDavey

Active member
That tends to happen if you're input scripts are too large to fit into the space allocated for them. I think there's some bank switching tricks others have done, but that has its own pitfalls, and is beyond my current coding abilities.

I don't know what you're personal needs are for ignoring inputs, but in the past I've gotten around this by grouping the action states I want to ignore inputs together, and use greater than / less than checks to skip inputs rather than separate checks for each action number.

This example below is for the move left script from my tutorial for adding custom death animations. Because I need it to ignore inputs for both my hurt action state & my death action state, by grouping them together at the end on state 6 & 7, I can just check if the action state is less than 6 (or greater than or equal to 6 depending on the circumstance).

Code:
    TXA
    STA temp ;; assumes the object we want to move is in x.
  GetActionStep temp  ;; get current action state
    CMP #$06  ;compare to 6
    BCC +notHurt ;; if less than 6 branch to code, else end  early
        RTS
    +notHurt
 
        StartMoving temp, #LEFT
        TXA
        STA temp ;; assumes the object we want to move is in x.
        ChangeFacingDirection temp, #FACE_LEFT

    RTS

This allows me to skip inputs on action states 6 & 7, with about the same amount of code as before. I'm not sure what your needs are, but if you can pack the states that you need to ignore inputs for at the end of the list you can use this trick.

BCC is branch if less than; BCS is branch if greater than or equal.
 

9Panzer

Well-known member
That is EXACTLY what I am trying to do. Basically getting the system to ignore the inputs when he dies or drowns. (Still figuring out how to make the water trigger drowning) lol!

mill give it a shot in the morning. Thanks Davey!
 
Last edited:

9Panzer

Well-known member
This worked like a charm! Thank you for the comments in the script - I would never have realized that CMP meant compare lol
 

offparkway

Active member
That tends to happen if you're input scripts are too large to fit into the space allocated for them. I think there's some bank switching tricks others have done, but that has its own pitfalls, and is beyond my current coding abilities.

I don't know what you're personal needs are for ignoring inputs, but in the past I've gotten around this by grouping the action states I want to ignore inputs together, and use greater than / less than checks to skip inputs rather than separate checks for each action number.

This example below is for the move left script from my tutorial for adding custom death animations. Because I need it to ignore inputs for both my hurt action state & my death action state, by grouping them together at the end on state 6 & 7, I can just check if the action state is less than 6 (or greater than or equal to 6 depending on the circumstance).

Code:
    TXA
    STA temp ;; assumes the object we want to move is in x.
  GetActionStep temp  ;; get current action state
    CMP #$06  ;compare to 6
    BCC +notHurt ;; if less than 6 branch to code, else end  early
        RTS
    +notHurt

        StartMoving temp, #LEFT
        TXA
        STA temp ;; assumes the object we want to move is in x.
        ChangeFacingDirection temp, #FACE_LEFT

    RTS

This allows me to skip inputs on action states 6 & 7, with about the same amount of code as before. I'm not sure what your needs are, but if you can pack the states that you need to ignore inputs for at the end of the list you can use this trick.

BCC is branch if less than; BCS is branch if greater than or equal.
I’m doing exactly this (death state is 06) but somehow all of my inputs still register as my player dies... meaning I can start walking and it cancels out my death animation. My health resets and I can still walk around and play the game as long as I keep moving when I get killed. So weird.

my death action step is set to StopMoving and my inputs are supposed to be ignored any action step higher than 01. But somehow I can still start walking as my death animation plays.
 
Last edited:
Top Bottom