[Solved] Death Animations (4.5)

dale_coop

Moderator
Staff member
Basically, it depends what do YOU want for your game, yeah

For example... Here a modified script:

Code:
	TXA
	STA temp
	
	GetActionStep temp
	CMP #$07 ;; we will use action step 7 for hurt.
	BNE +
	JMP +doSkipHurtingThisObject ;; if he is hurt, he can't be hurt again.
	+
	CMP #$06 ;; we will use action step 6 for death.
	BNE +
	JMP +doSkipHurtingThisObject ;; if he is hurt, he can't be hurt again.
	+

		DEC Object_health,x
		LDA Object_health,x
		BEQ +dontSkipHurtingThisObject
			;; reverse :
			TYA
			PHA
			LDA Object_direction,x
			AND #%00000111
			CLC
			ADC #$04
			AND #%00000111
			TAY ;; this is the "direction", where
				;; 0 = down, counterclockwise, 7=down-left
			LDA DirectionTableOrdered,y
			ORA FacingTableOrdered,y
			STA Object_direction,x
			PLA
			TAY
			ChangeActionStep temp, #$07
			LDA #$80
			STA Object_action_timer,x
			JMP +doSkipHurtingThisObject
		+dontSkipHurtingThisObject:
			;; maintain x and y positions for dropable location
			LDA Object_x_hi,x
			STA tempA
			LDA Object_y_hi,x
			STA tempB
			ChangeActionStep temp, #$06	
			;; stops
			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			
			
			CountObjects #%00001000
			BNE +notZeroCount
				LDA scrollByte
				ORA #%00000010
				STA scrollByte
				;;; if there are no more monsters left, we want to disable
				;;; the edge check for scrolling.
				LDA ScreenFlags00
				AND #%11101111
				STA ScreenFlags00
			+notZeroCount
	+doSkipHurtingThisObject


The action Step 7 will do a recoil, reverse code (hurt state)... and the action Step 6, will stop the monster (death state).
 

jorotroid

Member
Here is my take on the adventure hurt code, mouse. Just noticed Dale's post above, so if his code worked for you, then I guess this is just an alternative for future scholars to study. This covers just the relevant part of the file from the start of the file down to the comment saying ";;; here, we can handle droppables"

Code:
	TXA
	PHA
	STA temp
	GetActionStep temp
	CMP #$07 ;; we will use action step 7 for hurt.
	BNE +
		JMP +doSkipHurtingThisObject ;; if he is hurt, he can't be hurt again.
	+:
		CMP #$06
		BNE +dontSkipHurtingThisObject
			JMP +doSkipHurtingThisObject
	+dontSkipHurtingThisObject:
		;;;;;;;;;;;;;;;;;; Here, we need to determine the direction.
		;;;;;;;;;;;;;;;;;; To do that, we can compare positions of self and other's center.
		;;;;;;;;;;;;;;;;;;;; HANDLE RECOIL
			TXA
			PHA
			LDX selfObject
			LDA Object_direction,x
			AND #%11110000
			STA temp1
			PLA
			TAX
			
			LDA Object_direction,x
			AND #%00001111
			ORA temp1
			STA Object_direction,x
			
		;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
	
	
		
		DEC Object_health,x
		
		BEQ dontSkipHurtingThisObject
			ChangeActionStep temp, #$07
			JMP +doSkipHurtingThisObject
		dontSkipHurtingThisObject:
			ChangeActionStep temp, #$06
			;; maintain x and y positions for dropable location
			LDA Object_x_hi,x
			STA tempA
			LDA Object_y_hi,x
			STA tempB

			;;; here, we can handle droppables.

Side note, you might notice that I nixed the line after the health variable gets decremented (LDA Object_health,x). I did this because the line after is a BEQ and the DEC opcode already sets the zero flag. So this will save you 3 bytes!
 

vanderblade

Active member
Hey Davey. Thanks for this. The monster death works perfectly, as far as I can tell. But I'm having troubles adapting your fix for the shooter mod to the brawler. Any chance you could adapt it?

I do every step, but I'm having issues like health not decreasing and my timer on the player death object not being adhered to. I see a glimpse of (in my case) action state 6 with the death animation and then immediately reset without having taken a life away.
 

AllDarnDavey

Active member
Hey Davey. Thanks for this. The monster death works perfectly, as far as I can tell. But I'm having troubles adapting your fix for the shooter mod to the brawler. Any chance you could adapt it?

I do every step, but I'm having issues like health not decreasing and my timer on the player death object not being adhered to. I see a glimpse of (in my case) action state 6 with the death animation and then immediately reset without having taken a life away.
If you're seeing it just start to play before the reset, then it is triggering correctly, just not waiting until the end of the animation for the reset. Did you set both the EndAnimation and EndAction to GoToContinue? Try setting EndAnimation to Repeat, but EndAction to GoToContinue, and make the Action Timer a bigger number to give the animation plenty of time.
 

vanderblade

Active member
It's so strange. No matter what I do, the game reloads instantly, with only a glimpse of my death animation. All that is supposed to happen when health reaches 0 is the game switches to my death action step. That's the only code there.

Even if I set both EndAction and EndAnimation to repeat or loop on my death action state, the game still triggers a reload. Yet it shouldn't since all the code to do that is in the GoToContinue part of the EndTimerScripts.

Makes me think there is some other code somewhere in the brawler mod that is hijacking this process. Any thoughts?

Current HurtPlayer script:

Code:
LDA gameHandler
    AND #%10000000
    BEQ +canHurtPlayer
        JMP +skipHurt
+canHurtPlayer:

    GetActionStep player1_object
    CMP #$07 ;; hurt state.
    BNE +notAlreadyInHurtState
        JMP +skipHurt
    +notAlreadyInHurtState
    
         PlaySound #sfx_seven
         DEC myHealth
        
         BMI +healthBelowZero
         BEQ +healthBelowZero
             JMP +notDeadYet
         +healthBelowZero
             JMP +playerHealthIsZero
         +notDeadYet
;         UpdateHudElement #$02
         ChangeActionStep player1_object, #$07
         JMP +skipHurt

 +playerHealthIsZero:

    ;ChangeActionStep player1_object, #$06
    Dec myLives
    LDA myLives
    BNE myLivesNotZero
        JMP RESET ;; game over
        ;;;; could also warp to gameover screen here
        
myLivesNotZero
    ChangeActionStep player1_object, #$06
    RTS
    ;LDA continueMap
    ;STA warpMap
    
    ;LDA continueScreen
    ;STA currentNametable
    
    ;LDX player1_object
    ;STA Object_screen,x
    
    ;LDA #$02 ;; this is continue type warp.
    ;STA screenTransitionType ;; is of warp type

    ;LDA gameHandler
    ;ORA #%10000000
    ;STA gameHandler ;; this will set the next game loop to update the screen.
    ;LDA myMaxHealth
    ;STA myHealth
+skipHurt

Current EndTimer GoToContinue script excerpt:

Code:
;;; 09 = Go To Continue
goToContinue_action:
    LDA continueMap
    STA warpMap
    
    LDA continueScreen
    STA currentNametable
    
    LDX player1_object
    STA Object_screen,x
    
    LDA #$02 ;; this is continue type warp.
    STA screenTransitionType ;; is of warp type

    LDA gameHandler
    ORA #%10000000
    STA gameHandler ;; this will set the next game loop to update the screen.
    LDA myMaxHealth
    STA myHealth


    RTS
 

PasseGaming

Active member
I had a similar issue with my SHMUP. I don't remember what I did to fix it, cause it works fine now. I'll take a peek under the hood and see if I can find what's different about what I did.
 

Barry2

Member
Was this
It's so strange. No matter what I do, the game reloads instantly, with only a glimpse of my death animation. All that is supposed to happen when health reaches 0 is the game switches to my death action step. That's the only code there.

Even if I set both EndAction and EndAnimation to repeat or loop on my death action state, the game still triggers a reload. Yet it shouldn't since all the code to do that is in the GoToContinue part of the EndTimerScripts.

Makes me think there is some other code somewhere in the brawler mod that is hijacking this process. Any thoughts?

Current HurtPlayer script:

Code:
LDA gameHandler
    AND #%10000000
    BEQ +canHurtPlayer
        JMP +skipHurt
+canHurtPlayer:

    GetActionStep player1_object
    CMP #$07 ;; hurt state.
    BNE +notAlreadyInHurtState
        JMP +skipHurt
    +notAlreadyInHurtState
   
         PlaySound #sfx_seven
         DEC myHealth
       
         BMI +healthBelowZero
         BEQ +healthBelowZero
             JMP +notDeadYet
         +healthBelowZero
             JMP +playerHealthIsZero
         +notDeadYet
;         UpdateHudElement #$02
         ChangeActionStep player1_object, #$07
         JMP +skipHurt

+playerHealthIsZero:

    ;ChangeActionStep player1_object, #$06
    Dec myLives
    LDA myLives
    BNE myLivesNotZero
        JMP RESET ;; game over
        ;;;; could also warp to gameover screen here
       
myLivesNotZero
    ChangeActionStep player1_object, #$06
    RTS
    ;LDA continueMap
    ;STA warpMap
   
    ;LDA continueScreen
    ;STA currentNametable
   
    ;LDX player1_object
    ;STA Object_screen,x
   
    ;LDA #$02 ;; this is continue type warp.
    ;STA screenTransitionType ;; is of warp type

    ;LDA gameHandler
    ;ORA #%10000000
    ;STA gameHandler ;; this will set the next game loop to update the screen.
    ;LDA myMaxHealth
    ;STA myHealth
+skipHurt

Current EndTimer GoToContinue script excerpt:

Code:
;;; 09 = Go To Continue
goToContinue_action:
    LDA continueMap
    STA warpMap
   
    LDA continueScreen
    STA currentNametable
   
    LDX player1_object
    STA Object_screen,x
   
    LDA #$02 ;; this is continue type warp.
    STA screenTransitionType ;; is of warp type

    LDA gameHandler
    ORA #%10000000
    STA gameHandler ;; this will set the next game loop to update the screen.
    LDA myMaxHealth
    STA myHealth


    RTS
Was this code ever fix or solved? I just resets after i die. I like to have a death, instead of a reset
 

AllDarnDavey

Active member
Was this code ever fix or solved? I just resets after i die. I like to have a death, instead of a reset
Yeah, @vanderblade and I got a working brawler version. It was a bit more complicated, we had to change most inputs scripts a bit to avoid a major bug. He was going to post it to the forums, but last I talked to him, he still had a non death animation bug he was trying to get working in his project first.

Give me a few days, I'll gather all the changes we had to make to get it working and post a tutorial on the forums.
 

Barry2

Member
Yeah, @vanderblade and I got a working brawler version. It was a bit more complicated, we had to change most inputs scripts a bit to avoid a major bug. He was going to post it to the forums, but last I talked to him, he still had a non death animation bug he was trying to get working in his project first.

Give me a few days, I'll gather all the changes we had to make to get it working and post a tutorial on the forums.
Thanks you!!
 

Logana

Well-known member
Thanks you!!
hello barry welcome to the forums, noticed these are your only posts, please post in introduce your self, you would meet a lot oc cool people like dale and jolly shadow and passes gaming and nishi ect im sure they would be glad to see you ;3
 

AllDarnDavey

Active member
@Barry2
I posted a Brawler Death Animation tutorial here.
 

vanderblade

Active member
Thanks for posting that, Davey. I've been caught up with my new kid and work lately, so I've been MIA as far as NESDev goes.
 

ronin1011

Member
The easiest way to add death animations for enemies is to make an explosion VFX and change the doHandleHurtMonster script to spawn that in when the object is destroyed. I actually just figured out something very similar for making bullet hit VFX for my game.
You'll want to replace your doHandleHurtMonster shooter script with this. I kept in all the normal stuff allowing for monsters with more than a single hit of health, and the bit about counting monsters to unlock the scroll.
Code:
    DEC Object_health,x
    LDA Object_health,x
    CMP #$00
    BNE +
        ;;;; play vfx
        ;;;; destroy this object
        TXA ;; Store X in stack
        PHA
        TAX
        LDA Object_x_hi,x ;; Get this object's origin location
        CLC
        ADC self_center_x
        STA tempA
        LDA Object_y_hi,x ;; Get this object's origin location
        CLC
        ADC self_center_y
        STA tempB
        LDA Object_screen,x
        CLC
        ADC #$00
        STA tempD
        DestroyObject       
        CreateObjectOnScreen tempA, tempB, #$08, #$00, tempD
        PLA    ;; Restore X from stack
        TAX
    +:
    CountObjects #%00001000
    BNE +notZeroCount
        ;;; if there are no more monsters left, we want to disable
        ;;; the edge check for scrolling.
        LDA ScreenFlags00
        AND #%11101111
        STA ScreenFlags00

+notZeroCount:
Of course this is just a single VFX for all enemies dying, you'll have to get more creative if you want custom death VFX per enemy type.
Hey Davey when you say create a VFX do you mean as a new game object or an animation for the monster object?
 

AllDarnDavey

Active member
Hey Davey when you say create a VFX do you mean as a new game object or an animation for the monster object?
I mean new game object. You get the players X&Y position and then spawn in the death VFX game object using those X&Y values. You could combine several different deathVFX into a single game object (so long as they all fit into the same size rectangle), by putting a different deathVFX into each action slot of one game object, set the end action as "destroy me" and after spawning in that new game object use ChangActionState to set the specific the deathVFX you want by forcing it into that action state.
 

PewkoGames

Member
I'm having an issue with my player death animation using the shooter module. I'm using hurt tiles as the main form of hazard. But when I hit them no matter how many times I've tried, it just resets the screen without playing the animation. It has to do with the fact that I'm using hurt tiles. I've noticed this problem in other modules. Can you help me figure this out?
 

Attachments

  • TombGator7.gif
    TombGator7.gif
    2.6 MB · Views: 13

ronin1011

Member
I'm having an issue with my player death animation using the shooter module. I'm using hurt tiles as the main form of hazard. But when I hit them no matter how many times I've tried, it just resets the screen without playing the animation. It has to do with the fact that I'm using hurt tiles. I've noticed this problem in other modules. Can you help me figure this out?
I was just looking for an answer to that myself. I was able to make a death animation play when hit by a monster or monster projectile but when hitting a hurt tile it doesn't play the animation.
 
Top Bottom