Raised This Month: $ Target: $400
 0% 

weird problem with NPC movement.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xLeoNNN
Veteran Member
Join Date: Sep 2010
Location: de_dust2
Old 07-28-2013 , 13:43   weird problem with NPC movement.
Reply With Quote #1

Hi everyone.

I am working with a smart NPC, this, can move, attack, follow player, etc.
Generally, i test my plugins in CS 1.6 new game option (not a host server, or dedicated), and npc plugin works good, but when i upload and test my npc plugin in a hosted or dedicated server, i have the next problem:

in cs 1.6 game (new game option), when i create the NPC, it follow me with run animation, and when distance between the entity and me, are near (distance: 60.0 example), this attack me.
works ok... but:

if i create the entity in a host or dedicated server (with no other plugins, updated server), the entity follow me, but the model of entity is in the respawn ent origin, and play run sequence, but how i said, the entity follow me, but the model no.
after, when the entity is close to me, the npc attack me and the attack sequence and model works good, (the model appears close to my and play attack sequence, effects, etc).

basically, the problem is that the entity follow me, but the model not (how i check this ? with a BEAMENTPOINT between entity and i, and when i shoot to the entity, this bloods).

check this image:
Spoiler


the boomer model, is in the respawn entity site, but you can see that the entity, is more close to my (i make TE_BEAMENTPOINT [red line] to check the current origin of entity).

now, i stop walk and when the entity is close to my, this attack me, a little screenfade effect, etc.

Spoiler


ending explication of the problem, here is my code (credits to dias for him npc's plugins).

PHP Code:
public fw_think(ent)
{
    if(!
is_valid_ent(ent))
        return 
HAM_IGNORED
        
    
if(pev(entpev_iuser4) == 1
        return 
HAM_IGNORED
        
    
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)
    
    
message_begin(MSG_BROADCASTSVC_TEMPENTITY); 
    
write_byte(TE_BEAMPOINTS);        // 0 
    
engfunc(EngFunc_WriteCoordOrigin[0]);    //centerpoint 
    
engfunc(EngFunc_WriteCoordOrigin[1]);    //left top corner 
    
engfunc(EngFunc_WriteCoordOrigin[2]);    //horizontal height 
    
engfunc(EngFunc_WriteCoordVicOrigin[0]);//centerpoint 
    
engfunc(EngFunc_WriteCoordVicOrigin[1]);//left right corner 
    
engfunc(EngFunc_WriteCoordVicOrigin[2]);    //horizontal height 
    
write_short(line);    //sprite to use 
    
write_byte (1)      // Start frame                
    
write_byte (10)     // Frame rate                    
    
write_byte (1)       // Life
    
write_byte (5)     // Line width                
    
write_byte (0)      // Noise
    
write_byte(255)        // red
    
write_byte(0)   // green
    
write_byte(0)    // blue
    
write_byte(150// brightness
    
write_byte(25// scroll speed in 0.1's
    
message_end()  
    
//yes, this can be optimized.
    
if(is_user_alive(victim))
    {
        if(
distance <= 60.0)
        {
            if(!
is_valid_ent(ent))
                return 
FMRES_IGNORED    
                
            npc_turntotarget
(entOriginvictimVicOrigin)

            
set_entity_anim(entSEQ_ATTACK)
                
            
entity_set_float(entEV_FL_nextthinkget_gametime() + 1.0)
            
        } 
        else 
/*this is the code when entity start follow player and play run sequence (if is in water, swim, but i dont test it)*/
        
{
            if(
get_entity_flags(ent) & FL_INWATER)
            {
                if(
pev(entpev_sequence) != SEQ_SWIM)
                    
set_entity_anim(entSEQ_SWIM)
            }
            else
            {
                
                if(
pev(entpev_sequence) != SEQ_RUN)
                    
set_entity_anim(entSEQ_RUN)
                    
            }
                
            
npc_turntotarget(entOriginvictimVicOrigin)
            
hook_ent(entvictim100.0)
            
            
entity_set_float(entEV_FL_nextthinkget_gametime() + 0.1)
        }
    } 
    else 
    {
        if(
get_entity_flags(ent) & FL_INWATER)
        {
            if(
pev(entpev_sequence) != SEQ_TREADWATER)
            {
                
set_entity_anim(entSEQ_TREADWATER)
            }    
        }
        else
        {
            if(
pev(entpev_sequence) != SEQ_IDLE)
            {
                
set_entity_anim(entSEQ_IDLE)
            }
        }
            
        
entity_set_float(entEV_FL_nextthinkget_gametime() + 1.0)
    }    
        
    return 
HAM_HANDLED
}

/* credits to dias*/
public npc_turntotarget(entFloat:Ent_Origin[3], targetFloat:Vic_Origin[3]) 
{
    if(!
is_user_connected(target) || !pev_valid(ent))
        return;
            
    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)
}

public 
hook_ent(entvictimFloat:speed)
{
    static 
Float:fl_Velocity[3]
    static 
Float:VicOrigin[3], Float:EntOrigin[3]

    
pev(entpev_originEntOrigin)
    
pev(victimpev_originVicOrigin)
    
    static 
Float:distance_f
    distance_f 
get_distance_f(EntOriginVicOrigin)

    if (
distance_f 60.0)
    {
        new 
Float:fl_Time distance_f speed

        fl_Velocity
[0] = (VicOrigin[0] - EntOrigin[0]) / fl_Time
        fl_Velocity
[1] = (VicOrigin[1] - EntOrigin[1]) / fl_Time
        fl_Velocity
[2] = (VicOrigin[2] - EntOrigin[2]) / fl_Time
    
} else
    {
        
fl_Velocity[0] = 0.0
        fl_Velocity
[1] = 0.0
        fl_Velocity
[2] = 0.0
    
}

    
entity_set_vector(entEV_VEC_velocityfl_Velocity)
}

stock set_entity_anim(entanim)
{
    
entity_set_float(entEV_FL_animtimeget_gametime())
    
entity_set_float(entEV_FL_framerate1.0)
    
entity_set_int(entEV_INT_sequenceanim)    

if, i remove this code:

PHP Code:
//if(pev(ent, pev_sequence) != SEQ_RUN)
    
set_entity_anim(entSEQ_RUN
the model and entity follow me, but the run sequence play and play o faster (0.1 secs, check set_entity_anim stock), like this:

Spoiler


if i edit the entity think time (0.1 to 1.0), the sequence play correctly, but the entity run bad, not realistic.

i try a lot things, make a fix with variable, with task, edit framerate and animtime, use other stocks, and more, but i don't get good results, sorry for the long explication, and any question only ask me.

PD: i use engine and fakemeta, later i will edit the plugin, now i'm testing because i get weird errors...

Best regards, and sorry for my bad and basic english.
__________________

Last edited by xLeoNNN; 07-28-2013 at 13:46.
xLeoNNN is offline
Send a message via MSN to xLeoNNN
Bos93
Veteran Member
Join Date: Jul 2010
Old 07-28-2013 , 14:30   Re: weird problem with NPC movement.
Reply With Quote #2

movetype MOVETYPE_PUSHSTEP ?
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
xLeoNNN
Veteran Member
Join Date: Sep 2010
Location: de_dust2
Old 07-28-2013 , 14:47   Re: weird problem with NPC movement.
Reply With Quote #3

Quote:
Originally Posted by Bos93 View Post
movetype MOVETYPE_PUSHSTEP ?
i currently using MOVETYPE_STEP, i'll try with pushstep.

PD: mm works perfectly, but what is the difference between STEP and PUSHSTEP ? i don't work usually with entities, but now i wanna learn about this xD
__________________

Last edited by xLeoNNN; 07-28-2013 at 14:49.
xLeoNNN is offline
Send a message via MSN to xLeoNNN
baneado
Veteran Member
Join Date: Dec 2012
Location: amxmodx-es.com
Old 07-28-2013 , 16:14   Re: weird problem with NPC movement.
Reply With Quote #4

Code:
#define	MOVETYPE_STEP		4		/* gravity, special edge handling -- monsters use this */
#define	MOVETYPE_PUSHSTEP	13		/* BSP model that needs physics/world collisions (uses nearest hull for world collision)
baneado is offline
xLeoNNN
Veteran Member
Join Date: Sep 2010
Location: de_dust2
Old 07-28-2013 , 16:18   Re: weird problem with NPC movement.
Reply With Quote #5

Quote:
Originally Posted by baneado View Post
Code:
#define	MOVETYPE_STEP		4		/* gravity, special edge handling -- monsters use this */
#define	MOVETYPE_PUSHSTEP	13		/* BSP model that needs physics/world collisions (uses nearest hull for world collision)
thanks!
solved :L
__________________

Last edited by xLeoNNN; 07-28-2013 at 16:22.
xLeoNNN is offline
Send a message via MSN to xLeoNNN
Reply


Thread Tools
Display Modes

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 15:52.


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