AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   SetAnimation dude. (https://forums.alliedmods.net/showthread.php?t=206313)

fearAR 01-20-2013 22:25

SetAnimation dude.
 
Hi, I am playing with m_szAnimExtention, changing its values to my requirements, and It is working perfect, but I have one dude about the use of it. For example I change the value of m_szAnimExtention to "bow", so the function will search for "ref_aim_bow"/"crouch_aim_bow"/"ref_shoot..." inside the model's sequence list, and then it will work, or it doesn't work that way?

and other dude:

The Engine looks inside the new model for the model's total frame value of each sequence, or it just take it from one variable, so it is saved. I'm asking this because I have some problems when I use a new sequence in place of "mp5" sequences, because this new sequence have a different amount of frames, and the sequence takes an acceleration.

PHP Code:

void GetSequenceInfovoid *pmodelentvars_t *pevfloat *pflFrameRatefloat *pflGroundSpeed )
{
    
studiohdr_t *pstudiohdr;
    
    
pstudiohdr = (studiohdr_t *)pmodel;
    if (! 
pstudiohdr)
        return;

    
mstudioseqdesc_t    *pseqdesc;

    if (
pev->sequence >= pstudiohdr->numseq)
    {
        *
pflFrameRate 0.0;
        *
pflGroundSpeed 0.0;
        return;
    }

    
pseqdesc = (mstudioseqdesc_t *)((byte *)pstudiohdr pstudiohdr->seqindex) + (int)pev->sequence;

    if (
pseqdesc->numframes 1)
    {
        *
pflFrameRate 256 pseqdesc->fps / (pseqdesc->numframes 1);
        *
pflGroundSpeed sqrtpseqdesc->linearmovement[0]*pseqdesc->linearmovement[0]+ pseqdesc->linearmovement[1]*pseqdesc->linearmovement[1]+ pseqdesc->linearmovement[2]*pseqdesc->linearmovement[2] );
        *
pflGroundSpeed = *pflGroundSpeed pseqdesc->fps / (pseqdesc->numframes 1);
    }
    else
    {
        *
pflFrameRate 256.0;
        *
pflGroundSpeed 0.0;
    }


I saw this in the SDK, and this gets the value of FrameRate per sequence, and I think it could be changed.

Grettings.

PHP Code:

int CBaseAnimating :: LookupSequence ( const char *label )
{
    
void *pmodel GET_MODEL_PTRENT(pev) );

    return ::
LookupSequencepmodellabel );


PHP Code:

//=========================================================
//=========================================================
void CBaseAnimating :: ResetSequenceInfo ( )
{
    
void *pmodel GET_MODEL_PTRENT(pev) );

    
GetSequenceInfopmodelpev, &m_flFrameRate, &m_flGroundSpeed );
    
m_fSequenceLoops = ((GetSequenceFlags() & STUDIO_LOOPING) != 0);
    
pev->animtime gpGlobals->time;
    
pev->framerate 1.0;
    
m_fSequenceFinished FALSE;
    
m_flLastEventCheck gpGlobals->time;


Edit: I saw this macro on LookUpSequence function:

PHP Code:

#define GET_MODEL_PTR                (*g_engfuncs.pfnGetModelPtr) 

And now the problem is, how to access this engFunc, so it could return me a value that I can set calling LookUpSequence's function with Orpheu.

meTaLiCroSS 01-22-2013 00:07

Re: SetAnimation dude.
 
Quote:

Originally Posted by fearAR (Post 1877203)
Hi, I am playing with m_szAnimExtention, changing its values to my requirements, and It is working perfect, but I have one dude about the use of it. For example I change the value of m_szAnimExtention to "bow", so the function will search for "ref_aim_bow"/"crouch_aim_bow"/"ref_shoot..." inside the model's sequence list, and then it will work, or it doesn't work that way?.

https://forums.alliedmods.net/showpo...70&postcount=7

fearAR 01-22-2013 13:48

Re: SetAnimation dude.
 
I saw the SDK, but I'm not referring to that part, because I saw LookUpSequence function too, but I tried adding a new animation to the player, named:

ref_aim_bow
ref_shoot_bow

and I set the value of m_szAnimExtention to "bow", but It doesn't found the sequence and then It sets in "dummy" sequence, It seems to get the values in the precache list, from the original players, and then when LookUpSequence is used, It looks up inside an array.

For that reason I'm looking for a way to acces to GET_MODEL_PTR macro.

PHP Code:

int CBaseAnimating :: LookupSequence ( const char *label )
{
    
void *pmodel GET_MODEL_PTRENT(pev) );

    return ::
LookupSequencepmodellabel );


Greetings.

Bos93 01-22-2013 14:11

Re: SetAnimation dude.
 
Quote:

and I set the value of m_szAnimExtention to "bow", but It doesn't found the sequence and then It sets in "dummy" sequence
just set the model index

fearAR 01-22-2013 15:21

Re: SetAnimation dude.
 
I tried setting the value that returns EngFunc_ModelIndex, to pev_modelindex of id, but it doesn't work, I think it is because EngFunc_GetModelPtr isnt the same as EngFunc_ModelIndex.

Directives from enginecallback.cpp;
PHP Code:

#define MODEL_INDEX        (*g_engfuncs.pfnModelIndex)
#define GET_MODEL_PTR                (*g_engfuncs.pfnGetModelPtr) 

Edit:

I'm using the way to prevent SVC_BAD error:

PHP Code:

public fm_set_user_modeltaskid )
{    
    if( 
is_valid_playerID_MODEL ) )
    {
        
set_user_info(ID_MODEL"model"g_player_modelID_MODEL ]);
        
        new 
szModel128 ];
        
        
formatexszModelsizeof szModel 1"models/player/%s/%s.mdl"
        
g_player_modelID_MODEL ],
                
g_player_modelID_MODEL ] );
        
        new 
indexMdl engfuncEngFunc_ModelIndexszModel );
        
client_printID_MODELprint_chat"%d"indexMdl );
        
set_pevID_MODELpev_modelindexindexMdl );
    }



meTaLiCroSS 01-22-2013 20:16

Re: SetAnimation dude.
 
What about the modelindex offset

fearAR 01-22-2013 21:27

Re: SetAnimation dude.
 
It worked, thank you. Now I have a new problem, the sequence seems to be found, but when it has to be played it isn't, it stays like in the first frame.

* I added the two new sequences at the end of the QC Script, Could it be the problem?

Edit:

It is working fine with the Offset m_iModelIndex = 496.

* It gets the correct framerate per sequence.
* It founds the sequence correctly.

I added the animation before the die sequences. I didn't test with more than 111 sequences ( it is the max animation default for each player model in CS ), I deleted some sequences that I didnt use.
Now, I have a problem with the DIE sequences, I'm trying to fix it, ( the problem is that the sequence plays good except the legs, they stays like in dummy sequence ). If I have changes, I'll notice here.

Bos93 04-23-2013 08:11

Re: SetAnimation dude.
 
I can set animation with offset CBaseAnimating ? I want to set the animation at a random time of death. I have a new model with new animations.


All times are GMT -4. The time now is 13:35.

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