Team Fortress 2 Source Code as on 22/4/2020
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.
|
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#include "cbase.h"
#include "hegrenade_projectile.h"
#include "soundent.h"
#include "cs_player.h"
#include "KeyValues.h"
#include "weapon_csbase.h"
#define GRENADE_MODEL "models/Weapons/w_eq_fraggrenade_thrown.mdl"
LINK_ENTITY_TO_CLASS( hegrenade_projectile, CHEGrenadeProjectile ); PRECACHE_WEAPON_REGISTER( hegrenade_projectile );
CHEGrenadeProjectile* CHEGrenadeProjectile::Create( const Vector &position, const QAngle &angles, const Vector &velocity, const AngularImpulse &angVelocity, CBaseCombatCharacter *pOwner, float timer ) { CHEGrenadeProjectile *pGrenade = (CHEGrenadeProjectile*)CBaseEntity::Create( "hegrenade_projectile", position, angles, pOwner ); // Set the timer for 1 second less than requested. We're going to issue a SOUND_DANGER
// one second before detonation.
pGrenade->SetDetonateTimerLength( 1.5 ); pGrenade->SetAbsVelocity( velocity ); pGrenade->SetupInitialTransmittedGrenadeVelocity( velocity ); pGrenade->SetThrower( pOwner );
pGrenade->SetGravity( BaseClass::GetGrenadeGravity() ); pGrenade->SetFriction( BaseClass::GetGrenadeFriction() ); pGrenade->SetElasticity( BaseClass::GetGrenadeElasticity() );
pGrenade->m_flDamage = 100; pGrenade->m_DmgRadius = pGrenade->m_flDamage * 3.5f; pGrenade->ChangeTeam( pOwner->GetTeamNumber() ); pGrenade->ApplyLocalAngularVelocityImpulse( angVelocity );
// make NPCs afaid of it while in the air
pGrenade->SetThink( &CHEGrenadeProjectile::DangerSoundThink ); pGrenade->SetNextThink( gpGlobals->curtime );
pGrenade->m_pWeaponInfo = GetWeaponInfo( WEAPON_HEGRENADE );
return pGrenade; }
void CHEGrenadeProjectile::Spawn() { SetModel( GRENADE_MODEL ); BaseClass::Spawn(); }
void CHEGrenadeProjectile::Precache() { PrecacheModel( GRENADE_MODEL );
PrecacheScriptSound( "HEGrenade.Bounce" );
BaseClass::Precache(); }
void CHEGrenadeProjectile::BounceSound( void ) { EmitSound( "HEGrenade.Bounce" ); }
void CHEGrenadeProjectile::Detonate() { BaseClass::Detonate();
// tell the bots an HE grenade has exploded
CCSPlayer *player = ToCSPlayer(GetThrower()); if ( player ) { IGameEvent * event = gameeventmanager->CreateEvent( "hegrenade_detonate" ); if ( event ) { event->SetInt( "userid", player->GetUserID() ); event->SetFloat( "x", GetAbsOrigin().x ); event->SetFloat( "y", GetAbsOrigin().y ); event->SetFloat( "z", GetAbsOrigin().z ); gameeventmanager->FireEvent( event ); } } }
|