Problem about forward think and bug animation
I got a problem about bug animation. When play death animation in NPC, it's play the dummy animation then play death animation.
You can see in this video: http://www.youtube.com/watch?v=U8M3cKK3-UY
Full Video: http://www.youtube.com/watch?v=ot5dj3n6yJ0
When i shoot the zombie and the zombie death. error death animation. I make sure this model is from Nexon CSO game. there is no bug with the model
Here is the code: I think the problem is "ent_move_to" function, if i delete it -> work great, if use it -> Bug animation. But i still don't know how to fix
PHP Code:
public fw_zb_think(ent) { if(!is_valid_ent(ent)) return FMRES_IGNORED if(g_dead[ent]) return FMRES_IGNORED if((pev(ent, pev_health) - 1000.0) <= 0.0) { g_dead[ent] = 1 zombie_dead(ent) return FMRES_IGNORED } if(g_think[ent]) { static victim static Float:Origin[3], Float:VicOrigin[3], Float:distance victim = FindClosesEnemy(ent) pev(ent, pev_origin, Origin) pev(victim, pev_origin, VicOrigin) distance = get_distance_f(Origin, VicOrigin) if(is_user_alive(victim)) { if(distance <= 60.0) { new Float:Ent_Origin[3], Float:Vic_Origin[3] pev(ent, pev_origin, Ent_Origin) pev(victim, pev_origin, Vic_Origin) npc_turntotarget(ent, Ent_Origin, victim, Vic_Origin) zombie_attack(ent, victim) entity_set_float(ent, EV_FL_nextthink, get_gametime() + 2.0) } else { if(get_anim(ent) != ANIM_WALK) play_anim(ent, ANIM_WALK, 1.0) new Float:Ent_Origin[3], Float:Vic_Origin[3] pev(ent, pev_origin, Ent_Origin) pev(victim, pev_origin, Vic_Origin) npc_turntotarget(ent, Ent_Origin, victim, Vic_Origin) ent_move_to(ent, victim, 150) entity_set_float(ent, EV_FL_nextthink, get_gametime() + 0.1) } current_target[ent] = victim } else { if(get_anim(ent) != ANIM_IDLE) play_anim(ent, ANIM_IDLE, 1.0) entity_set_float(ent, EV_FL_nextthink, get_gametime() + 1.0) } } else { if(get_anim(ent) != ANIM_IDLE) play_anim(ent, ANIM_IDLE, 1.0) entity_set_float(ent, EV_FL_nextthink, get_gametime() + 1.0) }
return FMRES_IGNORED }
public zombie_attack(ent, victim) { play_anim(ent, ANIM_ATTACK, 1.0) emit_sound(victim, CHAN_BODY, sound_attack[random_num(0, charsmax(sound_attack))], 1.0, ATTN_NORM, 0, PITCH_NORM) ExecuteHam(Ham_TakeDamage, victim, 0, victim, random_float(25.0, 50.0), DMG_SLASH) remove_task(ent+TASK_ATTACK) set_task(1.5, "stop_attack", ent+TASK_ATTACK) }
public stop_attack(ent) { ent -= TASK_ATTACK play_anim(ent, ANIM_IDLE, 1.0) remove_task(ent+TASK_ATTACK) }
public zombie_dead(ent) { entity_set_int(ent, EV_INT_solid, SOLID_NOT) play_anim(ent, ANIM_DIE, 1.0) emit_sound(ent, CHAN_BODY, sound_die[random_num(0, charsmax(sound_die))], 1.0, ATTN_NORM, 0, PITCH_NORM) set_task(3.0, "remove_zombie", ent) //cs_set_user_money(i, cs_get_user_money(i) + 200) }
public remove_zombie(ent) { if(!pev_valid(ent)) return remove_entity(ent) }
public npc_turntotarget(ent, Float:Ent_Origin[3], target, Float:Vic_Origin[3]) { if(target) { new Float:newAngle[3] entity_get_vector(ent, EV_VEC_angles, newAngle) new Float:x = Vic_Origin[0] - Ent_Origin[0] new Float:z = Vic_Origin[1] - Ent_Origin[1]
new Float:radians = floatatan(z/x, radian) newAngle[1] = radians * (180 / 3.14) if (Vic_Origin[0] < Ent_Origin[0]) newAngle[1] -= 180.0 entity_set_vector(ent, EV_VEC_angles, newAngle) } }
stock ent_move_to(ent, victim, speed) { // set vel static Float:vec[3], Float:Target[3] pev(victim, pev_origin, Target) aim_at_origin(ent, Target, vec) engfunc(EngFunc_MakeVectors, vec) global_get(glb_v_forward, vec) vec[0] *= speed vec[1] *= speed vec[2] *= speed set_pev(ent, pev_velocity, vec) }
stock aim_at_origin(id, Float:target[3], Float:angles[3]) { static Float:vec[3] pev(id,pev_origin,vec) vec[0] = target[0] - vec[0] vec[1] = target[1] - vec[1] vec[2] = target[2] - vec[2] engfunc(EngFunc_VecToAngles,vec,angles) angles[0] *= -1.0, angles[2] = 0.0 }
stock play_anim(index, sequence, Float:framerate = 1.0) { if(is_valid_ent(index)) { entity_set_int(index, EV_INT_sequence, sequence) entity_set_float(index, EV_FL_animtime, get_gametime()) entity_set_float(index, EV_FL_framerate, framerate) entity_set_float(index, EV_FL_frame, 0.0) } }
|