4.5.9 Disable user input during attack animation?

Skelet0n

New member
I'm using NESMaker 4.5.9's Adventure BASE, and have followed the extremely helpful tutorials by Joe.

I synced up the sword animations to the player's attack animations, however,
I noticed that you can pivot almost immediately after the attacking animation starts,
which leaves the sword object in the air for a short amount of time
(see video).

In the Intermediate Adventure tutorial, at 49:35,
Joe addresses the sword "leave behind",
but he didn't go over how to achieve the solutions (as far as I can tell).

The two proposed solutions were:
1. Disable movement scripts while the attack animation is playing.
2. Destroy the sword object when the player changes directions.

I like the first solution, any tips on how to do it?
 

dale_coop

Moderator
Staff member
I think the action step used for attack is 2.
So, you would need to modify all your input scripts, to add a piece of code that should checked the player's action step... and if it's 2, then skip the script.

Something like:

Code:
    STX temp
    GetActionStep temp
    CMP #$02
    BNE +notAttacking
        RTS        ;; skip the script
    +notAttacking:

    ;; continue the script:

Piece of code to be placed at the beginning of all your input scripts maybe (the "move" ones and maybe the attack/shoot ones?).
 

Skelet0n

New member
I think the action step used for attack is 2.
So, you would need to modify all your input scripts, to add a piece of code that should checked the player's action step... and if it's 2, then skip the script.

Something like:

Code:
    STX temp
    GetActionStep temp
    CMP #$02
    BNE +notAttacking
        RTS        ;; skip the script
    +notAttacking:

    ;; continue the script:

Piece of code to be placed at the beginning of all your input scripts maybe (the "move" ones and maybe the attack/shoot ones?).
Thank you for your help. I put this piece of code at the beginning of the move/attack/shoot scripts but unfortunately, the issue still persists, here are a few screenshots of what I added to the code and a screenshot of the 'leave behind' still happening. If I did it wrong or if there are any other ideas, I'd be happy to hear them.
 

Attachments

  • Capture.PNG
    Capture.PNG
    80.8 KB · Views: 18
  • Capture1.PNG
    Capture1.PNG
    161.7 KB · Views: 17
  • Capture2.PNG
    Capture2.PNG
    2.6 KB · Views: 18
I have the same problem, and I am not an expert on the script. It could be possible to add a timer to disable all of the input when pressing the attack button.
For your weapon to disappear after the attack, you must add "Destroy Me" in both of EndAction and End Animation in the "Actions" box of your weapon "Object Details"
Edit: Don't forget to set timer 1 in each direction of the weapon.
For your weapon location must be modified in your ChangeToAttack_AdcentureBase.asm. My character is 32x16 pixel and I set my weapon location.
WEAPON_POSITION_RIGHT_X = #$0F
WEAPON_POSITION_RIGHT_Y = #$0A
WEAPON_POSITION_UP_X = #$00
WEAPON_POSITION_UP_Y = #$F3
WEAPON_POSITION_DOWN_X = -#$03
WEAPON_POSITION_DOWN_Y = #$15
WEAPON_POSITION_LEFT_X = #$F2
WEAPON_POSITION_LEFT_Y = #$0B
WEAPON_OBJECT = #$01
WEAPON_RIGHT_STATE = #$00
WEAPON_LEFT_STATE = #$01
WEAPON_UP_STATE = #$02
WEAPON_DOWN_STATE = #$03
 
Last edited:

Skelet0n

New member
I have the same problem, and I am not an expert on the script. It could be possible to add a timer to disable all of the input when pressing the attack button.
For your weapon to disappear after the attack, you must add "Destroy Me" in both of EndAction and End Animation in the "Actions" box of your weapon "Object Details"
Edit: Don't forget to set timer 1 in each direction of the weapon.
For your weapon location must be modified in your ChangeToAttack_AdcentureBase.asm. My character is 32x16 pixel and I set my weapon location.
WEAPON_POSITION_RIGHT_X = #$0F
WEAPON_POSITION_RIGHT_Y = #$0A
WEAPON_POSITION_UP_X = #$00
WEAPON_POSITION_UP_Y = #$F3
WEAPON_POSITION_DOWN_X = -#$03
WEAPON_POSITION_DOWN_Y = #$15
WEAPON_POSITION_LEFT_X = #$F2
WEAPON_POSITION_LEFT_Y = #$0B
WEAPON_OBJECT = #$01
WEAPON_RIGHT_STATE = #$00
WEAPON_LEFT_STATE = #$01
WEAPON_UP_STATE = #$02
WEAPON_DOWN_STATE = #$03
This is an interesting solution.

I actually figured out how to fix this bug using the bit of code Dale provided. The issue was; I needed to put that snippet of code at the beginning of the ChangeToAttack, changeActionToStop, and changeActionToMoving scripts (in addition to the movement scripts where I had already put it).

I appreciate the help!
 

dale_coop

Moderator
Staff member
Also, you need make sure to have"synchronized" your weapon action step and your player's attack one.
For example, if you set the player's attack state to "GoFirst" after a timer of "2". You need to set your weapon action step to "destroyMe" after a timer of "2".
 
@dale_coop wondering if the issue I’m having can be solved similarly. 4.5.9 Brawler. I added and A button attack. Unlike the built in attack with tutorial, you can keep moving as you punch.

I’m almost there on fixing it. If the code above might help, I can certainly give it a shot. Thanks.

Here’s an ongoing thread for reference to show what I’ve done to this point.
Post in thread '[4.5.9] Brawler - player won't stop moving when attacking'
http://www.nesmakers.com/index.php?...nt-stop-moving-when-attacking.6820/post-41334
 

ResidentEmil

New member
I figured out a way to do this while the player is in a certain state, for example, during the death animation i want to disable input so the state does not accidentally change during the death animation (note, you need to have the state change itself at the end timer/animation to the next or another state or it may softlock)

In 4.5.9 at the top of Game\Subroutines\doHandleInputReads.asm
(change #$07 to the state you want to ignore input for)

Code:
GetActionStep player1_object
CMP #$07
BNE +
    JMP AllButtonStatesChecked
+
 

baardbi

Well-known member
@dale_coop and @baardbi to the rescue!!!! Thanks yet again!!!

Scroll down below the middle of the page in this post:

 
Last edited:
Top Bottom