ReGameDLL_CS/regamedll/dlls/wpn_shared/wpn_galil.cpp

199 lines
4.5 KiB
C++
Raw Normal View History

2015-06-30 12:46:07 +03:00
#include "precompiled.h"
LINK_ENTITY_TO_CLASS(weapon_galil, CGalil, CCSGalil)
2015-06-30 12:46:07 +03:00
void CGalil::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_GALIL;
SET_MODEL(edict(), "models/w_galil.mdl");
m_iDefaultAmmo = GALIL_DEFAULT_GIVE;
// Get ready to fall down
2015-11-24 00:01:09 +03:00
FallInit();
// extend
CBasePlayerWeapon::Spawn();
2015-06-30 12:46:07 +03:00
}
void CGalil::Precache()
2015-06-30 12:46:07 +03:00
{
2015-12-06 22:57:51 +03:00
PRECACHE_MODEL("models/v_galil.mdl");
PRECACHE_MODEL("models/w_galil.mdl");
PRECACHE_SOUND("weapons/galil-1.wav");
PRECACHE_SOUND("weapons/galil-2.wav");
PRECACHE_SOUND("weapons/galil_clipout.wav");
PRECACHE_SOUND("weapons/galil_clipin.wav");
PRECACHE_SOUND("weapons/galil_boltpull.wav");
m_iShell = PRECACHE_MODEL("models/rshell.mdl");
2015-11-24 00:01:09 +03:00
m_usFireGalil = PRECACHE_EVENT(1, "events/galil.sc");
2015-06-30 12:46:07 +03:00
}
int CGalil::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 = "556Nato";
p->iMaxAmmo1 = MAX_AMMO_556NATO;
2017-10-12 17:50:56 +03:00
p->pszAmmo2 = nullptr;
2015-12-06 22:57:51 +03:00
p->iMaxAmmo2 = -1;
p->iMaxClip = GALIL_MAX_CLIP;
p->iSlot = 0;
p->iPosition = 17;
p->iId = m_iId = WEAPON_GALIL;
p->iFlags = 0;
p->iWeight = GALIL_WEIGHT;
2015-11-24 00:01:09 +03:00
return 1;
2015-06-30 12:46:07 +03:00
}
BOOL CGalil::Deploy()
2015-06-30 12:46:07 +03:00
{
m_flAccuracy = 0.2f;
2015-12-06 22:57:51 +03:00
m_iShotsFired = 0;
iShellOn = 1;
2015-11-24 00:01:09 +03:00
return DefaultDeploy("models/v_galil.mdl", "models/p_galil.mdl", GALIL_DRAW, "ak47", UseDecrement() != FALSE);
2015-06-30 12:46:07 +03:00
}
void CGalil::SecondaryAttack()
2015-06-30 12:46:07 +03:00
{
2015-11-24 00:01:09 +03:00
;
2015-06-30 12:46:07 +03:00
}
void CGalil::PrimaryAttack()
2015-06-30 12:46:07 +03:00
{
2015-12-06 22:57:51 +03:00
if (m_pPlayer->pev->waterlevel == 3)
{
PlayEmptySound();
m_flNextPrimaryAttack = GetNextAttackDelay(0.15);
return;
}
if (!(m_pPlayer->pev->flags & FL_ONGROUND))
{
GalilFire(0.04 + (0.3 * m_flAccuracy), 0.0875, FALSE);
}
else if (m_pPlayer->pev->velocity.Length2D() > 140)
{
GalilFire(0.04 + (0.07 * m_flAccuracy), 0.0875, FALSE);
}
else
{
GalilFire(0.0375 * m_flAccuracy, 0.0875, FALSE);
2015-11-24 00:01:09 +03:00
}
2015-06-30 12:46:07 +03:00
}
2015-11-24 00:01:09 +03:00
void CGalil::GalilFire(float flSpread, float flCycleTime, BOOL fUseAutoAim)
{
2015-12-06 22:57:51 +03:00
Vector vecAiming, vecSrc, vecDir;
int flag;
m_bDelayFire = true;
2017-10-12 17:50:56 +03:00
m_iShotsFired++;
2015-12-06 22:57:51 +03:00
m_flAccuracy = ((m_iShotsFired * m_iShotsFired * m_iShotsFired) / 200) + 0.35f;
2015-12-06 22:57:51 +03:00
if (m_flAccuracy > 1.25f)
m_flAccuracy = 1.25f;
2015-12-06 22:57:51 +03:00
if (m_iClip <= 0)
{
if (m_fFireOnEmpty)
{
PlayEmptySound();
m_flNextPrimaryAttack = GetNextAttackDelay(0.2);
}
2017-10-12 17:50:56 +03:00
if (TheBots)
2015-12-06 22:57:51 +03:00
{
TheBots->OnEvent(EVENT_WEAPON_FIRED_ON_EMPTY, m_pPlayer);
}
return;
2015-11-24 00:01:09 +03:00
}
2017-10-12 17:50:56 +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);
vecSrc = m_pPlayer->GetGunPosition();
vecAiming = gpGlobals->v_forward;
vecDir = m_pPlayer->FireBullets3(vecSrc, vecAiming, flSpread, 8192, 2, BULLET_PLAYER_556MM,
GALIL_DAMAGE, GALIL_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
PLAYBACK_EVENT_FULL(flag, m_pPlayer->edict(), m_usFireGalil, 0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y,
int(m_pPlayer->pev->punchangle.x * 10000000), int(m_pPlayer->pev->punchangle.y * 10000000), FALSE, FALSE);
2015-12-06 22:57:51 +03:00
m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME;
m_pPlayer->m_iWeaponFlash = BRIGHT_GUN_FLASH;
m_flNextPrimaryAttack = m_flNextSecondaryAttack = GetNextAttackDelay(flCycleTime);
if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
{
2017-10-12 17:50:56 +03:00
m_pPlayer->SetSuitUpdate("!HEV_AMO0", SUIT_SENTENCE, SUIT_REPEAT_OK);
2015-12-06 22:57:51 +03:00
}
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.28f;
2015-11-24 00:01:09 +03:00
if (m_pPlayer->pev->velocity.Length2D() > 0)
2015-12-06 22:57:51 +03:00
{
2015-11-24 00:01:09 +03:00
KickBack(1.0, 0.45, 0.28, 0.045, 3.75, 3.0, 7);
2015-12-06 22:57:51 +03:00
}
2015-11-24 00:01:09 +03:00
else if (!(m_pPlayer->pev->flags & FL_ONGROUND))
2015-12-06 22:57:51 +03:00
{
2015-11-24 00:01:09 +03:00
KickBack(1.2, 0.5, 0.23, 0.15, 5.5, 3.5, 6);
2015-12-06 22:57:51 +03:00
}
2015-11-24 00:01:09 +03:00
else if (m_pPlayer->pev->flags & FL_DUCKING)
2015-12-06 22:57:51 +03:00
{
2015-11-24 00:01:09 +03:00
KickBack(0.6, 0.3, 0.2, 0.0125, 3.25, 2.0, 7);
2015-12-06 22:57:51 +03:00
}
2015-11-24 00:01:09 +03:00
else
2015-12-06 22:57:51 +03:00
{
2015-11-24 00:01:09 +03:00
KickBack(0.65, 0.35, 0.25, 0.015, 3.5, 2.25, 7);
}
2015-06-30 12:46:07 +03:00
}
void CGalil::Reload()
2015-06-30 12:46:07 +03:00
{
2015-11-24 00:01:09 +03:00
#ifdef REGAMEDLL_FIXES
// to prevent reload if not enough ammo
2015-12-06 22:57:51 +03:00
if (m_pPlayer->ammo_556nato <= 0)
return;
#endif
2015-12-06 22:57:51 +03:00
if (DefaultReload(iMaxClip(), GALIL_RELOAD, GALIL_RELOAD_TIME))
2015-12-06 22:57:51 +03:00
{
m_pPlayer->SetAnimation(PLAYER_RELOAD);
m_flAccuracy = 0.2f;
2015-12-06 22:57:51 +03:00
m_iShotsFired = 0;
m_bDelayFire = false;
2015-11-24 00:01:09 +03:00
}
2015-06-30 12:46:07 +03:00
}
void CGalil::WeaponIdle()
2015-11-24 00:01:09 +03:00
{
2015-12-06 22:57:51 +03:00
ResetEmptySound();
m_pPlayer->GetAutoaimVector(AUTOAIM_10DEGREES);
if (m_flTimeWeaponIdle <= UTIL_WeaponTimeBase())
{
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 20.0f;
2015-12-06 22:57:51 +03:00
SendWeaponAnim(GALIL_IDLE1, UseDecrement() != FALSE);
2015-11-24 00:01:09 +03:00
}
}