HandlePlayerHurt and its associated constants...

Post Reply
WillElm
Posts: 75
Joined: Wed Mar 20, 2019 3:56 am

HandlePlayerHurt and its associated constants...

Post by WillElm » Tue May 14, 2019 3:32 am

I'm trying to implement chronicleroflegends' boss code ([url]http://www.nesmakers.com/viewtopic.php?f=40&t=2298[/url]), 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: Select all

;;; 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:
User avatar
dale_coop
Posts: 3954
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: HandlePlayerHurt and its associated constants...

Post by dale_coop » Tue May 14, 2019 7:48 am

If I remember well you can find some recoil and hurt timer constants in the GameEngineData\GameData\Constants.asm script...
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
WillElm
Posts: 75
Joined: Wed Mar 20, 2019 3:56 am

Re: HandlePlayerHurt and its associated constants...

Post by WillElm » Tue May 14, 2019 11:41 am

dale_coop wrote:
Tue May 14, 2019 7:48 am
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.
User avatar
dale_coop
Posts: 3954
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: HandlePlayerHurt and its associated constants...

Post by dale_coop » Tue May 14, 2019 11:58 am

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.
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
WillElm
Posts: 75
Joined: Wed Mar 20, 2019 3:56 am

Re: HandlePlayerHurt and its associated constants...

Post by WillElm » Tue May 14, 2019 11:06 pm

dale_coop wrote:
Tue May 14, 2019 7:48 am
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.
User avatar
dale_coop
Posts: 3954
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: HandlePlayerHurt and its associated constants...

Post by dale_coop » Wed May 15, 2019 7:06 am

Glad it worked.
(I think it a next version ALL those constants/variables will be in the "Project Settings" tabs)
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
User avatar
Elarath
Posts: 28
Joined: Fri Apr 05, 2019 6:33 am

Re: HandlePlayerHurt and its associated constants...

Post by Elarath » Wed Jun 26, 2019 4:09 pm

I have noticed that the invincibility timer set seems to apply for monsters as well. Are there separate constants located somewhere for monsters?
User avatar
dale_coop
Posts: 3954
Joined: Fri Feb 16, 2018 7:05 am
Location: France

Re: HandlePlayerHurt and its associated constants...

Post by dale_coop » Wed Jun 26, 2019 11:02 pm

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)
-----
Sorry about my poor english
All I need: A Damn Fine Cup of Coffee
My games: PRESS START GAME / UNDERGROUND ADVENTURE / UNDERGROUND ADVENTURE (Arcade version - Byte-Off-2019)
Post Reply