AI.h 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024
  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. // AI.h //
  24. // AI header file
  25. // Author: Michael S. Booth, November 2000
  26. #pragma once
  27. #ifndef _AI_H_
  28. #define _AI_H_
  29. #include "Common/Snapshot.h"
  30. #include "Common/SubsystemInterface.h"
  31. #include "Common/GameMemory.h"
  32. #include "Common/GameType.h"
  33. #include "GameLogic/Damage.h"
  34. #include "Common/STLTypedefs.h"
  35. class AIGroup;
  36. class AttackPriorityInfo;
  37. class BuildListInfo;
  38. class CommandButton;
  39. class Object;
  40. class PartitionFilter;
  41. class Path;
  42. class Pathfinder;
  43. class Player;
  44. class PolygonTrigger;
  45. class UpgradeTemplate;
  46. class WeaponTemplate;
  47. enum GUICommandType;
  48. enum HackerAttackMode;
  49. enum WeaponSetType;
  50. enum WeaponLockType;
  51. enum SpecialPowerType;
  52. typedef std::vector<ObjectID> VecObjectID;
  53. typedef VecObjectID::iterator VecObjectIDIt;
  54. typedef std::list<Object *> ListObjectPtr;
  55. typedef ListObjectPtr::iterator ListObjectPtrIt;
  56. enum AIDebugOptions
  57. {
  58. AI_DEBUG_NONE = 0,
  59. AI_DEBUG_PATHS,
  60. AI_DEBUG_TERRAIN,
  61. AI_DEBUG_CELLS,
  62. AI_DEBUG_GROUND_PATHS,
  63. AI_DEBUG_ZONES,
  64. AI_DEBUG_END
  65. };
  66. enum
  67. {
  68. // multiply by the owner type, either AI or human
  69. AI_VISIONFACTOR_OWNERTYPE = 0x01,
  70. // multiply by the "mood" of the unit
  71. AI_VISIONFACTOR_MOOD = 0x02,
  72. // If we want to consider the inner radius, we will specify guard inner. Otherwise, use guard outer.
  73. AI_VISIONFACTOR_GUARDINNER = 0x04,
  74. };
  75. enum {MAX_AI_UPGRADES = 20};
  76. typedef struct {
  77. Int m_numSkills;
  78. ScienceType m_skills[MAX_AI_UPGRADES];
  79. } TSkillSet;
  80. class AISideInfo : public MemoryPoolObject
  81. {
  82. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(AISideInfo, "AISideInfo")
  83. public:
  84. AISideInfo( void ) : m_easy(0), m_normal(1), m_hard(2), m_next(NULL)
  85. {
  86. m_side.clear();
  87. m_baseDefenseStructure1.clear();
  88. }
  89. AsciiString m_side; ///< Name of the side
  90. Int m_easy; ///< Number of gatherers to use in easy, normal & hard
  91. Int m_normal;
  92. Int m_hard;
  93. TSkillSet m_skillSet1;
  94. TSkillSet m_skillSet2;
  95. TSkillSet m_skillSet3;
  96. TSkillSet m_skillSet4;
  97. TSkillSet m_skillSet5;
  98. AsciiString m_baseDefenseStructure1;
  99. AISideInfo *m_next;
  100. };
  101. EMPTY_DTOR(AISideInfo)
  102. class AISideBuildList : public MemoryPoolObject
  103. {
  104. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(AISideBuildList, "AISideBuildList")
  105. public:
  106. AISideBuildList( AsciiString side );
  107. //~AISideBuildList();
  108. void addInfo(BuildListInfo *info);
  109. public:
  110. AsciiString m_side; ///< Name of the faction.
  111. BuildListInfo* m_buildList; ///< Build list for the faction.
  112. AISideBuildList* m_next;
  113. };
  114. class TAiData : public Snapshot
  115. {
  116. public:
  117. TAiData();
  118. ~TAiData();
  119. void addSideInfo(AISideInfo *info);
  120. void addFactionBuildList(AISideBuildList *buildList);
  121. // --------------- inherited from Snapshot interface --------------
  122. void crc( Xfer *xfer );
  123. void xfer( Xfer *xfer );
  124. void loadPostProcess( void );
  125. Real m_structureSeconds; // Try to build a structure every N seconds.
  126. Real m_teamSeconds; // Try to build a team every N seconds.
  127. Int m_resourcesWealthy; // How many resources to be wealthy.
  128. Int m_resourcesPoor; // How few resources to be poor.
  129. UnsignedInt m_forceIdleFramesCount; // How many frames does a unit need to be Idle before it can begin looking for enemies?
  130. Real m_structuresWealthyMod; // Factor to multiply m_structurFrames by if we are wealthy.
  131. Real m_teamWealthyMod; // Factor to multiply m_teamFrames by if we are wealthy.
  132. Real m_structuresPoorMod; // Factor to multiply m_structureFrames by if we are poor.
  133. Real m_teamPoorMod; // Factor to multiply m_teamFrames if we are poor.
  134. Real m_teamResourcesToBuild; // Amount of the resources needed to build a team required before we start.
  135. Real m_guardInnerModifierAI; // Multiply the AI unit's vision by this much == guard inner circle.
  136. Real m_guardOuterModifierAI; // Multiply the AI unit's vision by this much == guard outer circle.
  137. Real m_guardInnerModifierHuman; // Multiply the human unit's vision by this much == guard inner circle
  138. Real m_guardOuterModifierHuman; // Multiply the human unit's vision by this much == guard outer circle
  139. UnsignedInt m_guardChaseUnitFrames; // Number of frames for which a unit should
  140. UnsignedInt m_guardEnemyScanRate; // rate to scan for enemies while guarding
  141. UnsignedInt m_guardEnemyReturnScanRate; // rate to scan for enemies while guarding but returning
  142. Real m_wallHeight; // Height of special wall units can walk on top of.
  143. Real m_alertRangeModifier; // When a unit is alert, its range will be modified by this value
  144. Real m_aggressiveRangeModifier; // When a unit is aggressive, its range will be modified by this value
  145. /* The attack priority distance modifier changes relative values. The relative priority
  146. is reduced by the distance away, divided by the modifier.
  147. Example: tanks are priority 10, powerplants priority 15, and modifier = 100.0
  148. If a powerplant is 700 feet away from the attacker, and the tank is
  149. 100 feet, the effective priority for tank is 9 (10-(100/100), and the
  150. effective priority for powerplant is 8 (15 -(700/100). So the tanks
  151. would be attacked first because their distance weighted priority is greater. */
  152. Real m_attackPriorityDistanceModifier; // Distance to reduce a relative AttackPriority by 1.
  153. /*
  154. How close to a waypoint does a group of units have to be to consider itself at the waypoint?
  155. m_skirmishGroupFudgeValue is multiplied by the number of the units in the group asking if its
  156. close enough to determine this.
  157. So for instance (if m_skirmishGroupFudgeValue was 5), if 2 units are walking along a path,
  158. they would check to see if they were less than 10 feet away from the waypoint in order
  159. to say they were close enough. A group of 10 units would consider themselves close enough
  160. if they were within 50 feet of the waypoint.
  161. */
  162. Real m_skirmishGroupFudgeValue;
  163. Real m_maxRecruitDistance; // Maximum distance away that units can be recruited.
  164. Real m_skirmishBaseDefenseExtraDistance; ///< instead of building base defenses right on the template bounding circle, push them out this much.
  165. Real m_repulsedDistance; // How far a repulsed unit will run past vision range before stopping.
  166. Bool m_enableRepulsors; // Is repulsion enabled?
  167. Bool m_forceSkirmishAI; // If true, forces skirmish ai instead of solo ai for development until the skirmish ui is done. jba.
  168. Bool m_rotateSkirmishBases; // If true, rotates skirmish ai bases to face the center of the map. jba.
  169. Bool m_attackUsesLineOfSight; // If true, attack for units with KINDOF_ATTACK_NEEDS_LINE_OF_SIGHT uses line of sight. jba.
  170. Bool m_attackIgnoreInsignificantBuildings; // If true, attack for ALL UNITS ignores buildings that are hostile that are not significant. jkmcd
  171. // Group pathfind info.
  172. Int m_minInfantryForGroup; // We need at least this many to do it.
  173. Int m_minVehiclesForGroup; // We need at least this many vehicles to do it.
  174. Real m_minDistanceForGroup; // We need to move at least this far to do it.
  175. Real m_distanceRequiresGroup; // If we are moving this far or farther, force group moving.
  176. Real m_minClumpDensity; // What density constitues a clump. .5 means units occupying 1/2 of their bounding area.
  177. Int m_infantryPathfindDiameter; // Diameter of path in cells for infantry.
  178. Int m_vehiclePathfindDiameter; // Diameter of path in cells for vehicles.
  179. Int m_rebuildDelaySeconds; // Seconds to delay rebuilding after a base building is destroyed or captured.
  180. Real m_supplyCenterSafeRadius; // Radius to scan for enemies to determine safety.
  181. Real m_aiDozerBoredRadiusModifier; // Modifies ai dozers scan range so the move out farther than human ones.
  182. Bool m_aiCrushesInfantry; // If true, AI vehicles will attempt to crush infantry.
  183. // Retaliate params. [8/25/2003]
  184. Real m_maxRetaliateDistance; // If attacker is > this distance, don't retaliate. [8/25/2003]
  185. Real m_retaliateFriendsRadius; // If we have friends within this radius, get them to help retaliate. [8/25/2003]
  186. AISideInfo *m_sideInfo;
  187. AISideBuildList *m_sideBuildLists;
  188. TAiData *m_next;
  189. } ;
  190. //------------------------------------------------------------------------------------------------------------
  191. /**
  192. * The AI subsystem is responsible for the implementation of
  193. * the Artificial Intelligence of the game. This includes
  194. * the behaviors or all game entities, pathfinding, etc.
  195. */
  196. class AI : public SubsystemInterface, public Snapshot
  197. {
  198. public:
  199. AI( void );
  200. ~AI();
  201. virtual void init( void ); ///< initialize AI to default values
  202. virtual void reset( void ); ///< reset the AI system to prepare for a new map
  203. virtual void update( void ); ///< do one frame of AI computation
  204. inline Pathfinder *pathfinder( void ) { return m_pathfinder; } ///< public access to the pathfind system
  205. enum
  206. {
  207. CAN_SEE = 1 << 0,
  208. CAN_ATTACK = 1 << 1,
  209. IGNORE_INSIGNIFICANT_BUILDINGS = 1 << 2,
  210. ATTACK_BUILDINGS = 1 << 3,
  211. WITHIN_ATTACK_RANGE = 1 << 4,
  212. UNFOGGED = 1 << 5
  213. };
  214. Object *findClosestEnemy( const Object *me, Real range, UnsignedInt qualifiers,
  215. const AttackPriorityInfo *info=NULL, PartitionFilter *optionalFilter=NULL);
  216. Object *findClosestRepulsor( const Object *me, Real range);
  217. Object *findClosestAlly( const Object *me, Real range, UnsignedInt qualifiers);
  218. // --------------- inherited from Snapshot interface --------------
  219. void crc( Xfer *xfer );
  220. void xfer( Xfer *xfer );
  221. void loadPostProcess( void );
  222. // AI Groups -----------------------------------------------------------------------------------------------
  223. AIGroup *createGroup( void ); ///< instantiate a new AI Group
  224. void destroyGroup( AIGroup *group ); ///< destroy the given AI Group
  225. AIGroup *findGroup( UnsignedInt id ); ///< return the AI Group with the given ID
  226. // Formation info
  227. enum FormationID getNextFormationID(void);
  228. static void parseAiDataDefinition( INI* ini );
  229. const TAiData *getAiData() {return m_aiData;}
  230. // Note: Does not work for things that do not have AI. (This is in AI.h, after all)
  231. static Real getAdjustedVisionRangeForObject(const Object *object, Int factorsToConsider);
  232. static void parseSideInfo( INI* ini, void *instance, void *store, const void *userData ); ///< Parse the image part of the INI file
  233. static void parseSkirmishBuildList( INI* ini, void *instance, void *store, const void *userData ); ///< Parse the image part of the INI file
  234. static void parseStructure( INI* ini, void *instance, void *store, const void *userData ); ///< Parse the image part of the INI file
  235. static void parseSkillSet( INI* ini, void *instance, void *store, const void *userData ); ///< Parse the image part of the INI file
  236. static void parseScience( INI* ini, void *instance, void *store, const void *userData ); ///< Parse the image part of the INI file
  237. inline UnsignedInt getNextGroupID( void ) { return ++m_nextGroupID; }
  238. protected:
  239. Pathfinder *m_pathfinder; ///< the pathfinding system
  240. std::list<AIGroup *> m_groupList; ///< the list of AIGroups
  241. TAiData *m_aiData;
  242. void newOverride(void);
  243. void addSideInfo(AISideInfo *info);
  244. UnsignedInt m_nextGroupID;
  245. FormationID m_nextFormationID;
  246. };
  247. extern AI *TheAI; ///< the Artificial Intelligence singleton
  248. class Waypoint;
  249. class Team;
  250. class Weapon;
  251. // Note - written out in save/load xfer and .map files, don't change these numbers.
  252. enum AttitudeType { AI_SLEEP = -2, AI_PASSIVE=-1, AI_NORMAL=0, AI_ALERT=1, AI_AGGRESSIVE=2, AI_INVALID=3 }; ///< AI "attitude" behavior modifiers
  253. enum CommandSourceType;
  254. typedef UnsignedInt CommandSourceMask;
  255. #ifdef DEFINE_COMMANDSOURCEMASK_NAMES
  256. static const char *TheCommandSourceMaskNames[] =
  257. {
  258. "FROM_PLAYER",
  259. "FROM_SCRIPT",
  260. "FROM_AI",
  261. "FROM_DOZER", //don't use this
  262. "DEFAULT_SWITCH_WEAPON", //unit will pick this weapon when normal logic fails.
  263. NULL
  264. };
  265. #endif
  266. //------------------------------------------------------------------------------------------------------------
  267. enum AICommandType // Stored in save file, do not reorder/renumber. jba.
  268. {
  269. AICMD_NO_COMMAND = -1,
  270. AICMD_MOVE_TO_POSITION = 0,
  271. AICMD_MOVE_TO_OBJECT,
  272. AICMD_TIGHTEN_TO_POSITION,
  273. AICMD_MOVE_TO_POSITION_AND_EVACUATE,
  274. AICMD_MOVE_TO_POSITION_AND_EVACUATE_AND_EXIT,
  275. AICMD_IDLE,
  276. AICMD_FOLLOW_WAYPOINT_PATH,
  277. AICMD_FOLLOW_WAYPOINT_PATH_AS_TEAM,
  278. AICMD_FOLLOW_USER_PATH, //Created by player in waypoint mode (this one will create little waypoint markers)
  279. AICMD_FOLLOW_PATH,
  280. AICMD_FOLLOW_EXITPRODUCTION_PATH, // same as AICMD_FOLLOW_PATH, but only used when exiting your production facility.
  281. AICMD_ATTACK_OBJECT,
  282. AICMD_FORCE_ATTACK_OBJECT,
  283. AICMD_ATTACK_TEAM,
  284. AICMD_ATTACK_POSITION,
  285. AICMD_ATTACKMOVE_TO_POSITION,
  286. AICMD_ATTACKFOLLOW_WAYPOINT_PATH,
  287. AICMD_ATTACKFOLLOW_WAYPOINT_PATH_AS_TEAM,
  288. AICMD_HUNT,
  289. AICMD_REPAIR,
  290. #ifdef ALLOW_SURRENDER
  291. AICMD_PICK_UP_PRISONER,
  292. AICMD_RETURN_PRISONERS,
  293. #endif
  294. AICMD_RESUME_CONSTRUCTION,
  295. AICMD_GET_HEALED,
  296. AICMD_GET_REPAIRED,
  297. AICMD_ENTER,
  298. AICMD_DOCK,
  299. AICMD_EXIT,
  300. AICMD_EVACUATE,
  301. AICMD_EXECUTE_RAILED_TRANSPORT,
  302. AICMD_GO_PRONE,
  303. AICMD_GUARD_POSITION,
  304. AICMD_GUARD_OBJECT,
  305. AICMD_GUARD_AREA,
  306. AICMD_DEPLOY_ASSAULT_RETURN,
  307. AICMD_ATTACK_AREA,
  308. AICMD_HACK_INTERNET,
  309. AICMD_FACE_OBJECT,
  310. AICMD_FACE_POSITION,
  311. AICMD_RAPPEL_INTO, // note that this applies to the rappeller.
  312. AICMD_COMBATDROP, // note that this applies to the thing-being-rappelled-from.
  313. AICMD_COMMANDBUTTON_POS,
  314. AICMD_COMMANDBUTTON_OBJ,
  315. AICMD_COMMANDBUTTON,
  316. AICMD_WANDER,
  317. AICMD_WANDER_IN_PLACE,
  318. AICMD_PANIC,
  319. AICMD_BUSY,
  320. AICMD_FOLLOW_WAYPOINT_PATH_EXACT,
  321. AICMD_FOLLOW_WAYPOINT_PATH_AS_TEAM_EXACT,
  322. AICMD_MOVE_AWAY_FROM_UNIT,
  323. AICMD_FOLLOW_PATH_APPEND,
  324. AICMD_MOVE_TO_POSITION_EVEN_IF_SLEEPING, // same as AICMD_MOVE_TO_POSITION, but even AI_SLEEP units respond.
  325. AICMD_GUARD_TUNNEL_NETWORK,
  326. AICMD_EVACUATE_INSTANTLY,
  327. AICMD_EXIT_INSTANTLY,
  328. AICMD_GUARD_RETALIATE,
  329. AICMD_NUM_COMMANDS // keep last
  330. };
  331. struct AICommandParms
  332. {
  333. AICommandType m_cmd;
  334. CommandSourceType m_cmdSource;
  335. Coord3D m_pos;
  336. Object* m_obj;
  337. Object* m_otherObj;
  338. const Team* m_team;
  339. std::vector<Coord3D> m_coords;
  340. const Waypoint* m_waypoint;
  341. const PolygonTrigger* m_polygon;
  342. Int m_intValue; /// misc usage
  343. DamageInfo m_damage;
  344. const CommandButton* m_commandButton;
  345. Path* m_path;
  346. AICommandParms(AICommandType cmd, CommandSourceType cmdSource);
  347. };
  348. class AICommandParmsStorage
  349. {
  350. private:
  351. AICommandType m_cmd;
  352. CommandSourceType m_cmdSource;
  353. Coord3D m_pos;
  354. ObjectID m_obj;
  355. ObjectID m_otherObj;
  356. AsciiString m_teamName;
  357. std::vector<Coord3D> m_coords;
  358. const Waypoint* m_waypoint;
  359. const PolygonTrigger* m_polygon;
  360. Int m_intValue; /// misc usage
  361. DamageInfo m_damage;
  362. const CommandButton* m_commandButton;
  363. Path* m_path;
  364. public:
  365. void store(const AICommandParms& parms);
  366. void reconstitute(AICommandParms& parms) const;
  367. void doXfer(Xfer *xfer);
  368. AICommandType getCommandType() const { return m_cmd; }
  369. };
  370. /**
  371. AI interface. AIGroups, or Objects with an AIUpdate can be given these commands.
  372. NOTE NOTE NOTE: all of these may be overridden and possibly deferred by various AI classes,
  373. so they are NOT ALLOWED TO RETURN ANY VALUES, since the particular command issued might
  374. not be executed immediately...
  375. */
  376. class AICommandInterface
  377. {
  378. public:
  379. virtual void aiDoCommand(const AICommandParms* parms) = 0;
  380. inline void aiMoveToPosition( const Coord3D *pos, CommandSourceType cmdSource )
  381. {
  382. AICommandParms parms(AICMD_MOVE_TO_POSITION, cmdSource);
  383. parms.m_pos = *pos;
  384. aiDoCommand(&parms);
  385. }
  386. inline void aiMoveToPositionEvenIfSleeping( const Coord3D *pos, CommandSourceType cmdSource )
  387. {
  388. AICommandParms parms(AICMD_MOVE_TO_POSITION_EVEN_IF_SLEEPING, cmdSource);
  389. parms.m_pos = *pos;
  390. aiDoCommand(&parms);
  391. }
  392. inline void aiMoveToObject( Object *obj, CommandSourceType cmdSource )
  393. {
  394. AICommandParms parms(AICMD_MOVE_TO_OBJECT, cmdSource);
  395. parms.m_obj = obj;
  396. aiDoCommand(&parms);
  397. }
  398. inline void aiTightenToPosition( const Coord3D *pos, CommandSourceType cmdSource )
  399. {
  400. AICommandParms parms(AICMD_TIGHTEN_TO_POSITION, cmdSource);
  401. parms.m_pos = *pos;
  402. aiDoCommand(&parms);
  403. }
  404. inline void aiMoveToAndEvacuate( const Coord3D *pos, CommandSourceType cmdSource )
  405. {
  406. AICommandParms parms(AICMD_MOVE_TO_POSITION_AND_EVACUATE, cmdSource);
  407. parms.m_pos = *pos;
  408. aiDoCommand(&parms);
  409. }
  410. inline void aiMoveToAndEvacuateAndExit( const Coord3D *pos, CommandSourceType cmdSource )
  411. {
  412. AICommandParms parms(AICMD_MOVE_TO_POSITION_AND_EVACUATE_AND_EXIT, cmdSource);
  413. parms.m_pos = *pos;
  414. aiDoCommand(&parms);
  415. }
  416. inline void aiIdle(CommandSourceType cmdSource)
  417. {
  418. AICommandParms parms(AICMD_IDLE, cmdSource);
  419. aiDoCommand(&parms);
  420. }
  421. inline void aiBusy(CommandSourceType cmdSource)
  422. {
  423. AICommandParms parms(AICMD_BUSY, cmdSource);
  424. aiDoCommand(&parms);
  425. }
  426. inline void aiFollowWaypointPath( const Waypoint *way, CommandSourceType cmdSource )
  427. {
  428. AICommandParms parms(AICMD_FOLLOW_WAYPOINT_PATH, cmdSource);
  429. parms.m_waypoint = way;
  430. aiDoCommand(&parms);
  431. }
  432. inline void aiFollowWaypointPathExact( const Waypoint *way, CommandSourceType cmdSource )
  433. {
  434. AICommandParms parms(AICMD_FOLLOW_WAYPOINT_PATH_EXACT, cmdSource);
  435. parms.m_waypoint = way;
  436. aiDoCommand(&parms);
  437. }
  438. inline void aiFollowWaypointPathAsTeam( const Waypoint *way, CommandSourceType cmdSource )
  439. {
  440. AICommandParms parms(AICMD_FOLLOW_WAYPOINT_PATH_AS_TEAM, cmdSource);
  441. parms.m_waypoint = way;
  442. aiDoCommand(&parms);
  443. }
  444. inline void aiFollowWaypointPathExactAsTeam( const Waypoint *way, CommandSourceType cmdSource )
  445. {
  446. AICommandParms parms(AICMD_FOLLOW_WAYPOINT_PATH_AS_TEAM_EXACT, cmdSource);
  447. parms.m_waypoint = way;
  448. aiDoCommand(&parms);
  449. }
  450. inline void aiFollowExitProductionPath( const std::vector<Coord3D>* path, Object *ignoreObject, CommandSourceType cmdSource )
  451. {
  452. AICommandParms parms(AICMD_FOLLOW_EXITPRODUCTION_PATH, cmdSource);
  453. parms.m_coords = *path;
  454. parms.m_obj = ignoreObject;
  455. aiDoCommand(&parms);
  456. }
  457. inline void aiFollowPath( const std::vector<Coord3D>* path, Object *ignoreObject, CommandSourceType cmdSource )
  458. {
  459. AICommandParms parms(AICMD_FOLLOW_PATH, cmdSource);
  460. parms.m_coords = *path;
  461. parms.m_obj = ignoreObject;
  462. aiDoCommand(&parms);
  463. }
  464. inline void aiFollowPathAppend( const Coord3D* pos, CommandSourceType cmdSource )
  465. {
  466. AICommandParms parms(AICMD_FOLLOW_PATH_APPEND, cmdSource);
  467. parms.m_pos = *pos;
  468. aiDoCommand(&parms);
  469. }
  470. inline void aiAttackObject( Object *victim, Int maxShotsToFire, CommandSourceType cmdSource )
  471. {
  472. AICommandParms parms(AICMD_ATTACK_OBJECT, cmdSource);
  473. parms.m_obj = victim;
  474. parms.m_intValue = maxShotsToFire;
  475. aiDoCommand(&parms);
  476. }
  477. inline void aiForceAttackObject( Object *victim, Int maxShotsToFire, CommandSourceType cmdSource )
  478. {
  479. AICommandParms parms(AICMD_FORCE_ATTACK_OBJECT, cmdSource);
  480. parms.m_obj = victim;
  481. parms.m_intValue = maxShotsToFire;
  482. aiDoCommand(&parms);
  483. }
  484. inline void aiGuardRetaliate( Object *victim, const Coord3D *pos, Int maxShotsToFire, CommandSourceType cmdSource )
  485. {
  486. AICommandParms parms(AICMD_GUARD_RETALIATE, cmdSource);
  487. parms.m_obj = victim;
  488. parms.m_pos = *pos;
  489. parms.m_intValue = maxShotsToFire;
  490. aiDoCommand(&parms);
  491. }
  492. inline void aiAttackTeam( const Team *team, Int maxShotsToFire, CommandSourceType cmdSource )
  493. {
  494. AICommandParms parms(AICMD_ATTACK_TEAM, cmdSource);
  495. parms.m_team = team;
  496. parms.m_intValue = maxShotsToFire;
  497. aiDoCommand(&parms);
  498. }
  499. inline void aiAttackPosition( const Coord3D *pos, Int maxShotsToFire, CommandSourceType cmdSource )
  500. {
  501. AICommandParms parms(AICMD_ATTACK_POSITION, cmdSource);
  502. parms.m_pos = *pos;
  503. parms.m_intValue = maxShotsToFire;
  504. aiDoCommand(&parms);
  505. }
  506. inline void aiAttackMoveToPosition( const Coord3D *pos, Int maxShotsToFire, CommandSourceType cmdSource )
  507. {
  508. AICommandParms parms(AICMD_ATTACKMOVE_TO_POSITION, cmdSource);
  509. parms.m_pos = *pos;
  510. parms.m_intValue = maxShotsToFire;
  511. aiDoCommand(&parms);
  512. }
  513. inline void aiAttackFollowWaypointPath( const Waypoint *way, Int maxShotsToFire, CommandSourceType cmdSource )
  514. {
  515. AICommandParms parms(AICMD_ATTACKFOLLOW_WAYPOINT_PATH, cmdSource);
  516. parms.m_waypoint = way;
  517. parms.m_intValue = maxShotsToFire;
  518. aiDoCommand(&parms);
  519. }
  520. inline void aiAttackFollowWaypointPathAsTeam( const Waypoint *way, Int maxShotsToFire, CommandSourceType cmdSource )
  521. {
  522. AICommandParms parms(AICMD_ATTACKFOLLOW_WAYPOINT_PATH_AS_TEAM, cmdSource);
  523. parms.m_waypoint = way;
  524. parms.m_intValue = maxShotsToFire;
  525. aiDoCommand(&parms);
  526. }
  527. inline void aiHunt( CommandSourceType cmdSource )
  528. {
  529. AICommandParms parms(AICMD_HUNT, cmdSource);
  530. aiDoCommand(&parms);
  531. }
  532. inline void aiAttackArea( const PolygonTrigger *areaToGuard, CommandSourceType cmdSource )
  533. {
  534. AICommandParms parms(AICMD_ATTACK_AREA, cmdSource);
  535. parms.m_polygon = areaToGuard;
  536. aiDoCommand(&parms);
  537. }
  538. inline void aiRepair( Object *obj, CommandSourceType cmdSource )
  539. {
  540. AICommandParms parms(AICMD_REPAIR, cmdSource);
  541. parms.m_obj = obj;
  542. aiDoCommand(&parms);
  543. }
  544. #ifdef ALLOW_SURRENDER
  545. inline void aiPickUpPrisoner( Object *obj, CommandSourceType cmdSource )
  546. {
  547. AICommandParms parms( AICMD_PICK_UP_PRISONER, cmdSource );
  548. parms.m_obj = obj;
  549. aiDoCommand( &parms );
  550. }
  551. #endif
  552. #ifdef ALLOW_SURRENDER
  553. inline void aiReturnPrisoners( Object *prison, CommandSourceType cmdSource )
  554. {
  555. AICommandParms parms( AICMD_RETURN_PRISONERS, cmdSource );
  556. parms.m_obj = prison;
  557. aiDoCommand( &parms );
  558. }
  559. #endif
  560. inline void aiResumeConstruction( Object *obj, CommandSourceType cmdSource )
  561. {
  562. AICommandParms parms(AICMD_RESUME_CONSTRUCTION, cmdSource);
  563. parms.m_obj = obj;
  564. aiDoCommand(&parms);
  565. }
  566. inline void aiGetHealed( Object *healDepot, CommandSourceType cmdSource )
  567. {
  568. AICommandParms parms(AICMD_GET_HEALED, cmdSource);
  569. parms.m_obj = healDepot;
  570. aiDoCommand(&parms);
  571. }
  572. inline void aiGetRepaired( Object *repairDepot, CommandSourceType cmdSource )
  573. {
  574. AICommandParms parms(AICMD_GET_REPAIRED, cmdSource);
  575. parms.m_obj = repairDepot;
  576. aiDoCommand(&parms);
  577. }
  578. inline void aiEnter( Object *obj, CommandSourceType cmdSource )
  579. {
  580. AICommandParms parms(AICMD_ENTER, cmdSource);
  581. parms.m_obj = obj;
  582. aiDoCommand(&parms);
  583. }
  584. inline void aiDock( Object *obj, CommandSourceType cmdSource )
  585. {
  586. AICommandParms parms(AICMD_DOCK, cmdSource);
  587. parms.m_obj = obj;
  588. aiDoCommand(&parms);
  589. }
  590. inline void aiExit( Object *objectToExit, CommandSourceType cmdSource )
  591. {
  592. AICommandParms parms(AICMD_EXIT, cmdSource);
  593. parms.m_obj = objectToExit;
  594. aiDoCommand(&parms);
  595. }
  596. inline void aiExitInstantly( Object *objectToExit, CommandSourceType cmdSource )
  597. {
  598. AICommandParms parms(AICMD_EXIT_INSTANTLY, cmdSource);
  599. parms.m_obj = objectToExit;
  600. aiDoCommand(&parms);
  601. }
  602. inline void aiEvacuate( Bool exposeStealthUnits, CommandSourceType cmdSource )
  603. {
  604. AICommandParms parms(AICMD_EVACUATE, cmdSource);
  605. if( exposeStealthUnits )
  606. parms.m_intValue = 1;
  607. else
  608. parms.m_intValue = 0;
  609. aiDoCommand(&parms);
  610. }
  611. inline void aiEvacuateInstantly( Bool exposeStealthUnits, CommandSourceType cmdSource )
  612. {
  613. AICommandParms parms(AICMD_EVACUATE_INSTANTLY, cmdSource);
  614. if( exposeStealthUnits )
  615. parms.m_intValue = 1;
  616. else
  617. parms.m_intValue = 0;
  618. aiDoCommand(&parms);
  619. }
  620. inline void aiExecuteRailedTransport( CommandSourceType cmdSource )
  621. {
  622. AICommandParms parms( AICMD_EXECUTE_RAILED_TRANSPORT, cmdSource );
  623. aiDoCommand( &parms );
  624. }
  625. inline void aiGoProne( const DamageInfo *damageInfo, CommandSourceType cmdSource )
  626. {
  627. AICommandParms parms(AICMD_GO_PRONE, cmdSource);
  628. parms.m_damage = *damageInfo;
  629. aiDoCommand(&parms);
  630. }
  631. inline void aiGuardPosition( const Coord3D *pos, GuardMode guardMode, CommandSourceType cmdSource )
  632. {
  633. AICommandParms parms(AICMD_GUARD_POSITION, cmdSource);
  634. parms.m_pos = *pos;
  635. parms.m_intValue = guardMode;
  636. aiDoCommand(&parms);
  637. }
  638. inline void aiGuardObject( Object *objToGuard, GuardMode guardMode, CommandSourceType cmdSource )
  639. {
  640. AICommandParms parms(AICMD_GUARD_OBJECT, cmdSource);
  641. parms.m_obj = objToGuard;
  642. parms.m_intValue = guardMode;
  643. aiDoCommand(&parms);
  644. }
  645. inline void aiGuardArea( const PolygonTrigger *areaToGuard, GuardMode guardMode, CommandSourceType cmdSource )
  646. {
  647. AICommandParms parms(AICMD_GUARD_AREA, cmdSource);
  648. parms.m_polygon = areaToGuard;
  649. parms.m_intValue = guardMode;
  650. aiDoCommand(&parms);
  651. }
  652. inline void aiGuardTunnelNetwork( GuardMode guardMode, CommandSourceType cmdSource )
  653. {
  654. AICommandParms parms(AICMD_GUARD_TUNNEL_NETWORK, cmdSource);
  655. parms.m_intValue = guardMode;
  656. aiDoCommand(&parms);
  657. }
  658. inline void aiHackInternet( CommandSourceType cmdSource )
  659. {
  660. AICommandParms parms(AICMD_HACK_INTERNET, cmdSource);
  661. aiDoCommand(&parms);
  662. }
  663. inline void aiFaceObject( Object *target, CommandSourceType cmdSource )
  664. {
  665. AICommandParms parms(AICMD_FACE_OBJECT, cmdSource);
  666. parms.m_obj = target;
  667. aiDoCommand(&parms);
  668. }
  669. inline void aiFacePosition( const Coord3D *pos, CommandSourceType cmdSource )
  670. {
  671. AICommandParms parms(AICMD_FACE_POSITION, cmdSource);
  672. parms.m_pos = *pos;
  673. aiDoCommand(&parms);
  674. }
  675. inline void aiRappelInto( Object *target, const Coord3D& pos, CommandSourceType cmdSource )
  676. {
  677. AICommandParms parms(AICMD_RAPPEL_INTO, cmdSource);
  678. parms.m_obj = target;
  679. parms.m_pos = pos;
  680. aiDoCommand(&parms);
  681. }
  682. inline void aiCombatDrop( Object *target, const Coord3D& pos, CommandSourceType cmdSource )
  683. {
  684. AICommandParms parms(AICMD_COMBATDROP, cmdSource);
  685. parms.m_obj = target;
  686. parms.m_pos = pos;
  687. aiDoCommand(&parms);
  688. }
  689. inline void aiDoCommandButton( const CommandButton *commandButton, CommandSourceType cmdSource )
  690. {
  691. AICommandParms parms(AICMD_COMMANDBUTTON, cmdSource);
  692. parms.m_commandButton = commandButton;
  693. aiDoCommand(&parms);
  694. }
  695. inline void aiDoCommandButtonAtPosition( const CommandButton *commandButton, const Coord3D *pos, CommandSourceType cmdSource )
  696. {
  697. AICommandParms parms(AICMD_COMMANDBUTTON_POS, cmdSource);
  698. parms.m_pos = *pos;
  699. parms.m_commandButton = commandButton;
  700. aiDoCommand(&parms);
  701. }
  702. inline void aiDoCommandButtonAtObject( const CommandButton *commandButton, Object *obj, CommandSourceType cmdSource )
  703. {
  704. AICommandParms parms(AICMD_COMMANDBUTTON_OBJ, cmdSource);
  705. parms.m_obj = obj;
  706. parms.m_commandButton = commandButton;
  707. aiDoCommand(&parms);
  708. }
  709. inline void aiMoveAwayFromUnit( Object *obj, CommandSourceType cmdSource )
  710. {
  711. AICommandParms parms(AICMD_MOVE_AWAY_FROM_UNIT, cmdSource);
  712. parms.m_obj = obj;
  713. aiDoCommand(&parms);
  714. }
  715. inline void aiWander( const Waypoint *way, CommandSourceType cmdSource )
  716. {
  717. AICommandParms parms(AICMD_WANDER, cmdSource);
  718. parms.m_waypoint = way;
  719. aiDoCommand(&parms);
  720. }
  721. inline void aiWanderInPlace(CommandSourceType cmdSource)
  722. {
  723. AICommandParms parms(AICMD_WANDER_IN_PLACE, cmdSource);
  724. aiDoCommand(&parms);
  725. }
  726. inline void aiPanic( const Waypoint *way, CommandSourceType cmdSource )
  727. {
  728. AICommandParms parms(AICMD_PANIC, cmdSource);
  729. parms.m_waypoint = way;
  730. aiDoCommand(&parms);
  731. }
  732. };
  733. //------------------------------------------------------------------------------------------------------------
  734. /**
  735. * An "AIGroup" is a simple collection of AI objects, used by the AI
  736. * for such things as Group Pathfinding.
  737. */
  738. class AIGroup : public MemoryPoolObject, public Snapshot
  739. {
  740. private:
  741. void groupAttackObjectPrivate( Bool forced, Object *victim, Int maxShotsToFire, CommandSourceType cmdSource ); ///< attack given object
  742. public:
  743. // --------------- inherited from Snapshot interface --------------
  744. void crc( Xfer *xfer );
  745. void xfer( Xfer *xfer );
  746. void loadPostProcess( void );
  747. void groupMoveToPosition( const Coord3D *pos, Bool addWaypoint, CommandSourceType cmdSource );
  748. void groupMoveToAndEvacuate( const Coord3D *pos, CommandSourceType cmdSource ); ///< move to given position(s)
  749. void groupMoveToAndEvacuateAndExit( const Coord3D *pos, CommandSourceType cmdSource ); ///< move to given position & unload transport.
  750. void groupIdle(CommandSourceType cmdSource); ///< Enter idle state.
  751. void groupScatter(CommandSourceType cmdSource); ///< Enter idle state.
  752. void groupCreateFormation(CommandSourceType cmdSource); ///< Make the current selection a user formation.
  753. void groupTightenToPosition( const Coord3D *pos, Bool addWaypoint, CommandSourceType cmdSource ); ///< move to given position(s)
  754. void groupFollowWaypointPath( const Waypoint *way, CommandSourceType cmdSource );///< start following the path from the given point
  755. void groupFollowWaypointPathAsTeam( const Waypoint *way, CommandSourceType cmdSource );///< start following the path from the given point
  756. void groupFollowWaypointPathExact( const Waypoint *way, CommandSourceType cmdSource );///< start following the path from the given point
  757. void groupFollowWaypointPathAsTeamExact( const Waypoint *way, CommandSourceType cmdSource );///< start following the path from the given point
  758. void groupFollowPath( const std::vector<Coord3D>* path, Object *ignoreObject, CommandSourceType cmdSource );///< follow the path defined by the given array of points
  759. void groupAttackObject( Object *victim, Int maxShotsToFire, CommandSourceType cmdSource )
  760. {
  761. groupAttackObjectPrivate(false, victim, maxShotsToFire, cmdSource);
  762. }
  763. void groupForceAttackObject( Object *victim, Int maxShotsToFire, CommandSourceType cmdSource )
  764. {
  765. groupAttackObjectPrivate(true, victim, maxShotsToFire, cmdSource);
  766. }
  767. void groupAttackTeam( const Team *team, Int maxShotsToFire, CommandSourceType cmdSource ); ///< attack the given team
  768. void groupAttackPosition( const Coord3D *pos, Int maxShotsToFire, CommandSourceType cmdSource ); ///< attack given spot
  769. void groupAttackMoveToPosition( const Coord3D *pos, Int maxShotsToFire, CommandSourceType cmdSource ); ///< Attack move to the location
  770. void groupHunt( CommandSourceType cmdSource ); ///< begin "seek and destroy"
  771. void groupRepair( Object *obj, CommandSourceType cmdSource ); ///< repair the given object
  772. void groupResumeConstruction( Object *obj, CommandSourceType cmdSource ); ///< resume construction on the object
  773. void groupGetHealed( Object *healDepot, CommandSourceType cmdSource ); ///< go get healed at the heal depot
  774. void groupGetRepaired( Object *repairDepot, CommandSourceType cmdSource );///< go get repaired at the repair depot
  775. void groupEnter( Object *obj, CommandSourceType cmdSource ); ///< enter the given object
  776. void groupDock( Object *obj, CommandSourceType cmdSource ); ///< get near given object and wait for enter clearance
  777. void groupExit( Object *objectToExit, CommandSourceType cmdSource ); ///< get out of this Object
  778. void groupEvacuate( CommandSourceType cmdSource ); ///< empty its contents
  779. void groupExecuteRailedTransport( CommandSourceType cmdSource ); ///< execute railed transport events
  780. void groupGoProne( const DamageInfo *damageInfo, CommandSourceType cmdSource ); ///< life altering state change, if this AI can do it
  781. void groupGuardPosition( const Coord3D *pos, GuardMode guardMode, CommandSourceType cmdSource ); ///< guard the given spot
  782. void groupGuardObject( Object *objToGuard, GuardMode guardMode, CommandSourceType cmdSource ); ///< guard an object
  783. void groupGuardArea( const PolygonTrigger *areaToGuard, GuardMode guardMode, CommandSourceType cmdSource ); ///< guard an area
  784. void groupAttackArea( const PolygonTrigger *areaToGuard, CommandSourceType cmdSource ); ///< guard an area
  785. void groupHackInternet( CommandSourceType cmdSource ); ///< Begin hacking the internet for free cash from the heavens.
  786. void groupDoSpecialPower( UnsignedInt specialPowerID, UnsignedInt commandOptions );
  787. void groupDoSpecialPowerAtObject( UnsignedInt specialPowerID, Object *object, UnsignedInt commandOptions );
  788. void groupDoSpecialPowerAtLocation( UnsignedInt specialPowerID, const Coord3D *location, Real angle, const Object *object, UnsignedInt commandOptions );
  789. #ifdef ALLOW_SURRENDER
  790. void groupSurrender( const Object *objWeSurrenderedTo, Bool surrender, CommandSourceType cmdSource );
  791. #endif
  792. void groupCheer( CommandSourceType cmdSource );
  793. void groupSell( CommandSourceType cmdSource );
  794. void groupToggleOvercharge( CommandSourceType cmdSource );
  795. #ifdef ALLOW_SURRENDER
  796. void groupPickUpPrisoner( Object *prisoner, CommandSourceType cmdSource ); ///< pick up prisoner
  797. void groupReturnToPrison( Object *prison, CommandSourceType cmdSource ); ///< return to prison
  798. #endif
  799. void groupCombatDrop( Object *target, const Coord3D& pos, CommandSourceType cmdSource );
  800. void groupDoCommandButton( const CommandButton *commandButton, CommandSourceType cmdSource );
  801. void groupDoCommandButtonAtPosition( const CommandButton *commandButton, const Coord3D *pos, CommandSourceType cmdSource );
  802. void groupDoCommandButtonUsingWaypoints( const CommandButton *commandButton, const Waypoint *way, CommandSourceType cmdSource );
  803. void groupDoCommandButtonAtObject( const CommandButton *commandButton, Object *obj, CommandSourceType cmdSource );
  804. void groupSetEmoticon( const AsciiString &name, Int duration );
  805. void groupOverrideSpecialPowerDestination( SpecialPowerType spType, const Coord3D *loc, CommandSourceType cmdSource );
  806. void setAttitude( AttitudeType tude ); ///< set the behavior modifier for this agent
  807. AttitudeType getAttitude( void ) const; ///< get the current behavior modifier state
  808. Bool isIdle() const;
  809. //Definition of busy -- when explicitly in the busy state. Moving or attacking is not considered busy!
  810. Bool isBusy() const;
  811. Bool isGroupAiDead() const;
  812. // Returns an object that can perform the special power. Useful for making queries on the Action Manager
  813. Object *getSpecialPowerSourceObject( UnsignedInt specialPowerID );
  814. // Returns an object that has a command button for the GUI command type.
  815. Object *getCommandButtonSourceObject( GUICommandType type );
  816. // Group methods --------------------------------------------------------------------------------
  817. Bool isMember( Object *obj ); ///< return true if object is in this group
  818. Real getSpeed( void ); ///< return the speed of the group's slowest member
  819. Bool getCenter( Coord3D *center ); ///< compute centroid of group
  820. Bool getMinMaxAndCenter( Coord2D *min, Coord2D *max, Coord3D *center );
  821. void computeIndividualDestination( Coord3D *dest, const Coord3D *groupDest,
  822. Object *obj, const Coord3D *center, Bool isFormation ); ///< compute destination of individual object, based on group destination
  823. Int getCount( void ); ///< return the number of objects in the group
  824. Bool isEmpty( void ); ///< returns true if the group has no members
  825. void queueUpgrade( const UpgradeTemplate *upgrade ); ///< queue an upgrade
  826. void add( Object *obj ); ///< add object to group
  827. // returns true if remove destroyed the group for us.
  828. Bool remove( Object *obj);
  829. // If the group contains any objects not owned by ownerPlayer, return TRUE.
  830. Bool containsAnyObjectsNotOwnedByPlayer( const Player *ownerPlayer );
  831. // Remove any objects that aren't owned by the player, and return true if the group was destroyed due to emptiness
  832. Bool removeAnyObjectsNotOwnedByPlayer( const Player *ownerPlayer );
  833. UnsignedInt getID( void );
  834. ///< get IDs for every object in this group
  835. const VecObjectID& getAllIDs ( void ) const;
  836. void recomputeGroupSpeed() { m_dirty = true; }
  837. void setMineClearingDetail( Bool set );
  838. Bool setWeaponLockForGroup( WeaponSlotType weaponSlot, WeaponLockType lockType ); ///< Set the groups' weapon choice.
  839. void releaseWeaponLockForGroup(WeaponLockType lockType);///< Clear each guys weapon choice
  840. void setWeaponSetFlag( WeaponSetType wst );
  841. protected:
  842. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( AIGroup, "AIGroupPool" ); ///< @todo Set real numbers for mem alloc
  843. ListObjectPtrIt internalRemove(ListObjectPtrIt iterToRemove);
  844. Bool friend_moveInfantryToPos( const Coord3D *pos, CommandSourceType cmdSource );
  845. Bool friend_moveVehicleToPos( const Coord3D *pos, CommandSourceType cmdSource );
  846. void friend_moveFormationToPos( const Coord3D *pos, CommandSourceType cmdSource );
  847. Bool friend_computeGroundPath( const Coord3D *pos, CommandSourceType cmdSource );
  848. private:
  849. // AIGroups must be created through TheAI->createGroup()
  850. friend class AI;
  851. AIGroup( void );
  852. void recompute( void ); ///< recompute various group info, such as speed, leader, etc
  853. ListObjectPtr m_memberList; ///< the list of member Objects
  854. UnsignedInt m_memberListSize; ///< the size of the list of member Objects
  855. Real m_speed; ///< maximum speed of group (slowest member)
  856. Bool m_dirty; ///< "dirty bit" - if true then group speed, leader, needs recompute
  857. UnsignedInt m_id; ///< the unique ID of this group
  858. Path *m_groundPath; ///< Group ground path.
  859. mutable VecObjectID m_lastRequestedIDList; ///< this is used so we can return by reference, saving a copy
  860. };
  861. #endif // _AI_H_