(SOLVED) 4.5.6 Metrodvania Monster Damage and Death

9Panzer

Well-known member
Can't seem to find the script that tells the game how to handle damage and death. I assumed that handle monster hut would be the script but I actually pulled it all together and the monster still disappear after taking a single shot. Can anyone point me in the right direction?
 

TakuikaNinja

Active member
The script you're looking for is BASE_4_5\Game\MOD_MetroidVania\Common\hurtPlayer_MetroidVania.asm
Hope that helps!
 

9Panzer

Well-known member
Thanks Takuika, but that one is for the player getting hurt I've managed to figure how to manipulate that one.
I tried messing with hurtmonster_PlatformBase.asm which seemed like the logical place to go:

Untitled-3.jpg

But it appears to be being ignored by the Metroidvania module somewhere. I even went as far as to set it to "blank.asm" and when the player shoots the monsters they still get immediately destroyed. Does it maybe have something to do with the default shoot script?
 

9Panzer

Well-known member
Okay I have a new issue on this topic. Maybe there is a quick fix? I commented out
;DestroyObject
;ChangeActionStep otherObject, #$07
As you suggested and that gave me access to the handlemonster script. Which made so much more sense when I got it going. I even managed to get my first boss fight started witch was AWESOME.

However, the code I used is causing the wrong object to die when I shoot them.


LDA gameHandler
AND #%10000000
BEQ +canHurtPlayer
JMP +skipHurt
+canHurtPlayer:
TXA
STA temp
GetActionStep temp ;;skip if already in either death or hurt state
CMP #$06 ;; hurt state.
BCC +notAlreadyInHurtState
JMP +skipHurt
+notAlreadyInHurtState

LDA Object_health,x
SEC
SBC #$01
BEQ +healthBelowZero
BMI +healthBelowZero
STA Object_health,x
ChangeActionStep temp, #$07
JMP +skipHurt
+healthBelowZero
;;;; if this is set to a right edge
;;;; flip the bit so that scrolling can continue
;;;; if all bad guys are gone.
CountObjects #%00001000
CMP #$02
BCC +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
ChangeActionStep temp, #$06

+notZeroCount:
ChangeActionStep temp, #$06
+skipHurt


Can anyone see where I am going wrong? I thought I had this licked last night. :(
 

9Panzer

Well-known member
Thanks for the quick response, Taku. Feel pretty bad constantly asking for help ...
I'm not really sure what is before that that is the way the default script starts. I just tried reverted back to the original and it does hit the proper objects and it uses action state to 6.

The only reason this script doesn't do what I'm after is that if the monster is at 0 health it needs to use a different action state to "kill" the monster. I've tried pulling every script I could find in the forums and nothing seems to fit the bill.

TXA
STA temp
GetActionStep temp
CMP #$06 ;; we will use action step 6 for hurt.
BEQ +doSkipHurtingThisObject ;; if he is hurt, he can't be hurt again.
ChangeActionStep temp, #$06
LDA #$80
STA Object_action_timer,x
DEC Object_health,x
LDA Object_health,x
BNE +doSkipHurtingThisObject
;DestroyObject
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
 

9Panzer

Well-known member
I think I figured it out. I used Alldarndaveys script from https://www.nesmakers.com/index.php?threads/solved-death-animations-4-5.6168/ that seems to be doing the trick for me. Thanks again Taku!

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 until the timer wears off.
+
CMP #$06 ;; we will use action step 6 for die.
BNE +
JMP +doSkipHurtingThisObject ;; if he is dying, he can't be hurt again.
+
StopMoving temp, #$FF, #$00 ;;stop it from moving
DEC Object_health,x ;;take off 1 point of health
LDA Object_health,x ;;load it's health into accumulator for comparison
BEQ +die ;;if zero health die
ChangeActionStep temp, #$07 ;change to hurt action
PlaySound #sfx_damage ;;play hurt sound
JMP +doSkipHurtingThisObject ;;skip the rest
+die
ChangeActionStep temp, #$06 ;;change to death action
PlaySound #sfx_dead ;; play death sound
CountObjects #%00001000 ;;count enemies onscreen for monster locks
;CMP #$02 ;;because the object kills itself at the end of it's death animation and this script doesn't kill it anymore we check for 1 monster left or 0 using BCC which means less than 02
BCC +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
 

vanderblade

Active member
I was definitely not paying attention when I replied, my bad.
You need to go to line 117 in doHandleObjectCollisions_PlatformerBase.asm and comment out the DestroyObject macro.
The monster hurt script should work after that.
I'm going through and making all these small changes just to get basic functionality working on the Metroidvania mod. Thanks for this, @TakuikaNinja! Lucikly, @9Panzer has a really clear breadcrumb trail to follow.
 

offparkway

Active member
I was definitely not paying attention when I replied, my bad.
You need to go to line 117 in doHandleObjectCollisions_PlatformerBase.asm and comment out the DestroyObject macro.
The monster hurt script should work after that.
I'm just now working with the Metroidvania module and wanted hit points for my enemies. I commented out this macro, but all that happens is the enemy charges at me much faster and can't be killed. Am I missing something?
 

offparkway

Active member
there should be a JSR doHandleHurtMonster placed after were you commented that line out.
Do you see that?
yes, it's there. does that need to be modified? (I'm just getting all this set up, so my scripts are pretty stock from the Metroidvania module)

(side note... i'm also noticing that if i get hit by an enemy, my character just slides in the idle state until i let go of the D pad or change directions)
 
Last edited:

9Panzer

Well-known member
yes, it's there. does that need to be modified? (I'm just getting all this set up, so my scripts are pretty stock from the Metroidvania module)

(side note... i'm also noticing that if i get hit by an enemy, my character just slides in the idle state until i let go of the D pad or change directions)
Check your other thread for the solution to your slide. I had the same issue.

Its been years since I've seen a stoke metroidvania module - but you need to follow the bouncing ball. by commenting out destroyme and having the JSR (Jump sub routine) you have now left that script. You need to go into your hurtMonster_platformer.asm to see what it is doing now. If its not loaded that could be your issue? If it is see what its running through.
 

offparkway

Active member
Check your other thread for the solution to your slide. I had the same issue.

Its been years since I've seen a stoke metroidvania module - but you need to follow the bouncing ball. by commenting out destroyme and having the JSR (Jump sub routine) you have now left that script. You need to go into your hurtMonster_platformer.asm to see what it is doing now. If its not loaded that could be your issue? If it is see what its running through.
it is loaded, and it's pretty bare bones so I don't see why it would be doing anything weird. But I'll take another look and see if I missed something. Thanks!
 

9Panzer

Well-known member
it is loaded, and it's pretty bare bones so I don't see why it would be doing anything weird. But I'll take another look and see if I missed something. Thanks!
Another thought - have you actually tolf the object what you want done when its hurt? The routine defaults to telling the object to jump into Actionstep 7. If you haven't setup anything for it to do after that it will stay in that actionstep forever.
 

offparkway

Active member
Another thought - have you actually tolf the object what you want done when its hurt? The routine defaults to telling the object to jump into Actionstep 7. If you haven't setup anything for it to do after that it will stay in that actionstep forever.
I actually did think of that originally, so I set the monster's hurt state to stop moving (for a count of 1) and go to first afterwords. but all that happens is the monster instantly speeds up, continues to move in the same direction, and can't die. It sort of seems like it's calling the recoil somehow, but recoiling in the same direction that it was already moving.
 

offparkway

Active member
Check your other thread for the solution to your slide. I had the same issue.

Its been years since I've seen a stoke metroidvania module - but you need to follow the bouncing ball. by commenting out destroyme and having the JSR (Jump sub routine) you have now left that script. You need to go into your hurtMonster_platformer.asm to see what it is doing now. If its not loaded that could be your issue? If it is see what its running through.
...one thing that is confusing me: the JSR directs to doHandleHurtMonster (which doesn't seem to be loaded in the game anywhere). However you're suggesting I check hurtMonster_PlatformBase.asm (which IS loaded into my game). I'm not sure how those two are connected. I don't see any code in them that relate to each other... doHandleHurtMonster just has a destroy macro in it.
 

9Panzer

Well-known member
its just embedded into the system under that name.

Because you are doing a JSR to the hurt routine it isn't looking at that macro rather its being told to jump to the Subroutine that handles "monster hurt". If its loaded it tells it to stop running the collisions script and jump over to the monster hurt routine which is loaded with hurtMonster_PlatformBase.asm.

When I'm debugging I usually use a sound macro to confirm I'm going the right direction. If you have loaded up the tutorial assets you should have a couple of sounds you can use.

Try putting this line in in where you want to test (You may need to change the name of the SFX):
PlaySound #sfx_damage

Maybe try putting it at the top of your Hurt monster routine and see if when you hit the monster it makes the noise. If it does then you know you are on the right track.
 

offparkway

Active member
its just embedded into the system under that name.

Because you are doing a JSR to the hurt routine it isn't looking at that macro rather its being told to jump to the Subroutine that handles "monster hurt". If its loaded it tells it to stop running the collisions script and jump over to the monster hurt routine which is loaded with hurtMonster_PlatformBase.asm.

When I'm debugging I usually use a sound macro to confirm I'm going the right direction. If you have loaded up the tutorial assets you should have a couple of sounds you can use.

Try putting this line in in where you want to test (You may need to change the name of the SFX):
PlaySound #sfx_damage

Maybe try putting it at the top of your Hurt monster routine and see if when you hit the monster it makes the noise. If it does then you know you are on the right track.
ah, ok. I thought it was calling that particular macro. I understand now.

Great idea... and yes, it does now play the sound when I shoot the monster. So it's jumping scripts properly it seems. The fast motion thing is still weird. Must be the recoil? I think I wasn't killing the monster because it was speeding toward me and would kill me or disappear before I could kill it, lol.
 
Last edited:
Top Bottom