(4.5.X) Brawler Mod. Fix for player weapon sprite not facing the right direction.

vanderblade

Active member
Hey all,

Looks like I once again am using a module nobody else seems to be using. So, I discovered when using the Brawler Module that regardless of whether the player is facing left or right, the weapon sprite (in the tutorial's case, a PlayerFist) doesn't flip orientation. The result is that one of the attack directions is going to have a backwards PlayerFist. If you look closely at the tutorial videos, you'll see this is happening, but Joe doesn't notice. Easy oversight.

There are probably many ways to fix this, but I simply went into the ChangeToAttack_BrawlerBase.asm and changed the two instances of Weapon_Object into Weapon_Object1 and Weapon_Object2. I kept Weapon_Object1 = #$01 (the tutorial PlayerFist) and simply updated the Weapon_Object in the +notRight section to Weapon_Object1.

I used game object #$08 for a dedicated right-oriented PlayerFist, so I made Weapon_Object2 = #$08. I then updated the Weapon_Object when facing right to Weapon_Object2.

There is probably a way to make it work as intended (the game object sprite in #$01 simply flipping between left and right animations depending on player orientation, but I couldn't figure it out. This method does waste a game object spot, so it's not ideal, but for newbies wanting a basic functioning attack that displays the right oriented sprite, this is an easy fix. I'll paste the full ChangeToAttack_BrawlerBase.asm code below. Just remember that if you use a different game object for your second PlayerFist sprite to change the value accordingly.

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.

    GetActionStep temp
    CMP #$02 ;; is it already attacking?
    BNE +canAttack
        ;; wait until we're back to idle to attack again.
        RTS
    +canAttack
    ChangeActionStep temp, #$02 ;; 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 = #$08
 
        WEAPON_POSITION_LEFT_X = #$F8
        WEAPON_POSITION_LEFT_Y = #$08
        WEAPON_OBJECT1 = #$01 ;; this will display the sprite in the second game object slot
        WEAPON_OBJECT2 = #$08 ;; this will display the sprite in the ninth game object slot
        WEAPON_RIGHT_STATE = #$00
        WEAPON_LEFT_STATE = #$00

        
        ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        ;; 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_OBJECT2
                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.
                   CreateObjectOnScreen tempA, tempB, tempC, #WEAPON_RIGHT_STATE, tempD
                   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_OBJECT1
                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.
                   CreateObjectOnScreen tempA, tempB, tempC, #WEAPON_LEFT_STATE, tempD
                 LDA #%10000000
                 STA Object_direction,x
                 JMP +doneWithCreatingWeapon
                 ;+notLeft
            
        +doneWithCreatingWeapon 
        
    RTS
 

PasseGaming

Active member
At the very least you know your way around the code. I'm sure this will help someone at some point. I have no doubt about it.

I'm using the shooter module and am more or less on my own. What's worse is that im inexperienced, frustrating.
 

Billy Squire

New member
I've been having the same problem forever and couldnt come anywhere near as close as you to solving it. I copied your code that you pasted here (thank you) But now my player has no fist when facing one of the directions. Im sure its because its looking in a location now where my graphic doesnt exist (because my character's size is different than the one in the module so some of my numbers needed to be adjusted). You seem to definitely know your way around the program more than I do. Is there anyway you could explain to me a little more basic (dumbed down) how I might be able to understand where the placement is of my character first graphic so that I can point my code in the right direction?
 

vanderblade

Active member
Hey, Billy. I overthought the problem and had a silly, unnecessary solution. The only thing you really have to change in the default script is this part:

WEAPON_RIGHT_STATE = #$00
WEAPON_LEFT_STATE = #$00

In the default script, right and left are pointing to action step 00. This is why the fist isn't flipping properly. In your player fist object, just use action step 01 for the left state, assuming you have action step 00 as your right orientation, and then change the code in the default script to #$01 on the WEAPON_LEFT_STATE.

So, WEAPON_LEFT_STATE = #$01

The worst part about trying to figure this stuff out on my own is that I make ALL the mistakes.
 

Billy Squire

New member
Thank you so much for your quick response and help. Sorry for the delay on my own. I was trying really hard to solve the problem on my own without bothering you, but ive run into another small issue. When you explained your original fix (in the original post) I didnt completely understand all of the changes you were saying that you made, so to simplify it for myself I just copied and pasted your script (only changing out the weapon position coordinates since my player is bigger).

Then you explained you had found a better fix. I had already saved over the older script with the new one I copied from your post. I then made the adjustments you suggested in your follow up post to the adjusted script and now my game gives me an error every time I try to export and test it. Its killing me because I was making progress before I crashed it.

Im ASSUMING that I need to copy and paste the ORIGINAL script for the brawler module back into my game and then make the adjustments you suggested onto that script and I should be good. Does this sound correct to you? And if so, could you copy and paste that script on here in a response for me?
 

dale_coop

Moderator
Staff member
My advice, when you made modifications in a script, for experimenting... always make a backup of your script before the modifications.

Another advice, never work on the original scripts. If you need to modify an original script, make a duplicate and assign that new script in the project settings > Script Settings (like explained by Joe in the tutorials).... Why? Because when Joe will release an update of nesmaker and its modules, if you decide to install the update (because you want all the fixes and new features) it will overwrite ALL the original scripts, and you will lost all the modifications you would have made on those original scripts.
 
Top Bottom