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.

114 lines
3.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #include "cbase.h"
  7. #include "util.h"
  8. #include "weapon_tfc_spanner.h"
  9. #if defined( CLIENT_DLL )
  10. #include "c_tfc_player.h"
  11. #else
  12. #include "tfc_player.h"
  13. #endif
  14. #define KNIFE_BODYHIT_VOLUME 128
  15. #define KNIFE_WALLHIT_VOLUME 512
  16. static ConVar tfc_spanner_damage_first( "tfc_spanner_damage_first", "25", 0, "First spanner hit damage." );
  17. static ConVar tfc_spanner_damage_next( "tfc_spanner_damage_next", "12.5", 0, "Spanner hit damage after first hit." );
  18. static Vector head_hull_mins( -16, -16, -18 );
  19. static Vector head_hull_maxs( 16, 16, 18 );
  20. // ----------------------------------------------------------------------------- //
  21. // CTFCSpanner tables.
  22. // ----------------------------------------------------------------------------- //
  23. IMPLEMENT_NETWORKCLASS_ALIASED( TFCSpanner, DT_WeaponSpanner )
  24. BEGIN_NETWORK_TABLE( CTFCSpanner, DT_WeaponSpanner )
  25. END_NETWORK_TABLE()
  26. BEGIN_PREDICTION_DATA( CTFCSpanner )
  27. END_PREDICTION_DATA()
  28. LINK_ENTITY_TO_CLASS( weapon_spanner, CTFCSpanner );
  29. PRECACHE_WEAPON_REGISTER( weapon_spanner );
  30. #ifndef CLIENT_DLL
  31. BEGIN_DATADESC( CTFCSpanner )
  32. DEFINE_FUNCTION( Smack )
  33. END_DATADESC()
  34. #endif
  35. // ----------------------------------------------------------------------------- //
  36. // CTFCSpanner implementation.
  37. // ----------------------------------------------------------------------------- //
  38. CTFCSpanner::CTFCSpanner()
  39. {
  40. }
  41. void CTFCSpanner::Precache()
  42. {
  43. BaseClass::Precache();
  44. PrecacheScriptSound( "Weapon_Spanner.Slash" );
  45. PrecacheScriptSound( "Weapon_Spanner.HitFlesh" );
  46. }
  47. TFCWeaponID CTFCSpanner::GetWeaponID( void ) const
  48. {
  49. return WEAPON_SPANNER;
  50. }
  51. #ifdef CLIENT_DLL
  52. // ------------------------------------------------------------------------------------------------ //
  53. // ------------------------------------------------------------------------------------------------ //
  54. // CLIENT DLL SPECIFIC CODE
  55. // ------------------------------------------------------------------------------------------------ //
  56. // ------------------------------------------------------------------------------------------------ //
  57. #else
  58. // ------------------------------------------------------------------------------------------------ //
  59. // ------------------------------------------------------------------------------------------------ //
  60. // GAME DLL SPECIFIC CODE
  61. // ------------------------------------------------------------------------------------------------ //
  62. // ------------------------------------------------------------------------------------------------ //
  63. void CTFCSpanner::AxeHit( CBaseEntity *pTarget, bool bFirstSwing, trace_t &tr, float *flDamage, bool *bDoEffects )
  64. {
  65. CTFCPlayer *pPlayer = GetPlayerOwner();
  66. if ( !pPlayer )
  67. return;
  68. // Check to see if it's a trigger that's activatable by a Spanner hit
  69. // If it's not on our team, whack it.
  70. if ( !pPlayer->IsAlly( pTarget ) )
  71. {
  72. *flDamage = 20;
  73. return;
  74. }
  75. // Otherwise, the Engineer can repair his buildings or repair his teammate's armor.
  76. variant_t voidVariant;
  77. *bDoEffects = pTarget->AcceptInput( "EngineerUse", pPlayer, this, voidVariant, 0 );
  78. }
  79. #endif