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