This is a sub-page of Development:Team Fortress 2.
Cut Weapons#
Every weapon cut before the game's release has its code in this codebase leak.
Nailgun#
tf_weapon_nailgun.cpp
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
//
//
//=============================================================================
#include "cbase.h"
#include "tf_weapon_nailgun.h"
//=============================================================================
//
// Weapon SMG tables.
//
IMPLEMENT_NETWORKCLASS_ALIASED( TFNailgun, DT_WeaponNailgun )
BEGIN_NETWORK_TABLE( CTFNailgun, DT_WeaponNailgun )
END_NETWORK_TABLE()
BEGIN_PREDICTION_DATA( CTFNailgun )
END_PREDICTION_DATA()
LINK_ENTITY_TO_CLASS( tf_weapon_nailgun, CTFNailgun );
PRECACHE_WEAPON_REGISTER( tf_weapon_nailgun);
// Server specific.
#ifndef CLIENT_DLL
BEGIN_DATADESC( CTFNailgun )
END_DATADESC()
#endif
//=============================================================================
//
// Weapon Nailgun functions.
//
tf_weapon_nailgun.h
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
//
//
//=============================================================================
#ifndef TF_WEAPON_NAILGUN_H
#define TF_WEAPON_NAILGUN_H
#ifdef _WIN32
#pragma once
#endif
#include "tf_weaponbase_gun.h"
// Client specific.
#ifdef CLIENT_DLL
#define CTFNailgun C_TFNailgun
#endif
//=============================================================================
//
// TF Weapon Sub-machine gun.
//
class CTFNailgun : public CTFWeaponBaseGun
{
public:
DECLARE_CLASS( CTFNailgun, CTFWeaponBaseGun );
DECLARE_NETWORKCLASS();
DECLARE_PREDICTABLE();
// Server specific.
#ifdef GAME_DLL
DECLARE_DATADESC();
#endif
CTFNailgun() {}
~CTFNailgun() {}
virtual int GetWeaponID( void ) const { return TF_WEAPON_NAILGUN; }
private:
CTFNailgun( const CTFNailgun & ) {}
};
#endif // TF_WEAPON_NAILGUN_H
Tranquilizer Gun#
tf_weapon_tranq.cpp
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
//
//
//=============================================================================
#include "cbase.h"
#include "tf_weapon_tranq.h"
#include "tf_fx_shared.h"
// Client specific.
#ifdef CLIENT_DLL
#include "c_tf_player.h"
// Server specific.
#else
#include "tf_player.h"
#endif
//=============================================================================
//
// Weapon Tranq tables.
//
IMPLEMENT_NETWORKCLASS_ALIASED( TFTranq, DT_WeaponTranq )
BEGIN_NETWORK_TABLE( CTFTranq, DT_WeaponTranq )
END_NETWORK_TABLE()
BEGIN_PREDICTION_DATA( CTFTranq )
END_PREDICTION_DATA()
LINK_ENTITY_TO_CLASS( tf_weapon_tranq, CTFTranq );
PRECACHE_WEAPON_REGISTER( tf_weapon_tranq );
// Server specific.
#ifndef CLIENT_DLL
BEGIN_DATADESC( CTFTranq )
END_DATADESC()
#endif
//=============================================================================
//
// Weapon Tranq functions.
//
tf_weapon_tranq.h
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======
//
//
//=============================================================================
#ifndef TF_WEAPON_TRANQ_H
#define TF_WEAPON_TRANQ_H
#ifdef _WIN32
#pragma once
#endif
#include "tf_weaponbase_gun.h"
// Client specific.
#ifdef CLIENT_DLL
#define CTFTranq C_TFTranq
#endif
//=============================================================================
//
// TF Weapon Tranq.
//
class CTFTranq : public CTFWeaponBaseGun
{
public:
DECLARE_CLASS( CTFTranq, CTFWeaponBaseGun );
DECLARE_NETWORKCLASS();
DECLARE_PREDICTABLE();
// Server specific.
#ifdef GAME_DLL
DECLARE_DATADESC();
#endif
CTFTranq() {}
~CTFTranq() {}
virtual int GetWeaponID( void ) const { return TF_WEAPON_TRANQ; }
private:
CTFTranq( const CTFTranq & ) {}
};
#endif // TF_WEAPON_TRANQ_H
Grenades#
tf_weapon_grenade_caltrop.cpp
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. =======//
//
// Purpose: TF Caltrop Grenade.
//
//=============================================================================//
#include "cbase.h"
#include "tf_weaponbase.h"
#include "tf_gamerules.h"
#include "npcevent.h"
#include "engine/IEngineSound.h"
#include "tf_weapon_grenade_caltrop.h"
// Server specific.
#ifdef GAME_DLL
#include "tf_player.h"
#include "items.h"
#include "tf_weaponbase_grenadeproj.h"
#include "soundent.h"
#include "KeyValues.h"
#endif
#define GRENADE_CALTROP_TIMER 3.0f //Seconds
#define GRENADE_CALTROP_RELEASE_COUNT 6
#define GRENADE_CALTROP_DAMAGE 10
//=============================================================================
//
// TF Caltrop Grenade tables.
//
IMPLEMENT_NETWORKCLASS_ALIASED( TFGrenadeCaltrop, DT_TFGrenadeCaltrop )
BEGIN_NETWORK_TABLE( CTFGrenadeCaltrop, DT_TFGrenadeCaltrop )
END_NETWORK_TABLE()
BEGIN_PREDICTION_DATA( CTFGrenadeCaltrop )
END_PREDICTION_DATA()
LINK_ENTITY_TO_CLASS( tf_weapon_grenade_caltrop, CTFGrenadeCaltrop );
PRECACHE_WEAPON_REGISTER( tf_weapon_grenade_caltrop );
//=============================================================================
//
// TF Caltrop Grenade functions.
//
// Server specific.
#ifdef GAME_DLL
BEGIN_DATADESC( CTFGrenadeCaltrop )
END_DATADESC()
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CTFWeaponBaseGrenadeProj *CTFGrenadeCaltrop::EmitGrenade( Vector vecSrc, QAngle vecAngles, Vector vecVel,
AngularImpulse angImpulse, CBasePlayer *pPlayer, float flTime, int iflags )
{
// Release several at a time (different directions, angles, speeds, etc.)
for ( int i = 0 ; i < GRENADE_CALTROP_RELEASE_COUNT ; i++ )
{
Vector velocity( random->RandomFloat(-100,100), random->RandomFloat(-100,100), random->RandomFloat(150,200) );
CTFGrenadeCaltropProjectile::Create( vecSrc, vecAngles, velocity, angImpulse,
pPlayer, GetTFWpnData(), random->RandomFloat( 10.0f, 15.0f ) );
}
return NULL;
}
#endif
//=============================================================================
//
// TF Caltrop Grenade Projectile functions (Server specific).
//
LINK_ENTITY_TO_CLASS( tf_weapon_grenade_caltrop_projectile, CTFGrenadeCaltropProjectile );
PRECACHE_WEAPON_REGISTER( tf_weapon_grenade_caltrop_projectile );
IMPLEMENT_NETWORKCLASS_ALIASED( TFGrenadeCaltropProjectile, DT_TFGrenadeCaltropProjectile )
BEGIN_NETWORK_TABLE( CTFGrenadeCaltropProjectile, DT_TFGrenadeCaltropProjectile )
END_NETWORK_TABLE()
#ifdef GAME_DLL
#define GRENADE_MODEL "models/weapons/w_models/w_grenade_beartrap.mdl"
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CTFGrenadeCaltropProjectile* CTFGrenadeCaltropProjectile::Create( const Vector &position, const QAngle &angles,
const Vector &velocity, const AngularImpulse &angVelocity,
CBaseCombatCharacter *pOwner, const CTFWeaponInfo &weaponInfo,
float timer, int iFlags )
{
CTFGrenadeCaltropProjectile *pGrenade = static_cast<CTFGrenadeCaltropProjectile*>( CTFWeaponBaseGrenadeProj::Create( "tf_weapon_grenade_caltrop_projectile", position, angles, velocity, angVelocity, pOwner, weaponInfo, timer, iFlags ) );
if ( pGrenade )
{
pGrenade->ApplyLocalAngularVelocityImpulse( angVelocity );
pGrenade->SetTouch( &CTFGrenadeCaltropProjectile::Touch );
}
return pGrenade;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFGrenadeCaltropProjectile::Spawn()
{
SetModel( GRENADE_MODEL );
BaseClass::Spawn();
// We want to get touch functions called so we can damage enemy players
AddSolidFlags( FSOLID_TRIGGER );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFGrenadeCaltropProjectile::Precache()
{
PrecacheModel( GRENADE_MODEL );
BaseClass::Precache();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFGrenadeCaltropProjectile::BounceSound( void )
{
EmitSound( "Weapon_Grenade_Caltrop.Bounce" );
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFGrenadeCaltropProjectile::Detonate()
{
if ( ShouldNotDetonate() )
{
RemoveGrenade();
return;
}
// have the caltrop disappear
UTIL_Remove( this );
#if 0
// Tell the bots an HE grenade has exploded
CTFPlayer *pPlayer = ToTFPlayer( GetThrower() );
if ( pPlayer )
{
KeyValues *pEvent = new KeyValues( "tf_weapon_grenade_detonate" );
pEvent->SetInt( "userid", pPlayer->GetUserID() );
gameeventmanager->FireEventServerOnly( pEvent );
}
#endif
}
#endif
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFGrenadeCaltropProjectile::Touch( CBaseEntity *pOther )
{
if ( !pOther->IsPlayer() || !( pOther->GetFlags() & FL_ONGROUND ) || !pOther->IsAlive() )
return;
// Don't hurt friendlies
if ( GetTeamNumber() == pOther->GetTeamNumber() )
return;
// Caltrops need to be on the ground. Check to see if we're still moving.
Vector vecVelocity;
VPhysicsGetObject()->GetVelocity( &vecVelocity, NULL );
if ( vecVelocity.LengthSqr() > (1*1) )
return;
#ifdef GAME_DLL
// Do the leg damage to the player
CTakeDamageInfo info( this, GetThrower(), GRENADE_CALTROP_DAMAGE, DMG_LEG_DAMAGE | DMG_PREVENT_PHYSICS_FORCE );
pOther->TakeDamage( info );
// have the caltrop disappear
UTIL_Remove( this );
#endif
}
#ifdef CLIENT_DLL
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFGrenadeCaltropProjectile::OnDataChanged(DataUpdateType_t updateType)
{
BaseClass::OnDataChanged(updateType);
if ( updateType == DATA_UPDATE_CREATED )
{
/*
SetSolidFlags( FSOLID_NOT_STANDABLE );
SetSolid( SOLID_BBOX );
SetCollisionBounds( Vector( -2.0f, -2.0f, -2.0f ), Vector( 2.0f, 2.0f, 2.0f ) );
// We want touch calls on the client.
// So override the collision group, but make it a trigger
SetCollisionGroup( COLLISION_GROUP_NONE );
AddSolidFlags( FSOLID_TRIGGER );
UpdatePartitionListEntry();
CollisionProp()->UpdatePartition();
*/
}
}
#endif
tf_weapon_grenade_caltrop.h
//====== Copyright © 1996-2005, Valve Corporation, All rights reserved. ========//
//
// Purpose: TF Caltrop Grenade.
//
//=============================================================================//
#ifndef TF_WEAPON_GRENADE_CALTROP_H
#define TF_WEAPON_GRENADE_CALTROP_H
#ifdef _WIN32
#pragma once
#endif
#include "tf_weaponbase_grenade.h"
#include "tf_weaponbase_grenadeproj.h"
// Client specific.
#ifdef CLIENT_DLL
#define CTFGrenadeCaltrop C_TFGrenadeCaltrop
#define CTFGrenadeCaltropProjectile C_TFGrenadeCaltropProjectile
#endif
//=============================================================================
//
// TF Caltrop Grenade
//
class CTFGrenadeCaltrop : public CTFWeaponBaseGrenade
{
public:
DECLARE_CLASS( CTFGrenadeCaltrop, CTFWeaponBaseGrenade );
DECLARE_NETWORKCLASS();
DECLARE_PREDICTABLE();
// DECLARE_ACTTABLE();
CTFGrenadeCaltrop() {}
// Unique identifier.
virtual int GetWeaponID( void ) const { return TF_WEAPON_GRENADE_CALTROP; }
// Server specific.
#ifdef GAME_DLL
DECLARE_DATADESC();
virtual CTFWeaponBaseGrenadeProj *EmitGrenade( Vector vecSrc, QAngle vecAngles, Vector vecVel, AngularImpulse angImpulse, CBasePlayer *pPlayer, float flTime, int iflags = 0 );
#endif
CTFGrenadeCaltrop( const CTFGrenadeCaltrop & ) {}
};
//=============================================================================
//
// TF Caltrop Grenade Projectile (Server specific.)
//
class CTFGrenadeCaltropProjectile : public CTFWeaponBaseGrenadeProj
{
public:
DECLARE_CLASS( CTFGrenadeCaltropProjectile, CTFWeaponBaseGrenadeProj );
DECLARE_NETWORKCLASS();
// Unique identifier.
virtual int GetWeaponID( void ) const { return TF_WEAPON_GRENADE_CALTROP; }
#ifdef GAME_DLL
// Creation.
static CTFGrenadeCaltropProjectile *Create( const Vector &position, const QAngle &angles, const Vector &velocity,
const AngularImpulse &angVelocity, CBaseCombatCharacter *pOwner, const CTFWeaponInfo &weaponInfo, float timer, int iFlags = 0 );
// Overrides.
virtual void Spawn();
virtual void Precache();
virtual void BounceSound( void );
virtual void Detonate();
#endif
virtual void Touch( CBaseEntity *pOther );
#ifdef CLIENT_DLL
virtual void OnDataChanged(DataUpdateType_t updateType);
#endif
private:
float m_flDetonateTime;
};
#endif // TF_WEAPON_GRENADE_CALTROP_H