Page 1 of 1

[Help] Player health and powerups

Posted: Tue May 24, 2016 8:10 pm
by SMB3
So a while ago, I made a post about using LunaDLL to force powerups. Since I can't commit to anything, it's been a while and I'm just now continuing research (didn't help that when I found out about LunaLua, it wasn't letting me download it).
It was dumb. I hadn't heard of LunaLua.
LL has made it much easier to do what I was trying to do; I have now given the player the ability to pick up an ice flower at will by hitting shift. I still have another problem, though; I still want health to be separate. I initially had the idea to create a variable, initialize it as equal to the player's current health, give them the powerup, then set their HP back to what it was using said variable. The problem is, in searching these pages, I couldn't find any constants I could use (or figure out how to use) to get/set the HP. Alternatively I could set a separate counter, and simply have that change when hits or at-will powerups are detected, but then I run into another problem. The hearts at the top of the screen would be meaningless and confusing, and I'd want to get rid of them, but I also need to find a nice-looking way to display the new health counter.

I'm also encountering a bug (I believe it was mentioned in a post I saw, or maybe on the PGE wiki) where, when using onLoop() to set the player's powerup if it's not what it's supposed to be, they phase through the floor if it happens while they're taking damage. If anyone has a tip for that, I could use it. Thanks!

Re: [Help] Player health and powerups

Posted: Tue May 24, 2016 8:34 pm
by S1eth
This might be useful: http://www.wohlsoft.ru/pgewiki/HUDofTime.lua

Either use this directly, or study the code.

Re: [Help] Player health and powerups

Posted: Tue May 24, 2016 9:04 pm
by PixelPest
For the second issue you can constantly keep a variable containing the int value of the player's power-up and when it changes set the player's position in the x to their current position plus 32 or 64, depending on how far they're dropping into the floor

Re: [Help] Player health and powerups

Posted: Wed May 25, 2016 1:34 am
by Emral
PixelPest wrote:For the second issue you can constantly keep a variable containing the int value of the player's power-up and when it changes set the player's position in the x to their current position plus 32 or 64, depending on how far they're dropping into the floor
That won't work and would be a hacky solution if you said "y".

There's a player offset for forced animation states (0x122). That's, amongst other things, the flicker for collecting a powerup. If the player loses their powerup, they'll sink the difference of their hitbox into the ground. What you ideally wanna do is skip all of that. Hoeloe has a solution for Link in HUDofTime.