So basically i have enemy action which is their AI; and I have a code in my bullets action saying that if the trace is hit and it's the enemy to make a blood cloud, otherwise make smoke and sparks.
The issue is it only works on one of the two enemies i have on the map. For one he bleeds and eventually dies. For the other he just sits still and smoke and sparks appear.
They both execute their actions, except one will not respond to the trace hit properly
Here's the code for the trace hit part of the bullet action:
if(trace_hit)
{
if(you==living)
{
bloodsprayAnzahlPartikel = max(1,random(50));
effect(bloodsprayspezial,max(1,bloodsprayAnzahlPartikel*time),your.x,nullvector);
blood_cloudAnzahlPartikel = max(1,random(60));
effect(blood_cloudspezial,max(1,blood_cloudAnzahlPartikel*time),your.x,nullvector);
your.skill1 -= 10;
}
else
{
wait(1);
vec_for_vertex(temp,me,9);
sparksAnzahlPartikel = max(1,random(60));
effect(sparksspezial,max(1,sparksAnzahlPartikel*time),temp,nullvector);
gun_smokeAnzahlPartikel = max(1,random(60));
effect(gun_smokespezial,max(1,gun_smokeAnzahlPartikel*time),temp,nullvector);
}
wait(1);
ent_remove(me);
return;
}
And here's the code for the enemy:
action the_enemey_1
{
wait(1);
define health,skill1;
my.health = 40;
var speed_down_2=0;
// AI();
//position
my.oriented=on;
// my.FAT = OFF;
// my.NARROW = ON;
my.POLYGON = ON;
move_min_z = -1;
move_friction = 0; // strong friction
// enemy = me;
living=me;
while(1)
{
/* var dist_down_2 = 0;
if (c_trace(my.x,vector(my.x,my.y,my.z-5000),IGNORE_ME | IGNORE_PASSABLE | USE_BOX) > 0)
{
dist_down_2 = my.z - target.z; // get distance between player's feet and the ground
}
//else
//{
// dist_down = 0;
//}
// apply gravity when the player is in the air
if (dist_down_2 > 5) // above floor, fall down with increasing speed
{
dist_down_2 = clamp(dist_down_2,0,accelerate(speed_down_2,0.5,0));
// my.z -= 0.5*time_step;
}
else // on or below floor, set downward speed to zero
{
speed_down_2 = 0;
}
// var dist_ahead;
// dist_ahead = (key_w-key_s)*time_step*5;
// dist_ahead = sign(dist_ahead)*(abs(dist_ahead) + 0.5*dist_down); // adapt the speed on slopes
c_move(me,vector(0,0,-dist_down_2),vector(0,0,0),IGNORE_PASSABLE | GLIDE); // move the player
wait(1);*/
/////////////////////////////////////////////
if(theplayer!=null)
{
vec_set(temp,theplayer.x);
vec_sub(temp,my.x);
vec_to_angle(my.pan,temp); // now MY looks at YOU
}
////////////////////////////////////////////
///////////////////////////////////////////////
if(my.health<=0)
{
my.passable=on;
ent_morph(me,"mainchardead.mdl");
c_trace (my.x,vector(my.x,my.y,my.z-1000),IGNORE_ME|IGNORE_PASSABLE);
//vec_for_min(temp,my);
my.z = target.z + 1;
break;
}
wait(1);
}
}
sorry my code is so messy, it's because i've been changing everything alot to try to fix it.