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.)