# MAxHealth

**URL:** <https://forum.kirupa.com/t/maxhealth/184855>\
**Category:** programming\
**Created:** [April 8, 2006, 3:17pm UTC](https://forum.kirupa.com/t/maxhealth/184855 "2006-04-08T15:17:09Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![ricer](https://avatars.discourse-cdn.com/v4/letter/r/e47774/32.png) [@ricer](https://forum.kirupa.com/u/ricer)\
**Post date:** [April 8, 2006, 3:17pm UTC](https://forum.kirupa.com/t/maxhealth/184855/1 "2006-04-08T15:17:09Z")

</div>

heya i need to know a small thing,

i have a rpg game with level and exp system but, i would like to add something extra,  
like:

if u get lvl 2 u gain health and attackrate

```auto
 
if (_root.exp>100){
 level = 2;
 "Maxhealth = 200;"
stop();

```

^ \<== thats what im trying nomal max healh = 150 and when u lvl up maxhealth gets 200  
so if u use a potion or a healing field or spell u need maxhealth else u go over the health limit

can anyone make a maxhealth system for me?

im noob in that kind of stuff

thnx 😃

regards,  
Ricer

---

<div class="post-metadata">

**Author:** ![bombsledder](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@bombsledder](https://forum.kirupa.com/u/bombsledder)\
**Post date:** [April 8, 2006, 4:16pm UTC](https://forum.kirupa.com/t/maxhealth/184855/2 "2006-04-08T16:16:16Z")

</div>

well from what i see you don’t know syntax 😛

```auto

if (_root.exp>=100){
 level++;
 Maxhealth = 200
//if its a textbox MaxHealth.Text=200
//also you exp leveling script isn't good unless you reset the _root.exp variable back to o
stop();

```

---

<div class="post-metadata">

**Author:** ![ricer](https://avatars.discourse-cdn.com/v4/letter/r/e47774/32.png) [@ricer](https://forum.kirupa.com/u/ricer)\
**Post date:** [April 8, 2006, 5:26pm UTC](https://forum.kirupa.com/t/maxhealth/184855/3 "2006-04-08T17:26:32Z")

</div>

i allready get that but i need a variable from maxhealth

the function of maxhealth must be to make the health stop at the value of maxhealth

---

<div class="post-metadata">

**Author:** ![woad](https://avatars.discourse-cdn.com/v4/letter/w/34f0e0/32.png) [@woad](https://forum.kirupa.com/u/woad)\
**Post date:** [April 8, 2006, 8:55pm UTC](https://forum.kirupa.com/t/maxhealth/184855/4 "2006-04-08T20:55:03Z")

</div>

if (health \>= Maxhealth)  
{  
health = Maxhealth;  
}

---

<div class="post-metadata">

**Author:** ![ricer](https://avatars.discourse-cdn.com/v4/letter/r/e47774/32.png) [@ricer](https://forum.kirupa.com/u/ricer)\
**Post date:** [April 8, 2006, 10:02pm UTC](https://forum.kirupa.com/t/maxhealth/184855/5 "2006-04-08T22:02:52Z")

</div>

it doesnt work =(

it still goes higher that 150 on lvl 1 when i got maxhealth on 150

---

<div class="post-metadata">

**Author:** ![Joppe](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@Joppe](https://forum.kirupa.com/u/Joppe)\
**Post date:** [April 8, 2006, 10:18pm UTC](https://forum.kirupa.com/t/maxhealth/184855/6 "2006-04-08T22:18:55Z")

</div>

if(health \> maxhealth){  
health = maxhealth  
}  
if (\_root.exp\>100){  
level = 2;  
maxhealth = 200;  
}  
if(\_root.exp\<100){  
level = 1;  
maxhealth = 150;  
}  
if(\_root.exp\>300){  
level = 3;  
maxhealth = 250  
}  
//etc etc etc…

---

<div class="post-metadata">

**Author:** ![ricer](https://avatars.discourse-cdn.com/v4/letter/r/e47774/32.png) [@ricer](https://forum.kirupa.com/u/ricer)\
**Post date:** [April 8, 2006, 10:21pm UTC](https://forum.kirupa.com/t/maxhealth/184855/7 "2006-04-08T22:21:23Z")

</div>

are u sure thats stops the health from healing?

like im lvl 1 and i stand on a healing place it cannot go further that 150  
but @ lvl 2 not higher that 200 ?

---

<div class="post-metadata">

**Author:** ![Joppe](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@Joppe](https://forum.kirupa.com/u/Joppe)\
**Post date:** [April 8, 2006, 10:24pm UTC](https://forum.kirupa.com/t/maxhealth/184855/8 "2006-04-08T22:24:41Z")

</div>

should be so. Try it.

Sooo im so incredlibly bored so I just had to edit this and tell you, yes it works 🙂

---

<div class="post-metadata">

**Author:** ![ricer](https://avatars.discourse-cdn.com/v4/letter/r/e47774/32.png) [@ricer](https://forum.kirupa.com/u/ricer)\
**Post date:** [April 9, 2006, 7:53am UTC](https://forum.kirupa.com/t/maxhealth/184855/9 "2006-04-09T07:53:41Z")

</div>

doesnt work for me =(

but thanks anyway for trying to help me

---

<div class="post-metadata">

**Author:** ![rpgfanatic](https://avatars.discourse-cdn.com/v4/letter/r/e9bcb4/32.png) [@rpgfanatic](https://forum.kirupa.com/u/rpgfanatic)\
**Post date:** [April 20, 2006, 2:39pm UTC](https://forum.kirupa.com/t/maxhealth/184855/10 "2006-04-20T14:39:00Z")

</div>

could be made smaller though but oh well,it gives you an idea,

## as the base put in= @first key frame:@

```auto
 
maxhp = 150;
hp = 150
exp = 0;
attackrate = 20;
lvl = 1;

```

* * *

## @on 2nd keyframe:@ note!1: the roots should be placed on frame 1,and where you actually play the game is: frame 2 (or another frame if you made an intro and/or start screen,where the battle begins) note!3: if it’s a game based on frames and not on mc’s,ALWAYS instead of going to frame 1, let it go back to frame 2(note!4 if you have frame 2(and maybe more)filled with an intro or startscreen or etc. don’t change a darn thing)

```auto

if(_root.exp>99){
if(_root.lvl==1){
_root.maxp=_root.maxhp+50;
_root.attackrate=_root.attackrate+5;
_root.exp=0;
_root.lvl=_root.lvl+1
}
}
// it can be changed to a smaller version,but let's keep it nice and big so it's easier to understand;-) 
 
if(_root.exp>149){
if(_root.lvl==2){
_root.maxp=_root.maxhp+50;
_root.attackrate=_root.attackrate+5;
_root.exp=0;
_root.lvl=_root.lvl +1;
}
}
 
if(_root.exp>199){
if(_root.lvl==3){
_root.maxp=_root.maxhp+50;
_root.attackrate=_root.attackrate+5;
_root.exp=0;
_root.lvl=_root.lvl +1;
}
}
stop()
//and on and and on.till your guy can reach the maxlvl you like him to :-)

```

* * *

be sure to read the notes! first before you just squat in the codes.  
hope it was helpfull,if you don’t understand something of it ask me and i will make an in-depth explenation.  
if it isn’t working or it has a bug tell me,  
the problem will probably be the scripting of the heal spot.

---

<div class="post-metadata">

**Author:** ![bombsledder](https://avatars.discourse-cdn.com/v4/letter/b/958977/32.png) [@bombsledder](https://forum.kirupa.com/u/bombsledder)\
**Post date:** [April 21, 2006, 12:21am UTC](https://forum.kirupa.com/t/maxhealth/184855/11 "2006-04-21T00:21:10Z")

</div>

you should probably make a formula for exp since its alot easier then writing if(exp \>200){//blah blah } check my posts i remember posting one before it was a whole tile based thing i think
