Raised This Month: $ Target: $400
 0% 

Problem about forward think and bug animation


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dias
BANNED
Join Date: Jul 2009
Location: South Vietnam
Old 05-09-2012 , 10:37   Problem about forward think and bug animation
Reply With Quote #1

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(entpev_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(entpev_originOrigin)
        
pev(victimpev_originVicOrigin)
        
        
distance get_distance_f(OriginVicOrigin)
        
        if(
is_user_alive(victim))
        {
            if(
distance <= 60.0)
            {            
                new 
Float:Ent_Origin[3], Float:Vic_Origin[3]
                
                
pev(entpev_originEnt_Origin)
                
pev(victimpev_originVic_Origin)            
            
                
npc_turntotarget(entEnt_OriginvictimVic_Origin)
                
                
zombie_attack(entvictim)
                
entity_set_float(entEV_FL_nextthinkget_gametime() + 2.0)
            } else {
                
                if(
get_anim(ent) != ANIM_WALK)
                    
play_anim(entANIM_WALK1.0)
                    
                new 
Float:Ent_Origin[3], Float:Vic_Origin[3]
                
                
pev(entpev_originEnt_Origin)
                
pev(victimpev_originVic_Origin)
                
                
npc_turntotarget(entEnt_OriginvictimVic_Origin)
                
ent_move_to(entvictim150)
    
                
entity_set_float(entEV_FL_nextthinkget_gametime() + 0.1)
            }
            
            
current_target[ent] = victim
        
} else {
            if(
get_anim(ent) != ANIM_IDLE)
                
play_anim(entANIM_IDLE1.0)
            
            
entity_set_float(entEV_FL_nextthinkget_gametime() + 1.0)
        }
    } else {
        if(
get_anim(ent) != ANIM_IDLE)
            
play_anim(entANIM_IDLE1.0)
            
        
entity_set_float(entEV_FL_nextthinkget_gametime() + 1.0)        
    }

    return 
FMRES_IGNORED
}

public 
zombie_attack(entvictim)
{
    
play_anim(entANIM_ATTACK1.0
    
    
emit_sound(victimCHAN_BODYsound_attack[random_num(0charsmax(sound_attack))], 1.0ATTN_NORM0PITCH_NORM)
    
ExecuteHam(Ham_TakeDamagevictim0victimrandom_float(25.050.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
(entANIM_IDLE1.0)
    
remove_task(ent+TASK_ATTACK)
}

public 
zombie_dead(ent)
{
    
entity_set_int(entEV_INT_solidSOLID_NOT)
    
play_anim(entANIM_DIE1.0)
    
    
emit_sound(entCHAN_BODYsound_die[random_num(0charsmax(sound_die))], 1.0ATTN_NORM0PITCH_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(entFloat:Ent_Origin[3], targetFloat:Vic_Origin[3]) 
{
    if(
target
    {
        new 
Float:newAngle[3]
        
entity_get_vector(entEV_VEC_anglesnewAngle)
        new 
Float:Vic_Origin[0] - Ent_Origin[0]
        new 
Float:Vic_Origin[1] - Ent_Origin[1]

        new 
Float:radians floatatan(z/xradian)
        
newAngle[1] = radians * (180 3.14)
        if (
Vic_Origin[0] < Ent_Origin[0])
            
newAngle[1] -= 180.0
        
        entity_set_vector
(entEV_VEC_anglesnewAngle)
    }
}

stock ent_move_to(entvictimspeed)
{
    
// set vel
    
static Float:vec[3], Float:Target[3]
    
pev(victimpev_originTarget)
    
    
aim_at_origin(entTargetvec)
    
engfunc(EngFunc_MakeVectorsvec)
    
global_get(glb_v_forwardvec)
    
vec[0] *= speed
    vec
[1] *= speed
    vec
[2] *= speed
    set_pev
(entpev_velocityvec)
}

stock aim_at_origin(idFloat: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.0angles[2] = 0.0
}

stock play_anim(indexsequenceFloat:framerate 1.0)
{
    if(
is_valid_ent(index))
    {
        
entity_set_int(indexEV_INT_sequencesequence)
        
entity_set_float(indexEV_FL_animtimeget_gametime())
        
entity_set_float(indexEV_FL_framerate,  framerate)
        
entity_set_float(indexEV_FL_frame0.0)
        
    }


Last edited by dias; 05-10-2012 at 05:48.
dias is offline
Send a message via Yahoo to dias Send a message via Skype™ to dias
NiHiLaNTh
Way Past Expiration
Join Date: May 2009
Location: Latvia
Old 05-09-2012 , 11:23   Re: Problem about forward think and bug animation
Reply With Quote #2

I am not sure, but maybe add DEAD_&* deadflag to the npc entity.
__________________

NiHiLaNTh is offline
Send a message via Skype™ to NiHiLaNTh
rak
Veteran Member
Join Date: Oct 2011
Location: banned country
Old 05-09-2012 , 19:18   Re: Problem about forward think and bug animation
Reply With Quote #3

pev(ent, pev_health) <---- return a int

show me zombie_dead(ent)
__________________

www.amxmodx-es.com

Steam: Luchokoldo
rak is offline
Send a message via MSN to rak Send a message via Skype™ to rak
dias
BANNED
Join Date: Jul 2009
Location: South Vietnam
Old 05-10-2012 , 05:48   Re: Problem about forward think and bug animation
Reply With Quote #4

- Updated Code to first post

PHP Code:
public zombie_attack(entvictim)
{
    
play_anim(entANIM_ATTACK1.0
    
    
emit_sound(victimCHAN_BODYsound_attack[random_num(0charsmax(sound_attack))], 1.0ATTN_NORM0PITCH_NORM)
    
ExecuteHam(Ham_TakeDamagevictim0victimrandom_float(25.050.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
(entANIM_IDLE1.0)
    
remove_task(ent+TASK_ATTACK)
}

public 
zombie_dead(ent)
{
    
entity_set_int(entEV_INT_solidSOLID_NOT)
    
play_anim(entANIM_DIE1.0)
    
    
emit_sound(entCHAN_BODYsound_die[random_num(0charsmax(sound_die))], 1.0ATTN_NORM0PITCH_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)


Last edited by dias; 05-10-2012 at 05:48.
dias is offline
Send a message via Yahoo to dias Send a message via Skype™ to dias
csoldjb
Member
Join Date: Dec 2010
Old 05-16-2012 , 05:49   Re: Problem about forward think and bug animation
Reply With Quote #5

Maybe is the MOVETYPE problem?Try another type,such like movetype_bouncemissle or others
csoldjb is offline
Bos93
Veteran Member
Join Date: Jul 2010
Old 05-16-2012 , 06:39   Re: Problem about forward think and bug animation
Reply With Quote #6

Quote:
Originally Posted by csoldjb View Post
Maybe is the MOVETYPE problem?Try another type,such like movetype_bouncemissle or others
Yes. MOVETYPE_PUSHSTEP

It is necessary to establish MOVETYPE_NONE, when playing the animation.
__________________
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
dias
BANNED
Join Date: Jul 2009
Location: South Vietnam
Old 05-16-2012 , 10:45   Re: Problem about forward think and bug animation
Reply With Quote #7

@csoldjb:
- Yes. That it's
dias is offline
Send a message via Yahoo to dias Send a message via Skype™ to dias
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:23.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode