Stopping while attacking gets stuck

BenjiBro

New member
I tried making my player stop while attacking for a melee attack with the metroidvania super ammo script by putting the stop moving ai code into it (because for some reason the StopMoving function kept saying error) and it doesn't let me move after attacking unless I press the d-pad again, and I'm trying to figure out how to animate the player attacking, I keep trying to access an action step but it makes the sword spawn far from the player for some reason. (line 51 to 58)
1660277799711.png
(pasted ai code under ;custom code
 

mouse spirit

Well-known member
I tried making my player stop while attacking for a melee attack with the metroidvania super ammo script by putting the stop moving ai code into it (because for some reason the StopMoving function kept saying error) and it doesn't let me move after attacking unless I press the d-pad again, and I'm trying to figure out how to animate the player attacking, I keep trying to access an action step but it makes the sword spawn far from the player for some reason. (line 51 to 58)
View attachment 6473
(pasted ai code under ;custom code
If you havnt watched these yet, they can help with some of these problems.
 

dale_coop

Moderator
Staff member
To stop the player when attacking:
In your attack input script, around line 56, add:
Code:
    ;; dale_coop: stop the Player's movements:
    LDA #$00
    STA Object_h_speed_lo,x
    STA Object_h_speed_hi,x 
    STA Object_v_speed_lo,x
    STA Object_v_speed_hi,x 
    LDA Object_direction,x
    AND #%00000111
    STA Object_direction,x
    ;; and stop the scrolling:
    LDA scrollByte
    AND #%00111110
    ORA #%00000010
    STA scrollByte
To play an animation when he's attacking, also add that line:
Code:
  ChangeActionStep player1_object, #$03  ;; <-- HERE use the action step you want for the "attack" state


AND, now, in all your movement input scripts, you find:
Code:
    GetActionStep temp
    CMP #$07
    BNE +notHurt
        RTS
    +notHurt
That code prevent from moving when the player is in his "hurt" state...
So, all you need to do is adding a code to also prevent when he is in his "attack" state (for example igf you are using action step #$03 for attack state / animation):
Code:
    GetActionStep temp
    CMP #$07
    BNE +notHurt
        RTS
    +notHurt
    CMP #$03      ;; is the player attacking ?
    BNE +notAttacking
        RTS
    +notAttacking:



Note: if you want to use another action step for your player's attack animation, just replace the #$03 by the other value (#$04 for action step 4, for example)

Your attack animation needs to be short (set a short timer value "1" with a "endAction" to GoToFirst... or EndAnimation to "GoToFirst" with a short animation speed):

2022-08-12 09_22_00-Monster Animation Info.png

2022-08-12 09_22_17-(3) Stopping while attacking gets stuck _ NESMakers.png
 

BenjiBro

New member
GetActionStep temp CMP #$07 BNE +notHurt RTS +notHurt CMP #$03 ;; is the player attacking ? BNE +notAttacking RTS +notAttacking:

To stop the player when attacking:
In your attack input script, around line 56, add:
Code:
    ;; dale_coop: stop the Player's movements:
    LDA #$00
    STA Object_h_speed_lo,x
    STA Object_h_speed_hi,x
    STA Object_v_speed_lo,x
    STA Object_v_speed_hi,x
    LDA Object_direction,x
    AND #%00000111
    STA Object_direction,x
    ;; and stop the scrolling:
    LDA scrollByte
    AND #%00111110
    ORA #%00000010
    STA scrollByte
To play an animation when he's attacking, also add that line:
Code:
  ChangeActionStep player1_object, #$03  ;; <-- HERE use the action step you want for the "attack" state


AND, now, in all your movement input scripts, you find:
Code:
    GetActionStep temp
    CMP #$07
    BNE +notHurt
        RTS
    +notHurt
That code prevent from moving when the player is in his "hurt" state...
So, all you need to do is adding a code to also prevent when he is in his "attack" state (for example igf you are using action step #$03 for attack state / animation):
Code:
    GetActionStep temp
    CMP #$07
    BNE +notHurt
        RTS
    +notHurt
    CMP #$03      ;; is the player attacking ?
    BNE +notAttacking
        RTS
    +notAttacking:



Note: if you want to use another action step for your player's attack animation, just replace the #$03 by the other value (#$04 for action step 4, for example)

Your attack animation needs to be short (set a short timer value "1" with a "endAction" to GoToFirst... or EndAnimation to "GoToFirst" with a short animation speed):

View attachment 6475

View attachment 6474
Thank you for helping! Appreciate it!
 

DamagedCreator

New member
To stop the player when attacking:
In your attack input script, around line 56, add:
Code:
;; dale_coop: stop the Player's movements:
LDA #$00
STA Object_h_speed_lo,x
STA Object_h_speed_hi,x
STA Object_v_speed_lo,x
STA Object_v_speed_hi,x
LDA Object_direction,x
AND #%00000111
STA Object_direction,x
;; and stop the scrolling:
LDA scrollByte
AND #%00111110
ORA #%00000010
STA scrollByte
Where is the attack input script located? Is it the "Handle Physics" script?
 
Last edited:

dale_coop

Moderator
Staff member
The melee attack is script you assigned to your Input Scripts. Depending of the module you use, that script can be located in different location
(don't hesitate to check/refer again to the tutorial videos).
 
Top Bottom