You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
165 lines
3.7 KiB
165 lines
3.7 KiB
8 years ago
|
/***
|
||
|
*
|
||
|
* Copyright (c) 1996-2002, Valve LLC. All rights reserved.
|
||
|
*
|
||
|
* This product contains software technology licensed from Id
|
||
|
* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc.
|
||
|
* All Rights Reserved.
|
||
|
*
|
||
|
* 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.
|
||
|
*
|
||
|
****/
|
||
8 years ago
|
|
||
|
#include "extdll.h"
|
||
|
#include "util.h"
|
||
|
#include "cbase.h"
|
||
|
#include "monsters.h"
|
||
|
#include "weapons.h"
|
||
|
#include "nodes.h"
|
||
|
#include "player.h"
|
||
8 years ago
|
#include "gamerules.h"
|
||
8 years ago
|
|
||
8 years ago
|
// special deathmatch shotgun spreads
|
||
|
#define VECTOR_CONE_DM_SHOTGUN Vector( 0.08716, 0.04362, 0.00 )// 10 degrees by 5 degrees
|
||
|
#define VECTOR_CONE_DM_DOUBLESHOTGUN Vector( 0.17365, 0.04362, 0.00 ) // 20 degrees by 5 degrees
|
||
8 years ago
|
#define WEAPON_ROCK 20
|
||
8 years ago
|
|
||
8 years ago
|
enum shotgun_e
|
||
8 years ago
|
{
|
||
8 years ago
|
PEPSIGUN_IDLE = 0,
|
||
|
PEPSIGUN_THROW,
|
||
|
PEPSIGUN_DRAW,
|
||
|
PEPSIGUN_FIDGET
|
||
8 years ago
|
};
|
||
|
|
||
8 years ago
|
class CRock : public CBasePlayerWeapon
|
||
|
{
|
||
|
public:
|
||
|
void Spawn( void );
|
||
|
void Precache( void );
|
||
8 years ago
|
int iItemSlot( void ) { return 4; }
|
||
8 years ago
|
int GetItemInfo(ItemInfo *p);
|
||
|
void PrimaryAttack( void );
|
||
|
BOOL Deploy( void );
|
||
|
void WeaponIdle( void );
|
||
|
|
||
7 years ago
|
virtual BOOL UseDecrement( void ){ return FALSE; }
|
||
8 years ago
|
};
|
||
|
|
||
8 years ago
|
|
||
8 years ago
|
LINK_ENTITY_TO_CLASS( weapon_rock, CRock )
|
||
|
|
||
|
void CRock::Spawn()
|
||
|
{
|
||
|
Precache();
|
||
|
m_iId = WEAPON_ROCK;
|
||
|
SET_MODEL( ENT( pev ), "models/w_rock.mdl" );
|
||
|
|
||
8 years ago
|
m_iDefaultAmmo = PEPSIGUN_DEFAULT_GIVE;
|
||
8 years ago
|
|
||
8 years ago
|
FallInit();// get ready to fall
|
||
8 years ago
|
}
|
||
|
|
||
|
void CRock::Precache( void )
|
||
|
{
|
||
|
PRECACHE_MODEL( "models/v_rock.mdl" );
|
||
8 years ago
|
PRECACHE_MODEL( "models/w_rock.mdl" );
|
||
8 years ago
|
PRECACHE_MODEL( "models/p_rock.mdl" );
|
||
|
}
|
||
|
|
||
8 years ago
|
|
||
8 years ago
|
int CRock::GetItemInfo( ItemInfo *p )
|
||
|
{
|
||
|
p->pszName = STRING( pev->classname );
|
||
8 years ago
|
p->pszAmmo1 = NULL;
|
||
|
p->iMaxAmmo1 = HANDGRENADE_MAX_CARRY;
|
||
8 years ago
|
p->pszAmmo2 = NULL;
|
||
|
p->iMaxAmmo2 = -1;
|
||
8 years ago
|
p->iMaxClip = 8;
|
||
8 years ago
|
p->iSlot = 4;
|
||
8 years ago
|
p->iPosition = 4;
|
||
8 years ago
|
p->iFlags = 0;
|
||
8 years ago
|
p->iId = m_iId = WEAPON_ROCK;
|
||
8 years ago
|
p->iWeight = 16;
|
||
8 years ago
|
|
||
|
return 1;
|
||
|
}
|
||
|
|
||
|
BOOL CRock::Deploy()
|
||
|
{
|
||
7 years ago
|
return DefaultDeploy( "models/v_rock.mdl", "models/p_rock.mdl", PEPSIGUN_DRAW, "crowbar" );
|
||
8 years ago
|
}
|
||
|
|
||
|
void CRock::PrimaryAttack()
|
||
|
{
|
||
7 years ago
|
Vector angThrow = m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle;
|
||
8 years ago
|
|
||
7 years ago
|
if( angThrow.x < 0 )
|
||
|
angThrow.x = -10 + angThrow.x * ( ( 90 - 10 ) / 90.0 );
|
||
|
else
|
||
|
angThrow.x = -10 + angThrow.x * ( ( 90 + 10 ) / 90.0 );
|
||
8 years ago
|
|
||
7 years ago
|
float flVel = ( 90 - angThrow.x ) * 4;
|
||
|
if( flVel > 500 )
|
||
|
flVel = 1300;
|
||
8 years ago
|
|
||
7 years ago
|
UTIL_MakeVectors( angThrow );
|
||
|
Vector vecSrc = m_pPlayer->pev->origin + m_pPlayer->pev->view_ofs + gpGlobals->v_forward * 16;
|
||
8 years ago
|
|
||
7 years ago
|
Vector vecThrow = gpGlobals->v_forward * flVel + m_pPlayer->pev->velocity;
|
||
|
CGrenadeRock::ShootTimed( m_pPlayer->pev, vecSrc, vecThrow * 1.5, 300000000000 );
|
||
|
SendWeaponAnim( PEPSIGUN_THROW );
|
||
|
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
|
||
8 years ago
|
|
||
7 years ago
|
m_flNextPrimaryAttack = gpGlobals->time + 0.5;
|
||
|
m_flNextSecondaryAttack = gpGlobals->time + 0.75;
|
||
|
m_flTimeWeaponIdle = gpGlobals->time + 0.75;
|
||
8 years ago
|
m_fInSpecialReload = 0;
|
||
|
}
|
||
8 years ago
|
|
||
|
|
||
8 years ago
|
void CRock::WeaponIdle( void )
|
||
|
{
|
||
|
ResetEmptySound();
|
||
8 years ago
|
|
||
8 years ago
|
m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES );
|
||
8 years ago
|
|
||
8 years ago
|
if( m_flPumpTime && m_flPumpTime < gpGlobals->time )
|
||
|
{
|
||
|
m_flPumpTime = 0;
|
||
8 years ago
|
}
|
||
|
|
||
7 years ago
|
if( m_flTimeWeaponIdle < gpGlobals->time )
|
||
8 years ago
|
{
|
||
8 years ago
|
if( m_iClip == 0 && m_fInSpecialReload == 0 && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] )
|
||
8 years ago
|
{
|
||
8 years ago
|
Reload();
|
||
8 years ago
|
}
|
||
8 years ago
|
else if( m_fInSpecialReload != 0 )
|
||
8 years ago
|
{
|
||
8 years ago
|
if( m_iClip != 8 && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] )
|
||
|
{
|
||
|
Reload();
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
m_fInSpecialReload = 0;
|
||
7 years ago
|
m_flTimeWeaponIdle = gpGlobals->time + 1.5;
|
||
8 years ago
|
}
|
||
8 years ago
|
}
|
||
8 years ago
|
else
|
||
|
{
|
||
|
int iAnim;
|
||
|
float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 );
|
||
8 years ago
|
|
||
8 years ago
|
iAnim = PEPSIGUN_IDLE;
|
||
7 years ago
|
m_flTimeWeaponIdle = gpGlobals->time + ( 20.0 / 9.0 );
|
||
8 years ago
|
SendWeaponAnim( iAnim );
|
||
|
}
|
||
8 years ago
|
}
|
||
|
}
|
||
8 years ago
|
|