TEAM.H 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. /*
  2. ** Command & Conquer Red Alert(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. /* $Header: /CounterStrike/TEAM.H 1 3/03/97 10:25a Joe_bostic $ */
  19. /***********************************************************************************************
  20. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  21. ***********************************************************************************************
  22. * *
  23. * Project Name : Command & Conquer *
  24. * *
  25. * File Name : TEAM.H *
  26. * *
  27. * Programmer : Joe L. Bostic *
  28. * *
  29. * Start Date : 12/11/94 *
  30. * *
  31. * Last Update : December 11, 1994 [JLB] *
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  36. #ifndef TEAM_H
  37. #define TEAM_H
  38. #include "wwfile.h"
  39. #include "teamtype.h"
  40. #include "abstract.h"
  41. /*
  42. ** Units are only allowed to stray a certain distance away from their
  43. ** team. When they exceed this distance, some sort of fixup must be
  44. ** done.
  45. */
  46. #define STRAY_DISTANCE 2
  47. class TeamClass : public AbstractClass
  48. {
  49. public:
  50. /*
  51. ** This specifies the type of team this is.
  52. */
  53. CCPtr<TeamTypeClass> Class;
  54. /*
  55. ** This specifies the owner of this team.
  56. */
  57. CCPtr<HouseClass> House;
  58. /*
  59. ** This flag forces the team into active state regardless of whether it
  60. ** is understrength or not.
  61. */
  62. unsigned IsForcedActive:1;
  63. /*
  64. ** This flag is set to true when the team initiates into active mode. The
  65. ** flag is never cleared. By examining this flag, it is possible to determine
  66. ** if the team has ever launched into active mode.
  67. */
  68. unsigned IsHasBeen:1;
  69. /*
  70. ** If the team is full strength, then this flag is true. A full strength
  71. ** team will not try to recruit members.
  72. */
  73. unsigned IsFullStrength:1;
  74. /*
  75. ** A team that is below half strength has this flag true. It means that the
  76. ** the team should hide back at the owner's base and try to recruit
  77. ** members.
  78. */
  79. unsigned IsUnderStrength:1;
  80. /*
  81. ** If a team is not understrength but is not yet full strength, then
  82. ** the team is regrouping. If this flag is set and the team becomes
  83. ** full strength, the all members of the team will become initiated
  84. ** and this flag will be reset.
  85. */
  86. unsigned IsReforming:1;
  87. /*
  88. ** This bit should be set if a team is determined to have lagging
  89. ** units in its formation.
  90. */
  91. unsigned IsLagging:1;
  92. /*
  93. ** If a team member was removed or added, then this flag will be set to true. The
  94. ** team system uses this flag to tell whether it should recalculate the team
  95. ** under strength or full strength flags. This process does not need to occur
  96. ** EVERY time a unit added or deleted from a team, just every so often if the
  97. ** team has been changed.
  98. */
  99. unsigned IsAltered:1;
  100. unsigned JustAltered:1;
  101. /*
  102. ** If the team is working on it's primary mission (it is past the build up stage)
  103. ** then this flag will be true. The transition between "moving" and "stationary"
  104. ** stages usually requires some action on the team's part.
  105. */
  106. unsigned IsMoving:1;
  107. /*
  108. ** When the team determines that the next mission should be advanced to, it will
  109. ** set this flag to true. Mission advance will either change the behavior of the
  110. ** team or cause it to disband.
  111. */
  112. unsigned IsNextMission:1;
  113. /*
  114. ** If at least one member of this team successfully left the map, then this
  115. ** flag will be set. At the time the team is terminated, if this flag is true, then
  116. ** if there are any triggers that depend upon this team leaving, they will be
  117. ** sprung.
  118. */
  119. unsigned IsLeaveMap:1;
  120. /*
  121. ** Records whether the team is suspended from production.
  122. */
  123. unsigned Suspended:1;
  124. /*
  125. ** A team will have a center point. This is the point used to determine if
  126. ** any member of the team is "too far" from the team and must return. This
  127. ** center point is usually calculated as the average position of all the
  128. ** team members.
  129. */
  130. TARGET Zone;
  131. /*
  132. ** This is the target value of the team member that is closest to the
  133. ** destination of the team. The implied location serves as the
  134. ** regroup point for the unit as it is moving.
  135. */
  136. TARGET ClosestMember;
  137. /*
  138. ** This is the target of the team. Typically, it is a unit or structure, but
  139. ** for the case of teams with a movement mission, it might represent a
  140. ** destination cell.
  141. */
  142. TARGET MissionTarget;
  143. TARGET Target;
  144. /*
  145. ** This is the total number of members in this team.
  146. */
  147. int Total;
  148. /*
  149. ** This is the teams combined risk value
  150. */
  151. int Risk;
  152. /*
  153. ** If this team is assigned a formation, then the formation type
  154. ** will be stored here. If the formation type is FORMATION_NONE, then
  155. ** the team is a loose grouping -- just like C&C.
  156. */
  157. FormationType Formation;
  158. /*
  159. ** This is the amount of time the team is suspended for.
  160. */
  161. CDTimerClass<FrameTimerClass> SuspendTimer;
  162. /*
  163. ** If there is a trigger that should be attached to every member of this team, then
  164. ** it is pointed to by this.
  165. */
  166. CCPtr<TriggerClass> Trigger;
  167. //------------------------------------------------------------
  168. TeamClass(TeamTypeClass const * team=0, HouseClass * owner=0);
  169. TeamClass(NoInitClass const & x) : AbstractClass(x), Class(x), House(x), SuspendTimer(x), Trigger(x), TimeOut(x), Member(x) {};
  170. virtual ~TeamClass(void);
  171. static void operator delete(void *ptr);
  172. static void * operator new(size_t size);
  173. static void * operator new(size_t, void * ptr) {return(ptr);};
  174. static void Init(void);
  175. static void Suspend_Teams(int priority, HouseClass const * house);
  176. void Debug_Dump(MonoClass * mono) const;
  177. /*
  178. ** File I/O.
  179. */
  180. bool Load(Straw & file);
  181. bool Save(Pipe & file) const;
  182. void Code_Pointers(void);
  183. void Decode_Pointers(void);
  184. bool Is_Empty(void) const {return(Member == (void*)NULL);}
  185. bool Has_Entered_Map(void) const;
  186. void Force_Active(void) {IsForcedActive = true;IsUnderStrength=false;};
  187. bool Remove(FootClass *, int typeindex=-1);
  188. void Detach(TARGET target, bool all);
  189. void AI(void);
  190. void Took_Damage(FootClass * obj, ResultType result, TechnoClass * source);
  191. bool Add(FootClass *);
  192. bool Can_Add(FootClass * obj, int & typeindex) const;
  193. void Assign_Mission_Target(TARGET new_target);
  194. bool Is_Leaving_Map(void) const;
  195. void Scan_Limit(void);
  196. private:
  197. /*
  198. ** The current mission index into the mission list is recorded here.
  199. */
  200. int CurrentMission;
  201. /*
  202. ** Some missions will time out. This is the timer that keeps track of the
  203. ** time to transition between missions.
  204. */
  205. CDTimerClass<FrameTimerClass> TimeOut;
  206. int TMission_Formation(void);
  207. int TMission_Attack(void);
  208. int TMission_Spy(void);
  209. int TMission_Follow(void);
  210. int TMission_Loop(void);
  211. int TMission_Load(void);
  212. int TMission_Unload(void);
  213. int TMission_Invulnerable(void);
  214. int TMission_Set_Global(void);
  215. int TMission_Patrol(void);
  216. int TMission_Deploy(void);
  217. bool Coordinate_Regroup(void);
  218. void Coordinate_Attack(void);
  219. void Coordinate_Move(void);
  220. bool Coordinate_Conscript(FootClass * unit);
  221. void Coordinate_Do(void);
  222. void Calc_Center(TARGET &center, TARGET &obj_center) const;
  223. int Recruit(int typeindex);
  224. bool Is_A_Member(void const * who) const;
  225. bool Lagging_Units(void);
  226. FootClass * Fetch_A_Leader(void) const;
  227. /*
  228. ** Points to the first member in the list of members for this team.
  229. */
  230. SmartPtr<FootClass> Member;
  231. unsigned char Quantity[TeamTypeClass::MAX_TEAM_CLASSCOUNT];
  232. };
  233. #endif