TEAM.H 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. /*
  2. ** Command & Conquer(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: F:\projects\c&c\vcs\code\team.h_v 2.16 16 Oct 1995 16:48:04 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. TeamTypeClass const * const Class;
  54. /*
  55. ** This specifies the owner of this team.
  56. */
  57. HouseClass * const 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. private:
  93. /*
  94. ** If a team member was removed or added, then this flag will be set to true. The
  95. ** team system uses this flag to tell whether it should recalculate the team
  96. ** under strength or full strength flags. This process does not need to occur
  97. ** EVERY time a unit added or deleted from a team, just every so often if the
  98. ** team has been changed.
  99. */
  100. unsigned IsAltered: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. ** Records whether the team is suspended from production.
  115. */
  116. unsigned Suspended:1;
  117. public:
  118. /*
  119. ** A team will have a center point. This is the point used to determine if
  120. ** any member of the team is "too far" from the team and must return. This
  121. ** center point is usually calculated as the average position of all the
  122. ** team members.
  123. */
  124. CELL Center;
  125. CELL ObjectiveCenter;
  126. /*
  127. ** This is the target of the team. Typically, it is a unit or structure, but
  128. ** for the case of teams with a movement mission, it might represent a
  129. ** destination cell.
  130. */
  131. TARGET MissionTarget;
  132. TARGET Target;
  133. /*
  134. ** This is the total number of members in this team.
  135. */
  136. int Total;
  137. /*
  138. ** This is the teams combined risk value
  139. */
  140. int Risk;
  141. /*
  142. ** This is the amount of time the team is suspended for.
  143. */
  144. TCountDownTimerClass SuspendTimer;
  145. //------------------------------------------------------------
  146. TeamClass(void) : Class(0), House(0) {IsActive=false;Member=0;IsAltered=true;};
  147. TeamClass(TeamTypeClass const * team, HouseClass * owner);
  148. virtual ~TeamClass(void);
  149. virtual RTTIType What_Am_I(void) const {return RTTI_TEAM;};
  150. static void operator delete(void *ptr);
  151. static void * operator new(size_t size);
  152. static void Init(void);
  153. static void Suspend_Teams(int priority);
  154. TARGET As_Target(void) const;
  155. /*
  156. ** File I/O.
  157. */
  158. bool Load(FileClass & file);
  159. bool Save(FileClass & file);
  160. void Code_Pointers(void);
  161. void Decode_Pointers(void);
  162. void Force_Active(void) {IsForcedActive = true;IsUnderStrength=false;};
  163. bool Remove(FootClass *, int typeindex=-1);
  164. void Detach(TARGET target, bool all);
  165. void AI(void);
  166. void Took_Damage(FootClass * obj, ResultType result, TechnoClass * source);
  167. bool Add(FootClass *, int typeindex=-1);
  168. void Assign_Mission_Target(TARGET new_target);
  169. /*
  170. ** Dee-buggin' support.
  171. */
  172. int Validate(void) const;
  173. /*
  174. ** This is a record of the current number of active teams of each
  175. ** type. It can range from zero to MaxAllowed.
  176. */
  177. static unsigned char Number[TEAMTYPE_MAX];
  178. private:
  179. /*
  180. ** The current mission index into the mission list is recorded here.
  181. */
  182. int CurrentMission;
  183. /*
  184. ** Some missions will time out. This is the timer that keeps track of the
  185. ** time to transition between missions.
  186. */
  187. TCountDownTimerClass TimeOut;
  188. void Coordinate_Unload(void);
  189. bool Coordinate_Regroup(void);
  190. void Coordinate_Attack(void);
  191. void Coordinate_Move(void);
  192. void Coordinate_Conscript(FootClass * unit);
  193. // void Control(FootClass *, bool initial=false);
  194. void Calc_Center(CELL &center, CELL &obj_center) const;
  195. int Recruit(int typeindex);
  196. bool Is_A_Member(void const * who) const;
  197. bool Lagging_Units(void);
  198. /*
  199. ** Points to the first member in the list of members for this team.
  200. */
  201. FootClass * Member;
  202. unsigned char Quantity[TeamTypeClass::MAX_TEAM_CLASSCOUNT];
  203. /*
  204. ** This records the success of each team type. As the team carries out its
  205. ** mission, it increments this counter if it considers the mission
  206. ** to have been successfully completed. Teams with greater success
  207. ** will be created more than the others.
  208. */
  209. static unsigned char Success[TEAMTYPE_MAX];
  210. /*
  211. ** This contains the value of the Virtual Function Table Pointer
  212. */
  213. static void * VTable;
  214. };
  215. #endif