HandlePlayerHurt and its associated constants...

WillElm

New member
I'm trying to implement chronicleroflegends' boss code (http://www.nesmakers.com/viewtopic.php?f=40&t=2298), and I noticed that my constants for everything having to do with recoil, invulnerability, and hurt timer have no effect on my game, in that if I go into Project Settings->User Constants and change the values, it has no effect. Then I remembered that I was tweaking all that stuff in the HandlePlayerHurt script, since it seems to just define the value of those constants at the beginning of the script.

I figured I could comment these line out:

HURT_TIMER = #$16
INVINCIBILITY_TIMER = #$16
RECOIL_SPEED_HI = #$02
RECOIL_SPEED_LO = #$02

And maybe that would fix it. But it just gives me a really short recoil and hurt/invincibility timer, regardless of what values I set in Project settings.

Here is the script. It's the only place I've seen that seems to directly define constants in the code. Maybe there's somewhere else?


Code:
;;; assumes myHealth variable
;;; if a different variable should handle health
;;; change thename of myHealth.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; uses timers set in GameData\Constants:
;;OBJECT TIMERS
HURT_TIMER = #$16
INVINCIBILITY_TIMER = #$16
RECOIL_SPEED_HI = #$02
RECOIL_SPEED_LO = #$02

;;;; To change invincibility time, knock back speed, or hurt duration
;;;; updating the abovevalues in constants.

    LDA Object_health,x
    SEC
    SBC #$01 ;; subtract other's strength
    CMP #$01
    BCS notPlayerDeath
    
    PlaySound #SND_HURT_PLAYER
    JSR HandlePlayerDeath
    JMP doneWithPlayerHurt

notPlayerDeath:
    STA Object_health,x
    STA myHealth
    
    STA hudElementTilesToLoad
        LDA #$00
        STA hudElementTilesMax
        ; LDA DrawHudBytes
        ; ora #HUD_myHealth
        ; STA DrawHudBytes
    UpdateHud HUD_myHealth
    ;; TURN ON handling the hud
    
    LDA Object_status,x
    ORA #%00000001
    STA Object_status,x 

    LDA #HURT_TIMER
    STA Object_timer_0,x
    ChangeObjectState #$06,#$02 ;; uses idle for hurt state.
    
    LDA selfCenterX
    STA recoil_selfX
    LDA selfCenterY
    STA recoil_selfY
    LDA otherCenterX
    STA recoil_otherX
    LDA otherCenterY
    STA recoil_otherY
    
    JSR DetermineRecoilDirection


    ;;;;; SCROLLER CAN NOT MAKE USE OF UPDATING HUD THIS WAY.


    
doneWithPlayerHurt:
 

dale_coop

Moderator
Staff member
If I remember well you can find some recoil and hurt timer constants in the GameEngineData\GameData\Constants.asm script...
 

WillElm

New member
dale_coop said:
If I remember well you can find some recoil and hurt timer constants in the GameEngineData\GameData\Constants.asm script...

I'll take a look later on. So that's how it works? If you directly define a constant, it trumps what you define in project settings? If guessing it has to do with where the definition occurs in your code.
 

dale_coop

Moderator
Staff member
Ideally, all the constants and variables should be accessible via the "Project Settings" tabs. You can add/modify them there.

...but, because the code engine has not been cleaned up completely yet, some "old" constants and variables are still stuck / declared and set in those old constant scripts (from the time where all that code was just the core of the Mystic Searches game). But it will not remains here for long.
 

WillElm

New member
dale_coop said:
If I remember well you can find some recoil and hurt timer constants in the GameEngineData\GameData\Constants.asm script...

This was indeed the case, thanks. Just responding here for future readers who might be wondering why their hurt/invincibility/recoil constants don't seem to work.
 

dale_coop

Moderator
Staff member
Glad it worked.
(I think it a next version ALL those constants/variables will be in the "Project Settings" tabs)
 

Atarath

Member
I have noticed that the invincibility timer set seems to apply for monsters as well. Are there separate constants located somewhere for monsters?
 

dale_coop

Moderator
Staff member
I might be wrong, but I don't think there are special constants for monsters... those constants are for all objects.
(but it would be doable to make specific ones to separate player/others)
 
Top Bottom