baardbi
Well-known member
In my metroidvania game in NESmaker 4.5.6 my player is sometimes hurt for no apparent reason. It's almost like there are invisible hurt tiles. The problem is that it doesn't happen in the same place every time. Can it be related to the hurt_monster script? I haven't done any tweaking to that script that would explain this behaviour. Has anyone else experienced this?
Here is my hurtPlayer_MetroidVania.asm:
Here is my hurtMonster_PlatformBase.asm:
Here is my hurtPlayer_MetroidVania.asm:
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?
+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
;PlaySound #sfx_noteDead
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
Here is my hurtMonster_PlatformBase.asm:
Code:
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
PlaySong song_STAGA
+notBossRoom
;ChangeTileAtCollision #$06, #$00
+notZeroCount
+doSkipHurtingThisObject