well i made a version of this but instead of taking away a life (which we dont really have any control over unless i kill the player - which ruins the "healing" effect) you just need to not die for 5 seconds once you reach 25% HP (both delay and HP threshold can be adjusted in the script)
but you can also make it so that it'll heal to a certain amount of max HP (because getting a free full heal might be too much)
we also can't force the player to lie down or not move and such (like when you die) so it's not really a hinderance but best i can do for now i think
if you really want the player to lose a life then you can change the line
Quote: "SetPlayerHealth(max_HP)"
to
Quote: "HurtPlayer(e,g_PlayerHealth)"
but it makes him scream and such... i didn't like it
(also uncomment the Checkpoint(e) line otherwise you wont spawn at that location)
there is a slight bug with the HP if you die while healing in that sometimes it'll still trigger the heal (although i tried to stop this)
it just seems to be a quick visual issue though as seen in the video (at the end)
as always let me know if you have any issues or need any help / changes
--self-heal script by smallg
--set to percentage of max HP to apply effect at (25 = 1/4 HP)
local percent_of_max_HP = 25
--set to amount of time (in seconds) before player "heals"
local delay = 5
--set to percentage of max HP to heal back to (i.e. 100 is full health)
local percent_to_heal = 50
local near_death_HP = 0
local timer_started = 0
local HP_set = 0
local max_HP = 0
function near_death_init(e)
end
function near_death_main(e)
if HP_set == 0 then
near_death_HP = g_PlayerHealth * (percent_of_max_HP / 100)
max_HP = g_PlayerHealth
HP_set = 1
end
if g_PlayerHealth <= near_death_HP then
Prompt("Healing")
PlaySoundIfSilent(e,0)
if GetTimer(e) >= delay * 1000 and timer_started == 1 then
--Checkpoint(e)
SetPlayerHealth(max_HP * (percent_to_heal / 100))
StartTimer(e)
end
if timer_started == 0 then
StartTimer(e)
timer_started = 1
end
else
timer_started = 0
end
end
life's one big game
windows vista ultimate
i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11