#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "monsters.h"
#include "weapons.h"
#include "nodes.h"
#include "player.h"
#include "gamerules.h"
enum fuckfinger_e {
FUCKFINGER_IDLE = 0,
FUCKFINGER_SHOOT1,
FUCKFINGER_SHOOT2,
FUCKFINGER_RELOAD,
FUCKFINGER_RELOAD_NOSHOOT,
FUCKFINGER_DRAW,
FUCKFINGER_SHOOT_EMPTY,
FUCKFINGER_EMPTY_IDLE
};
LINK_ENTITY_TO_CLASS(weapon_fuckfinger, CFuckfinger);
void CFuckfinger::Spawn()
{
pev->classname = MAKE_STRING("weapon_fuckfinger");
Precache();
m_iId = WEAPON_FUCKFINGER;
SET_MODEL(ENT(pev), "models/w_fuckfinger.mdl");
m_iDefaultAmmo = FUCKFINGER_DEFAULT_GIVE;
FallInit();// get ready to fall
}
void CFuckfinger::Precache(void)
{
PRECACHE_MODEL("models/v_fuckfinger.mdl");
PRECACHE_MODEL("models/w_fuckfinger.mdl");
PRECACHE_MODEL("models/p_fuckfinger.mdl");
m_iShell = PRECACHE_MODEL("models/shell.mdl");// brass shell
PRECACHE_SOUND("items/9mmclip1.wav");
PRECACHE_SOUND("items/9mmclip1.wav");
PRECACHE_SOUND("items/9mmclip2.wav");
PRECACHE_SOUND("weapons/pl_gun3.wav");
m_usFireFuckfinger1 = PRECACHE_EVENT(1, "events/fuckfinger.sc");
m_usFireFuckfinger2 = PRECACHE_EVENT(1, "events/fuckfinger2.sc");
}
int CFuckfinger::GetItemInfo(ItemInfo *p)
{
p->pszName = STRING(pev->classname);
p->pszAmmo1 = "ammo_45";
p->iMaxAmmo1 = _45_MAX_CARRY;
p->pszAmmo2 = NULL;
p->iMaxAmmo2 = -1;
p->iMaxClip = FUCKFINGER_MAX_CLIP;
p->iSlot = 1;
p->iPosition = 3;
p->iFlags = 0;
p->iId = m_iId = WEAPON_FUCKFINGER;
p->iWeight = FUCKFINGER_WEIGHT;
return 1;
}
BOOL CFuckfinger::Deploy()
{
return DefaultDeploy("models/v_fuckfinger.mdl", "models/p_fuckfinger.mdl", FUCKFINGER_DRAW, "onehanded");
}
void CFuckfinger::SecondaryAttack(void)
{
void;
}
void CFuckfinger::PrimaryAttack()
{
// don't fire underwater
if (m_pPlayer->pev->waterlevel == 3)
{
PlayEmptySound();
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.4;
return;
}
if (m_iClip <= 0)
{
if (!m_fFireOnEmpty)
Reload();
return;
}
m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME;
m_pPlayer->m_iWeaponFlash = NORMAL_GUN_FLASH;
m_iClip--;
int flags;
#if defined( CLIENT_WEAPONS )
flags = FEV_NOTHOST;
#else
flags = 0;
#endif
m_pPlayer->pev->effects = (int)(m_pPlayer->pev->effects) | EF_MUZZLEFLASH;
// player "shoot" animation
m_pPlayer->SetAnimation(PLAYER_ATTACK1);
Vector vecSrc = m_pPlayer->GetGunPosition();
Vector vecAiming = m_pPlayer->GetAutoaimVector(AUTOAIM_5DEGREES);
Vector vecDir;
vecDir = m_pPlayer->FireBulletsPlayer(1, vecSrc, vecAiming, VECTOR_CONE_FUCKFINGER, 8192, BULLET_PLAYER_45, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed);
PLAYBACK_EVENT_FULL(flags, m_pPlayer->edict(), m_usFireFuckfinger1, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, 0, 0, 0, 0);
if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
// HEV suit - indicate out of ammo condition
m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0);
m_flNextPrimaryAttack = 0.4;
m_flTimeWeaponIdle = UTIL_SharedRandomFloat(m_pPlayer->random_seed, 10, 15);
}
void CFuckfinger::Reload(void)
{
if (m_pPlayer->ammo_45 <= 0)
return;
int iResult;
if (m_iClip == 0)
iResult = DefaultReload(9, FUCKFINGER_RELOAD, 1.5);
else
iResult = DefaultReload(9, FUCKFINGER_RELOAD_NOSHOOT, 1.5);
if (iResult)
{
m_flTimeWeaponIdle + UTIL_SharedRandomFloat(m_pPlayer->random_seed, 10, 15);
}
}
void CFuckfinger::WeaponIdle(void)
{
ResetEmptySound();
m_pPlayer->GetAutoaimVector(AUTOAIM_10DEGREES);
if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase())
return;
// only idle if the slid isn't back
if (m_iClip != 0)
{
int iAnim;
float flRand = UTIL_SharedRandomFloat(m_pPlayer->random_seed, 0, 1);
if (flRand <= 0.5)
{
iAnim = FUCKFINGER_IDLE;
m_flTimeWeaponIdle + 70.0 / 30.0;
}
else if (flRand <= 0.7)
{
iAnim = FUCKFINGER_IDLE;
m_flTimeWeaponIdle + 60.0 / 16.0;
}
else
{
iAnim = FUCKFINGER_IDLE;
m_flTimeWeaponIdle + 88.0 / 30.0;
}
SendWeaponAnim(iAnim, 1);
}
}
class CFuckfingerAmmo : public CBasePlayerAmmo
{
void Spawn(void)
{
Precache();
SET_MODEL(ENT(pev), "models/w_9mmarclip.mdl");
CBasePlayerAmmo::Spawn();
}
void Precache(void)
{
PRECACHE_MODEL("models/w_9mmarclip.mdl");
PRECACHE_SOUND("items/9mmclip1.wav");
}
BOOL AddAmmo(CBaseEntity *pOther)
{
if (pOther->GiveAmmo(AMMO_FUCKFINGERCLIP_GIVE, "ammo_45", _45_MAX_CARRY) != -1)
{
EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM);
return TRUE;
}
return FALSE;
}
};
LINK_ENTITY_TO_CLASS(ammo_fuckfingerclip, CFuckfingerAmmo);