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.

82 lines
1.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #include "cbase.h"
  7. #include "tf_weapon_flag.h"
  8. #include "decals.h"
  9. // Client specific.
  10. #ifdef CLIENT_DLL
  11. #include "c_tf_player.h"
  12. // Server specific.
  13. #else
  14. #include "tf_player.h"
  15. #include "tf_team.h"
  16. #endif
  17. //=============================================================================
  18. //
  19. // Weapon Flag tables.
  20. //
  21. IMPLEMENT_NETWORKCLASS_ALIASED( TFFlag, DT_TFWeaponFlag )
  22. BEGIN_NETWORK_TABLE( CTFFlag, DT_TFWeaponFlag )
  23. END_NETWORK_TABLE()
  24. BEGIN_PREDICTION_DATA( CTFFlag )
  25. END_PREDICTION_DATA()
  26. LINK_ENTITY_TO_CLASS( tf_weapon_flag, CTFFlag );
  27. PRECACHE_WEAPON_REGISTER( tf_weapon_flag );
  28. //=============================================================================
  29. //
  30. // Weapon Flag functions.
  31. //
  32. //-----------------------------------------------------------------------------
  33. // Purpose:
  34. //-----------------------------------------------------------------------------
  35. CTFFlag::CTFFlag()
  36. {
  37. }
  38. //-----------------------------------------------------------------------------
  39. // Purpose:
  40. //-----------------------------------------------------------------------------
  41. bool CTFFlag::Deploy( void )
  42. {
  43. if ( BaseClass::Deploy() )
  44. {
  45. #ifdef GAME_DLL
  46. TFTeamMgr()->PlayerCenterPrint( ToTFPlayer( GetOwner() ), "#TF_Flag_AltFireToDrop" );
  47. #endif
  48. return true;
  49. }
  50. return false;
  51. }
  52. //-----------------------------------------------------------------------------
  53. // Purpose:
  54. //-----------------------------------------------------------------------------
  55. void CTFFlag::SecondaryAttack( void )
  56. {
  57. CTFPlayer *pPlayer = ToTFPlayer( GetOwner() );
  58. if ( !pPlayer )
  59. return;
  60. if ( !CanAttack() )
  61. return;
  62. #ifdef GAME_DLL
  63. pPlayer->DropCurrentWeapon();
  64. #endif
  65. pPlayer->SwitchToNextBestWeapon( this );
  66. }