AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   EngFunc_WalkMove Sequence Problem (https://forums.alliedmods.net/showthread.php?t=233868)

DavidJr 01-21-2014 05:39

EngFunc_WalkMove Sequence Problem
 
Hello, I'm trying to make NPC and I've problem with EngFunc_WalkMove to set walk sequence. The sequence is buggy when walk, but when collide with wall or something the animation plays perfectly. I ever read from somewhere to set the velocity but it neither working. Any suggestion?

PHP Code:

register_think(ZOMBIE_CLASSNAME"fwd_Think");

Public 
fwd_Think(iEnt)
{
    if (!
is_valid_ent(iEnt))
        return 
FMRES_SUPERCEDE;
    
    new 
Float:vOrigin[3], Float:pOrigin[3]
    
    new 
iPlayers[32], iNum;
    
get_players(iPlayersiNum"a");
    
    new 
iClosestPlayer 0iFarthestPlayer 0Float:flMinDist 100.0Float:flMaxDist 1000.0;
    new 
iPlayerFloat:flDist;
    
    for (new 
0iNumi++)
    {
        
iPlayer iPlayers[i];
        
entity_get_vector(iPlayerEV_VEC_originpOrigin);
        
entity_get_vector(iEntEV_VEC_originvOrigin);
        
        
flDist entity_range(iPlayeriEnt);
        
        if (
flDist flMinDist)
        {
            
iClosestPlayer iPlayer;
            
flMinDist flDist;
        }
        else if (
flMinDist flDist flMaxDist)
        {
            
iFarthestPlayer iPlayer;
            
flMaxDist flDist;
        }
    }
    
    if (
iClosestPlayer)
    {
        
SetTarget(iEntiClosestPlayer);
        
UTIL_ZombieSeq(iEntSEQ_ATTACK);
        
        
ExecuteHam(Ham_TakeDamageiClosestPlayeriEntiEnt20.0DMG_SLASH);
        
entity_set_float(iEntEV_FL_nextthinkget_gametime() + 2.0);
    }
    else if (
iFarthestPlayer)
    {
        
SetTarget(iEntiFarthestPlayer);
        
UTIL_ZombieSeq(iEntSEQ_WALK);
        
        
entity_set_float(iEntEV_FL_nextthinkget_gametime() + 0.01);
    }
    else
    {
        
UTIL_ZombieSeq(iEntSEQ_IDLE);
        
entity_set_float(iEntEV_FL_nextthinkget_gametime() + 0.01);
    }
    return 
FMRES_IGNORED;
}

SetTarget(iEntiPlayer
{
    static 
Float:iOrigin[3], Float:entOrigin[3], Float:iAngles[3];
    
pev(iPlayerpev_originiOrigin);
    
pev(iEntpev_originentOrigin);
    
    
xs_vec_sub(iOriginentOriginiOrigin);
    
xs_vec_normalize(iOriginiOrigin);
    
vector_to_angle(iOriginiAngles);
    
    
iAngles[0] = 0.0;
    
    
entity_set_vector(iEntEV_VEC_anglesiAngles);
    
SetVelocity(iEntiAngles);
}

SetVelocity(iEntFloat:flAngles[3])//Float:flAngles) 
{
    
engfunc(EngFunc_WalkMoveiEntflAngles[1], 2.0WALKMOVE_NORMAL);
    
    
UTIL_ZombieSeq(iEntSEQ_WALK);



meTaLiCroSS 01-24-2014 14:14

Re: EngFunc_WalkMove Sequence Problem
 
Any picture about it? Can you provide UTIL_ZombieSeq function?

DavidJr 01-25-2014 01:12

Re: EngFunc_WalkMove Sequence Problem
 
For good explanation I guess video is better than image. Here's the video: http://www.youtube.com/watch?v=d-7d9...e_gdata_player

About UTIL_ZombieSeq:

PHP Code:

UTIL_ZombieSeq(iEntiSeq)
{
       If (!
is_valid_ent(iEnt)) return;
    
       
entity_set_int(iEntEV_INT_sequenceiSeq);
       
entity_set_float(iEntEV_FL_animtime10.0);
       
entity_set_float(iEntEV_FL_framerate1.0);


Sometimes it collides with edge

DavidJr 01-25-2014 03:03

Re: EngFunc_WalkMove Sequence Problem
 
Solved by adding:

PHP Code:

SetVelocity(iEntFloat:flAngles[3])
{
          static 
Float:Direction[3];
          
engfunc(EngFunc_WalkMoveiEntflAngles[1], 100.0/100.0WALKMOVE_NORMAL);
          
angle_vector(flAnglesANGLEVECTOR_FORWARDDirection);
          
xs_vec_mul_scalar(Direction100.0Direction);
          
entity_set_vector(iEntEV_VEC_velocityDirection);
          
UTIL_ZombieSeq(iEntSEQ_WALK);


I have a question with this. Is it good to combine EngFunc_WalkMove with angle_vector, xs_vec_mul_scalar, and set the velocity like above?

meTaLiCroSS 01-27-2014 22:56

Re: EngFunc_WalkMove Sequence Problem
 
Quote:

Originally Posted by DavidJr (Post 2090601)
Solved by adding:

PHP Code:

SetVelocity(iEntFloat:flAngles[3])
{
          static 
Float:Direction[3];
          
engfunc(EngFunc_WalkMoveiEntflAngles[1], 100.0/100.0WALKMOVE_NORMAL);
          
angle_vector(flAnglesANGLEVECTOR_FORWARDDirection);
          
xs_vec_mul_scalar(Direction100.0Direction);
          
entity_set_vector(iEntEV_VEC_velocityDirection);
          
UTIL_ZombieSeq(iEntSEQ_WALK);


I have a question with this. Is it good to combine EngFunc_WalkMove with angle_vector, xs_vec_mul_scalar, and set the velocity like above?

Test it without WalkMove and see what happens.

About idle sequences, you can try this: http://forums.alliedmods.net/showpos...&postcount=115

DavidJr 01-28-2014 04:11

Re: EngFunc_WalkMove Sequence Problem
 
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(iEntFloat:flAngles[3]) 

          static 
Float:Direction[3]; 
          
angle_vector(flAnglesANGLEVECTOR_FORWARDDirection); 
          
xs_vec_mul_scalar(Direction100.0Direction); 
          
entity_set_vector(iEntEV_VEC_velocityDirection); 
          
UTIL_ZombieSeq(iEntSEQ_WALK); 


2. This code works perfectly too but when NPC collides with wall or something else, it can't move diagonally.
PHP Code:

SetVelocity(iEntFloat:flAngles[3]) 

          
engfunc(EngFunc_WalkMoveiEntflAngles[1], 100.0/100.0WALKMOVE_NORMAL); 
          
UTIL_ZombieSeq(iEntSEQ_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(iEntFloat:flAngles[3]) 

          static 
Float:Direction[3]; 
          
engfunc(EngFunc_WalkMoveiEntflAngles[1], 100.0/100.0WALKMOVE_NORMAL); 
          
angle_vector(flAnglesANGLEVECTOR_FORWARDDirection); 
          
xs_vec_mul_scalar(Direction100.0Direction); 
          
entity_set_vector(iEntEV_VEC_velocityDirection); 
          
UTIL_ZombieSeq(iEntSEQ_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(iEntiAttacker)
{
    if (!
is_valid_ent(iAttacker) || !is_valid_ent(iEnt)) return HAM_SUPERCEDE;
    
    new 
szClassname[33];
    
entity_get_string(iEntEV_SZ_classnameszClassnamesizeof szClassname);
    
    if (
equal(ZOMBIE_CLASSNAMEszClassname))
    {
        
entity_set_float(iEntEV_FL_nextthinkget_gametime() + 5.0);
        
entity_set_int(iEntEV_INT_solidSOLID_NOT)
        
UTIL_ZombieSeq(iEntrandom_num(SEQ_DEATH1SEQ_DEATH10));
        return 
HAM_SUPERCEDE;
    }
    return 
HAM_IGNORED;
}

UTIL_ZombieSeq(iEntiSeq)
{
    if (!
is_valid_ent(iEnt)) return;
    
    
entity_set_int(iEntEV_INT_sequenceiSeq);
    
//entity_set_float(iEnt, EV_FL_animtime, 10.0);
    
entity_set_float(iEntEV_FL_framerate1.0);
    
engfunc(EngFunc_AnimationAutomoveiEnt1.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(iEntEV_FL_health);
    
    if (
flHealth <= 0.0)
    {
        
entity_set_float(iEntEV_FL_nextthinkget_gametime() + 5.0);
        
entity_set_int(iEntEV_INT_solidSOLID_NOT)
        
UTIL_ZombieSeq(iEntrandom_num(SEQ_DEATH1SEQ_DEATH10));
    }
}

UTIL_ZombieSeq(iEntiSeq)
{
    if (!
is_valid_ent(iEnt)) return;
    
    
entity_set_int(iEntEV_INT_sequenceiSeq);
    
//entity_set_float(iEnt, EV_FL_animtime, 10.0);
    
entity_set_float(iEntEV_FL_framerate1.0);
    
engfunc(EngFunc_AnimationAutomoveiEnt1.0);


Any solutions?

Thank you

meTaLiCroSS 01-28-2014 12:37

Re: EngFunc_WalkMove Sequence Problem
 
Seems that you haven't read the post

http://forums.alliedmods.net/showpos...&postcount=115

Quote:

It will run in an endless loop.
As I said, for "idle" animations

DavidJr 01-29-2014 19:12

Re: EngFunc_WalkMove Sequence Problem
 
Oh sorry I didn't read if it's for idle animation :oops:
So is there any solution with death animation for my doubt?

meTaLiCroSS 01-29-2014 19:49

Re: EngFunc_WalkMove Sequence Problem
 
Don't use

PHP Code:

entity_set_float(iEntEV_FL_animtime10.0); 

on animtime, you must use

PHP Code:

entity_set_float(iEntEV_FL_animtimeget_gametime()); 

;)

DavidJr 01-29-2014 21:14

Re: EngFunc_WalkMove Sequence Problem
 
Thanks! It works! But the animation back to idle.

PHP Code:

UTIL_ZombieSeq(iEntiSeq)
{
    if (!
is_valid_ent(iEnt)) return;
    
    
entity_set_float(iEntEV_FL_animtimeget_gametime());
    
entity_set_float(iEntEV_FL_frame1.0);
    
entity_set_float(iEntEV_FL_framerate1.0);
    
entity_set_int(iEntEV_INT_sequenceiSeq);




All times are GMT -4. The time now is 10:15.

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