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:
Thanks for the help and sorry for the complicated post.
Rtsgamer706
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