4.5.9 Stop player moving while attacking help please

Matsuura77

New member
Hi folks. i feel incredibly thick as ive trawled through the posts / tutorials and cant find a solution. im hoping one of you wonderful people has a simple fix.

Im using metrovania in 4.5.9 and need a melee attack that does the following.
1. stops player movement while attack animation plays
2. returns player to doing whatever it was doing before button B was pressed.

I also need the melee weapon to have left and right states, depending (obviously) on the direction the player is facing when attacking).

thankyou all in advance for your help :)
 
Last edited:

dale_coop

Moderator
Staff member
Hi folks. i feel incredibly thick as ive trawled through the posts / tutorials and cant find a solution. im hoping one of you wonderful people has a simple fix.

Im using metrovania in 4.5.9 and need a melee attack that does the following.
1. stops player movement while attack animation plays
2. returns player to doing whatever it was doing before button B was pressed.

I also need the melee weapon to have left and right states, depending (obviously) on the direction the player is facing when attacking).

thankyou all in advance for your help :)
Can you share your current melee attack input script?
Adapting the other ones depends on how your script is set up, since every project is different.
 

Matsuura77

New member
I
Can you share your current melee attack input script?
Adapting the other ones depends on how your script is set up, since every project is different.
Im working with the brawler base change to attack. Ive rird a few bits but I keep brining what ive tried when it doesn't work šŸ˜‚
 

Matsuura77

New member
Ive a 2 frame attack animation. And the weapon sprite (left and right).
There are other bits with the 2nd weapon which ive more or less sorted thanks to the bomb tutorial.
Im using the metrovania base with left and right scrolling
 

dale_coop

Moderator
Staff member
ok...
without your actual code (script) it's difficult to give a guided advice.
in your movement inputs script, check your player's action step and if it's the attack, just skip the script (RTS)
 

Matsuura77

New member
ok.. so ive figured out everything except getting the player to not glide after attacking if the D pad is still pressed
 

Matsuura77

New member
Can you share your current melee attack input script?
Adapting the other ones depends on how your script is set up, since every project is different.
Here is the code im using. theres a couple of other bits and bobs ive added to some other scripts. atm the player attacks fine, everything is synced perfectly. the only issues i have now are 1. the player does the idle drift after attacking if the d pad is still pressed. 2. i need to stop the attack if hes jumping.

Code:
   ;; if you would like unlockable weapons,
    ;; that will be created with the b button
    ;; use this code.
   
 
    TXA
    STA temp ;; assumes the object that we want is in x.
   
    CMP #$04 ;; is it already attacking?
    BNE +canAttack
        ;; wait until we're back to idle to attack again.
        RTS
    +canAttack

    ChangeActionStep temp, #$04 ;; assumes that "attack" is in action 2
    ;arg0 = what object?
    ;arg1 = what behavior?
    StopMoving temp, #$FF, #$00
       

        WEAPON_POSITION_RIGHT_X = #$10
        WEAPON_POSITION_RIGHT_Y = #$00
 
        WEAPON_POSITION_LEFT_X = #$F8
        WEAPON_POSITION_LEFT_Y = #$00
        WEAPON_OBJECT = #$01
        WEAPON_RIGHT_STATE = #$00
        WEAPON_LEFT_STATE = #$01

       
        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        ;; Now, we have to create the object.
        ;; We will need to determine the direction
        ;; of the player.
        LDX player1_object
        TXA
        STA temp
        GetObjectDirection temp ;; temp still observed from above.
            ;;; this object's direction is now loaded into the
            ;;; accumulator for comparison after the macro.
            ;; 0 = down
            ;; 1 = downright
            ;; 2 = right
            ;; 3 = upright
            ;; 4 = up
            ;; 5 = upleft
            ;; 6 = left
            ;; 7 = downleft
         
                CMP #$02
                BNE +notRight
                ;;; CREATE RIGHT WEAPON
                LDX player1_object
                LDA Object_x_hi,x
                CLC
                ADC #WEAPON_POSITION_RIGHT_X
                STA tempA
                 LDA Object_screen,x
                ADC #$00
                STA tempD
               
                LDA Object_y_hi,x
                CLC
                ADC #WEAPON_POSITION_RIGHT_Y
                STA tempB
             
                LDA #WEAPON_OBJECT
                STA tempC
               
             
               ;; use this is you want to always create a single object, based on
                   ;; the constant above.
                   ; CreateObject tempA, tempB, #WEAPON_OBJECT, #WEAPON_RIGHT_STATE, currentNametable
               
                   ;;; use this if you want to create a variable object based on
                   ;;; the weaponChoice varaible.
                   ; PlaySound #sfx_damage
                   CreateObjectOnScreen tempA, tempB, tempC, #WEAPON_RIGHT_STATE, tempD
                   LDA #%11000000 ; LDA #%11000000
                   STA Object_direction,x
                   JMP +doneWithCreatingWeapon
            +notRight
           
                ;;; CREATE LEFT WEAPON
                LDX player1_object
                LDA Object_x_hi,x
                CLC
                ADC #WEAPON_POSITION_LEFT_X
                STA tempA
                LDA Object_screen,x
                SBC #$00
                STA tempD
                LDA Object_y_hi,x
                CLC
                ADC #WEAPON_POSITION_LEFT_Y
                STA tempB
               
                LDA #WEAPON_OBJECT
                STA tempC
               ;; use this is you want to always create a single object, based on
                   ;; the constant above.
                   ; CreateObject tempA, tempB, #WEAPON_OBJECT, #WEAPON_DOWN_STATE, currentNametable
               
                   ;;; use this if you want to create a variable object based on
                   ;;; the weaponChoice varaible.
                   ; PlaySound #sfx_damage
                   CreateObjectOnScreen tempA, tempB, tempC, #WEAPON_LEFT_STATE, tempD
                   LDA #%10000000 ;LDA #%10000000
                 STA Object_direction,x
                 JMP +doneWithCreatingWeapon
            +notLeft
           
        +doneWithCreatingWeapon
       
    RTS
 

dale_coop

Moderator
Staff member
Tn that attack script, the beginning should be:
Code:
    TXA
    STA temp ;; assumes the object that we want is in x.
    
    GetActionStep temp   
    
    CMP #$04 ;; is it already attacking?
    BNE +canAttack
        ;; wait until we're back to idle to attack again.
        RTS
    +canAttack


And to stop the player's movements, I would replace the:
Code:
  StopMoving temp, #$FF, #$00

By:
Code:
        ;; stop the player 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
    
        ;; stop the scrolling :
        LDA scrollByte
        AND #%00111110
        ORA #%00000010
        STA scrollByte

Finally in all your movements inputs scripts (the MoveUp, MoveDown, ... or StartMovingUp, ... ones), I would make sure to have, at the begining of each of them :
Code:
    TXA
    STA temp ;; assumes the object that we want is in x.
 
    GetActionStep temp   
  
    CMP #$04 ;; is it attacking?
    BNE +notAttacking
        ;; is attacking, exit the script
        RTS
    +notAttacking:
...to prevent the movement scripts to execute, if the player is in attack state
 
Top Bottom