Increase player health in steps

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

Increase player health in steps

Post 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... :?
Ric-hard
Sergeant Major
Posts: 102
Joined: Sun Feb 29, 2004 6:44 am
Location: sweden
Contact:

Post by Ric-hard »

Allo :) , I think fullhealth is 1 :? so try
local.player.health += 0.01

/Richard
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Try healthonly :)
Image
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

You can use

self heal .02 // % of maxhealth 2% in this case
Image
User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

Post by wacko »

Hey, this is nice :D :
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 :wink:

@Bdbodger, u're the winner :wink: . Yours did what I want :D
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 8-)
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Hehe yah bdb defo wins for providing a good solution and explaining it much better than I did :)

local.player healthonly (local.player.health + 1)

would have worked, but bdb's is v/ nice as well :)
Last edited by jv_map on Sun Dec 25, 2005 8:24 am, edited 1 time in total.
Image
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post by lizardkid »

how's healonly different from heal? is there a miniature difference?

i ask this because i've never heard of healonly..
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post 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.
Image
User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

Post 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?! :?
lizardkid
Windows Zealot
Posts: 3672
Joined: Fri Mar 19, 2004 7:16 pm
Location: Helena MT

Post 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?
Moderator

۞
Abyssus pro sapientia
Olympus pro Ignarus
۞

AND STUFF™ © 2006
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Oops sorry wacko ya I meant healthonly :oops:

Anyway, healthonly is not a variable, but a command.
Image
User avatar
wacko
Field Marshal
Posts: 2085
Joined: Fri Jul 05, 2002 8:42 pm
Location: Germany

Post by wacko »

okidoki.
the health booth is done and in the recycling bin (as all stuff of that kind should be :wink: )
the script could still be improved, and if u did, please let me know 8-)
Post Reply