(SOLVED) (4.5.9) Life lost in underworld sends to overworld (Arcade Plat)

I've been having this issue for a while now, and have been struggling with finding the solution. When losing a life in the underworld, I'm taken to the screen where my checkpoint is located, but on the overworld. (Losing a life in the overworld works fine). Here are the scripts for losing a life, checkpoints and timerendscripts. Where can this be fixed?

For further context, when my player loses a life, the player sprite turns off and creates a new object in its place. I have my player's death object set to "go to continue."

Player Death Script:
Code:
;;; Player death

doHandleKillPlayer1:
LDX player1_object
 LDA Object_x_hi,x
    CLC
 

LDA continueMap
STA warpToMap
STA continueMap ;;;;;

LDA continueX
STA newX
LDA continueY
STA newY

LDA continueScreen
STA warpToScreen
STA camScreen
 
;Get position where the player death object should be created (same as player object)
makeDeathObject:
LDA Object_x_hi,x
STA tempA
LDA Object_y_hi,x
STA tempB
LDA Object_screen,x
STA tempD

;StopSound
;PlaySound #sfx_lose

;Disable player sprite
LDA Object_status,x
AND #%11000001
STA Object_status,x

;Disable other sprites
;LDX otherObject
;DestroyObject
;LDA Object_status,x
;AND #%11000001
;STA Object_status,x

;Stop scrolling
;LDA scrollByte
;AND #%00111110
;ORA #%00000010
;STA scrollByte

;Reset player health
;LDA myMaxHealth
;STA Object_health,x
;STA myHealth

;Stop player horizontal speed
LDA #0
STA Object_h_speed_hi,x

;Create player death object
CreateObjectOnScreen tempA, tempB, #$0D, #0, tempD



RTS

Checkpoint Tile:
Code:
;;; sets a new player continue checkpoint.

  LDA updateScreenData
    AND #%00000100
    BEQ +doScript
        ;; wait until tile update is finished.
        RTS
    +doScript


    CPX player1_object
    BEQ +doCheckpoint
        JMP +skip
    +doCheckpoint
    LDA currentNametable
    STA continueScreen
    LDA Object_x_hi,x
    STA continueX
    LDA Object_y_hi,x
    STA continueY
    STA continueMap ;;;;;
    ;ChangeTileAtCollision #$00, #$00 ;; change to tile zero (make disappear), collision type 0
    
+skip

TimerEndScripts:
Code:
;;; 09 = Go To Continue
goToContinue_action:
     ;; if no more lives, warp to GAME OVER:
    LDA myLives
    BEQ +notMoreLives
        DEC myLives



        BEQ +notMoreLives
        BMI +notMoreLives

            ;; player still have lives, warp to last checkpoint:
            LDA continueMap
            STA warpToMap

 LDA continueScreen
            STA warpToScreen
            LDA #$02
            STA screenTransitionType
            JMP +doWarpToContinue

          
    +notMoreLives:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


;;;; THE PART HERE RESETS YOUR SCORE 8 DIGITS ;;;;

    LDA #$00
        STA myScore
        STA myScore+1
        STA myScore+2
        STA myScore+3
        STA myScore+4
        STA myScore+5
    STA myScore+6 
    STA myScore+7

    LDA #$00
    STA myAmmo
 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
            ;; no more lives:
            LDA #$00              ;; 00: Overworld, 01: Underworld
            STA warpToMap

            LDA #$FF              ;; screen Y:15, X:15 (our GAME OVER screen)
            STA warpToScreen         
            LDA #$01
            STA screenTransitionType

   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; when game over cash resets to zero ;;
    LDA #$00
    STA myCash
    STA myCash+1

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

      +doWarpToContinue:
        LDA myMaxHealth
        STA myHealth
        WarpToScreen warpToMap, warpToScreen, #$02 ;screenTransitionType
        ChangeActionStep player1_object, #$00
        LDX player1_object
        LDA #$00000000
        STA Object_direction,x
    RTS
 
I had this same issue too, and here's how I fixed it. First, I would move all the 'nomorelives' code from the TimerEndScripts to the PlayerDeath script. I would also add all the code to reset the score, ammo, cash, health, etc. Here's my PlayerDeath script. You may need to adjust the variable names if they are different.

Code:
;;; Player death

playerDeath:
    
    ;; Skip if player is already dead or hurt
    GetActionStep player1_object
    CMP #6 ;;; Death
    BEQ +skipDeath
    CMP #7 ;;; Hurt
    BEQ +skipDeath
    
        LDA Object_direction,x
        AND #%00000111
        STA Object_direction,x
        
        DEC myLives
        LDA myLives
        BNE myLivesNotZero
            LDA myMaxLives
            STA myLives
            
            LDA #0  ;;; 0 = Overworld map   1 = Underworld map
            STA warpToMap
            LDA #$FF ;; Game over screen
            STA warpToScreen
            
            JMP +changeAction
            
        myLivesNotZero:
            
            LDA warpMap
            STA continueMap
            
            LDA camScreen
            STA warpToScreen
        
        +changeAction:
            
            ;;; PS !!!!
            ;;; End of action for action step 6 (death)
            ;;; must be set to GoToWarp.
            
                ChangeActionStep player1_object, #6 ;;; Death
                StopSound
                PlaySound #sfx_playerdeath
            
            ;; Reset variables here
            
    +skipDeath:
    
    RTS

Then, change your player's death object to "go to warp." Here's my "go to warp" in my TimerEnd script:

Code:
;;; 07 = Go To Warp
goToWarp_action:        

    ;; Set facing direction to right
    ChangeFacingDirection player1_object, #FACE_RIGHT
    
    WarpToScreen warpToMap, warpToScreen, #$01

    RTS

Hope this helps!
 
I had this same issue too, and here's how I fixed it. First, I would move all the 'nomorelives' code from the TimerEndScripts to the PlayerDeath script. I would also add all the code to reset the score, ammo, cash, health, etc. Here's my PlayerDeath script. You may need to adjust the variable names if they are different.

Code:
;;; Player death

playerDeath:
   
    ;; Skip if player is already dead or hurt
    GetActionStep player1_object
    CMP #6 ;;; Death
    BEQ +skipDeath
    CMP #7 ;;; Hurt
    BEQ +skipDeath
   
        LDA Object_direction,x
        AND #%00000111
        STA Object_direction,x
       
        DEC myLives
        LDA myLives
        BNE myLivesNotZero
            LDA myMaxLives
            STA myLives
           
            LDA #0  ;;; 0 = Overworld map   1 = Underworld map
            STA warpToMap
            LDA #$FF ;; Game over screen
            STA warpToScreen
           
            JMP +changeAction
           
        myLivesNotZero:
           
            LDA warpMap
            STA continueMap
           
            LDA camScreen
            STA warpToScreen
       
        +changeAction:
           
            ;;; PS !!!!
            ;;; End of action for action step 6 (death)
            ;;; must be set to GoToWarp.
           
                ChangeActionStep player1_object, #6 ;;; Death
                StopSound
                PlaySound #sfx_playerdeath
           
            ;; Reset variables here
           
    +skipDeath:
   
    RTS

Then, change your player's death object to "go to warp." Here's my "go to warp" in my TimerEnd script:

Code:
;;; 07 = Go To Warp
goToWarp_action:       

    ;; Set facing direction to right
    ChangeFacingDirection player1_object, #FACE_RIGHT
   
    WarpToScreen warpToMap, warpToScreen, #$01

    RTS

Hope this helps!
Thanks Moonlight Magic this did the trick! This even works with my death object set to "go to continue" as well!
 
Top Bottom