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