I am finding a way to make a 2 mode Weapon but the shotgun reload is really hard to handle.
PHP Code:
public fw_Weapon_WeaponIdle( iEnt )
{
if(pev_valid(iEnt) != 2)
return
static id; id = get_pdata_cbase(iEnt, m_pPlayer, 5)
if(get_pdata_cbase(id, 373) != iEnt)
return
if(!Get_BitVar(g_Had_Spas12, id))
return
if( get_pdata_float(iEnt, m_flTimeWeaponIdle, 5) > 0.0 )
{
return
}
static iId ; iId = get_pdata_int(iEnt, m_iId, 5)
static iMaxClip ; iMaxClip = CLIP
static iClip ; iClip = get_pdata_int(iEnt, m_iClip, 5)
static fInSpecialReload ; fInSpecialReload = get_pdata_int(iEnt, m_fInSpecialReload, 5)
if( !iClip && !fInSpecialReload )
{
return
}
if( fInSpecialReload )
{
static iBpAmmo ; iBpAmmo = get_pdata_int(id, 381, XTRA_OFS_PLAYER)
static iDftMaxClip ; iDftMaxClip = g_iDftMaxClip[iId]
if( iClip < iMaxClip && iClip == iDftMaxClip && iBpAmmo )
{
Shotgun_Reload(iEnt, iId, iMaxClip, iClip, iBpAmmo, id)
return
}
else if( iClip == iMaxClip && iClip != iDftMaxClip )
{
switch(g_Spas12_Mode[id])
{
case SPAS12_A: Set_WeaponAnim(id, ANIM_AFTER_A)
case SPAS12_B: Set_WeaponAnim(id, ANIM_AFTER_B)
// case JANUS_ACTIVATE: Set_WeaponAnim(id, ANIM_AFTER2)
}
set_pdata_int(iEnt, m_fInSpecialReload, 0, 5)
set_pdata_float(iEnt, m_flTimeWeaponIdle, 1.5, 5)
}
}
return
}
public fw_Item_PostFrame( iEnt )
{
static id ; id = get_pdata_cbase(iEnt, m_pPlayer, 4)
static iBpAmmo ; iBpAmmo = get_pdata_int(id, 381, XTRA_OFS_PLAYER)
static iClip ; iClip = get_pdata_int(iEnt, m_iClip, 4)
static iId ; iId = get_pdata_int(iEnt, m_iId, 4)
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(iEnt, m_fInReload, 4) && get_pdata_float(id, m_flNextAttack, 5) <= 0.0 )
{
new j = min(iMaxClip - iClip, iBpAmmo)
set_pdata_int(iEnt, m_iClip, iClip + j, 4)
set_pdata_int(id, 381, iBpAmmo-j, XTRA_OFS_PLAYER)
set_pdata_int(iEnt, m_fInReload, 0, 4)
return
}
static iButton ; iButton = pev(id, pev_button)
if( iButton & IN_ATTACK && get_pdata_float(iEnt, m_flNextPrimaryAttack, 4) <= 0.0 )
{
return
}
if( iButton & IN_RELOAD )
{
if( iClip >= iMaxClip )
{
set_pev(id, pev_button, iButton & ~IN_RELOAD)
set_pdata_float(iEnt, m_flNextPrimaryAttack, 0.5, 4)
}
else if( iClip == g_iDftMaxClip[iId] )
{
if( iBpAmmo )
{
Shotgun_Reload(iEnt, iId, iMaxClip, iClip, iBpAmmo, id)
}
}
}
}
Shotgun_Reload(iEnt, iId, iMaxClip, iClip, iBpAmmo, id)
{
if(iBpAmmo <= 0 || iClip == iMaxClip)
return
if(get_pdata_int(iEnt, m_flNextPrimaryAttack, 4) > 0.0)
return
switch( get_pdata_int(iEnt, m_fInSpecialReload, 4) )
{
case 0:
{
switch(g_Spas12_Mode[id])
{
case SPAS12_A: Set_WeaponAnim(id, ANIM_START_A)
case SPAS12_B: Set_WeaponAnim(id, ANIM_START_B)
}
set_pdata_int(iEnt, m_fInSpecialReload, 1, 4)
set_pdata_float(id, m_flNextAttack, 0.55, 5)
set_pdata_float(iEnt, m_flTimeWeaponIdle, 0.55, 4)
set_pdata_float(iEnt, m_flNextPrimaryAttack, 0.55, 4)
set_pdata_float(iEnt, m_flNextSecondaryAttack, 0.55, 4)
return
}
case 1:
{
if( get_pdata_float(iEnt, m_flTimeWeaponIdle, 4) > 0.0 )
{
return
}
set_pdata_int(iEnt, m_fInSpecialReload, 2, 4)
static Float:CurTime
CurTime = get_gametime()
if(CurTime - 0.35 > g_PostFrame[id])
{
switch(g_Spas12_Mode[id])
{
case SPAS12_A: Set_WeaponAnim(id, ANIM_INSERT_A)
case SPAS12_B: Set_WeaponAnim(id, ANIM_INSERT_B)
}
}
g_PostFrame[id] = CurTime
set_pdata_float(iEnt, m_flTimeWeaponIdle, iId == CSW_XM1014 ? 0.30 : 0.45, 4)
}
default:
{
set_pdata_int(iEnt, m_iClip, iClip + 1, 4)
set_pdata_int(id, 381, iBpAmmo-1, XTRA_OFS_PLAYER)
set_pdata_int(iEnt, m_fInSpecialReload, 1, 4)
}
}
}