AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Death sequence problem. (https://forums.alliedmods.net/showthread.php?t=206571)

fearAR 01-24-2013 02:29

Death sequence problem.
 
Hi, I'm testing a plugin where the player model is changed by a new model, and I change the model by this way:

PHP Code:

// I'm using the way to prevent SVC_BAD error.
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 );
        
set_pdata_intID_MODELm_iModelIndexindexMdl );
    }


The player's model has a new list of sequences, the default CS have 111 sequences for each player, and this new model has 39 sequences.

The sequences play fine, I'm using the offset m_szAnimExtention for force the CS to play some animations like ref_aim, ref_shoot, crouch_aim, crouch_shoot. But I tested taking the use of this offset off, but it wasn't the problem.

The problem is the following:

When the player dies, how it was, this doesn't matter, the upper part of the body ( controlled by pev_sequence ) is played, the arms and head moves like he is dying, but the lower part of the body doesn't move, it stays like in "dummy" animation. I made some tests handling the SetAnimation function with Orpheu, and I did some prints that reported the states of:

* the parameter of SetAnimation function "PLAYER_ANIM"
* m_Activity offset
* pev->sequence
* pev->gaitsequence

and the values were the same, except pev_sequence, that is because the number of the animation where "dies" sequences resides arent the same because the default player has 111 sequences and this new model has 39 sequences.

when Player dies with the default cs model:
gaitsequence = 0

when player dies with the new model:
gaitsequence = 0

So, the SetAnimation function place it at "dummy" sequence, I can't understand how the CS makes to move all the body when the player dies, and it doesn't stays with the legs at the state of "dummy" sequence.

I will let some pictures just here:
http://cloud.steampowered.com/ugc/55...75274BB128848/

http://cloud.steampowered.com/ugc/55...7105399F4DE34/

Can you see how the model stays with the legs like in "dummy" sequence.
It is because the SetAnimation functions set pev_gaitsequence = 0 when player dies, but the default CS moves all body, and the value of gaitsequence is the same that with this plugin.

+Data:
PHP Code:

void CBasePlayer::Killedentvars_t *pevAttackerint iGib )
{
    
CSound *pSound;

    
// Holster weapon immediately, to allow it to cleanup
    
if ( m_pActiveItem )
        
m_pActiveItem->Holster( );

    
g_pGameRules->PlayerKilledthispevAttackerg_pevLastInflictor );

    if ( 
m_pTank != NULL )
    {
        
m_pTank->UsethisthisUSE_OFF);
        
m_pTank NULL;
    }

    
// this client isn't going to be thinking for a while, so reset the sound until they respawn
    
pSound CSoundEnt::SoundPointerForIndexCSoundEnt::ClientSoundIndexedict() ) );
    {
        if ( 
pSound )
        {
            
pSound->Reset();
        }
    }

    
SetAnimationPLAYER_DIE );
    
    
m_iRespawnFrames 0;

    
pev->modelindex g_ulModelIndexPlayer;    // don't use eyes

    
pev->deadflag        DEAD_DYING;
    
pev->movetype        MOVETYPE_TOSS;
    
ClearBitspev->flagsFL_ONGROUND );
    if (
pev->velocity.10)
        
pev->velocity.+= RANDOM_FLOAT(0,300);

    
// clear out the suit message cache so we don't keep chattering
    
SetSuitUpdate(NULLFALSE0);

    
// send "health" update message to zero
    
m_iClientHealth 0;
    
MESSAGE_BEGINMSG_ONEgmsgHealthNULLpev );
        
WRITE_BYTEm_iClientHealth );
    
MESSAGE_END();

    
// Tell Ammo Hud that the player is dead
    
MESSAGE_BEGINMSG_ONEgmsgCurWeaponNULLpev );
        
WRITE_BYTE(0);
        
WRITE_BYTE(0XFF);
        
WRITE_BYTE(0xFF);
    
MESSAGE_END();

    
// reset FOV
    
pev->fov m_iFOV m_iClientFOV 0;

    
MESSAGE_BEGINMSG_ONEgmsgSetFOVNULLpev );
        
WRITE_BYTE(0);
    
MESSAGE_END();


    
// UNDONE: Put this in, but add FFADE_PERMANENT and make fade time 8.8 instead of 4.12
    // UTIL_ScreenFade( edict(), Vector(128,0,0), 6, 15, 255, FFADE_OUT | FFADE_MODULATE );

    
if ( ( pev->health < -40 && iGib != GIB_NEVER ) || iGib == GIB_ALWAYS )
    {
        
pev->solid            SOLID_NOT;
        
GibMonster();    // This clears pev->model
        
pev->effects |= EF_NODRAW;
        return;
    }

    
DeathSound();
    
    
pev->angles.0;
    
pev->angles.0;

    
SetThink(PlayerDeathThink);
    
pev->nextthink gpGlobals->time 0.1;


PHP Code:

// Set the activity based on an event or current state
void CBasePlayer::SetAnimationPLAYER_ANIM playerAnim )
{
    
int animDesired;
    
float speed;
    
char szAnim[64];

    
speed pev->velocity.Length2D();

    if (
pev->flags FL_FROZEN)
    {
        
speed 0;
        
playerAnim PLAYER_IDLE;
    }

    switch (
playerAnim
    {
    case 
PLAYER_JUMP:
        
m_IdealActivity ACT_HOP;
        break;
    
    case 
PLAYER_SUPERJUMP:
        
m_IdealActivity ACT_LEAP;
        break;
    
    case 
PLAYER_DIE:
        
m_IdealActivity ACT_DIESIMPLE;
        
m_IdealActivity GetDeathActivity( );
        break;

    case 
PLAYER_ATTACK1:    
        switch( 
m_Activity )
        {
        case 
ACT_HOVER:
        case 
ACT_SWIM:
        case 
ACT_HOP:
        case 
ACT_LEAP:
        case 
ACT_DIESIMPLE:
            
m_IdealActivity m_Activity;
            break;
        default:
            
m_IdealActivity ACT_RANGE_ATTACK1;
            break;
        }
        break;
    case 
PLAYER_IDLE:
    case 
PLAYER_WALK:
        if ( !
FBitSetpev->flagsFL_ONGROUND ) && (m_Activity == ACT_HOP || m_Activity == ACT_LEAP) )    // Still jumping
        
{
            
m_IdealActivity m_Activity;
        }
        else if ( 
pev->waterlevel )
        {
            if ( 
speed == )
                
m_IdealActivity ACT_HOVER;
            else
                
m_IdealActivity ACT_SWIM;
        }
        else
        {
            
m_IdealActivity ACT_WALK;
        }
        break;
    }

    switch (
m_IdealActivity)
    {
    case 
ACT_HOVER:
    case 
ACT_LEAP:
    case 
ACT_SWIM:
    case 
ACT_HOP:
    case 
ACT_DIESIMPLE:
    default:
        if ( 
m_Activity == m_IdealActivity)
            return;
        
m_Activity m_IdealActivity;

        
animDesired LookupActivitym_Activity );
        
// Already using the desired animation?
        
if (pev->sequence == animDesired)
            return;

        
pev->gaitsequence 0;
        
pev->sequence        animDesired;
        
pev->frame            0;
        
ResetSequenceInfo( );
        return;

    case 
ACT_RANGE_ATTACK1:
        if ( 
FBitSetpev->flagsFL_DUCKING ) )    // crouching
            
strcpyszAnim"crouch_shoot_" );
        else
            
strcpyszAnim"ref_shoot_" );
        
strcatszAnimm_szAnimExtention );
        
animDesired LookupSequenceszAnim );
        if (
animDesired == -1)
            
animDesired 0;

        if ( 
pev->sequence != animDesired || !m_fSequenceLoops )
        {
            
pev->frame 0;
        }

        if (!
m_fSequenceLoops)
        {
            
pev->effects |= EF_NOINTERP;
        }

        
m_Activity m_IdealActivity;

        
pev->sequence        animDesired;
        
ResetSequenceInfo( );
        break;

    case 
ACT_WALK:
        if (
m_Activity != ACT_RANGE_ATTACK1 || m_fSequenceFinished)
        {
            if ( 
FBitSetpev->flagsFL_DUCKING ) )    // crouching
                
strcpyszAnim"crouch_aim_" );
            else
                
strcpyszAnim"ref_aim_" );
            
strcatszAnimm_szAnimExtention );
            
animDesired LookupSequenceszAnim );
            if (
animDesired == -1)
                
animDesired 0;
            
m_Activity ACT_WALK;
        }
        else
        {
            
animDesired pev->sequence;
        }
    }

    if ( 
FBitSetpev->flagsFL_DUCKING ) )
    {
        if ( 
speed == 0)
        {
            
pev->gaitsequence    LookupActivityACT_CROUCHIDLE );
            
// pev->gaitsequence    = LookupActivity( ACT_CROUCH );
        
}
        else
        {
            
pev->gaitsequence    LookupActivityACT_CROUCH );
        }
    }
    else if ( 
speed 220 )
    {
        
pev->gaitsequence    LookupActivityACT_RUN );
    }
    else if (
speed 0)
    {
        
pev->gaitsequence    LookupActivityACT_WALK );
    }
    else
    {
        
// pev->gaitsequence    = LookupActivity( ACT_WALK );
        
pev->gaitsequence    LookupSequence"deep_idle" );
    }


    
// Already using the desired animation?
    
if (pev->sequence == animDesired)
        return;

    
//ALERT( at_console, "Set animation to %d\n", animDesired );
    // Reset to first frame of desired animation
    
pev->sequence        animDesired;
    
pev->frame            0;
    
ResetSequenceInfo( );


Greetings!

Arkshine 01-24-2013 07:13

Re: Death sequence problem.
 
Possible to attach the model ? I would like to test something.

fearAR 01-24-2013 10:51

Re: Death sequence problem.
 
Ok, here it is the same but with other reference, the same sequences.

http://www.mediafire.com/?nyetccsd2fh560q

Bos93 01-24-2013 11:51

Re: Death sequence problem.
 
AddToFullPack :oops:

PHP Code:

register_forwardFM_AddToFullPack"fw_PlayerAddToFullPack");

public 
fw_PlayerAddToFullPackES_HandleEpEntpHostbsHostFlagspPlayerpSet )
{
    if( 
pPlayer 
    {

        static 
iAnim;
        
iAnim get_esES_HandleES_Sequence );
                    
        switch( 
iAnim )
        {
            case 
242526// death 1,2,3
            
{
                
set_esES_HandleES_Sequence27 ); // head
            
}
        }
    }



Arkshine 01-24-2013 14:51

Re: Death sequence problem.
 
I thought it was because you were missing sequence or missing activity but by reading model datas , it seems fine :

Spoiler


I've also check LookupActivity() ; It's well called for example with ACT_DIE_GUTSHOT and returns well a valid sequence like 28.
About gaitsequence, it doesn't seem it's needed to be set for such animation (also same for hover, swim, etc.), being set on 0 is the normal behavior probably because it's a full sequence.

At this point, no idea why the 'bottom" is fucked up ; it sounds like it's overwritten by something. Maybe there is a problem with the model or because it's a custom one ?

EDIT : Tried things like : if I force LookupActivity to return a death animation, in-game, the animation is well played, but once I'm dead, it fucks up.
Another try is I've hooked SetAnimation as post and when I'm dead, I set gaitsequence to the current sequence and I call ResetSequenceInfo (may not needed) ; then what you see is for some reason the death animation works fine, but randomly right after (once the other animation is done), it plays the same but it's fucked up (sometimes nothing is played, or the same is played properly or played and fucked up).
.
That's all for now, not sure what happens, it's weird.

fearAR 01-24-2013 18:45

Re: Death sequence problem.
 
@Arkshine:

I tried the same things than you, but no result...
Other thing that I've done is when PLAYER_ANIM == 4 in pre, supercede this and set values to randomly die sequences, but this doesn't matter, it plays the upper part of the body only...

I don't know why, but it is killing me... I'll have to try other things, like a new ent, but forcing the sequence doesn't take effect...

Maybe one forced solution? :P the best way possible...

Edit: I'll try setting in total 111 sequences to the model, like CS default model, in the case it worked I will notice here, meanwhile other solutions are accepted.


All times are GMT -4. The time now is 20:32.

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