meTaLiCroSS, thank you. I'm done with topic.
1. This code works perfectly but the NPC will be stuck in the edge:
PHP Code:
SetVelocity(iEnt, Float:flAngles[3])
{
static Float:Direction[3];
angle_vector(flAngles, ANGLEVECTOR_FORWARD, Direction);
xs_vec_mul_scalar(Direction, 100.0, Direction);
entity_set_vector(iEnt, EV_VEC_velocity, Direction);
UTIL_ZombieSeq(iEnt, SEQ_WALK);
}
2. This code works perfectly too but when NPC collides with wall or something else, it can't move diagonally.
PHP Code:
SetVelocity(iEnt, Float:flAngles[3])
{
engfunc(EngFunc_WalkMove, iEnt, flAngles[1], 100.0/100.0, WALKMOVE_NORMAL);
UTIL_ZombieSeq(iEnt, SEQ_WALK);
}
3. This code solved my problem, I combined first code with the second code above like this and NPC can move diagonally although it collides with wall or something, it won't be stuck at the edge.
PHP Code:
SetVelocity(iEnt, Float:flAngles[3])
{
static Float:Direction[3];
engfunc(EngFunc_WalkMove, iEnt, flAngles[1], 100.0/100.0, WALKMOVE_NORMAL);
angle_vector(flAngles, ANGLEVECTOR_FORWARD, Direction);
xs_vec_mul_scalar(Direction, 100.0, Direction);
entity_set_vector(iEnt, EV_VEC_velocity, Direction);
UTIL_ZombieSeq(iEnt, SEQ_WALK);
}
But I have another problem, it is about death animation. I want to play death animation when the NPC is killed and I have tested with two methods. Both don't work with EngFunc_AnimationAutomove.
First code. I tried it in Ham_Killed.
PHP Code:
RegisterHam(Ham_Killed, "info_target", "fwd_Killed");
public fwd_Killed(iEnt, iAttacker)
{
if (!is_valid_ent(iAttacker) || !is_valid_ent(iEnt)) return HAM_SUPERCEDE;
new szClassname[33];
entity_get_string(iEnt, EV_SZ_classname, szClassname, sizeof szClassname);
if (equal(ZOMBIE_CLASSNAME, szClassname))
{
entity_set_float(iEnt, EV_FL_nextthink, get_gametime() + 5.0);
entity_set_int(iEnt, EV_INT_solid, SOLID_NOT)
UTIL_ZombieSeq(iEnt, random_num(SEQ_DEATH1, SEQ_DEATH10));
return HAM_SUPERCEDE;
}
return HAM_IGNORED;
}
UTIL_ZombieSeq(iEnt, iSeq)
{
if (!is_valid_ent(iEnt)) return;
entity_set_int(iEnt, EV_INT_sequence, iSeq);
//entity_set_float(iEnt, EV_FL_animtime, 10.0);
entity_set_float(iEnt, EV_FL_framerate, 1.0);
engfunc(EngFunc_AnimationAutomove, iEnt, 1.0);
}
Second code. I tried it by checking entity's health in fwd_Think and neither work.
PHP Code:
register_think(ZOMBIE_CLASSNAME, "fwd_Think");
public fwd_Think(iEnt)
{
if (!is_valid_ent(iEnt))
return FMRES_SUPERCEDE;
new Float:flHealth = entity_get_float(iEnt, EV_FL_health);
if (flHealth <= 0.0)
{
entity_set_float(iEnt, EV_FL_nextthink, get_gametime() + 5.0);
entity_set_int(iEnt, EV_INT_solid, SOLID_NOT)
UTIL_ZombieSeq(iEnt, random_num(SEQ_DEATH1, SEQ_DEATH10));
}
}
UTIL_ZombieSeq(iEnt, iSeq)
{
if (!is_valid_ent(iEnt)) return;
entity_set_int(iEnt, EV_INT_sequence, iSeq);
//entity_set_float(iEnt, EV_FL_animtime, 10.0);
entity_set_float(iEnt, EV_FL_framerate, 1.0);
engfunc(EngFunc_AnimationAutomove, iEnt, 1.0);
}
Any solutions?
Thank you
__________________