Im Making an Rpg
My Characters health is the score but no matter the code i use it always ends up not letting him die and his health goes to negatives, so under repeatedly execute what code should i use for
if score <=0 then you change room to room 24
Something like this should do it:
if (score <= 0) cPlayer.ChangeRoom (24);
Of course you'll probably want to add an animation and other effects, so you'd need braces around the code if it's going to be more than the one line I have above.
Baron
score is an undefined symbol
Look up game.score from the manual.
Ah.... It's kind of confusing to use score to represent health anyway. Why not create a variable named "health"?
int health =100; //(at the beginning of your script)
I'm kind of confused on
int
so if i did
int health ==100
would i have to script something else for it to be recognized
and how would i lower the health like
(health -10)?
however i would like to not have to edit my whole script by that because im far in the game so if i could stick to the score one that would help a whole lot
It's "int health=100;"
Reducing it by 10: "health=health-10;" or simply "health-=10;"
well then all my scripts have to be changed is there any possible way to say
if score <= 0
also id have no way of knowing how to show health on GUI that way
Yep. You can say that easily
if (health <= 0)
{
//Do whatever happens when your player dies.
}
To show the health on your GUI can can put
LabelWithHealth.Text = String.Format("%d", health);
inside repeatedly_execute, and it will update your health label on the GUI. (Note: You have to change LabelWithHealth to the name of the label that shows your health)
so all i would have to do it that then for every battle instead of
GiveScore (-25)
make it
health=health-25
?
it tells me undefined token health
how do i define it
now it says cannot convert String*Int
this is what i have under game_start for int
int health = 100'
under repeatedly_execute i have
if (health <= 0)}
how do i define it
Couldn't you use a struct? Like:
struct Health {
int max;
int min;
String name; //in case you want to show player name
};
Quote from: ncw14 on Mon 24/12/2007 19:08:29
so all i would have to do it that then for every battle instead of
GiveScore (-25)
make it
health=health-25
?
Yes. A shorter way to do it would be
health -= 25;
Quote
it tells me undefined token health
how do i define it
now it says cannot convert String*Int
this is what i have under game_start for int
int health = 100'
The problem is that you declared health inside game_start. This means that you can only use this variable inside of game_start. You need to declare it at the very top of your global script.
Quote
under repeatedly_execute i have
if (health <= 0)}
how do i define it
It needs to have an opening brace as well. Something like this:
if (health <=0)
{
//The code you want to run when he dies.
}
I'm trying that but an easier thing would be
if (game.score < 1)
but it says error expected '('
where do i put it
Quote from: ncw14 on Mon 24/12/2007 02:53:28
Im Making an Rpg
My Characters health is the score but no matter the code i use it always ends up not letting him die and his health goes to negatives, so under repeatedly execute what code should i use for
if score <=0 then you change room to room 24
i fixed it sorry people thaank you
Please read the manual's Scripting tutorial (http://americangirlscouts.org/agswiki/Scripting_tutorial_part_1). It will explain a lot about scripting with AGS.