Health Stop (Press button for health)

DanielT1985

Member
I was wondering if I can create a health item/NPC that stays in place, and if I press a button on it (preferably, up), then it gives you a heart/health piece after the interaction (Maybe also having an animation to go along with it, if that can even be possible.) I thought about having spots for my game where you interact with someone in a part of a course. Not talking, but just pressing up to interact with them and getting the heart on the spot.
 

Mugi

Member
i suppose you could do an item (object) to do this just fine, but this is pratically identical to what i did with the health platforms in my game.
they are a tile script and it's pretty simple to do.

Code:
    LDA #TILE_SOLID
    STA tile_solidity
  
    CPX player1_object
    BEQ areYouAPlayer
    JMP dontActivateHealthPlatform
    
areYouAPlayer:
    LDA tileCollisionFlag
    BEQ +
    JMP dontActivateHealthPlatform
+
    LDA gamepad
    AND #%00100000
    BNE ++
    JMP dontActivateHealthPlatform
++
    LDX player1_object
    LDA Object_health,x
    CMP #$08
    BNE DoTheHealthThing
    RTS
    
DoTheHealthThing:
    ;LDA #$01
    ;STA tileCollisionFlag
    LDX player1_object
    LDA Object_health,x
    LDA #$08
    STA Object_health,x
    PlaySound #SND_POWERUP
    
dontActivateHealthPlatform:


this is a tiletype that acts as a solid tile, and if down is pressed while standing on it, it will restore your HP to full.
it also checks if your HP is already full and does nothing if it is.
Turning this into an object reaction should be fairly straightforward.

just change the needed values here, 08 is the max HP in my game so it checks against that and sets the HP to 08.
it also uses SND_POWERUP as the healing sound so change/remove that as per what you want.
also, this does not do anything to the tile HUD, so if you are using that, and want it to update, you will have to pull out code for that (the vanilla health pickup code should have that in it.)
 

dale_coop

Moderator
Staff member
And you want a animated object... just put a monster object with no particular property set (not a “monster” nor “box” no speed ...) on top of Mugi’s tile ;)

You will be like an npc that gives you health, but with no talking.
 
Top Bottom