Raised This Month: $ Target: $400
 0% 

About Reload speed


Post New Thread Reply   
 
Thread Tools Display Modes
MeRcyLeZZ
Veteran Member
Join Date: Dec 2007
Old 03-13-2009 , 15:31   Re: About Reload speed
Reply With Quote #11

That's pretty cool. Next step would be fixing the animation's speed (framerate) so that it matches with the actual reload speed.

BTW, you could also use
Code:
RegisterHam(Ham_Weapon_Reload, szWeapon, "Weapon_Reload_Post", 1)
So that the checks are only executed while the player is holding his reload key, instead of every frame.

@smoothjazz: I think shotguns would require a somewhat hackish way to do it, since their flNextAttack doesn't relate to their reload time (shotguns are the only type of weapon you can fire whilst reloading)
__________________
MeRcyLeZZ is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-13-2009 , 16:44   Re: About Reload speed
Reply With Quote #12

Gonna have a look for animations, thanks.

-edit-

Neither
set_pdata_float(id, 36, get_pdata_float(id, 36) * RELOAD_RATIO, 5)
nor
set_pev(id, pev_framerate, RELOAD_RATIO)
worked
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 03-13-2009 at 17:05.
ConnorMcLeod is offline
smoothjazz
Senior Member
Join Date: Jul 2008
Old 03-16-2009 , 04:49   Re: About Reload speed
Reply With Quote #13

@MeRcyLeZZ
Thx for ur information and Help!
It's really cool , if the amimation speed can also be increased!
smoothjazz is offline
YKH =]
Senior Member
Join Date: Sep 2008
Location: Hong Kong
Old 03-16-2009 , 08:45   Re: About Reload speed
Reply With Quote #14

Quote:
Originally Posted by ConnorMcLeod View Post
Try this :

#define RELOAD_RATIO 0.7
This is 30% quicker, feel free to change it.

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define PLUGIN "Reload Speed"
#define AUTHOR "ConnorMcLeod"
#define VERSION "0.2.0"

#define RELOAD_RATIO 0.7

const NOCLIP_WPN_BS    = ((1<<2)|(1<<CSW_HEGRENADE)|(1<<CSW_SMOKEGRENADE)|(1<<CSW_FLASHBANG)|(1<<CSW_KNIFE)|(1<<CSW_C4))
const 
SHOTGUNS_BS    = ((1<<CSW_M3)|(1<<CSW_XM1014))

// weapons offsets
const m_pPlayer            41
const m_iId                43
const m_flNextPrimaryAttack    46
const m_flNextSecondaryAttack    47
const m_flTimeWeaponIdle        48
const m_fInReload            54

const m_flNextAttack 83

stock 
const Float:g_fDelay[CSW_P90+1] = {
    
0.002.700.002.000.000.55,   0.003.153.300.004.50
         
2.703.503.352.453.30,   2.702.202.502.634.70
         
0.553.052.123.500.00,   2.203.002.450.003.40
}

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    new 
szWeapon[17]
    for(new 
i=1i<=CSW_P90i++)
    {
        if( !(
NOCLIP_WPN_BS & (1<<i)) && get_weaponname(iszWeaponcharsmax(szWeapon)) )
        {
            if( !(
SHOTGUNS_BS & (1<<i)) )
            {
                
RegisterHam(Ham_Item_PostFrameszWeapon"Item_PostFrame_Post"1)
            }
        }
    }
}

public 
Item_PostFrame_Post(iEnt)
{    
    if( 
get_pdata_int(iEntm_fInReload4) )
    {
        new 
Float:fDelay g_fDelay[get_pdata_int(iEntm_iId4)] * RELOAD_RATIO
        set_pdata_float
(get_pdata_cbase(iEntm_pPlayer4), m_flNextAttackfDelay5)
        
set_pdata_float(iEntm_flTimeWeaponIdlefDelay 0.54)
    }

Hi, can you make some note for this plugin that i understand which weapon's reload speeed that i can changed.
__________________
Approved Plugins

[ZP] Effect Plugins :
Damage Effect
Real Death
YKH =] is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-16-2009 , 14:19   Re: About Reload speed
Reply With Quote #15

g_fDelay is the default cs reload time for each weapon, follow weapons id order :

0.00, 2.70, 0.00, 2.00, 0.00, 0.55

0 not a weapon

1 = CSW_P228 -> 2.7 sec

2 not a weapon

3 = CSW_SCOUT = 2.00 sec

4 = CSW_HEGRENADE (or CSW_C4 cant remember), can't reload

5 = CSW_M3 or CSW_XM1014 , shotguns use a special reload method, see my plugin weapons maxclip for more details, or look at hlsdk shotguns.cpp code.


etc..


Updated with Reload forward :

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define PLUGIN "Reload Speed"
#define AUTHOR "ConnorMcLeod"
#define VERSION "0.2.0"

#define RELOAD_RATIO 0.5

const NOCLIP_WPN_BS    = ((1<<2)|(1<<CSW_HEGRENADE)|(1<<CSW_SMOKEGRENADE)|(1<<CSW_FLASHBANG)|(1<<CSW_KNIFE)|(1<<CSW_C4))
const 
SHOTGUNS_BS    = ((1<<CSW_M3)|(1<<CSW_XM1014))

// weapons offsets
const m_pPlayer               41
const m_iId                    43
const m_flNextPrimaryAttack     46
const m_flNextSecondaryAttack    47
const m_flTimeWeaponIdle        48
const m_iPrimaryAmmoType         49
const m_iClip                51
const m_fInReload            54

const m_flNextAttack 83
const m_pActiveItem 373
const m_rgAmmo_Slot0 376

stock 
const Float:g_fDelay[CSW_P90+1] = {
    
0.002.700.002.000.000.55,   0.003.153.300.004.50
         
2.703.503.352.453.30,   2.702.202.502.634.70
         
0.553.052.123.500.00,   2.203.002.450.003.40
}

stock const g_iReloadAnims[CSW_P90+1] = {
    -
1,  5, -13, -1,  6,   -111, -114
        
4,  23,  1,  1,   1374,  1,  3
        
6111,  3, -1,    411, -1,  1}

stock const g_iDftMaxClip[CSW_P90+1] = {
    -
1,  13, -110,  1,  7,    13030,  1,  30
        
2025303525,   12201030100
        
303020,  2,    73030, -1,  50}

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    new 
szWeapon[17]
    for(new 
i=1i<=CSW_P90i++)
    {
        if( !(
NOCLIP_WPN_BS & (1<<i)) && get_weaponname(iszWeaponcharsmax(szWeapon)) )
        {
            if( !(
SHOTGUNS_BS & (1<<i)) )
            {
            
//    RegisterHam(Ham_Weapon_Reload, szWeapon, "Weapon_Reload_Pre")
                
RegisterHam(Ham_Weapon_ReloadszWeapon"Weapon_Reload_Post"1)
            }
        }
    }
}

public 
Weapon_Reload_Post(iEnt)
{    
    if( 
get_pdata_int(iEntm_fInReload4) )
    {
            new 
id get_pdata_cbase(iEntm_pPlayer4)
        new 
Float:fDelay g_fDelay[get_pdata_int(iEntm_iId4)] * RELOAD_RATIO
        set_pdata_float
(idm_flNextAttackfDelay5)
        
set_pdata_float(iEntm_flTimeWeaponIdlefDelay 0.54)
        
set_pev(idpev_frame200.0)
    }
}

/*public Weapon_Reload_Pre( iEnt )
{
    new id = get_pdata_cbase(iEnt, m_pPlayer, 4)
    new iBpAmmo = get_pdata_int(id, m_rgAmmo_Slot0 + get_pdata_int(iEnt, m_iPrimaryAmmoType, 4), 5)
    if( !iBpAmmo )
    {
        return HAM_SUPERCEDE
    }

    new iId = get_pdata_int(iEnt, m_iId, 4)
    if( ! min(g_iDftMaxClip[iId] - get_pdata_int(iEnt, m_iClip, 4), iBpAmmo) )
    {
        return HAM_SUPERCEDE
    }

    new Float:fDelay = g_fDelay[get_pdata_int(iEnt, m_iId, 4)] * RELOAD_RATIO
    set_pdata_float(id, m_flNextAttack, fDelay, 5)
    set_pev(id, pev_frame, 200.0)

    SendWeaponAnim(id, g_iReloadAnims[iId])

    set_pdata_int(iEnt, m_fInReload, true)

    set_pdata_float(iEnt, m_flTimeWeaponIdle, fDelay + 0.5, 4)

    return HAM_SUPERCEDE
}

stock SendWeaponAnim(id, iAnim)
{
    set_pev(id, pev_weaponanim, iAnim)

    message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, _, id)
    write_byte(iAnim)
    write_byte(pev(id,pev_body))
    message_end()
}*/ 
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 03-24-2009 at 12:19.
ConnorMcLeod is offline
smoothjazz
Senior Member
Join Date: Jul 2008
Old 03-28-2009 , 09:58   Re: About Reload speed
Reply With Quote #16

Quote:
Originally Posted by ConnorMcLeod View Post
g_fDelay is the default cs reload time for each weapon, follow weapons id order :

0.00, 2.70, 0.00, 2.00, 0.00, 0.55

0 not a weapon

1 = CSW_P228 -> 2.7 sec

2 not a weapon

3 = CSW_SCOUT = 2.00 sec

4 = CSW_HEGRENADE (or CSW_C4 cant remember), can't reload

5 = CSW_M3 or CSW_XM1014 , shotguns use a special reload method, see my plugin weapons maxclip for more details, or look at hlsdk shotguns.cpp code.


etc..


Updated with Reload forward :

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
 
#define PLUGIN "Reload Speed"
#define AUTHOR "ConnorMcLeod"
#define VERSION "0.2.0"
 
#define RELOAD_RATIO 0.5
 
const NOCLIP_WPN_BS    = ((1<<2)|(1<<CSW_HEGRENADE)|(1<<CSW_SMOKEGRENADE)|(1<<CSW_FLASHBANG)|(1<<CSW_KNIFE)|(1<<CSW_C4))
const 
SHOTGUNS_BS    = ((1<<CSW_M3)|(1<<CSW_XM1014))
 
// weapons offsets
const m_pPlayer               41
const m_iId                    43
const m_flNextPrimaryAttack     46
const m_flNextSecondaryAttack    47
const m_flTimeWeaponIdle        48
const m_iPrimaryAmmoType         49
const m_iClip                51
const m_fInReload            54
 
const m_flNextAttack 83
const m_pActiveItem 373
const m_rgAmmo_Slot0 376
 
stock 
const Float:g_fDelay[CSW_P90+1] = {
    
0.002.700.002.000.000.55,   0.003.153.300.004.50
         
2.703.503.352.453.30,   2.702.202.502.634.70
         
0.553.052.123.500.00,   2.203.002.450.003.40
}
 
stock const g_iReloadAnims[CSW_P90+1] = {
    -
1,  5, -13, -1,  6,   -111, -114
        
4,  23,  1,  1,   1374,  1,  3
        
6111,  3, -1,    411, -1,  1}
 
stock const g_iDftMaxClip[CSW_P90+1] = {
    -
1,  13, -110,  1,  7,    13030,  1,  30
        
2025303525,   12201030100
        
303020,  2,    73030, -1,  50}
 
public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
 
    new 
szWeapon[17]
    for(new 
i=1i<=CSW_P90i++)
    {
        if( !(
NOCLIP_WPN_BS & (1<<i)) && get_weaponname(iszWeaponcharsmax(szWeapon)) )
        {
            if( !(
SHOTGUNS_BS & (1<<i)) )
            {
            
//    RegisterHam(Ham_Weapon_Reload, szWeapon, "Weapon_Reload_Pre")
                
RegisterHam(Ham_Weapon_ReloadszWeapon"Weapon_Reload_Post"1)
            }
        }
    }
}
 
public 
Weapon_Reload_Post(iEnt)
{    
    if( 
get_pdata_int(iEntm_fInReload4) )
    {
            new 
id get_pdata_cbase(iEntm_pPlayer4)
        new 
Float:fDelay g_fDelay[get_pdata_int(iEntm_iId4)] * RELOAD_RATIO
        set_pdata_float
(idm_flNextAttackfDelay5)
        
set_pdata_float(iEntm_flTimeWeaponIdlefDelay 0.54)
        
set_pev(idpev_frame200.0)
    }
}
 
/*public Weapon_Reload_Pre( iEnt )
{
    new id = get_pdata_cbase(iEnt, m_pPlayer, 4)
    new iBpAmmo = get_pdata_int(id, m_rgAmmo_Slot0 + get_pdata_int(iEnt, m_iPrimaryAmmoType, 4), 5)
    if( !iBpAmmo )
    {
        return HAM_SUPERCEDE
    }
 
    new iId = get_pdata_int(iEnt, m_iId, 4)
    if( ! min(g_iDftMaxClip[iId] - get_pdata_int(iEnt, m_iClip, 4), iBpAmmo) )
    {
        return HAM_SUPERCEDE
    }
 
    new Float:fDelay = g_fDelay[get_pdata_int(iEnt, m_iId, 4)] * RELOAD_RATIO
    set_pdata_float(id, m_flNextAttack, fDelay, 5)
    set_pev(id, pev_frame, 200.0)
 
    SendWeaponAnim(id, g_iReloadAnims[iId])
 
    set_pdata_int(iEnt, m_fInReload, true)
 
    set_pdata_float(iEnt, m_flTimeWeaponIdle, fDelay + 0.5, 4)
 
    return HAM_SUPERCEDE
}
 
stock SendWeaponAnim(id, iAnim)
{
    set_pev(id, pev_weaponanim, iAnim)
 
    message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, _, id)
    write_byte(iAnim)
    write_byte(pev(id,pev_body))
    message_end()
}*/ 
@ConnorMcLeod
Thx for ur update!
It's almost perfect!
smoothjazz is offline
Owyn
Veteran Member
Join Date: Nov 2007
Old 01-26-2010 , 12:43   Re: About Reload speed
Reply With Quote #17

for some reason it doesn't stop reloading animation for deagle =\ any ideas why?
__________________
☜ Free Mozy ☂backup\҉sync user
Quote:
Американский форум - Задаёшь вопрос, потом тебе отвечают.
Израильский форум - Задаёшь вопрос, потом тебе задают вопрос.
Русский форум - Задаёшь вопрос, потом тебе долго рассказывают, какой ты мудак.
Owyn is offline
Send a message via ICQ to Owyn
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-26-2010 , 14:36   Re: About Reload speed
Reply With Quote #18

Should be due to another plugin i guess.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Owyn
Veteran Member
Join Date: Nov 2007
Old 01-26-2010 , 15:17   Re: About Reload speed
Reply With Quote #19

Quote:
amxx list
Currently loaded plugins:
name version author file st
atus
[ 1] Reload Speed 0.2.0 ConnorMcLeod reload.amxx ru
nning
1 plugins, 1 running
nope
__________________
☜ Free Mozy ☂backup\҉sync user
Quote:
Американский форум - Задаёшь вопрос, потом тебе отвечают.
Израильский форум - Задаёшь вопрос, потом тебе задают вопрос.
Русский форум - Задаёшь вопрос, потом тебе долго рассказывают, какой ты мудак.
Owyn is offline
Send a message via ICQ to Owyn
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-26-2010 , 15:30   Re: About Reload speed
Reply With Quote #20

Another client side animation bug as you can have without any plugin, though you may not have that bug without that plugin.
Anyway i have no idea how to fix.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Reply



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 08:58.


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