AISkirmishPlayer.h 4.3 KB

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