ReGameDLL_CS/regamedll/dlls/wpn_shared/wpn_p90.cpp

190 lines
4.2 KiB
C++
Raw Normal View History

2015-06-30 12:46:07 +03:00
#include "precompiled.h"
LINK_ENTITY_TO_CLASS(weapon_p90, CP90, CCSP90);
2015-06-30 12:46:07 +03:00
void CP90::__MAKE_VHOOK(Spawn)()
2015-06-30 12:46:07 +03:00
{
2015-12-06 22:57:51 +03:00
Precache();
2015-12-06 22:57:51 +03:00
m_iId = WEAPON_P90;
SET_MODEL(edict(), "models/w_p90.mdl");
m_iDefaultAmmo = P90_DEFAULT_GIVE;
m_flAccuracy = 0.2f;
2015-12-06 22:57:51 +03:00
m_iShotsFired = 0;
m_bDelayFire = false;
2015-09-16 23:19:21 +03:00
FallInit();
2015-06-30 12:46:07 +03:00
}
void CP90::__MAKE_VHOOK(Precache)()
2015-06-30 12:46:07 +03:00
{
2015-12-06 22:57:51 +03:00
PRECACHE_MODEL("models/v_p90.mdl");
PRECACHE_MODEL("models/w_p90.mdl");
PRECACHE_SOUND("weapons/p90-1.wav");
PRECACHE_SOUND("weapons/p90_clipout.wav");
PRECACHE_SOUND("weapons/p90_clipin.wav");
PRECACHE_SOUND("weapons/p90_boltpull.wav");
PRECACHE_SOUND("weapons/p90_cliprelease.wav");
m_iShell = PRECACHE_MODEL("models/rshell.mdl");
2015-09-16 23:19:21 +03:00
m_usFireP90 = PRECACHE_EVENT(1, "events/p90.sc");
2015-06-30 12:46:07 +03:00
}
2015-09-16 23:19:21 +03:00
int CP90::__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 = P90_MAX_CLIP;
p->iSlot = 0;
p->iPosition = 8;
p->iId = m_iId = WEAPON_P90;
p->iFlags = 0;
p->iWeight = P90_WEIGHT;
2015-09-16 23:19:21 +03:00
return 1;
2015-06-30 12:46:07 +03:00
}
BOOL CP90::__MAKE_VHOOK(Deploy)()
2015-12-06 22:57:51 +03:00
{
m_iShotsFired = 0;
m_bDelayFire = false;
m_flAccuracy = 0.2f;
2015-12-06 22:57:51 +03:00
iShellOn = 1;
2015-09-16 23:19:21 +03:00
return DefaultDeploy("models/v_p90.mdl", "models/p_p90.mdl", P90_DRAW, "carbine", UseDecrement() != FALSE);
2015-06-30 12:46:07 +03:00
}
void CP90::__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))
{
P90Fire(0.3 * m_flAccuracy, 0.066, FALSE);
}
else if (m_pPlayer->pev->velocity.Length2D() > 170)
{
P90Fire(0.115 * m_flAccuracy, 0.066, FALSE);
}
else
{
P90Fire(0.045 * m_flAccuracy, 0.066, 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 CP90::P90Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim)
{
2015-09-28 03:13:39 +03:00
Vector vecAiming, vecSrc, vecDir;
2015-09-16 23:19:21 +03:00
int flag;
2015-12-06 22:57:51 +03:00
m_bDelayFire = true;
++m_iShotsFired;
2015-12-06 22:57:51 +03:00
m_flAccuracy = (m_iShotsFired * m_iShotsFired / 175) + 0.45f;
2015-12-06 22:57:51 +03:00
if (m_flAccuracy > 1)
m_flAccuracy = 1;
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-09-16 23:19:21 +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);
m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME;
m_pPlayer->m_iWeaponFlash = DIM_GUN_FLASH;
vecSrc = m_pPlayer->GetGunPosition();
vecAiming = gpGlobals->v_forward;
vecDir = m_pPlayer->FireBullets3(vecSrc, vecAiming, flSpread, 8192, 1, BULLET_PLAYER_57MM, P90_DAMAGE, P90_RANGE_MODIFER, m_pPlayer->pev, false, m_pPlayer->random_seed);
#ifdef CLIENT_WEAPONS
flag = FEV_NOTHOST;
#else
flag = 0;
#endif
2015-12-06 22:57:51 +03:00
2015-11-24 00:01:09 +03:00
PLAYBACK_EVENT_FULL(flag, m_pPlayer->edict(), m_usFireP90, 0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y,
int(m_pPlayer->pev->punchangle.x * 100), int(m_pPlayer->pev->punchangle.y * 100), 5, FALSE);
2015-09-16 23:19:21 +03:00
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);
}
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0f;
2015-12-06 22:57:51 +03:00
if (!(m_pPlayer->pev->flags & FL_ONGROUND))
{
KickBack(0.9, 0.45, 0.35, 0.04, 5.25, 3.5, 4);
}
else if (m_pPlayer->pev->velocity.Length2D() > 0)
{
KickBack(0.45, 0.3, 0.2, 0.0275, 4.0, 2.25, 7);
}
else if (m_pPlayer->pev->flags & FL_DUCKING)
{
KickBack(0.275, 0.2, 0.125, 0.02, 3.0, 1.0, 9);
}
else
{
KickBack(0.3, 0.225, 0.125, 0.02, 3.25, 1.25, 8);
2015-09-16 23:19:21 +03:00
}
2015-06-30 12:46:07 +03:00
}
void CP90::__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(P90_MAX_CLIP, P90_RELOAD, P90_RELOAD_TIME))
{
m_pPlayer->SetAnimation(PLAYER_RELOAD);
m_flAccuracy = 0.2f;
2015-12-06 22:57:51 +03:00
m_iShotsFired = 0;
2015-09-16 23:19:21 +03:00
}
2015-06-30 12:46:07 +03:00
}
void CP90::__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;
}
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 20.0f;
2015-09-16 23:19:21 +03:00
SendWeaponAnim(P90_IDLE1, UseDecrement() != FALSE);
2015-06-30 12:46:07 +03:00
}
2015-09-16 23:19:21 +03:00
float CP90::__MAKE_VHOOK(GetMaxSpeed)()
2015-09-16 23:19:21 +03:00
{
return P90_MAX_SPEED;
}