while(my.status == attacking)
{
trace_result = c_trace(vector(my.x,my.y,my.z),vector(my.x,my.y,my.z-20),IGNORE_ME | IGNORE_PASSABLE | IGNORE_SPRITES | IGNORE_FLAG2 | IGNORE_CONTENT | IGNORE_MODELS);
if(trace_result == 0)
{
c_move(my,nullvector,vector(0,0,(-1*mod->zone_VAR_gravity) + my.gravity_mod),IGNORE_ME | IGNORE_PASSABLE | IGNORE_SPRITES | IGNORE_FLAG2 | IGNORE_CONTENT);
}
else
{
if(trace_result >= 2)
{
c_move(my,nullvector,vector(0,0,(-1*mod->zone_VAR_gravity) + my.gravity_mod),IGNORE_ME | IGNORE_PASSABLE | IGNORE_SPRITES | IGNORE_FLAG2 | IGNORE_CONTENT);
}
}
if(main_tar == NULL)
{
//If main_tar is null this NPC is attacked before it scanned
//Adn we pass pointer to attacker by combat skill
main_tar = my.combat;
my.combat = 0;
}
//if(c_trace)
vec_set(temp,me.x);
//We have a clear look to the player
if(vec_dist(my.x,main_tar.x) > 100)
{
my.status = evade;
break;
}
if(vec_dist(my.x,main_tar.x) > 6)
{
you = main_tar;
if(c_trace(vector(my.x,my.y,my.z),vector(my.x+10*cos(my.pan),my.y+10*sin(my.pan),my.z),IGNORE_ME | IGNORE_SPRITES | IGNORE_PASSABLE | IGNORE_FLAG2 | IGNORE_YOU | IGNORE_WORLD | IGNORE_MAPS | IGNORE_CONTENT) == 0)
{
if(walk_anim >= 100)
walk_anim = 0;
else
walk_anim +=4.5*time_step;
ent_animate(me,"walk",walk_anim,ANM_CYCLE);
c_move(me,vector(3*time_step,0,0),nullvector,GLIDE | IGNORE_SPRITES | IGNORE_PASSABLE | IGNORE_FLAG2 | IGNORE_CONTENT);
vec_set(temp,main_tar.x);
vec_sub(temp,my.x);
vec_to_angle(my.pan,temp);
}
else
{
vec_set(target_pos,vector(main_tar.x,main_tar.y+50,main_tar.z));
my.status = re_routing;
break;
}
}
else
{
//main_tar = you;
if(u_hea > 0 && (total_frames %80) == chr->atk_speed)
{
AI_hit_system(mod,chr,chr_you,me,main_tar);
}
}
wait(1);
}