Page 1 of 1

actor hp variable ignoring itself

PostPosted: Tue Sep 08, 2009 3:15 am
by segismundo
hi there,

thanks in advance to anyone who can help me with this problem. i am brand spanking new to this whole thing so please talk to me like i am a retarded stepchild.

so, here's the problem. i can deal damage to my monsters with one attack ("fireball"), whittling down the Actor variable "mobhp," and eventually destroying the monster (yay), and i can do the same thing with another attack ("vortex"). but if i take the monster's health down to 1 with fireball, then attempt to finish it off with vortex, i find that, as far as vortex is concerned, the monster is still at full health (the same is true the other way around, meaning, i think, that the hp variable is being treated locally by each collision script, not taking into account what happens to the variable mobhp during the other collision).

my GUESS is that i need to create some sort of mob_is_hurt function, to be called by each collision event (or, i suppose, any time i want something to hurt the monster), and have all the damage and dying take place within that function.

but how do i do that? and where do i put it? in the draw actor script for each monster?

or is there something simpler ...

Re: actor hp variable ignoring itself

PostPosted: Tue Sep 08, 2009 3:59 am
by Kalladdolf
First off, welcome and congrats for choosing Game Editor.

Concerning your problem, the first thing that would pop into my tired mind right now is that you might wanna check which collision event you're using.
Are you putting that whole event+action on the attack itself or the monster?
What I mean is:
Do you click on the monster and go on "Collision" -> "Any side of attack" etc...
Or do you click on the attack and go on "Collision" -> "Any side of monster" etc... ?
I don't know how you set up your code but if you chose the second way, please take the first one.
If it still doesn't work, there might be a couple of other things we might want to take into consideration, but this is really the first thing I could think of.
Good luck!

Re: actor hp variable ignoring itself

PostPosted: Tue Sep 08, 2009 5:40 am
by segismundo
kalladdolf--

thanks for the speedy reply.

i do have the collision events stemming from the monster.

actually the problem is solved. it was so simple, i'm kind of embarrassed that i asked for help.

all i had to do was create a an actor variable (not a function) called mobishurt, set it to 1 in the collision event (this is recommended in the GE help docs, though kind of obliquely), as well as store an amount of damage in another actor variable. then, in the draw actor event for the monster: deal the damage and if the mob1hurt variable is 1 (and, of course, set the mobishurt variable back to 0).

yours,
--segismundo

p.s. incidentally my new problem is trying to display the damage in floating text. i tried, in damagetick > createactor > edit script:

sprintf(damagetick.text, "%d", mob1damage);

but when i hit the monster with my fireball it always prints 0, even though 1 was stored in mob1damage in the collision event. i'd like to simply use the "Set Text" action. is there a way to imbed a variable in that text box?

Re: actor hp variable ignoring itself

PostPosted: Tue Sep 08, 2009 1:45 pm
by Kalladdolf
For your convenience Game Editor has actually come up with its own variable: textNumber.
Just say on the draw actor event:
Code: Select all
textNumber = hpvariable;

That should do it.

Re: actor hp variable ignoring itself

PostPosted: Tue Sep 08, 2009 4:19 pm
by segismundo
cool. thanks for the tip.

Re: actor hp variable ignoring itself

PostPosted: Thu Sep 24, 2009 2:04 am
by Bee-Ant
Back to your sprintf,
Well you will need this code to add some text on it...
To show float number is using %2f if I'm not mistaken.