enemy health

Posted By: rtsgamer706

enemy health - 06/08/11 15:23

I am a programmer working with the free version of A8
I am making a shooting game and i have an issue.
Thanks to a recent post my bullet collisions are working properly now.
I would like it to take 3 shots to kill each enemy, so I created a variable as you can see below.
the problem is that the collision is according to my bullet, so if I say:
hp - 1;
I will get an error because it doesn't know what hp is.
I can't make the variable global either because then all enemies will die when hp = 0
here is the relevant part of my code:
Code:
function deal_dmg()
{
	if(event_type = EVENT_ENTITY)`
	{
		wait(1);
		ent_remove (me);
		if (you.skill57)
		{
		wait(1);
		ent_remove (you);
		}
	}
}

action shot()
{
	c_setminmax(me);
	my.pan = guy.pan;
	var durability = 85;
	my.emask |= (ENABLE_ENTITY);
	my.event = deal_dmg;
	while(my)
	{
		c_move (me, vector(0, 25*time_step, 0), nullvector, IGNORE_PASSABLE); // move the bullet forward
		durability -= 1;
		if(durability <= 1)
		{
			wait(1);
			ent_remove (me);
		}
		wait(1);
	}
}

action enemy()
{
	var hp = 3;
	my.pan -= 90;
	c_setminmax(me);
	my.skill57 = 1;
	my.emask |= (ENABLE_ENTITY);
}



Thanks for the help and sorry for the complicated post.
Rtsgamer706
Posted By: the_clown

Re: enemy health - 06/08/11 15:27

Make it a skill.
Posted By: rtsgamer706

Re: enemy health - 06/08/11 20:59

how do I do that?
Sorry, I have no idea what that means...
Posted By: tzw

Re: enemy health - 06/08/11 21:10

use a skill to store hp that global can access it
#define hp skill2
....
you.hp-=5;
Posted By: rtsgamer706

Re: enemy health - 06/09/11 12:19

Wow, works perfectly now
and I now know how to use skills (a little)
Thanks a ton!
© 2023 lite-C Forums