(Solved by dale_coop) Changing my shooting point when ducking/crouched

LaffinJoker

New member
So I followed this:

4.5.X] Quick tutorial: Adding the "skip top object collision" flag to use when crouching​

and it worked brilliantly but I’d like to make it where I can shoot when ducking and it will look like I’m shooting from my gun rather than the original position when not ducking. Does anyone have any idea how I would do this?
 

dale_coop

Moderator
Staff member
Hmmm. In your shoot script, check the the "skip collision" action step flag is set (= if the player is "crouching")... in that case, change the value used for the vertical position of the projectile.

In the script, you will see something like:
Code:
        LDA Object_y_hi,x
        CLC
        ADC #$04
        STA tempB
In that variable the vertical position value is set.

So, after those lines... add a code like that:
Code:
    LDA Object_vulnerability,x
    AND #%10000000  ;; skip top collision set?
    BEQ +notCrouching ;; no, skip        
        LDA tempB
        CLC
        ADC #$03  ;; 3 pixel lower than the normal shooting position
        STA tempB
    +notCrouching:
 

LaffinJoker

New member
Hmmm. In your shoot script, check the the "skip collision" action step flag is set (= if the player is "crouching")... in that case, change the value used for the vertical position of the projectile.

In the script, you will see something like:
Code:
        LDA Object_y_hi,x
        CLC
        ADC #$04
        STA tempB
In that variable the vertical position value is set.

So, after those lines... add a code like that:
Code:
    LDA Object_vulnerability,x
    AND #%10000000  ;; skip top collision set?
    BEQ +notCrouching ;; no, skip       
        LDA tempB
        CLC
        ADC #$03  ;; 3 pixel lower than the normal shooting position
        STA tempB
    +notCrouching:
Thank you a million. I got it working with your code, I had to change the ADC #$03 to ADC #$08 but my character is 3x4 sprites so I’m not using the original ADC #$04 setting. Thank you very much for helping me break through my stuck point.
 
Top Bottom