AISkirmishPlayer.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. // AISkirmishPlayer.h
  24. // Computerized opponent
  25. // Author: Michael S. Booth, January 2002
  26. #pragma once
  27. #ifndef _AI_SKIRMISH_PLAYER_H_
  28. #define _AI_SKIRMISH_PLAYER_H_
  29. #include "Common/GameMemory.h"
  30. #include "GameLogic/AIPlayer.h"
  31. class BuildListInfo;
  32. class SpecialPowerTemplate;
  33. #if !defined(_PLAYTEST)
  34. /**
  35. * The computer-controlled opponent.
  36. */
  37. class AISkirmishPlayer : public AIPlayer
  38. {
  39. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( AISkirmishPlayer, "AISkirmishPlayer" )
  40. public: // AISkirmish specific methods.
  41. AISkirmishPlayer( Player *p ); ///< constructor
  42. virtual void computeSuperweaponTarget(const SpecialPowerTemplate *power, Coord3D *pos, Int playerNdx, Real weaponRadius); ///< Calculates best pos for weapon given radius.
  43. public: // AIPlayer interface methods.
  44. virtual void update(); ///< simulates the behavior of a player
  45. virtual void newMap(); ///< New map loaded call.
  46. /// Invoked when a unit I am training comes into existence
  47. virtual void onUnitProduced( Object *factory, Object *unit );
  48. virtual void buildSpecificAITeam(TeamPrototype *teamProto, Bool priorityBuild); ///< Builds this team immediately.
  49. virtual void buildSpecificAIBuilding(const AsciiString &thingName); ///< Builds this building as soon as possible.
  50. virtual void buildAIBaseDefense(Bool flank); ///< Builds base defense on front or flank of base.
  51. virtual void buildAIBaseDefenseStructure(const AsciiString &thingName, Bool flank); ///< Builds base defense on front or flank of base.
  52. virtual void recruitSpecificAITeam(TeamPrototype *teamProto, Real recruitRadius); ///< Builds this team immediately.
  53. virtual Bool isSkirmishAI(void) {return true;}
  54. virtual Bool checkBridges(Object *unit, Waypoint *way);
  55. virtual Player *getAiEnemy(void); ///< Solo AI attacks based on scripting. Only skirmish auto-acquires an enemy at this point. jba.
  56. protected:
  57. // snapshot methods
  58. virtual void crc( Xfer *xfer );
  59. virtual void xfer( Xfer *xfer );
  60. virtual void loadPostProcess( void );
  61. virtual void doBaseBuilding(void);
  62. virtual void checkReadyTeams(void);
  63. virtual void checkQueuedTeams(void);
  64. virtual void doTeamBuilding(void);
  65. virtual Object *findDozer(const Coord3D *pos);
  66. virtual void queueDozer(void);
  67. protected:
  68. virtual Bool selectTeamToBuild( void ); ///< determine the next team to build
  69. virtual Bool selectTeamToReinforce( Int minPriority ); ///< determine the next team to reinforce
  70. virtual Bool startTraining( WorkOrder *order, Bool busyOK, AsciiString teamName); ///< find a production building that can handle the order, and start building
  71. virtual Bool isAGoodIdeaToBuildTeam( TeamPrototype *proto ); ///< return true if team should be built
  72. virtual void processBaseBuilding( void ); ///< do base-building behaviors
  73. virtual void processTeamBuilding( void ); ///< do team-building behaviors
  74. protected:
  75. void adjustBuildList(BuildListInfo *list);
  76. Int getMyEnemyPlayerIndex(void);
  77. void acquireEnemy(void);
  78. protected:
  79. Int m_curFrontBaseDefense; // First is 0.
  80. Int m_curFlankBaseDefense; // First is 0.
  81. Real m_curFrontLeftDefenseAngle;
  82. Real m_curFrontRightDefenseAngle;
  83. Real m_curLeftFlankLeftDefenseAngle;
  84. Real m_curLeftFlankRightDefenseAngle;
  85. Real m_curRightFlankLeftDefenseAngle;
  86. Real m_curRightFlankRightDefenseAngle;
  87. UnsignedInt m_frameToCheckEnemy;
  88. Player *m_currentEnemy;
  89. };
  90. #endif
  91. #endif // _AI_SKIRMISH_PLAYER_H_