Page 1 of 2

boss hp

PostPosted: Sat May 17, 2008 1:47 am
by deamonslayer4292
i need to get a boss to take more then one hit i want him to take 100 so i made a counter for his hp and tryed to make a script to kill hime once the counter reached 0 but it dident work :twisted: :evil: :twisted: :evil: :twisted: :evil: if someone can help thanks

Re: boss hp

PostPosted: Sat May 17, 2008 6:52 am
by Bee-Ant
make "health" variable set it to actor, integer
Boss>DrawActor>
Code: Select all
if(health<=0)
{
///die
}

Boss>CreateActor>
Code: Select all
health=100;

Boss>Collision>Player>
Code: Select all
//when player declare an attack
health-=5; //depending on your desire

Re: boss hp

PostPosted: Sat May 17, 2008 2:52 pm
by deamonslayer4292
thanks

Re: boss hp

PostPosted: Sat May 17, 2008 5:27 pm
by DST
A couple things on that:

The if (health == 0) thing could also go in the collision with player 1's weapon.
Remember that boss health will only be 0 once....but in draw actor it will check every single frame....for an action that will only occur once in the whole game? All enemies should have that health == 0 script in their collision rather than draw actor.
You could also put it in player 1's bullet/sword/fist collision....if (collide.health==0) etc. etc.

Also, how about health-=mypower; now any time player1 powers up, the damage is automatically adjusted.

Re: boss hp

PostPosted: Sun May 18, 2008 12:59 am
by deamonslayer4292
what would the script be for the health integer? boss.health=100;?

Re: boss hp

PostPosted: Sun May 18, 2008 1:14 am
by DST
I make health an actor variable, so i can use it for all actors, and it saves for each of them.

just put health=100; in boss's createactor event.

Re: boss hp

PostPosted: Sun May 18, 2008 2:28 am
by deamonslayer4292
no i mean to create the variable what is healths script

Re: boss hp

PostPosted: Sun May 18, 2008 3:08 am
by DST
use the 'variables' button at the bottom of the script editor.

Re: boss hp

PostPosted: Sun May 18, 2008 4:44 am
by catacomber
If you're not familiar with c code but you may very well be--when you declare a variable--you have to set it to a type that indicates whether it's going to be an integer (numbers that aren't decimals), character, string (of characters) or float which is for numbers that involve decimals.

Could be:

int x

char c

string munch

float x

but look down below:

So in GE when you want to add a new variable, you can hit script up top, and click on any script that's shown and choose variables down at the bottom--then you get a chance to add a new one.

asks you to give it a name.

Easy. Here it's health.

Then in a dropdown menu,it asks you whether that variable is going to be an

integer
real
or
string

now I don't have a clue what a real is but am going to search it here : )

a string is usually characters and an integer numbers

I hope I'm not being too basic -- forgive me if I am

before you can use a variable in script you have to create it like that

then, once you create it

use the scripts just as above where and how Bee-Ant has told you to put the script that uses your newly declared variable and DST has commented on it.

if you're still not sure, come back :D Again, I'm sorry if I'm being too simple but am not sure exactly where you're stuck.

AHA! A "real" variable is a subset of what I know to be a "float". That is when you want your variable to be expressed as a decimal.

So if you want your variable to be expressed as a decimal use ---choose "real" in the dropdown menu.

Use "integer" in dropdown menu for variable when you don't want your number to be expressed as a decimal.

Thanks to your question, have added new knowledge to my little array. : )

Re: boss hp

PostPosted: Sun May 18, 2008 1:55 pm
by deamonslayer4292
o i thought that healt had to have a script so i put the first script, i get it now ill be back if it dosent work thanks alot for the detailed explanations everyone. :D :D :mrgreen:

Re: boss hp

PostPosted: Sun May 18, 2008 11:23 pm
by deamonslayer4292
ok i put all the scripts in place but he still wont die so i did a test run making him have 2 hp in stead of 100 which would make him die in 2 hits but he just wont die :evil: :evil: :evil: :evil:

Re: boss hp

PostPosted: Mon May 19, 2008 2:15 am
by catacomber
Could you post your code? I don't know if I can help but maybe someone else can.

Re: boss hp

PostPosted: Tue May 20, 2008 1:28 am
by deamonslayer4292
it alright dst inspired me to try and find out on my own it took like 2 hours but i got it thanks anyway

Re: boss hp

PostPosted: Mon Jun 16, 2008 5:09 am
by xr2alex99
I actually know about this hp stuff its my recent work that requires it alot
basically its a variable made thing mine looks like this.
Variable/Name:My_hp_points=monsters hp/it is a actor variable ok.
to make them die if they have 0 My_hp_points this works
if (My_HP_Points < 1) Draw actor/script editor
{
My_HP_Points = 0;
DestroyActor("Event Actor");
}
to set the hp points Create actor/script editor
My_HP_Points =30;
to make damages work add collisions like collide with this or that actor = script editor
My_HP_Points = My_HP_Points - 2; it means hp-2/so chars hp is maxed at 30 and so he loses 2 =28hp left

Re: boss hp

PostPosted: Mon Jun 16, 2008 11:27 am
by DST
You're doing a lot of extra work there. It doesn't need to be so difficult.

First off, call it health, or hp, and use it for all actors.
Hp is much easier to type than My_Long_Hp_Name.

Secondly, dump the hp=0. Its just a wasted line of code.

If (hp<1){DestroyActor("Event Actor");}

Why bother to set hp to 0 if, on the very next line, you're gonna destroy the actor anyway?

And you don't need to restate the hp, just use
hp-=2;

rather than
hp=hp-2;