Monster Death Animation

Barry2

Member
Here is the code that I'm using for my monster hurt script. As of now my "hurt" for action step 7 is my death animation for my monster. I only have a 1 hit kill for this game so far but this is how I got it working. I have not added sound yet but that is something that i will be adding later. This is for Metromania 4.5.9. For those that are having a hard time with this as I did, my monster death animation is 6, which is #$06 in the code under ,CreateObjectOnScreen, you can put any number you like for your game I just happen to use #6. Please see that photo attached. Please remember that it starts with 0 not 1.

I am using Metromania platform 4.5.9 for this code.

I hope this helps someone out there :cool:




Code:
TXA
STA temp
GetActionStep temp
    CMP #$07 ;; we will use action step 7 for hurt.
    BNE +doNotSkipHurtingThisObject;;; if he is hurt, he cant be hurt again
        JMP +doSkipHurtingThisObject
+doNotSkipHurtingThisObject:
            ChangeActionStep temp, #$07
        LDA #$80  
        STA  Object_action_timer,x
        DEC Object_health,x
        LDA  Object_health,x
        BEQ +doNotSkipHurtingThisObject
                 JMP +doNotSkipHurtingThisObject
+doNotSkipHurtingThisObject:
               
                LDA Object_x_hi,x
                CLC
                ADC #$04
                STA tempA
                LDA Object_screen,x
                ADC #$00
                STA tempD
                LDA Object_y_hi,x
                    CLC
                ADC #$04
                STA tempB
                LDA Object_direction,x
                AND #%00000111
                STA tempC
               
                DestroyObject
               
                CreateObjectOnScreen tempA, tempB, #$06, #$00, tempD
           
            CountObjects  #%00001000  
            BNE +notZeroCount
                LDA scrollByte
                ORA #%00000010
                STA scrollByte
                ;;;if there are no more monster left, we want to disable
                ;;; the edge check for scrolling
                ;LDA screenflag00
                AND #%11101111
                ;STA screenflag00
            +notZeroCount:
    +doSkipHurtingThisObject
 

Attachments

  • Game object for nesmaker.JPG
    Game object for nesmaker.JPG
    28.9 KB · Views: 12

TolerantX

Active member
Here is the code that I'm using for my monster hurt script. As of now my "hurt" for action step 7 is my death animation for my monster. I only have a 1 hit kill for this game so far but this is how I got it working. I have not added sound yet but that is something that i will be adding later. This is for Metromania 4.5.9. For those that are having a hard time with this as I did, my monster death animation is 6, which is #$06 in the code under ,CreateObjectOnScreen, you can put any number you like for your game I just happen to use #6. Please see that photo attached. Please remember that it starts with 0 not 1.

I am using Metromania platform 4.5.9 for this code.

I hope this helps someone out there :cool:




Code:
TXA
STA temp
GetActionStep temp
    CMP #$07 ;; we will use action step 7 for hurt.
    BNE +doNotSkipHurtingThisObject;;; if he is hurt, he cant be hurt again
        JMP +doSkipHurtingThisObject
+doNotSkipHurtingThisObject:
            ChangeActionStep temp, #$07
        LDA #$80 
        STA  Object_action_timer,x
        DEC Object_health,x
        LDA  Object_health,x
        BEQ +doNotSkipHurtingThisObject
                 JMP +doNotSkipHurtingThisObject
+doNotSkipHurtingThisObject:
              
                LDA Object_x_hi,x
                CLC
                ADC #$04
                STA tempA
                LDA Object_screen,x
                ADC #$00
                STA tempD
                LDA Object_y_hi,x
                    CLC
                ADC #$04
                STA tempB
                LDA Object_direction,x
                AND #%00000111
                STA tempC
              
                DestroyObject
              
                CreateObjectOnScreen tempA, tempB, #$06, #$00, tempD
          
            CountObjects  #%00001000 
            BNE +notZeroCount
                LDA scrollByte
                ORA #%00000010
                STA scrollByte
                ;;;if there are no more monster left, we want to disable
                ;;; the edge check for scrolling
                ;LDA screenflag00
                AND #%11101111
                ;STA screenflag00
            +notZeroCount:
    +doSkipHurtingThisObject
There's a typo in your code :



Code:
BEQ +doNotSkipHurtingThisObject
                 JMP +doNotSkipHurtingThisObject
+doNotSkipHurtingThisObject:

is really suppose to be :

Code:
BEQ +doNotSkipHurtingThisObject
                 JMP +doSkipHurtingThisObject
+doNotSkipHurtingThisObject:
 

TolerantX

Active member
@Barry2
Here's a fixed code:

Code:
STA temp
GetActionStep temp
    CMP #$07 ;; we will use action step 7 for hurt.
    BNE +doNotSkipHurtingThisObject;;; if he is hurt, he cant be hurt again
        JMP +doSkipHurtingThisObject
+doNotSkipHurtingThisObject
        ChangeActionStep temp, #$07
        LDA #$80 
        STA  Object_action_timer,x
        DEC Object_health,x
        LDA  Object_health,x
        BEQ +doNotSkipHurtingThisObject
                 JMP +doSkipHurtingThisObject
+doNotSkipHurtingThisObject
              
                LDA Object_x_hi,x
                CLC
                ADC #$04
                STA tempA
                LDA Object_screen,x
                ADC #$00
                STA tempD
                LDA Object_y_hi,x
                    CLC
                ADC #$04
                STA tempB
                LDA Object_direction,x
                AND #%00000111
                STA tempC
              
                DestroyObject
              
                CreateObjectOnScreen tempA, tempB, #$06, #$00, tempD
          
            CountObjects  #%00001000 
            BNE +notZeroCount
                LDA scrollByte
                ORA #%00000010
                STA scrollByte
                ;;;if there are no more monster left, we want to disable
                ;;; the edge check for scrolling
                ;LDA screenflag00
                AND #%11101111
                ;STA screenflag00
            +notZeroCount:
    +doSkipHurtingThisObject


I haven't tested it, just simply fixed the typo in the code.
 
Top Bottom