summaryrefslogtreecommitdiff
path: root/game/shared/tf2/weapon_plasmarifle.cpp
blob: d89f7f51579f3ac193bc6ec3746b8fd81553fc0a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Medic's plasma rifle
//
// $NoKeywords: $
//=============================================================================//
#include "cbase.h"
#include "tf_player.h"
#include "in_buttons.h"
#include "gamerules.h"
#include "ammodef.h"
#include "entitylist.h"
#include "plasmaprojectile.h"
#include "tf_shareddefs.h"
#include "basegrenade_shared.h"
#include "tf_basecombatweapon.h"

// Damage CVars
ConVar	weapon_plasmarifle_damage( "weapon_plasmarifle_damage","0", FCVAR_NONE, "Plasma Rifle maximum damage" );

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
class CWeaponPlasmaRifle : public CTFMachineGun
{
	DECLARE_CLASS( CWeaponPlasmaRifle, CTFMachineGun );
public:
	virtual void	FireBullets( CBaseTFCombatWeapon *pWeapon, int cShots, const Vector &vecSrc, const Vector &vecDirShooting, const Vector &vecSpread, float flDistance, int iBulletType, int iTracerFreq);
	virtual const Vector& GetBulletSpread( void ); 
	virtual float	GetFireRate( void );
};

LINK_ENTITY_TO_CLASS( weapon_plasmarifle, CWeaponPlasmaRifle );
PRECACHE_WEAPON_REGISTER(weapon_plasmarifle);

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CWeaponPlasmaRifle::FireBullets( CBaseTFCombatWeapon *pWeapon, int cShots, const Vector &vecSrc, const Vector &vecDirShooting, const Vector &vecSpread, float flDistance, int iBulletType, int iTracerFreq )
{
	CBaseTFPlayer *pPlayer = static_cast< CBaseTFPlayer * >( GetOwner() );
	if ( !pPlayer )
		return;

	Vector vecForward;
	pPlayer->EyeVectors( &vecForward );
	Vector vecOrigin = pPlayer->EyePosition();
	trace_t tr;

	Vector vecTracerSrc = pWeapon->GetTracerSrc( (Vector&)vecSrc, (Vector&)vecDirShooting );

	// Fire the emp projectile
	CBasePlasmaProjectile *pPlasma = CBasePlasmaProjectile::Create( vecTracerSrc, vecDirShooting, DMG_ENERGYBEAM, pPlayer );
	pPlasma->SetDamage( weapon_plasmarifle_damage.GetFloat() );
	pPlasma->m_hOwner = pPlayer;
}

//-----------------------------------------------------------------------------
// Purpose: Get the accuracy derived from weapon and player, and return it
//-----------------------------------------------------------------------------
const Vector& CWeaponPlasmaRifle::GetBulletSpread( void )
{
	static Vector cone = VECTOR_CONE_4DEGREES;
	return cone;
}

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
float CWeaponPlasmaRifle::GetFireRate( void )
{	
	return 0.2; 
}