/* Copyright (c) 1999, Cold Ice Modification. This code has been written by SlimShady ( darcuri@optonline.net ) Use, distribution, and modification of this source code and/or resulting object code is restricted to non-commercial enhancements to products from Valve LLC. All other use, distribution, or modification is prohibited without written permission from Valve LLC and from the Cold Ice team. Please if you use this code in any public form, please give us credit. */ #include "extdll.h" #include "util.h" #include "cbase.h" #include "monsters.h" #include "weapons.h" #include "nodes.h" #include "player.h" #include "soundent.h" #include "gamerules.h" enum mag_e { MAG_LONGIDLE = 0, MAG_IDLE1, MAG_LAUNCH, MAG_RELOAD, MAG_DEPLOY, MAG_FIRE1, MAG_FIRE2, MAG_FIRE3, }; class CMag60 : public CBasePlayerWeapon { public: void Spawn( void ); void Precache( void ); int iItemSlot( void ) { return 2; } int GetItemInfo(ItemInfo *p); int AddToPlayer( CBasePlayer *pPlayer ); int menu_on; void PrimaryAttack( void ); BOOL Deploy( void ); void Reload( void ); void WeaponIdle( void ); float m_flNextAnimTime; int m_iShell; }; LINK_ENTITY_TO_CLASS( weapon_mag60, CMag60 ); LINK_ENTITY_TO_CLASS( weapon_357, CMag60 ); //========================================================= //========================================================= void CMag60::Spawn( ) { pev->classname = MAKE_STRING("weapon_mag60"); Precache( ); SET_MODEL(ENT(pev), "models/wmodels/w_mag.mdl"); m_iId = WEAPON_MAG60; m_iDefaultAmmo = MAG60_DEFAULT_GIVE; FallInit(); } void CMag60::Precache( void ) { PRECACHE_MODEL("models/vmodels/v_mag.mdl"); PRECACHE_MODEL("models/wmodels/w_mag.mdl"); PRECACHE_MODEL("models/pmodels/p_mag.mdl"); m_iShell = PRECACHE_MODEL ("models/shell.mdl"); PRECACHE_SOUND ("weapons/mag1.wav"); } int CMag60::GetItemInfo(ItemInfo *p) { p->pszName = STRING(pev->classname); p->pszAmmo1 = "38acp"; p->iMaxAmmo1 = MAG60_MAX_CARRY; p->pszAmmo2 = NULL; p->iMaxAmmo2 = -1; p->iMaxClip = MAG60_MAX_CLIP; p->iSlot = 1; p->iPosition = 1; p->iFlags = 0; p->iId = m_iId = WEAPON_MAG60; p->iWeight = MAG60_WEIGHT; return 1; } int CMag60::AddToPlayer( CBasePlayer *pPlayer ) { if ( CBasePlayerWeapon::AddToPlayer( pPlayer ) ) { MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev ); WRITE_BYTE( m_iId ); MESSAGE_END(); return TRUE; } return FALSE; } BOOL CMag60::Deploy( ) { return DefaultDeploy( "models/vmodels/v_mag.mdl", "models/pmodels/p_mag.mdl", MAG_DEPLOY, "onehanded" ); } void CMag60::PrimaryAttack() { if (m_pPlayer->pev->waterlevel == 3) { PlayEmptySound( ); m_flNextPrimaryAttack = gpGlobals->time + 0.15; return; } if (m_iClip <= 0) { PlayEmptySound(); m_flNextPrimaryAttack = gpGlobals->time + 0.15; return; } m_pPlayer->m_iWeaponVolume = LOUD_GUN_VOLUME; m_pPlayer->m_iWeaponFlash = BRIGHT_GUN_FLASH; m_iClip--; m_pPlayer->pev->effects = (int)(m_pPlayer->pev->effects) | EF_MUZZLEFLASH; SendWeaponAnim( MAG_FIRE1 ); m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/mag1.wav", 1, ATTN_NORM, 0, 94 + RANDOM_LONG(0,0xf)); UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle ); Vector vecShellVelocity = m_pPlayer->pev->velocity + gpGlobals->v_right * RANDOM_FLOAT(50,70) + gpGlobals->v_up * RANDOM_FLOAT(100,150) + gpGlobals->v_forward * 25; EjectBrass ( pev->origin + m_pPlayer->pev->view_ofs + gpGlobals->v_up * -12 + gpGlobals->v_forward * 32 + gpGlobals->v_right * 6 , vecShellVelocity, pev->angles.y, m_iShell, TE_BOUNCE_SHELL ); Vector vecSrc = m_pPlayer->GetGunPosition( ); Vector vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES ); m_pPlayer->FireBullets( 1, vecSrc, vecAiming, VECTOR_CONE_6DEGREES, 8192, BULLET_PLAYER_MP5, 0 ); m_flNextPrimaryAttack = m_flNextPrimaryAttack + 0.07; if (m_flNextPrimaryAttack < gpGlobals->time) m_flNextPrimaryAttack = gpGlobals->time + 0.07; m_flTimeWeaponIdle = gpGlobals->time + RANDOM_FLOAT ( 10, 15 ); m_pPlayer->pev->punchangle.x = RANDOM_FLOAT( -2, 2 ); } void CMag60::Reload( void ) { DefaultReload( MAG60_MAX_CLIP, MAG_RELOAD, 1.5 ); } void CMag60::WeaponIdle( void ) { ResetEmptySound( ); m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES ); if (m_flTimeWeaponIdle > gpGlobals->time) return; int iAnim; switch ( RANDOM_LONG( 0, 1 ) ) { case 0: iAnim = MAG_LONGIDLE; break; default: case 1: iAnim = MAG_IDLE1; break; } SendWeaponAnim( iAnim ); m_flTimeWeaponIdle = gpGlobals->time + RANDOM_FLOAT ( 10, 15 ); } class CMagAmmoClip : public CBasePlayerAmmo { void Spawn( void ) { Precache( ); SET_MODEL(ENT(pev), "models/ammo/w_38acp.mdl"); CBasePlayerAmmo::Spawn( ); } void Precache( void ) { PRECACHE_MODEL ("models/ammo/w_38acp.mdl"); PRECACHE_SOUND("items/9mmclip1.wav"); } BOOL AddAmmo( CBaseEntity *pOther ) { int bResult = (pOther->GiveAmmo( AMMO_MAGCLIP_GIVE, "38acp", MAG60_MAX_CARRY) != -1); if (bResult) { EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM); } return bResult; } }; LINK_ENTITY_TO_CLASS( ammo_magclip, CMagAmmoClip );