2015-06-30 12:46:07 +03:00
|
|
|
#include "precompiled.h"
|
|
|
|
|
2016-03-17 20:44:52 +03:00
|
|
|
LINK_ENTITY_TO_CLASS(weapon_awp, CAWP, CCSAWP);
|
2015-06-30 12:46:07 +03:00
|
|
|
|
2016-02-04 03:18:26 +03:00
|
|
|
void CAWP::__MAKE_VHOOK(Spawn)()
|
2015-06-30 12:46:07 +03:00
|
|
|
{
|
2015-09-16 23:19:21 +03:00
|
|
|
Precache();
|
2016-02-04 03:18:26 +03:00
|
|
|
|
2015-09-16 23:19:21 +03:00
|
|
|
m_iId = WEAPON_AWP;
|
|
|
|
SET_MODEL(ENT(pev), "models/w_awp.mdl");
|
|
|
|
|
|
|
|
m_iDefaultAmmo = AWP_DEFAULT_GIVE;
|
|
|
|
FallInit();
|
2015-06-30 12:46:07 +03:00
|
|
|
}
|
|
|
|
|
2016-02-04 03:18:26 +03:00
|
|
|
void CAWP::__MAKE_VHOOK(Precache)()
|
2015-06-30 12:46:07 +03:00
|
|
|
{
|
2015-12-06 22:57:51 +03:00
|
|
|
PRECACHE_MODEL("models/v_awp.mdl");
|
|
|
|
PRECACHE_MODEL("models/w_awp.mdl");
|
|
|
|
|
|
|
|
PRECACHE_SOUND("weapons/awp1.wav");
|
|
|
|
PRECACHE_SOUND("weapons/boltpull1.wav");
|
|
|
|
PRECACHE_SOUND("weapons/boltup.wav");
|
|
|
|
PRECACHE_SOUND("weapons/boltdown.wav");
|
|
|
|
PRECACHE_SOUND("weapons/zoom.wav");
|
|
|
|
PRECACHE_SOUND("weapons/awp_deploy.wav");
|
|
|
|
PRECACHE_SOUND("weapons/awp_clipin.wav");
|
|
|
|
PRECACHE_SOUND("weapons/awp_clipout.wav");
|
|
|
|
|
|
|
|
m_iShell = PRECACHE_MODEL("models/rshell_big.mdl");
|
|
|
|
m_iShellId = m_iShell;
|
2015-09-16 23:19:21 +03:00
|
|
|
m_usFireAWP = PRECACHE_EVENT(1, "events/awp.sc");
|
2015-06-30 12:46:07 +03:00
|
|
|
}
|
|
|
|
|
2015-09-16 23:19:21 +03:00
|
|
|
int CAWP::__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 = "338Magnum";
|
|
|
|
p->iMaxAmmo1 = MAX_AMMO_338MAGNUM;
|
|
|
|
p->pszAmmo2 = NULL;
|
|
|
|
p->iMaxAmmo2 = -1;
|
|
|
|
p->iMaxClip = AWP_MAX_CLIP;
|
|
|
|
p->iSlot = 0;
|
|
|
|
p->iPosition = 2;
|
|
|
|
p->iId = m_iId = WEAPON_AWP;
|
|
|
|
p->iFlags = 0;
|
|
|
|
p->iWeight = AWP_WEIGHT;
|
|
|
|
|
2015-09-16 23:19:21 +03:00
|
|
|
return 1;
|
2015-06-30 12:46:07 +03:00
|
|
|
}
|
|
|
|
|
2016-02-04 03:18:26 +03:00
|
|
|
BOOL CAWP::__MAKE_VHOOK(Deploy)()
|
2015-06-30 12:46:07 +03:00
|
|
|
{
|
2015-12-06 22:57:51 +03:00
|
|
|
if (DefaultDeploy("models/v_awp.mdl", "models/p_awp.mdl", AWP_DRAW, "rifle", UseDecrement() != FALSE))
|
|
|
|
{
|
|
|
|
m_pPlayer->m_flNextAttack = GetNextAttackDelay(1.45);
|
|
|
|
m_flNextPrimaryAttack = m_pPlayer->m_flNextAttack;
|
2016-02-04 03:18:26 +03:00
|
|
|
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.0f;
|
2015-12-06 22:57:51 +03:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2015-09-16 23:19:21 +03:00
|
|
|
return FALSE;
|
2015-06-30 12:46:07 +03:00
|
|
|
}
|
|
|
|
|
2016-02-04 03:18:26 +03:00
|
|
|
void CAWP::__MAKE_VHOOK(SecondaryAttack)()
|
2015-06-30 12:46:07 +03:00
|
|
|
{
|
2015-12-06 22:57:51 +03:00
|
|
|
switch (m_pPlayer->m_iFOV)
|
|
|
|
{
|
|
|
|
case 90: m_pPlayer->m_iFOV = m_pPlayer->pev->fov = 40; break;
|
|
|
|
case 40: m_pPlayer->m_iFOV = m_pPlayer->pev->fov = 10; break;
|
|
|
|
default: m_pPlayer->m_iFOV = m_pPlayer->pev->fov = 90; break;
|
2015-09-16 23:19:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (TheBots != NULL)
|
|
|
|
{
|
|
|
|
TheBots->OnEvent(EVENT_WEAPON_ZOOMED, m_pPlayer);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_pPlayer->ResetMaxSpeed();
|
|
|
|
EMIT_SOUND(m_pPlayer->edict(), CHAN_ITEM, "weapons/zoom.wav", 0.2, 2.4);
|
|
|
|
|
2015-09-28 03:13:39 +03:00
|
|
|
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.3;
|
2015-06-30 12:46:07 +03:00
|
|
|
}
|
|
|
|
|
2016-02-04 03:18:26 +03:00
|
|
|
void CAWP::__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))
|
|
|
|
{
|
|
|
|
AWPFire(0.85, 1.45, FALSE);
|
|
|
|
}
|
|
|
|
else if (m_pPlayer->pev->velocity.Length2D() > 140)
|
|
|
|
{
|
|
|
|
AWPFire(0.25, 1.45, FALSE);
|
|
|
|
}
|
|
|
|
else if (m_pPlayer->pev->velocity.Length2D() > 10)
|
|
|
|
{
|
|
|
|
AWPFire(0.1, 1.45, FALSE);
|
|
|
|
}
|
|
|
|
else if (m_pPlayer->pev->flags & FL_DUCKING)
|
|
|
|
{
|
|
|
|
AWPFire(0.0, 1.45, FALSE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
AWPFire(0.001, 1.45, FALSE);
|
2015-09-16 23:19:21 +03:00
|
|
|
}
|
2015-06-30 12:46:07 +03:00
|
|
|
}
|
|
|
|
|
2015-09-16 23:19:21 +03:00
|
|
|
void CAWP::AWPFire(float flSpread, float flCycleTime, BOOL fUseAutoAim)
|
2015-12-06 22:57:51 +03:00
|
|
|
{
|
|
|
|
Vector vecAiming, vecSrc, vecDir;
|
|
|
|
int flag;
|
|
|
|
|
|
|
|
if (m_pPlayer->pev->fov != DEFAULT_FOV)
|
|
|
|
{
|
|
|
|
m_pPlayer->m_bResumeZoom = true;
|
|
|
|
m_pPlayer->m_iLastZoom = m_pPlayer->m_iFOV;
|
|
|
|
|
|
|
|
// reset a fov
|
|
|
|
m_pPlayer->m_iFOV = DEFAULT_FOV;
|
|
|
|
m_pPlayer->pev->fov = DEFAULT_FOV;
|
|
|
|
}
|
2016-01-19 14:54:31 +03:00
|
|
|
// If we are not zoomed in, the bullet diverts more.
|
2015-12-06 22:57:51 +03:00
|
|
|
else
|
|
|
|
{
|
2016-02-04 03:18:26 +03:00
|
|
|
flSpread += 0.08f;
|
2015-12-06 22:57:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2016-02-04 03:18:26 +03:00
|
|
|
--m_iClip;
|
2015-12-06 22:57:51 +03:00
|
|
|
m_pPlayer->pev->effects |= EF_MUZZLEFLASH;
|
|
|
|
m_pPlayer->SetAnimation(PLAYER_ATTACK1);
|
|
|
|
|
|
|
|
UTIL_MakeVectors(m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle);
|
|
|
|
|
2016-02-04 03:18:26 +03:00
|
|
|
m_pPlayer->m_flEjectBrass = gpGlobals->time + 0.55f;
|
2015-12-06 22:57:51 +03:00
|
|
|
m_pPlayer->m_iWeaponVolume = BIG_EXPLOSION_VOLUME;
|
|
|
|
m_pPlayer->m_iWeaponFlash = NORMAL_GUN_FLASH;
|
|
|
|
|
|
|
|
vecSrc = m_pPlayer->GetGunPosition();
|
|
|
|
vecAiming = gpGlobals->v_forward;
|
|
|
|
|
|
|
|
vecDir = m_pPlayer->FireBullets3(vecSrc, vecAiming, flSpread, 8192, 3, BULLET_PLAYER_338MAG, AWP_DAMAGE, AWP_RANGE_MODIFER, m_pPlayer->pev, true, m_pPlayer->random_seed);
|
|
|
|
|
|
|
|
#ifdef CLIENT_WEAPONS
|
|
|
|
flag = FEV_NOTHOST;
|
|
|
|
#else
|
|
|
|
flag = 0;
|
2016-02-23 02:13:52 +03:00
|
|
|
#endif
|
2015-12-06 22:57:51 +03:00
|
|
|
|
|
|
|
PLAYBACK_EVENT_FULL(flag, m_pPlayer->edict(), m_usFireAWP, 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.x * 100), FALSE, 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, 0);
|
|
|
|
}
|
|
|
|
|
2016-02-04 03:18:26 +03:00
|
|
|
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0f;
|
|
|
|
m_pPlayer->pev->punchangle.x -= 2.0f;
|
2015-06-30 12:46:07 +03:00
|
|
|
}
|
|
|
|
|
2016-02-04 03:18:26 +03:00
|
|
|
void CAWP::__MAKE_VHOOK(Reload)()
|
2015-06-30 12:46:07 +03:00
|
|
|
{
|
2015-12-06 22:57:51 +03:00
|
|
|
if (m_pPlayer->ammo_338mag <= 0)
|
|
|
|
return;
|
2015-09-16 23:19:21 +03:00
|
|
|
|
2015-11-24 00:01:09 +03:00
|
|
|
if (DefaultReload(AWP_MAX_CLIP, AWP_RELOAD, AWP_RELOAD_TIME))
|
2015-09-16 23:19:21 +03:00
|
|
|
{
|
2015-12-06 22:57:51 +03:00
|
|
|
m_pPlayer->SetAnimation(PLAYER_RELOAD);
|
|
|
|
|
|
|
|
if (m_pPlayer->pev->fov != DEFAULT_FOV)
|
|
|
|
{
|
|
|
|
m_pPlayer->m_iFOV = 10;
|
|
|
|
m_pPlayer->pev->fov = 10;
|
|
|
|
|
|
|
|
SecondaryAttack();
|
2015-09-16 23:19:21 +03:00
|
|
|
}
|
|
|
|
}
|
2015-06-30 12:46:07 +03:00
|
|
|
}
|
|
|
|
|
2016-02-04 03:18:26 +03:00
|
|
|
void CAWP::__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() && m_iClip)
|
|
|
|
{
|
2016-02-04 03:18:26 +03:00
|
|
|
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 60.0f;
|
2015-12-06 22:57:51 +03:00
|
|
|
SendWeaponAnim(AWP_IDLE, UseDecrement() != FALSE);
|
2015-09-16 23:19:21 +03:00
|
|
|
}
|
2015-06-30 12:46:07 +03:00
|
|
|
}
|
|
|
|
|
2016-02-04 03:18:26 +03:00
|
|
|
float CAWP::__MAKE_VHOOK(GetMaxSpeed)()
|
2015-09-16 23:19:21 +03:00
|
|
|
{
|
2016-01-19 14:54:31 +03:00
|
|
|
if (m_pPlayer->m_iFOV == DEFAULT_FOV)
|
|
|
|
return AWP_MAX_SPEED;
|
|
|
|
|
|
|
|
// Slower speed when zoomed in.
|
|
|
|
return AWP_MAX_SPEED_ZOOM;
|
2015-09-16 23:19:21 +03:00
|
|
|
}
|