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.

77 lines
1.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #include "cbase.h"
  7. #include "triggers.h"
  8. #include "cs_player.h"
  9. //======================================
  10. // Bomb target area
  11. //
  12. //
  13. class CBuyZone : public CBaseTrigger
  14. {
  15. public:
  16. DECLARE_CLASS( CBuyZone, CBaseTrigger );
  17. DECLARE_DATADESC();
  18. CBuyZone();
  19. void Spawn();
  20. void EXPORT BuyZoneTouch( CBaseEntity* pOther );
  21. public:
  22. int m_LegacyTeamNum;
  23. };
  24. LINK_ENTITY_TO_CLASS( func_buyzone, CBuyZone );
  25. BEGIN_DATADESC( CBuyZone )
  26. DEFINE_FUNCTION( BuyZoneTouch ),
  27. // This is here to support maps that haven't updated to using "teamnum" yet.
  28. DEFINE_INPUT( m_LegacyTeamNum, FIELD_INTEGER, "team" )
  29. END_DATADESC()
  30. CBuyZone::CBuyZone()
  31. {
  32. m_LegacyTeamNum = -1;
  33. }
  34. void CBuyZone::Spawn()
  35. {
  36. InitTrigger();
  37. SetTouch( &CBuyZone::BuyZoneTouch );
  38. // Support for legacy-style teamnums.
  39. if ( m_LegacyTeamNum == 1 )
  40. {
  41. ChangeTeam( TEAM_TERRORIST );
  42. }
  43. else if ( m_LegacyTeamNum == 2 )
  44. {
  45. ChangeTeam( TEAM_CT );
  46. }
  47. }
  48. void CBuyZone::BuyZoneTouch( CBaseEntity* pOther )
  49. {
  50. CCSPlayer *p = dynamic_cast< CCSPlayer* >( pOther );
  51. if ( p )
  52. {
  53. // compare player team with buy zone team number
  54. if ( p->GetTeamNumber() == GetTeamNumber() )
  55. {
  56. p->m_bInBuyZone = true;
  57. }
  58. }
  59. }