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.

73 lines
2.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #include "cbase.h"
  7. #include "tfc_player.h"
  8. #include "tfc_building.h"
  9. //=========================================================================
  10. // Destroys a single Engineer building
  11. void DestroyBuilding(CTFCPlayer *eng, char *bld)
  12. {
  13. CBaseEntity *pEnt = gEntList.FindEntityByClassname( NULL, bld );
  14. while ( pEnt )
  15. {
  16. CTFBaseBuilding *pBuilding = dynamic_cast<CTFBaseBuilding*>( pEnt );
  17. if (pBuilding && pBuilding->real_owner == eng)
  18. {
  19. // If it's fallen out of the world, give the engineer
  20. // some metal back
  21. int pos = UTIL_PointContents(pEnt->GetAbsOrigin());
  22. #ifdef TFCTODO // CONTENTS_SKY doesn't exist in the new engine
  23. if (pos == CONTENT_SOLID || pos == CONTENT_SKY)
  24. #else
  25. if (pos == CONTENTS_SOLID)
  26. #endif
  27. {
  28. eng->GiveAmmo( 100, TFC_AMMO_CELLS );
  29. eng->TeamFortress_CheckClassStats();
  30. }
  31. pEnt->TakeDamage( CTakeDamageInfo( pEnt, pEnt, 500, 0 ) );
  32. }
  33. pEnt = gEntList.FindEntityByClassname( pEnt, bld );
  34. }
  35. }
  36. //=========================================================================
  37. // Destroys a teleporter (determined by type)
  38. void DestroyTeleporter(CTFCPlayer *eng, int type)
  39. {
  40. CBaseEntity *pEnt = gEntList.FindEntityByClassname( NULL, "building_teleporter" );
  41. while ( pEnt )
  42. {
  43. CTFTeleporter *pTeleporter = dynamic_cast<CTFTeleporter*>( pEnt );
  44. if (pTeleporter && pTeleporter->real_owner == eng && pTeleporter->m_iType == type )
  45. {
  46. // If it's fallen out of the world, give the engineer
  47. // some metal back
  48. int pos = UTIL_PointContents(pEnt->GetAbsOrigin());
  49. #ifdef TFCTODO // CONTENTS_SKY doesn't exist in the new engine
  50. if (pos == CONTENT_SOLID || pos == CONTENT_SKY)
  51. #else
  52. if (pos == CONTENTS_SOLID)
  53. #endif
  54. {
  55. eng->GiveAmmo( 100, TFC_AMMO_CELLS );
  56. eng->TeamFortress_CheckClassStats();
  57. }
  58. pEnt->TakeDamage( CTakeDamageInfo( pEnt, pEnt, 500, 0 ) );
  59. }
  60. pEnt = gEntList.FindEntityByClassname( pEnt, "building_teleporter" );
  61. }
  62. }