Page 1 of 1
Increase player health in steps
Posted: Thu Dec 22, 2005 2:05 pm
by wacko
I want to do a health giving machine(?), which when useheld adds 1% per second to the players health until he's at 100%.
It got a trigger_use "health_trigger_1" and an alarmswitch "health_switch_1". And here's my script so far:
Code: Select all
givehealth1:
$health_trigger_1 nottriggerable
local.player = parm.other
$health_switch_1 anim turnon
while (local.player.useheld)
{
if (local.player.health <= 99)
{
$health_switch_1 playsound clickswitch
// iprintln_noloc local.player.health
local.player.health++
}
wait 1
}
$health_switch_1 anim turnoff
wait 1
$health_trigger_1 triggerable
end
Well, what it does is that the switch is working but the damn machine fills up player's health to 100% in one step. Why does it? Btw, the iprintln counts up slowly (as I want it to do), just health is set to 100% immediately...

Posted: Thu Dec 22, 2005 2:32 pm
by Ric-hard
Allo

, I think fullhealth is 1

so try
local.player.health += 0.01
/Richard
Posted: Thu Dec 22, 2005 3:25 pm
by jv_map
Try healthonly

Posted: Thu Dec 22, 2005 5:39 pm
by bdbodger
You can use
self heal .02 // % of maxhealth 2% in this case
Posted: Thu Dec 22, 2005 7:14 pm
by wacko
Hey, this is nice

:
Three possible solutions in 4 hours. Thanks!!
Okay then.
@Ric-hard, full health must be 100, because
if (local.player.health <= 1) doesn't work as desired, but u're on the right track

.
@Jv, I think yours don't work (in my trials they didn't), because 'healonly' is a readonly variable; I get an errormessage sayin sth like that, if I try
local.player.healonly++.
Nevertheless, knowing ur and my scripting, I'm probably just misunderstanding ur two words
@Bdbodger, u're the winner

. Yours did what I want
Here's my workin code:
Code: Select all
givehealth1:
$health_trigger_1 nottriggerable
local.player = parm.other
$health_switch_1 anim turnon
while (local.player.useheld)
{
if (local.player.health <= 99)
{
$health_switch_1 playsound click_switch
local.player heal .01
}
local.waiting = local.player.health / 200 //this decreases healing speed towards 100%
wait local.waiting
}
$health_switch_1 anim turnoff
wait 1
$health_trigger_1 triggerable
end
Thanks and Merry Xmas to all of you

Posted: Fri Dec 23, 2005 8:19 am
by jv_map
Hehe yah bdb defo wins for providing a good solution and explaining it much better than I did
local.player heal
thonly (local.player.health + 1)
would have worked, but bdb's is v/ nice as well

Posted: Sat Dec 24, 2005 5:06 am
by lizardkid
how's healonly different from heal? is there a miniature difference?
i ask this because i've never heard of healonly..
Posted: Sat Dec 24, 2005 7:42 am
by jv_map
healthonly changes health without changing max_health. health changes health and increases max_health. heal is similar to healthonly, except for the different syntax.
Posted: Sat Dec 24, 2005 10:23 am
by wacko
@jv was it ur intention to write "healthonly" instead of "healonly"? I still think, health and healthonly are just variables that can't be written, whereas heal and healonly (?) are commands to change the player's health?!
Then: If "local.player healonly (local.player.health + 1)" added 1% to player's health, there would be a big difference to local.player heal, because "local.player heal 1" adds 100% health, doesn't it?!

Posted: Sun Dec 25, 2005 12:47 am
by lizardkid
heal increases health by a set amount. and health sets health to that amount.
it seems to me that health can also raise max_health, if it goes above that value, and healthonly cannot.
heal also increases by a decimal, (.02 = 2% of hp) as opposed to a number, if i understand right.
good god why could they not make this simple?
Posted: Sun Dec 25, 2005 8:26 am
by jv_map
Oops sorry wacko ya I meant healthonly
Anyway, healthonly is not a variable, but a command.
Posted: Mon Jan 02, 2006 4:34 pm
by wacko
okidoki.
the health booth is done and in the recycling bin (as all stuff of that kind should be

)
the script could still be improved, and if u did, please let me know
