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.

83 lines
2.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Bomb target area
  4. //
  5. //=============================================================================//
  6. #include "cbase.h"
  7. #include "cs_player.h"
  8. #include "func_bomb_target.h"
  9. #include "cs_gamerules.h"
  10. LINK_ENTITY_TO_CLASS( func_bomb_target, CBombTarget );
  11. BEGIN_DATADESC( CBombTarget )
  12. DEFINE_FUNCTION( BombTargetTouch ),
  13. DEFINE_FUNCTION( BombTargetUse ), //needed?
  14. // Inputs
  15. DEFINE_INPUTFUNC( FIELD_VOID, "BombExplode", OnBombExplode ),
  16. DEFINE_INPUTFUNC( FIELD_VOID, "BombPlanted", OnBombPlanted ),
  17. DEFINE_INPUTFUNC( FIELD_VOID, "BombDefused", OnBombDefused ),
  18. // Outputs
  19. DEFINE_OUTPUT( m_OnBombExplode, "BombExplode" ),
  20. DEFINE_OUTPUT( m_OnBombPlanted, "BombPlanted" ),
  21. DEFINE_OUTPUT( m_OnBombDefused, "BombDefused" ),
  22. DEFINE_KEYFIELD( m_bIsHeistBombTarget, FIELD_BOOLEAN, "heistbomb" ),
  23. DEFINE_KEYFIELD( m_szMountTarget, FIELD_STRING, "bomb_mount_target" ),
  24. END_DATADESC()
  25. CBombTarget::CBombTarget( void )
  26. {
  27. m_bIsHeistBombTarget = false;
  28. m_szMountTarget = NULL_STRING;
  29. }
  30. void CBombTarget::Spawn()
  31. {
  32. InitTrigger();
  33. SetTouch( &CBombTarget::BombTargetTouch );
  34. SetUse( &CBombTarget::BombTargetUse );
  35. }
  36. void CBombTarget::BombTargetTouch( CBaseEntity* pOther )
  37. {
  38. CCSPlayer *p = dynamic_cast< CCSPlayer* >( pOther );
  39. if ( p )
  40. {
  41. if ( p->HasC4() && CSGameRules()->m_bBombPlanted == false )
  42. {
  43. p->m_bInBombZone = true;
  44. p->m_iBombSiteIndex = entindex();
  45. if ( !(p->m_iDisplayHistoryBits & DHF_IN_TARGET_ZONE) )
  46. {
  47. p->HintMessage( "#Hint_you_are_in_targetzone", false );
  48. p->m_iDisplayHistoryBits |= DHF_IN_TARGET_ZONE;
  49. }
  50. }
  51. }
  52. }
  53. void CBombTarget::BombTargetUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
  54. {
  55. //SUB_UseTargets( NULL, USE_TOGGLE, 0 );
  56. DevMsg( 2, "BombTargetUse does nothing\n" );
  57. }
  58. // Relay to our outputs
  59. void CBombTarget::OnBombExplode( inputdata_t &inputdata )
  60. {
  61. m_OnBombExplode.FireOutput(this, this);
  62. }
  63. // Relay to our outputs
  64. void CBombTarget::OnBombPlanted( inputdata_t &inputdata )
  65. {
  66. m_OnBombPlanted.FireOutput(this, this);
  67. }
  68. // Relay to our outputs
  69. void CBombTarget::OnBombDefused( inputdata_t &inputdata )
  70. {
  71. m_OnBombDefused.FireOutput(this, this);
  72. }