DefectorSpecialPower.cpp 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /*
  2. ** Command & Conquer Generals(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. ///////////////////////////////////////////////////////////////////////////////////////////////////
  24. //
  25. // FILE: DefectorSpecialPower.cpp
  26. // Author: Mark Lorenzen, JULY 2002
  27. // Desc: General can click command cursor on any enemy, and it becomes his
  28. //
  29. ///////////////////////////////////////////////////////////////////////////////////////////////////
  30. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  31. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  32. #include "Common/Player.h"
  33. #include "Common/SpecialPower.h"
  34. #include "Common/Team.h"
  35. #include "Common/Xfer.h"
  36. #include "GameLogic/Module/DefectorSpecialPower.h"
  37. #include "GameLogic/Object.h"
  38. // ------------------------------------------------------------------------------------------------
  39. // ------------------------------------------------------------------------------------------------
  40. DefectorSpecialPowerModuleData::DefectorSpecialPowerModuleData( void )
  41. {
  42. m_fatCursorRadius = 0.0f;
  43. } // end DefectorSpecialPowerModuleData
  44. // ------------------------------------------------------------------------------------------------
  45. // ------------------------------------------------------------------------------------------------
  46. //static
  47. void DefectorSpecialPowerModuleData::buildFieldParse(MultiIniFieldParse& p)
  48. {
  49. SpecialPowerModuleData::buildFieldParse( p );
  50. static const FieldParse dataFieldParse[] =
  51. {
  52. { "FatCursorRadius", INI::parseReal, NULL, offsetof( DefectorSpecialPowerModuleData, m_fatCursorRadius ) },
  53. { 0, 0, 0, 0 }
  54. };
  55. p.add(dataFieldParse);
  56. } // end buildFieldParse
  57. ///////////////////////////////////////////////////////////////////////////////////////////////////
  58. ///////////////////////////////////////////////////////////////////////////////////////////////////
  59. ///////////////////////////////////////////////////////////////////////////////////////////////////
  60. // ------------------------------------------------------------------------------------------------
  61. // ------------------------------------------------------------------------------------------------
  62. DefectorSpecialPower::DefectorSpecialPower( Thing *thing, const ModuleData *moduleData )
  63. : SpecialPowerModule( thing, moduleData )
  64. {
  65. } // end DefectorSpecialPower
  66. // ------------------------------------------------------------------------------------------------
  67. // ------------------------------------------------------------------------------------------------
  68. DefectorSpecialPower::~DefectorSpecialPower( void )
  69. {
  70. } // end ~DefectorSpecialPower
  71. // ------------------------------------------------------------------------------------------------
  72. void DefectorSpecialPower::doSpecialPowerAtLocation( const Coord3D *loc, UnsignedInt commandOptions )
  73. {
  74. if (getObject()->isDisabled())
  75. return;
  76. // only allowed at objects
  77. return;
  78. }
  79. // ------------------------------------------------------------------------------------------------
  80. void DefectorSpecialPower::doSpecialPowerAtObject( Object *objectToMakeDefector, UnsignedInt commandOptions )
  81. {
  82. if (getObject()->isDisabled())
  83. return;
  84. // sanity check
  85. if (!objectToMakeDefector)
  86. {
  87. return;
  88. }
  89. // another sanity check
  90. const Object *self = getObject();
  91. if (!self)
  92. {
  93. return;
  94. }
  95. // call the base class action cause we are *EXTENDING* functionality
  96. SpecialPowerModule::doSpecialPowerAtObject( objectToMakeDefector, commandOptions );
  97. //AIUpdateInterface *hisAI = objectToMakeDefector->getAIUpdateInterface();
  98. //if (hisAI)
  99. //{
  100. // how do I get at SpecialPowerTemplate::getDetectionTime() from here?
  101. const SpecialPowerTemplate *specPowTemp = getSpecialPowerTemplate();
  102. UnsignedInt time = specPowTemp->getDetectionTime();
  103. objectToMakeDefector->defect(self->getControllingPlayer()->getDefaultTeam(), time );// @todo lorenzen hook into the new AIUpdateI methods
  104. //}
  105. }
  106. // ------------------------------------------------------------------------------------------------
  107. /** CRC */
  108. // ------------------------------------------------------------------------------------------------
  109. void DefectorSpecialPower::crc( Xfer *xfer )
  110. {
  111. // extend base class
  112. SpecialPowerModule::crc( xfer );
  113. } // end crc
  114. // ------------------------------------------------------------------------------------------------
  115. /** Xfer method
  116. * Version Info:
  117. * 1: Initial version */
  118. // ------------------------------------------------------------------------------------------------
  119. void DefectorSpecialPower::xfer( Xfer *xfer )
  120. {
  121. // version
  122. XferVersion currentVersion = 1;
  123. XferVersion version = currentVersion;
  124. xfer->xferVersion( &version, currentVersion );
  125. // extend base class
  126. SpecialPowerModule::xfer( xfer );
  127. } // end xfer
  128. // ------------------------------------------------------------------------------------------------
  129. /** Load post process */
  130. // ------------------------------------------------------------------------------------------------
  131. void DefectorSpecialPower::loadPostProcess( void )
  132. {
  133. // extend base class
  134. SpecialPowerModule::loadPostProcess();
  135. } // end loadPostProcess