Page 1 of 2

Health Script

Posted: December 7th, 2010, 10:45 am
by DaGeek247
I made a working health script. I also made a demo map for it. tell me what you think!

oh yea, here is the code on the website:

Code: Select all

//tag 1 is spikes or -5 health
//tag 2-4 is heat (2 is -20 health 4 is -10)
//tag 5 is radiation or -10 health
//tag 6 is smoke inhalation or -5 health
//tag 7 is health or +10 health
//tag 8 is instant death or -101 health
//all objects have a trigger type of 6, so they keep hurting you

//set health and whatnot
on_start = [
	editbind "I" [showgui health];
	health = 100
]

//health gui, press i to see it.
newgui health [
	guitext ( format "You have %1 health." $health )
	if ( < $health 21 ) [
		guitext "You are in the RED ZONE. You need health."
	]
	guibar
	guibutton "OK." [cleargui]

]

level_trigger_1 = [ //Pokey spikes
	health = (- $health 10 );
	echo "Ouch! That hurt!";
	echo ( format "You now have %1 Health." $health );
	if ( < $health 1 ) [
		nap;
		health = 100;
		echo "You died!"
	]
	
]

level_trigger_2 = [ //fire level 1
	health = (- $health 20 );
	echo "It burns!";
	echo ( format "You now have %1 Health." $health )
	if ( < $health 1 ) [
		nap;
		health = 100;
		echo "You died!"
	]
]

level_trigger_3 = [ //fire level 2
	health = (- $health 15 );
	echo "The pain!";
	echo ( format "You now have %1 Health." $health )
	if ( < $health 1 ) [
		nap;
		health = 100;
		echo "You died!"
	]
]

level_trigger_4 = [ //fire level 3
	health = (- $health 10 );
	echo "Thats hot!";
	echo ( format "You now have %1 Health." $health )
	if ( < $health 1 ) [
		nap;
		health = 100;
		echo "You died!"
	]
]

level_trigger_5 = [ //radiation
	health = (- $health 10 );
	echo "Radiation! AUGH!";
	echo ( format "You now have %1 Health." $health )
	if ( < $health 1 ) [
		nap;
		health = 100;
		echo "You died!"
	]
]

level_trigger_6 = [ //smoke in lungs
	health = (- $health 5 );
	echo "*COUGH!* *COUGH!*";
	echo ( format "You now have %1 Health." $health )
	if ( < $health 1 ) [
		nap;
		health = 100;
		echo "You died!"
	]
]

level_trigger_7 = [ //health
	if ( < $health 100 ) [
		health = (+ $health 10 );
		echo "Ahhhhh...";
		echo ( format "You now have %1 Health." $health )
	] [
		health = 100
	]
]

level_trigger_8 = [ //instant death
	health =  (- $health 101 );
	if ( < $health 1 ) [
		nap;
		health = 100;
		echo "You died!"
	]
]
the download for the demo map is in the attachment.

Re: Health Script

Posted: December 7th, 2010, 1:42 pm
by arcones
Okay:

Code: Select all

on_start = [
   editbind "I" [showgui health];
   health = 100
]
Why in the world did you use an EDITbind??

Re: Health Script

Posted: December 12th, 2010, 8:23 pm
by DaGeek247
it was my failed attempt at making it easier to view the health info. i have no idea on how to put a static progress bar in game, or even just text. I came up with THAT bit of code by exploring defaults.cfg :P (Dont edit that unless you know what you are doing.) It does not do anything, but display an error. the script still works perfectly.

Re: Health Script

Posted: December 12th, 2010, 8:40 pm
by kid matthew
I might use that for my game =]

Re: Health Script

Posted: June 7th, 2011, 10:10 pm
by jSoftApps
Thanx! This is exactly what I was looking for

Re: Health Script

Posted: June 8th, 2011, 8:29 am
by Bigboss
hehe I will probably use this and recode it for a static bar and text and a picture :)

Re: Health Script

Posted: June 14th, 2011, 11:45 am
by Leo_V117
DaGeek247 wrote:I made a working health script. I also made a demo map for it. tell me what you think!

oh yea, here is the code on the website:

Code: Select all

//tag 1 is spikes or -5 health
//tag 2-4 is heat (2 is -20 health 4 is -10)
//tag 5 is radiation or -10 health
//tag 6 is smoke inhalation or -5 health
//tag 7 is health or +10 health
//tag 8 is instant death or -101 health
//all objects have a trigger type of 6, so they keep hurting you

//set health and whatnot
on_start = [
	bind "I" [showgui health];
	health = 100
]

//health gui, press i to see it.
newgui health [
	guitext ( format "You have %1 health." $health )
	if ( < $health 21 ) [
		guitext "You are in the RED ZONE. You need health."
	]
	guibar
	guibutton "OK." [cleargui]

]

level_trigger_1 = [ //Pokey spikes
	health = (- $health 10 );
	echo "Ouch! That hurt!";
	echo ( format "You now have %1 Health." $health );
	if ( < $health 1 ) [
		nap;
		health = 100;
		echo "You died!"
	]
	
]

level_trigger_2 = [ //fire level 1
	health = (- $health 20 );
	echo "It burns!";
	echo ( format "You now have %1 Health." $health )
	if ( < $health 1 ) [
		nap;
		health = 100;
		echo "You died!"
	]
]

level_trigger_3 = [ //fire level 2
	health = (- $health 15 );
	echo "The pain!";
	echo ( format "You now have %1 Health." $health )
	if ( < $health 1 ) [
		nap;
		health = 100;
		echo "You died!"
	]
]

level_trigger_4 = [ //fire level 3
	health = (- $health 10 );
	echo "Thats hot!";
	echo ( format "You now have %1 Health." $health )
	if ( < $health 1 ) [
		nap;
		health = 100;
		echo "You died!"
	]
]

level_trigger_5 = [ //radiation
	health = (- $health 10 );
	echo "Radiation! AUGH!";
	echo ( format "You now have %1 Health." $health )
	if ( < $health 1 ) [
		nap;
		health = 100;
		echo "You died!"
	]
]

level_trigger_6 = [ //smoke in lungs
	health = (- $health 5 );
	echo "*COUGH!* *COUGH!*";
	echo ( format "You now have %1 Health." $health )
	if ( < $health 1 ) [
		nap;
		health = 100;
		echo "You died!"
	]
]

level_trigger_7 = [ //health
	if ( < $health 100 ) [
		health = (+ $health 10 );
		echo "Ahhhhh...";
		echo ( format "You now have %1 Health." $health )
	] [
		health = 100
	]
]

level_trigger_8 = [ //instant death
	health =  (- $health 101 );
	if ( < $health 1 ) [
		nap;
		health = 100;
		echo "You died!"
	]
]
the download for the demo map is in the attachment.
Never use editbind...

Re: Health Script

Posted: June 14th, 2011, 1:43 pm
by kgklimyriad
Looks okay apart from the editbind i may have a look at this and use it for my game (save me some coding).

Re: Health Script

Posted: June 15th, 2011, 10:18 am
by arcones
Realistically you might want to use an "on-release" bind, or a bind with cntrl. But those are just some of the ideas that randomly float around my head. I need to get working on my Shift-Speed script.

Re: Health Script

Posted: June 18th, 2011, 6:18 am
by Leo_V117
arcones wrote:Realistically you might want to use an "on-release" bind, or a bind with cntrl. But those are just some of the ideas that randomly float around my head. I need to get working on my Shift-Speed script.
I'm gonna take it you meant "ctrl" there... :lol:

I havent tested this script out yet... But I'm probably going to use it to test out EasyScriptBuilder 0.1.5 before I release it. Maybe even use it for 0.5.0 to test out Error Checking... If I ever implement it.