Monster Death Animation don´t play

dale_coop

Moderator
Staff member
By default, there is no monster death animation in this version. You will have to add the code to the script...
A search on the forum, will help you to find that ;)
 

9-Volt

New member
Thank you for answering.

I already made a research on the forum before making this topic, but the code I was using was crashing my game.

I studied the code and found the problem, but after using this code, my monster became imortal and I can´t solve that problem. Can you help me, please? I cannot find the problem:

Code:
;;; what should we do with the monster?
        ;;; monster is loaded in x
        LDA Object_vulnerability,x
        AND #%00000100 ;; is it weapon immune?
        BEQ notWeaponImmune
        ;PlaySound #SFX_MISS
        JMP skipHurtingMonsterAndSound
    notWeaponImmune:
        
        LDA Object_status,x
        AND #HURT_STATUS_MASK
        BEQ dontskipHurtingMonster
        JMP skipHurtingMonster
    dontskipHurtingMonster:
        LDA Object_status,x
        ORA #%00000001
        STA Object_status,x
        LDA #HURT_TIMER
        STA Object_timer_0,x
        
        ;;; assume idle is in step 0 - uses idle for hurt state - JF
    
        ChangeObjectState #$00,#$02
        
    ;;;; unfortunately this recoil is backwards
        LDA Object_status,x
        AND #%00000100
        BNE skipRecoilBecauseOnEdge
        LDA Object_vulnerability,x
        AND #%00001000 
        BNE skipRecoilBecauseOnEdge ;; skip recoil because bit is flipped to ignore recoil
        
        LDA selfCenterX
        STA recoil_otherX
        LDA selfCenterY
        STA recoil_otherY
        LDA otherCenterX
        STA recoil_selfX
        LDA otherCenterY
        STA recoil_selfY
        JSR DetermineRecoilDirection
    skipRecoilBecauseOnEdge:
        LDA Object_health,x
        SEC
        SBC #$01
        CMP #$01
        BCC +
        JMP notMonsterDeath
    +

       LDA Object_x_hi,x
       STA temp
       LDA Object_y_hi,x
       STA temp1

        
       
        ChangeObjectState #$07,#$01 ;;; step 07 is destroyed monster  -JF
             

        
        ;;; DC suggestion - uncomment this and the monster is no longer a monster
        ;LDA Object_flags,x
        ;AND #%11110111  ;; remove the "monster" flag of the object
        ;STA Object_flags,x
        
        ;;; destroy monster after killing - JF
        

        
        ;DeactivateCurrentObject
    
        
        
        


        ;PlaySound #SND_MONSTER_DEATH
        ;;;;;;;;;;;;;;;;;; ok, so now we also add points to score
        ;LDY Object_type,x
        ;LDA ObjectWorth,y
        ;STA temp
;       AddValue #$03, GLOBAL_Player1_Score, temp
                ;arg0 = how many places this value has.
                ;arg1 = home variable
                ;arg2 = amount to add ... places?
        ;; and this should trip the update hud flag?
        
        ;;;; 
    

    TXA
    STA tempy   ;;dale_coop

    ;AddValue #$08, myScore, #$01, #$00
    ;STA hudElementTilesToLoad
    ;UpdateHud HUD_myScore
    LDX tempy   ;;dale_coop

        JSR HandleDrops
        
        ;;JSR HandleToggleScrolling ;; dale_coop removed handle scroll
        
        CountObjects #%00001000, #$00
        LDA monsterCounter
        CLC ;;dale_coop
        BEQ +
        JMP ++
    +
        .include SCR_KILLED_LAST_MONSTER
    ++
        JMP skipHurtingMonster
    notMonsterDeath:
        STA Object_health,x
        ;PlaySound #SND_MONSTER_HURT
    skipHurtingMonster: 
        ;;PlaySound #SND_MONSTER_HURT
    
    skipHurtingMonsterAndSound:
        LDX tempx
        LDA Object_type,x
        ;; we don't destroy the melee object
        ;CMP #OBJECT_PLAYER_MELEE
        BEQ +
        ;; what should we do with the projectile?
        DeactivateCurrentObject ;; destroy it ?
        +
 

dale_coop

Moderator
Staff member
This script looks correct, It think.
How the rest of your settings?
I see in the code that your Monster is not destroyed, right? But instead, you set it to state 7 (action step 7). So how is set that Action Step?

Also... I think it's just a logic error.
Your monster spawns with a specific number of Health (let's say "3")... when the player hurts your monster, the 1st time, the health of your monster decrease (so "2"). Then, when the player hurst again the monster, its health goes to "1"... and lastly, when your slash the monster it goes to "0" and (instead of being destroyed) plays the Action Step 7.
Perfect... and then what?! Because you changed the default behavior, you have now a game logic issue.
Your monster's health is "0", it means that the players will not really hurts hime, he has now almost infinite health (he can't lose more, you can't kill him anymore).
You forgot to find/get a way to set his health back to its initially value ("3" in my scenario).

Maybe when you the Action Step 7 ended?
Or just maybe when the monster goes to Action Step 7, in that case, just add:
Code:
	LDA #$03		;; value 3
	STA Object_health,x	;; store in health
After your line :
Code:
	ChangeObjectState #$07,#$01 ;;; step 07 is destroyed monster  -JF
 

9-Volt

New member
Thank you, I changed the script and worked.

May I ask why in the scrip bellow, if I put ChangeObjectState #$03 works but if I put ChangeObjectState #$07 or ChangeObjectState #$05 don´t work, I copied the same attributes and animation in the action objetc 5 and 7.

Thank you for your time.


Code:
;; Created by Dale Coop
;; http://www.nesmakers.com/viewtopic.php?f=35&t=1703&fbclid=IwAR26DZvG3Q1OBJaNKvFdQs5rvfLKrgBY06exJCi5M-G9KzHCBl_CZ8iZ_CI

LDA gameHandler
AND #%00100000
BEQ canShoot
JMP doneShooting
canShoot:
LDX player1_object
;;; IF YOU WANT TO USE AN SPECIFIC ANIMATION / ACTION STEP WHEN SHOOTING, comment out the following 3 lines:
;;; check if already shooting (assuming the shoot action step is 05)
GetCurrentActionType player1_object
CMP #$03
BNE notAlreadyShooting
JMP wasAlreadyShooting
notAlreadyShooting
;;; IF YOU WANT TO USE AN SPECIFIC ANIMATION / ACTION STEP WHEN SHOOTING, comment out the following 1 line:
;;; if not already shooting, change it's action step (assuming the shoot action step is 05)
ChangeObjectState #$03, #$00

;;; if you want your player stops when he's shooting, comment out the following lines:
LDA Object_movement,x
AND #%00001111
STA Object_movement,x
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

;; if was already shooting
wasAlreadyShooting:

LDA Object_movement,x
AND #%00000111
STA temp2
TAY

LDA Object_x_hi,x
SEC
SBC #$08 ;; width of projectile
STA temp
LDA Object_scroll,x
SBC #$00
STA temp3

LDA temp
;;; offset x for creation
CLC
ADC projOffsetTableX,y
STA temp
LDA temp3
ADC #$00
STA temp3

LDA Object_y_hi,x
CLC
ADC projOffsetTableY,y
sec
sbc #$08 ;; height of projectile
STA temp1


  CreateObject temp, temp1, #OBJECT_PLAYER_PROJECTILE, #$00, temp3

  ;;;; x is now the newly created object's x.
  LDA Object_movement,x
  ORA temp2
  STA Object_movement,x
  LDY temp2
  LDA directionTable,y
  ORA Object_movement,x
  STA Object_movement,x

  ;PlaySound #SND_SHOOT
doneShooting:
RTS
 

dale_coop

Moderator
Staff member
I guess it's because there is another script, that overrides the player's states (action steps) on certain situations (the script is "Extra Control Script")
When your player falls, it will set the action step 2, when he's on a ladder tile it will set the action step 4 , etc...). That script might do some checks for the common action steps (2, 3, 4...) but not 5 or 6, 7... so if you use those and use the default Extra Controls Script, it might set you back to Action Step 0, maybe?
 

9-Volt

New member
Thank you for the heads up about the Extra Control Script, that was messing up all the other scripts/actions that I was trying to do. Thank you for your time!
 
Top Bottom