(SOLVED) 4.5.6 Metrodvania Monster Damage and Death

9Panzer

Well-known member
hmm... Actionstep 7 (Hurt) is programmed to move the monster left as a recoil by default. There are some tweaks you can do to make it react differently... but I'm not convinced your problem is to do with recoil.

this is the settings I have for an average monster object. See how close you are.

1.jpg
- Make sure he has Health
- and his Max Speed and acceleration are set.

2.jpg
- Make sure end action is set to go to whatever action step you want to use (maybe first?) Mine says return action state with a custom code.
- No Object collisions you won't have, thats another custom code.
- Make sure he has an animation speed set to at least 1
-

3.jpg
- Finally make sure you have action step 6 (Kills object) set to Destroyme.
 

Barry2

Member
OK, for the life of me I cant seem to understand this. I've read everything I could for 2 days. I'm just trying to have a jump on kill for my monsters. I've tried changing scripts but I just seem to get a error every time I try to test my game. So I've not put my scripts back to where they were from the beginning. Can anyone simplify this prosses to me. What script am I changing, and were am I putting the new code. I'm at my wits end. I'm running 4.5.9 and I thought I seen by default that kill on jump was updated, but my player just go to the hurt action. I've tried modding the doHandleObjectCollisions_platformerbase Script. That didnt seem to work. I looking for a simple jump on kill and i cant seem to understand it. ANY HELP would be great.
THANK YOU FOR ANY INFO!!!!!!!
 

Barry2

Member
TXA
STA temp
GetActionStep temp
CMP #$07 ;; we will use action step 7 for hurt.
;BEQ +doSkipHurtingThisObject ;; if he is hurt, he can't be hurt again.
BNE +doNotSkipHurtingThisObject
JMP +doSkipHurtingThisObject
+doNotSkipHurtingThisObject
ChangeActionStep temp, #$07
LDA #$80
STA Object_action_timer,x
DEC Object_health,x
LDA Object_health,x
BEQ +dontSkipHurtingThisObject
JMP +doSkipHurtingThisObject
+dontSkipHurtingThisObject:
LDA Object_x_hi,x
STA tempx
LDA Object_y_hi,x
STA tempy

LDA Object_screen,x
STA tempD


DestroyObject
CreateObjectOnScreen tempx, tempy, #$0E, #$00, tempD

CountObjects #%00001000
BEQ +zeroCount
JMP +notZeroCount
+zeroCount:
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

LDA screenType
CMP #$6F
BNE +notBossRoom
TriggerScreen #$6F
StopSound

+notBossRoom
;ChangeTileAtCollision #$06, #$00
+notZeroCount
+doSkipHurtingThisObject





This is what i have right now for my Handle monster hurt. I have not yet put a death action, which if I'm right will be action step 7.
i am using the Metrodvania platform
Im sorry for posting this on here. I know it has already be solved on this post, but this was the post i thought i would get a answer and reply. Thank you guys!!
 

dale_coop

Moderator
Staff member
Check the Metroidvania tutorial project, the jumpOn kill is already implemented (the code is in the "handle player hurt" script).
 

Barry2

Member
Check the Metroidvania tutorial project, the jumpOn kill is already implemented (the code is in the "handle player hurt" script).
Thanks for the reply. I've watch them and the platform tutorial and in the platform tutorial it show that he can do it but not how he did it. I seen in the post that it should already be implemented but when I jump on my monster, my hurt action shows and takes health. That is were I'm a little confused on.


;;;;;;;;;;;;;;;;;; Presumes there is a variable called myLives defined in user variables.
;;;;;;;;;;;;;;;;;; You could also create your own variable for this.

LDA gameHandler
AND #%10000000
BEQ +canHurtPlayer
JMP +skipHurt
+canHurtPlayer:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;; is the monster below our feet?
;;;;;;;;;; and are we moving downward?

+doHurtPlayer
TXA
STA temp
GetActionStep temp
CMP #$07
BNE +canHurtPlayer
JMP +skipHurt
+canHurtPlayer
;;; will presume there is a variable myHealth
;;; and that player hurt state is action state 7.
GetActionStep player1_object
CMP #$07 ;; hurt state.
BEQ +notAlreadyInHurtState
DEC myHealth

BMI +healthBelowZero
BEQ +healthBelowZero
JMP +notDeadYet
+healthBelowZero

JMP +playerHealthIsZero
+notDeadYet
UpdateHudElement #$02
ChangeActionStep player1_object, #$07
;; recoil
LDA #$00
STA Object_h_speed_hi,x
STA Object_h_speed_lo,x
STA Object_v_speed_hi,x
STA Object_v_speed_lo,x
LDA xPrev
STA Object_x_hi,x
LDA yPrev
STA Object_y_hi,x
+notAlreadyInHurtState
LDA Object_x_hi,x
CLC
ADC self_center_x
STA tempA
LDA Object_y_hi,x
CLC
ADC self_center_y
STA tempB
TXA
PHA
LDX otherObject
LDA Object_x_hi,x
CLC
ADC other_center_x
STA tempC
LDA Object_y_hi,x
CLC
ADC other_center_y
STA tempD
PLA
TAX

;;; RECOIL L/R
;+recoilHor
LDA tempA
CMP tempC
BCS +recoilRight
LDA Object_direction,x
AND #%00001111
ORA #%10000000
STA Object_direction,x
JMP +skipHurt

+recoilRight
LDA Object_direction,x
AND #%00001111
ORA #%11000000
STA Object_direction,x
JMP +skipHurt

+playerHealthIsZero:

LDA continueMap
STA warpMap

LDA continueX
STA newX
LDA continueY
STA newY

LDA continueScreen
STA warpToScreen
STA camScreen


LDA myMaxHealth
STA myHealth



WarpToScreen warpToMap, warpToScreen, #$02
;; arg0 = warp to map. 0= map1. 1= map2.
;; arg1 = screen to warp to.
;; arg2 = screen transition type - most likely use 1 here.
;; 1 = warp, where it observes the warp in position for the player.


+skipHurt


This is my code that I'm running. Does it look right for this. I know its a simple things so I thought that I had it right but I seem to be missing something. When I jump on my monsters, I just get hurt. I've watch the Metroidvania tutorial project and Im getting the same results.

Thanks again @dale_coop you are always a huge help. I know you have seen and answered this questions a 100 times. I just don't think I am getting it right
 

dale_coop

Moderator
Staff member
If not in the MetroidVania, maybe it was in the Platformer module one...
Basically in the script, it checked the speed of the player and if there is a monster under his feet... if so, it kills the monster object and skip the rest of the hurt player code.

Check the hurtPlayer script in the PlatformerBase (Common) folder, you will see the code related to the jump :
Code:
+canHurtPlayer:
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;; is the monster below our feet?
    ;;;;;;;;;; and are we moving downward?
    
    LDA Object_v_speed_hi,x
    BEQ +doHurtPlayer ;; equal to zero
    BMI +doHurtPlayer ;; or negative
     ;; here we are moving downward.
    TXA
    PHA
        LDX otherObject
        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
    PLA
    TAX

     ;; Do a hop
     LDA #$FC
     STA Object_v_speed_hi,x

     JMP +skipHurt
    
+doHurtPlayer   
;; continue the normal hurt player code, from here:
 
Last edited:

Levty87

New member
I'm not a programmer but I've tried to combine the 2 codes from the hurtplayer from the platform version and the metrovaniaversion. My goal is to jump on a enemy. My enemy then gets crushed before the object is destroyed.
So I looked up the jump on enemy-part of the platform-hurtplayer script and tried to past it in the metrovania script in order to keep the way the hud part is designed. Now I can jump on a enemy. The object is destroyed like in the platformversion. I recoil and get hurt and lose a heart. Now I don't now how to proceed. ^_^'
Can somebody help me?

this is the script:

Code:
    ;;;;;;;;;;;;;;;;;; Presumes there is a variable called myLives defined in user variables.
    ;;;;;;;;;;;;;;;;;; You could also create your own variable for this.

    LDA gameHandler
    AND #%10000000
    BEQ +canHurtPlayer
        JMP +skipHurt
+canHurtPlayer:
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;;;;;;;;; is the monster below our feet?
    ;;;;;;;;;; and are we moving downward?


LDA Object_v_speed_hi,x    ;; Pasted this from the platformversion
    BEQ +doHurtPlayer ;; equal to zero
    BMI +doHurtPlayer ;; or negative
     ;; here we are moving downward.
    TXA
    PHA
        LDX otherObject
        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
    PLA
    TAX

     ;; Do a hop
     LDA #$FC
     STA Object_v_speed_hi,x  ;; untill here

      +doHurtPlayer   
    TXA
    STA temp
    GetActionStep temp
    CMP #$07
    BNE +canHurtPlayer
        JMP +skipHurt
    +canHurtPlayer


    ;;; will presume there is a variable myHealth
    ;;; and that player hurt state is action state 7.
    GetActionStep player1_object
    CMP #$07 ;; hurt state.
    BEQ +notAlreadyInHurtState
        DEC myHealth
        
        BMI +healthBelowZero
        BEQ +healthBelowZero
            JMP +notDeadYet
        +healthBelowZero
            
            JMP +playerHealthIsZero
        +notDeadYet
        UpdateHudElement #$02
        ChangeActionStep player1_object, #$07
            ;; recoil
            LDA #$00
            STA Object_h_speed_hi,x
            STA Object_h_speed_lo,x
            STA Object_v_speed_hi,x
            STA Object_v_speed_lo,x
            LDA xPrev
            STA Object_x_hi,x
            LDA yPrev
            STA Object_y_hi,x
    +notAlreadyInHurtState
        LDA Object_x_hi,x
        CLC
        ADC self_center_x
        STA tempA
        LDA Object_y_hi,x
        CLC
        ADC self_center_y
        STA tempB
        TXA
        PHA
            LDX otherObject
            LDA Object_x_hi,x
            CLC
            ADC other_center_x
            STA tempC
            LDA Object_y_hi,x
            CLC
            ADC other_center_y
            STA tempD
        PLA
        TAX
    
        ;;; RECOIL L/R
            ;+recoilHor
                LDA tempA
                CMP tempC
                BCS +recoilRight
                    LDA Object_direction,x
                    AND #%00001111
                    ORA #%10000000
                    STA Object_direction,x
                    JMP +skipHurt

                +recoilRight
                    LDA Object_direction,x
                    AND #%00001111
                    ORA #%11000000
                    STA Object_direction,x
                    JMP +skipHurt
    
+playerHealthIsZero:

    LDA continueMap
    STA warpMap
    
    LDA continueX
    STA newX
    LDA continueY
    STA newY
    
    LDA continueScreen
    STA warpToScreen
    STA camScreen
    

    LDA myMaxHealth
    STA myHealth
    
    
    
    WarpToScreen warpToMap, warpToScreen, #$02
        ;; arg0 = warp to map.  0= map1.  1= map2.
        ;; arg1 = screen to warp to.
        ;; arg2 = screen transition type - most likely use 1 here.
            ;; 1 = warp, where it observes the warp in position for the player.

    
+skipHurt
 

Levty87

New member
:D I have another question. My player can now jump on my enemies and when they die that way you see a deathanimation (actionstep 6 because of recoil in 7) before they get destroyed.
I have two other ways to die.
1. is by shooting
2. is by exploding

each way has his own death/hit animation. How do I set this up? Is there a way to check if it's death by jumping, shooting, or exploding?

I have reserved actionstep 5 for the post explotion animation, 7 for the hit by shooting animation.
'Projectile source' is my shooting projectile. 'Effect 0' is my bombexplotion. I'm setting the bomb up like Joe did in the advanced adventure tutorial :)
 
Top Bottom