Raised This Month: $ Target: $400
 0% 

Solved Wrong Shotgun Reload Animation


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 07-06-2017 , 12:11   Wrong Shotgun Reload Animation
Reply With Quote #1

I am finding a way to make a 2 mode Weapon but the shotgun reload is really hard to handle.
I tried this but it didn't change the animation at all
This code is by Dias acutally.

PHP Code:
public fw_Weapon_WeaponIdleiEnt )
{
    if(
pev_valid(iEnt) != 2)
        return 
    static 
idid get_pdata_cbase(iEntm_pPlayer5)
    if(
get_pdata_cbase(id373) != iEnt)
        return
    if(!
Get_BitVar(g_Had_Spas12id))
        return
    
    if( 
get_pdata_float(iEntm_flTimeWeaponIdle5) > 0.0 )
    {
        return
    }
    
    static 
iId iId get_pdata_int(iEntm_iId5)
    static 
iMaxClip iMaxClip CLIP

    
static iClip iClip get_pdata_int(iEntm_iClip5)
    static 
fInSpecialReload fInSpecialReload get_pdata_int(iEntm_fInSpecialReload5)

    if( !
iClip && !fInSpecialReload )
    {
        return
    }

    if( 
fInSpecialReload )
    {
        static 
iBpAmmo iBpAmmo get_pdata_int(id381XTRA_OFS_PLAYER)
        static 
iDftMaxClip iDftMaxClip g_iDftMaxClip[iId]

        if( 
iClip iMaxClip && iClip == iDftMaxClip && iBpAmmo )
        {
            
Shotgun_Reload(iEntiIdiMaxClipiClipiBpAmmoid)
            return
        }
        else if( 
iClip == iMaxClip && iClip != iDftMaxClip )
        {
            switch(
g_Spas12_Mode[id])
            {
                case 
SPAS12_ASet_WeaponAnim(idANIM_AFTER_A)
                case 
SPAS12_BSet_WeaponAnim(idANIM_AFTER_B)
                
// case JANUS_ACTIVATE: Set_WeaponAnim(id, ANIM_AFTER2)
            
}

            
set_pdata_int(iEntm_fInSpecialReload05)
            
set_pdata_float(iEntm_flTimeWeaponIdle1.55)
        }
    }
    
    return
}

public 
fw_Item_PostFrameiEnt )
{
    static 
id id get_pdata_cbase(iEntm_pPlayer4)    

    static 
iBpAmmo iBpAmmo get_pdata_int(id381XTRA_OFS_PLAYER)
    static 
iClip iClip get_pdata_int(iEntm_iClip4)
    static 
iId iId get_pdata_int(iEntm_iId4)
    static 
iMaxClip iMaxClip CLIP

    
// Support for instant reload (used for example in my plugin "Reloaded Weapons On New Round")
    // It's possible in default cs
    
if( get_pdata_int(iEntm_fInReload4) && get_pdata_float(idm_flNextAttack5) <= 0.0 )
    {
        new 
min(iMaxClip iClipiBpAmmo)
        
set_pdata_int(iEntm_iClipiClip j4)
        
set_pdata_int(id381iBpAmmo-jXTRA_OFS_PLAYER)
        
        
set_pdata_int(iEntm_fInReload04)
        return
    }

    static 
iButton iButton pev(idpev_button)
    if( 
iButton IN_ATTACK && get_pdata_float(iEntm_flNextPrimaryAttack4) <= 0.0 )
    {
        return
    }
    
    if( 
iButton IN_RELOAD  )
    {
        if( 
iClip >= iMaxClip )
        {
            
set_pev(idpev_buttoniButton & ~IN_RELOAD)
            
set_pdata_float(iEntm_flNextPrimaryAttack0.54)
        }

        else if( 
iClip == g_iDftMaxClip[iId] )
        {
            if( 
iBpAmmo )
            {
                
Shotgun_Reload(iEntiIdiMaxClipiClipiBpAmmoid)
            }
        }
    }
}


Shotgun_Reload(iEntiIdiMaxClipiClipiBpAmmoid)
{
    if(
iBpAmmo <= || iClip == iMaxClip)
        return

    if(
get_pdata_int(iEntm_flNextPrimaryAttack4) > 0.0)
        return

    switch( 
get_pdata_int(iEntm_fInSpecialReload4) )
    {
        case 
0:
        {
            switch(
g_Spas12_Mode[id])
            {
                case 
SPAS12_ASet_WeaponAnim(idANIM_START_A)
                case 
SPAS12_BSet_WeaponAnim(idANIM_START_B)
            }
        
            
set_pdata_int(iEntm_fInSpecialReload14)
            
set_pdata_float(idm_flNextAttack0.555)
            
set_pdata_float(iEntm_flTimeWeaponIdle0.554)
            
set_pdata_float(iEntm_flNextPrimaryAttack0.554)
            
set_pdata_float(iEntm_flNextSecondaryAttack0.554)
            return
        }
        case 
1:
        {
            if( 
get_pdata_float(iEntm_flTimeWeaponIdle4) > 0.0 )
            {
                return
            }
            
set_pdata_int(iEntm_fInSpecialReload24)
            
            static 
Float:CurTime
            CurTime 
get_gametime()
        
            if(
CurTime 0.35 g_PostFrame[id])
            {
                switch(
g_Spas12_Mode[id])
                {
                    case 
SPAS12_ASet_WeaponAnim(idANIM_INSERT_A)
                    case 
SPAS12_BSet_WeaponAnim(idANIM_INSERT_B)
                }
            }
            
            
g_PostFrame[id] = CurTime
            
            set_pdata_float
(iEntm_flTimeWeaponIdleiId == CSW_XM1014 0.30 0.454)
        }
        default:
        {
            
set_pdata_int(iEntm_iClipiClip 14)
            
set_pdata_int(id381iBpAmmo-1XTRA_OFS_PLAYER)
            
set_pdata_int(iEntm_fInSpecialReload14)
        }
    }

__________________
My plugin:

Last edited by Celena Luna; 07-08-2017 at 07:57.
Celena Luna is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 07-06-2017 , 12:30   Re: Wrong Shotgun Reload Animation
Reply With Quote #2

Code:
static id; id = get_pdata_cbase(iEnt, 41, 4)
__________________








CrazY. is offline
NiHiLaNTh
Way Past Expiration
Join Date: May 2009
Location: Latvia
Old 07-06-2017 , 16:30   Re: Wrong Shotgun Reload Animation
Reply With Quote #3

Shotgun reload is done by hooking WeaponReload and WeaponIdle. Also why in WeaponIdle all offsets have +5? +5 is for players, +4 for weapons. What you better to do is to hook and supercede the Reload method and insert there your Shotgun_Reload method. PostFrame for shotguns is not needed.
__________________

NiHiLaNTh is offline
Send a message via Skype™ to NiHiLaNTh
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 07-07-2017 , 06:45   Re: Wrong Shotgun Reload Animation
Reply With Quote #4

Quote:
Originally Posted by NiHiLaNTh View Post
What you better to do is to hook and supercede the Reload method and insert there your Shotgun_Reload method. PostFrame for shotguns is not needed.
You mean like this? (I haven't test yet)

PHP Code:
public fw_Weapon_Reload(iEnt)
{
    static 
id id get_pdata_cbase(iEntm_pPlayerXTRA_OFS_WEAPON)    

    static 
iBpAmmo iBpAmmo get_pdata_int(id381XTRA_OFS_PLAYER)
    static 
iClip iClip get_pdata_int(iEntm_iClipXTRA_OFS_WEAPON)
    static 
iId iId get_pdata_int(iEntm_iIdXTRA_OFS_WEAPON)
    static 
iMaxClip iMaxClip CLIP

    Shotgun_Reload
(iEntiIdiMaxClipiClipiBpAmmoid)
    return 
HAM_SUPERCEDE
}

Shotgun_Reload(iEntiIdiMaxClipiClipiBpAmmoid)
{
    if(
iBpAmmo <= || iClip == iMaxClip)
        return

    if(
get_pdata_int(iEntm_flNextPrimaryAttackXTRA_OFS_WEAPON) > 0.0)
        return

    switch( 
get_pdata_int(iEntm_fInSpecialReloadXTRA_OFS_WEAPON) )
    {
        case 
0:
        {
            switch(
g_Spas12_Mode[id])
            {
                case 
SPAS12_ASet_WeaponAnim(idANIM_START_A)
                case 
SPAS12_BSet_WeaponAnim(idANIM_START_B)
            }
        
            
set_pdata_int(iEntm_fInSpecialReload1XTRA_OFS_WEAPON)
            
set_pdata_float(idm_flNextAttack0.45)
            
set_pdata_float(iEntm_flTimeWeaponIdle0.4XTRA_OFS_WEAPON)
            
set_pdata_float(iEntm_flNextPrimaryAttack0.4XTRA_OFS_WEAPON)
            
set_pdata_float(iEntm_flNextSecondaryAttack0.4XTRA_OFS_WEAPON)
            return
        }
        case 
1:
        {
            if( 
get_pdata_float(iEntm_flTimeWeaponIdleXTRA_OFS_WEAPON) > 0.0 )
            {
                return
            }
            
set_pdata_int(iEntm_fInSpecialReload2XTRA_OFS_WEAPON)
            
            
//emit_sound(id, CHAN_ITEM, random_num(0,1) ? "weapons/reload1.wav" : "weapons/reload3.wav", 1.0, ATTN_NORM, 0, 85 + random_num(0,0x1f))
            
switch(g_Janus_Mode[id])
            {
                case 
JANUS_NORMALSet_WeaponAnim(idANIM_INSERT)
                case 
JANUS_SIGNALSet_WeaponAnim(idANIM_INSERT_SIGNAL)
            }

            
//set_pdata_float(iEnt, m_flTimeWeaponIdle, iId == CSW_XM1014 ? 0.30 : 0.45, XTRA_OFS_WEAPON)
            
if(iClip != iMaxClip)
                
set_pdata_float(iEntm_flTimeWeaponIdleiId == CSW_XM1014 0.30 0.30XTRA_OFS_WEAPON)
        }
        default:
        {
            
set_pdata_int(iEntm_iClipiClip 1XTRA_OFS_WEAPON)
            
set_pdata_int(id381iBpAmmo-1XTRA_OFS_PLAYER)
            
set_pdata_int(iEntm_fInSpecialReload1XTRA_OFS_WEAPON)
        }
    }

__________________
My plugin:
Celena Luna is offline
NiHiLaNTh
Way Past Expiration
Join Date: May 2009
Location: Latvia
Old 07-07-2017 , 10:03   Re: Wrong Shotgun Reload Animation
Reply With Quote #5

Yes. But you forgot to check in Reload method whether player has spas12.
__________________

NiHiLaNTh is offline
Send a message via Skype™ to NiHiLaNTh
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 07-07-2017 , 11:57   Re: Wrong Shotgun Reload Animation
Reply With Quote #6

Quote:
Originally Posted by NiHiLaNTh View Post
Yes. But you forgot to check in Reload method whether player has spas12.
Thank you ^^.
I fixed that problem but now I tried to change weapon speed but the Reload Animation is loop 2-3 times in 1 bullet load and it only stop at 8 ammo (maxium of normal weapon) but not 9 as I set it If I use this:
PHP Code:
public Event_CurWeapon(id)
{
    if(!
is_player(id1))
        return
    
    static 
CSWIDCSWID read_data(2)

    if((
CSWID == CSW_SPAS12 && g_OldWeapon[id] == CSW_SPAS12) && Get_BitVar(g_Had_Spas12id)) 
    {
        static 
EntEnt fm_get_user_weapon_entity(idCSW_SPAS12)
        if(!
pev_valid(Ent)) return
        
        
set_pdata_float(Ent46SPEED4)
        
set_pdata_float(Ent47SPEED4)
    }
    
    
g_OldWeapon[id] = CSWID

This one is work but on the server, the reload animation didn't work at all and if I hold attack button, the next attack time seem to be increase each bullet shoot
PHP Code:
public Event_CurWeapon(id)
{
    if(!
is_player(id1))
        return
    
    static 
CSWIDCSWID read_data(2)

    if((
CSWID == CSW_SPAS12 && g_OldWeapon[id] == CSW_SPAS12) && Get_BitVar(g_Had_Spas12id)) 
    {
        static 
EntEnt fm_get_user_weapon_entity(idCSW_SPAS12)
        if(!
pev_valid(Ent)) return
        
        
set_pdata_float(Ent46get_pdata_float(Ent464) * SPEED4)
        
set_pdata_float(Ent47get_pdata_float(Ent464) * SPEED4)
    }
    
    
g_OldWeapon[id] = CSWID

SOLVED: Set attack speed at Ham_Weapon_PrimaryAttack Post
__________________
My plugin:

Last edited by Celena Luna; 07-07-2017 at 12:52.
Celena Luna is offline
NiHiLaNTh
Way Past Expiration
Join Date: May 2009
Location: Latvia
Old 07-07-2017 , 13:44   Re: Wrong Shotgun Reload Animation
Reply With Quote #7

Code:
if( iClip < iMaxClip && iClip == iDftMaxClip && iBpAmmo )
        {
            Shotgun_Reload(iEnt, iId, iMaxClip, iClip, iBpAmmo, id)
            return
        }
        else if( iClip == iMaxClip && iClip != iDftMaxClip )
        {
-->

Code:
if( iClip < iMaxClip && iBpAmmo )
        {
            Shotgun_Reload(iEnt, iId, iMaxClip, iClip, iBpAmmo, id)
            return
        }
        else if( iClip == iMaxClip )
        {
__________________

NiHiLaNTh is offline
Send a message via Skype™ to NiHiLaNTh
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 07-08-2017 , 00:02   Re: Wrong Shotgun Reload Animation
Reply With Quote #8

Quote:
Originally Posted by NiHiLaNTh View Post
Code:
if( iClip < iMaxClip && iClip == iDftMaxClip && iBpAmmo )
        {
            Shotgun_Reload(iEnt, iId, iMaxClip, iClip, iBpAmmo, id)
            return
        }
        else if( iClip == iMaxClip && iClip != iDftMaxClip )
        {
-->

Code:
if( iClip < iMaxClip && iBpAmmo )
        {
            Shotgun_Reload(iEnt, iId, iMaxClip, iClip, iBpAmmo, id)
            return
        }
        else if( iClip == iMaxClip )
        {
It will make the reload stop at 8 (default of Weapon)
__________________
My plugin:
Celena Luna is offline
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 23:10.


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