4.5.9 A Fix For The Weapon Spawning Bug

Bucket Mouse

Active member
If you pull out your Melee Weapon in the Adventure module, then quickly change directions (as players tend to do when dodging enemy fire), the weapon will hang there in midair for the duration of the attack time, without you. This obviously looks bad. Joe mentions it in the tutorial videos and offers a theory on how to fix it, but stops short of telling you specifically how.

I don't know why anyone would want this in their game, so here is the fix.

Open doDrawSprites and toward the bottom, right after "doneDrawingThisSprite," throw this in:

Code:
        ;;;  THIS ADDED PART KEEPS THE MELEE WEAPON FROM STAYING ONSCREEN ONCE THE PLAYER SPRITE MOVES
        LDA Object_flags,x
        AND #%00000100
        BNE +isWeapon
        JMP +isNotWeapon
            +isWeapon
            TXA
            TAY
            GetActionStep player1_object
            CMP #$01 ; attacking
            BNE +isNotWeapon
            TYA
            TAX
            DestroyObject
        +isNotWeapon
                        ;;;; END OF ADDED PART

There, problem over.

Take note of where I've marked "Attacking." In my game I have it set to Action Step 02 (the third action). If you have your attack set to a different step, you should change the number to whatever yours is.
 
Last edited:

offparkway

Member
If you pull out your Melee Weapon in the Adventure module, then quickly change directions (as players tend to do when dodging enemy fire), the weapon will hang there in midair for the duration of the attack time, without you. This obviously looks bad. Joe mentions it in the tutorial videos and offers a theory on how to fix it, but stops short of telling you specifically how.

I don't know why anyone would want this in their game, so here is the fix.

Open doDrawSprites and toward the bottom, right after "doneDrawingThisSprite," throw this in:

Code:
        ;;;  THIS ADDED PART KEEPS THE MELEE WEAPON FROM STAYING ONSCREEN ONCE THE PLAYER SPRITE MOVES
        LDA Object_flags,x
        AND #%00000100
        BNE +isWeapon
        JMP +isNotWeapon
            +isWeapon
            TXA
            TAY
            GetActionStep player1_object
            CMP #$02 ; attacking
            BEQ +isNotWeapon
            TYA
            TAX
            DestroyObject
        +isNotWeapon
                        ;;;; END OF ADDED PART

There, problem over.

Take note of where I've marked "Attacking." In my game I have it set to Action Step 02 (the third action). If you have your attack set to a different step, you should change the number to whatever yours is.
I'm super interested in this! As I've been having this same issue in the Brawler module, since the "punch" works like a melee weapon would.

I have two attacks: a punch and a kick. Using this code had no effect on my punch (when it seems like it should have, as it is action step 02) but my kick was affected instead (03) and the weapon object just disappears way too quickly, regardless if the player is moving or not. I changed the code to CMP 03, and that affected my punch but the same thing happens.... the weapon just flashes very briefly on screen and disappears.
 

Otterbits

New member
I'm super interested in this! As I've been having this same issue in the Brawler module, since the "punch" works like a melee weapon would.

I have two attacks: a punch and a kick. Using this code had no effect on my punch (when it seems like it should have, as it is action step 02) but my kick was affected instead (03) and the weapon object just disappears way too quickly, regardless if the player is moving or not. I changed the code to CMP 03, and that affected my punch but the same thing happens.... the weapon just flashes very briefly on screen and disappears.
This is what happened to me too, which is very frustrating. The weapon disappears so quickly I can barely even see it. Sometimes it doesn't even appear at all. Any idea how to fix this anybody?
 

offparkway

Member
This is what happened to me too, which is very frustrating. The weapon disappears so quickly I can barely even see it. Sometimes it doesn't even appear at all. Any idea how to fix this anybody?
I ended up disabling inputs as long as my player was attacking. So he can't turn until the weapon (in my case a fist and a kick) goes away.
 

PasseGaming

Active member
I just watched the Brawler video and he also touches upon this but offers no fix. I don't understand how he couldn't see why no one would want this in their game. I would of addressed it straight away. Thanks for this!
 
Top Bottom