2015-06-30 12:46:07 +03:00
|
|
|
#include "precompiled.h"
|
|
|
|
|
2016-03-17 20:44:52 +03:00
|
|
|
LINK_ENTITY_TO_CLASS(weapon_fiveseven, CFiveSeven, CCSFiveSeven);
|
2015-06-30 12:46:07 +03:00
|
|
|
|
2016-02-04 03:18:26 +03:00
|
|
|
void CFiveSeven::__MAKE_VHOOK(Spawn)()
|
2015-06-30 12:46:07 +03:00
|
|
|
{
|
2015-12-06 22:57:51 +03:00
|
|
|
Precache();
|
2016-02-04 03:18:26 +03:00
|
|
|
|
2015-12-06 22:57:51 +03:00
|
|
|
m_iId = WEAPON_FIVESEVEN;
|
|
|
|
SET_MODEL(edict(), "models/w_fiveseven.mdl");
|
|
|
|
|
|
|
|
m_iDefaultAmmo = FIVESEVEN_DEFAULT_GIVE;
|
|
|
|
m_iWeaponState &= ~WPNSTATE_SHIELD_DRAWN;
|
2016-02-04 03:18:26 +03:00
|
|
|
m_flAccuracy = 0.92f;
|
2015-12-06 22:57:51 +03:00
|
|
|
|
2015-11-24 00:01:09 +03:00
|
|
|
FallInit();
|
2015-06-30 12:46:07 +03:00
|
|
|
}
|
|
|
|
|
2016-02-04 03:18:26 +03:00
|
|
|
void CFiveSeven::__MAKE_VHOOK(Precache)()
|
2015-06-30 12:46:07 +03:00
|
|
|
{
|
2015-12-06 22:57:51 +03:00
|
|
|
PRECACHE_MODEL("models/v_fiveseven.mdl");
|
|
|
|
PRECACHE_MODEL("models/w_fiveseven.mdl");
|
|
|
|
PRECACHE_MODEL("models/shield/v_shield_fiveseven.mdl");
|
|
|
|
|
|
|
|
PRECACHE_SOUND("weapons/fiveseven-1.wav");
|
|
|
|
PRECACHE_SOUND("weapons/fiveseven_clipout.wav");
|
|
|
|
PRECACHE_SOUND("weapons/fiveseven_clipin.wav");
|
|
|
|
PRECACHE_SOUND("weapons/fiveseven_sliderelease.wav");
|
|
|
|
PRECACHE_SOUND("weapons/fiveseven_slidepull.wav");
|
|
|
|
|
|
|
|
m_iShell = PRECACHE_MODEL("models/pshell.mdl");
|
2015-11-24 00:01:09 +03:00
|
|
|
m_usFireFiveSeven = PRECACHE_EVENT(1, "events/fiveseven.sc");
|
2015-06-30 12:46:07 +03:00
|
|
|
}
|
|
|
|
|
2015-11-24 00:01:09 +03:00
|
|
|
int CFiveSeven::__MAKE_VHOOK(GetItemInfo)(ItemInfo *p)
|
2015-06-30 12:46:07 +03:00
|
|
|
{
|
2015-12-06 22:57:51 +03:00
|
|
|
p->pszName = STRING(pev->classname);
|
|
|
|
p->pszAmmo1 = "57mm";
|
|
|
|
p->iMaxAmmo1 = MAX_AMMO_57MM;
|
|
|
|
p->pszAmmo2 = NULL;
|
|
|
|
p->iMaxAmmo2 = -1;
|
|
|
|
p->iMaxClip = FIVESEVEN_MAX_CLIP;
|
|
|
|
p->iSlot = 1;
|
|
|
|
p->iPosition = 6;
|
|
|
|
p->iId = m_iId = WEAPON_FIVESEVEN;
|
|
|
|
p->iFlags = 0;
|
|
|
|
p->iWeight = FIVESEVEN_WEIGHT;
|
|
|
|
|
2015-11-24 00:01:09 +03:00
|
|
|
return 1;
|
2015-06-30 12:46:07 +03:00
|
|
|
}
|
|
|
|
|
2016-02-04 03:18:26 +03:00
|
|
|
BOOL CFiveSeven::__MAKE_VHOOK(Deploy)()
|
2015-06-30 12:46:07 +03:00
|
|
|
{
|
2016-02-04 03:18:26 +03:00
|
|
|
m_flAccuracy = 0.92f;
|
2015-12-06 22:57:51 +03:00
|
|
|
m_fMaxSpeed = FIVESEVEN_MAX_SPEED;
|
|
|
|
m_iWeaponState &= ~WPNSTATE_SHIELD_DRAWN;
|
|
|
|
m_pPlayer->m_bShieldDrawn = false;
|
|
|
|
|
|
|
|
if (m_pPlayer->HasShield())
|
|
|
|
return DefaultDeploy("models/shield/v_shield_fiveseven.mdl", "models/shield/p_shield_fiveseven.mdl", FIVESEVEN_DRAW, "shieldgun", UseDecrement() != FALSE);
|
|
|
|
else
|
2015-11-24 00:01:09 +03:00
|
|
|
return DefaultDeploy("models/v_fiveseven.mdl", "models/p_fiveseven.mdl", FIVESEVEN_DRAW, "onehanded", UseDecrement() != FALSE);
|
2015-06-30 12:46:07 +03:00
|
|
|
}
|
|
|
|
|
2016-02-04 03:18:26 +03:00
|
|
|
void CFiveSeven::__MAKE_VHOOK(PrimaryAttack)()
|
2015-06-30 12:46:07 +03:00
|
|
|
{
|
2015-12-06 22:57:51 +03:00
|
|
|
if (!(m_pPlayer->pev->flags & FL_ONGROUND))
|
|
|
|
{
|
|
|
|
FiveSevenFire(1.5 * (1 - m_flAccuracy), 0.2, FALSE);
|
|
|
|
}
|
|
|
|
else if (m_pPlayer->pev->velocity.Length2D() > 0)
|
|
|
|
{
|
|
|
|
FiveSevenFire(0.255 * (1 - m_flAccuracy), 0.2, FALSE);
|
|
|
|
}
|
|
|
|
else if (m_pPlayer->pev->flags & FL_DUCKING)
|
|
|
|
{
|
|
|
|
FiveSevenFire(0.075 * (1 - m_flAccuracy), 0.2, FALSE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FiveSevenFire(0.15 * (1 - m_flAccuracy), 0.2, FALSE);
|
2015-11-24 00:01:09 +03:00
|
|
|
}
|
2015-06-30 12:46:07 +03:00
|
|
|
}
|
|
|
|
|
2016-02-04 03:18:26 +03:00
|
|
|
void CFiveSeven::__MAKE_VHOOK(SecondaryAttack)()
|
2015-06-30 12:46:07 +03:00
|
|
|
{
|
2015-11-24 00:01:09 +03:00
|
|
|
ShieldSecondaryFire(SHIELDGUN_UP, SHIELDGUN_DOWN);
|
2015-06-30 12:46:07 +03:00
|
|
|
}
|
|
|
|
|
2015-11-24 00:01:09 +03:00
|
|
|
void CFiveSeven::FiveSevenFire(float flSpread, float flCycleTime, BOOL fUseSemi)
|
2015-12-06 22:57:51 +03:00
|
|
|
{
|
|
|
|
Vector vecAiming, vecSrc, vecDir;
|
|
|
|
int flag;
|
|
|
|
|
|
|
|
flCycleTime -= 0.05;
|
|
|
|
|
|
|
|
if (++m_iShotsFired > 1)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-02-04 03:18:26 +03:00
|
|
|
if (m_flLastFire != 0.0f)
|
2015-12-06 22:57:51 +03:00
|
|
|
{
|
2016-02-04 03:18:26 +03:00
|
|
|
m_flAccuracy -= (0.275f - (gpGlobals->time - m_flLastFire)) * 0.25f;
|
2015-12-06 22:57:51 +03:00
|
|
|
|
2016-02-04 03:18:26 +03:00
|
|
|
if (m_flAccuracy > 0.92f)
|
2015-12-06 22:57:51 +03:00
|
|
|
{
|
2016-02-04 03:18:26 +03:00
|
|
|
m_flAccuracy = 0.92f;
|
2015-12-06 22:57:51 +03:00
|
|
|
}
|
2016-02-04 03:18:26 +03:00
|
|
|
else if (m_flAccuracy < 0.725f)
|
2015-12-06 22:57:51 +03:00
|
|
|
{
|
2016-02-04 03:18:26 +03:00
|
|
|
m_flAccuracy = 0.725f;
|
2015-12-06 22:57:51 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_flLastFire = gpGlobals->time;
|
|
|
|
|
|
|
|
if (m_iClip <= 0)
|
|
|
|
{
|
|
|
|
if (m_fFireOnEmpty)
|
|
|
|
{
|
|
|
|
PlayEmptySound();
|
|
|
|
m_flNextPrimaryAttack = GetNextAttackDelay(0.2);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TheBots != NULL)
|
|
|
|
{
|
|
|
|
TheBots->OnEvent(EVENT_WEAPON_FIRED_ON_EMPTY, m_pPlayer);
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
2015-11-24 00:01:09 +03:00
|
|
|
}
|
|
|
|
|
2016-02-04 03:18:26 +03:00
|
|
|
--m_iClip;
|
2015-11-24 00:01:09 +03:00
|
|
|
m_pPlayer->pev->effects |= EF_MUZZLEFLASH;
|
|
|
|
SetPlayerShieldAnim();
|
|
|
|
|
|
|
|
m_pPlayer->SetAnimation(PLAYER_ATTACK1);
|
|
|
|
UTIL_MakeVectors(m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle);
|
|
|
|
|
2015-12-06 22:57:51 +03:00
|
|
|
m_pPlayer->m_iWeaponVolume = BIG_EXPLOSION_VOLUME;
|
2015-11-24 00:01:09 +03:00
|
|
|
m_pPlayer->m_iWeaponFlash = DIM_GUN_FLASH;
|
|
|
|
|
2015-12-06 22:57:51 +03:00
|
|
|
vecSrc = m_pPlayer->GetGunPosition();
|
|
|
|
vecAiming = gpGlobals->v_forward;
|
2015-11-24 00:01:09 +03:00
|
|
|
|
2016-02-04 03:18:26 +03:00
|
|
|
vecDir = m_pPlayer->FireBullets3(vecSrc, vecAiming, flSpread, 4096, 1, BULLET_PLAYER_57MM, FIVESEVEN_DAMAGE, FIVESEVEN_RANGE_MODIFER, m_pPlayer->pev, false, m_pPlayer->random_seed);
|
2015-12-06 22:57:51 +03:00
|
|
|
|
|
|
|
#ifdef CLIENT_WEAPONS
|
|
|
|
flag = FEV_NOTHOST;
|
|
|
|
#else
|
|
|
|
flag = 0;
|
2016-02-23 02:13:52 +03:00
|
|
|
#endif
|
2015-11-24 00:01:09 +03:00
|
|
|
|
2015-12-06 22:57:51 +03:00
|
|
|
PLAYBACK_EVENT_FULL(flag, m_pPlayer->edict(), m_usFireFiveSeven, 0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y,
|
2016-02-23 02:13:52 +03:00
|
|
|
int(m_pPlayer->pev->punchangle.x * 100), int(m_pPlayer->pev->punchangle.y * 100), m_iClip == 0, FALSE);
|
2015-12-06 22:57:51 +03:00
|
|
|
|
|
|
|
m_flNextPrimaryAttack = m_flNextSecondaryAttack = GetNextAttackDelay(flCycleTime);
|
|
|
|
|
|
|
|
if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
|
|
|
|
{
|
|
|
|
m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, FALSE);
|
|
|
|
}
|
|
|
|
|
2016-02-04 03:18:26 +03:00
|
|
|
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0f;
|
|
|
|
m_pPlayer->pev->punchangle.x -= 2.0f;
|
2015-11-24 00:01:09 +03:00
|
|
|
ResetPlayerShieldAnim();
|
2015-06-30 12:46:07 +03:00
|
|
|
}
|
|
|
|
|
2016-02-04 03:18:26 +03:00
|
|
|
void CFiveSeven::__MAKE_VHOOK(Reload)()
|
2015-06-30 12:46:07 +03:00
|
|
|
{
|
2015-12-06 22:57:51 +03:00
|
|
|
if (m_pPlayer->ammo_57mm <= 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (DefaultReload(FIVESEVEN_MAX_CLIP, FIVESEVEN_RELOAD, FIVESEVEN_RELOAD_TIME))
|
|
|
|
{
|
|
|
|
m_pPlayer->SetAnimation(PLAYER_RELOAD);
|
2016-02-04 03:18:26 +03:00
|
|
|
m_flAccuracy = 0.92f;
|
2015-11-24 00:01:09 +03:00
|
|
|
}
|
2015-06-30 12:46:07 +03:00
|
|
|
}
|
|
|
|
|
2016-02-04 03:18:26 +03:00
|
|
|
void CFiveSeven::__MAKE_VHOOK(WeaponIdle)()
|
2015-06-30 12:46:07 +03:00
|
|
|
{
|
2015-12-06 22:57:51 +03:00
|
|
|
ResetEmptySound();
|
|
|
|
m_pPlayer->GetAutoaimVector(AUTOAIM_10DEGREES);
|
|
|
|
|
|
|
|
if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_pPlayer->HasShield())
|
|
|
|
{
|
2016-02-04 03:18:26 +03:00
|
|
|
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 20.0f;
|
2015-12-06 22:57:51 +03:00
|
|
|
|
|
|
|
if (m_iWeaponState & WPNSTATE_SHIELD_DRAWN)
|
|
|
|
{
|
|
|
|
SendWeaponAnim(SHIELDGUN_DRAWN_IDLE, UseDecrement() != FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (m_iClip)
|
|
|
|
{
|
2016-02-04 03:18:26 +03:00
|
|
|
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 3.0625f;
|
2015-12-06 22:57:51 +03:00
|
|
|
SendWeaponAnim(FIVESEVEN_IDLE, UseDecrement() != FALSE);
|
2015-11-24 00:01:09 +03:00
|
|
|
}
|
2015-06-30 12:46:07 +03:00
|
|
|
}
|