FOOT.H (15227B)
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/FOOT.H 1 3/03/97 10:24a 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 : FOOT.H * 24 * * 25 * Programmer : Joe L. Bostic * 26 * * 27 * Start Date : April 14, 1994 * 28 * * 29 * Last Update : April 14, 1994 [JLB] * 30 * * 31 *---------------------------------------------------------------------------------------------* 32 * Functions: * 33 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 34 35 #ifndef FOOT_H 36 #define FOOT_H 37 38 #include "target.h" 39 #include "type.h" 40 #include "techno.h" 41 #include "ftimer.h" 42 43 class UnitClass; 44 class BuildingClass; 45 46 47 /**************************************************************************** 48 ** Movable objects are handled by this class definition. Moveable objects 49 ** cover everything except buildings. 50 */ 51 class FootClass : public TechnoClass 52 { 53 public: 54 /* 55 ** This flag controls whether a range limiting effect should be in place. If 56 ** true, then target scanning will be limited to the range of the object 57 ** regardless of what was requested from the target scanning logic. This value 58 ** is used for ships so that they won't permanently stick on a an attack mission 59 ** for a target they can never get within range of. This value will toggle when 60 ** a path cannot be generated and the target is not within range. It will also 61 ** toggle when path limiting is true, but there is not target found within 62 ** the limited range. 63 */ 64 unsigned IsScanLimited:1; 65 66 /* 67 ** If this unit has officially joined the team's group, then this flag is 68 ** true. A newly assigned unit to a team is not considered part of the 69 ** team until it actually reaches the location where the team is. By 70 ** using this flag, it allows a team to continue to intelligently attack 71 ** a target without falling back to regroup the moment a distant member 72 ** joins. 73 */ 74 unsigned IsInitiated:1; 75 76 /* 77 ** When the player gives this object a navigation target AND that target 78 ** does not result in any movement of the unit, then a beep should be 79 ** sounded. This typically occurs when selecting an invalid location for 80 ** movement. This flag is cleared if any movement was able to be performed. 81 ** It never gets set for computer controlled units. 82 */ 83 unsigned IsNewNavCom:1; 84 85 /* 86 ** There are certain cases where a unit should perform a full scan rather than 87 ** the more efficient "ring scan". This situation occurs when a unit first 88 ** appears on the map or when it finishes a multiple cell movement track. 89 */ 90 unsigned IsPlanningToLook:1; 91 92 /* 93 ** Certain units have the ability to metamorphize into a building. When this 94 ** operation begins, certain processes must occur. During these operations, this 95 ** flag will be true. This ensures that any necessary special case code gets 96 ** properly executed for this unit. 97 */ 98 unsigned IsDeploying:1; 99 100 /* 101 ** This flag tells the system that the unit is doing a firing animation. This is 102 ** critical to the firing logic. 103 */ 104 unsigned IsFiring:1; 105 106 /* 107 ** This unit could be either rotating its body or rotating its turret. During the 108 ** process of rotation, this flag is set. By examining this flag, unnecessary logic 109 ** can be avoided. 110 */ 111 unsigned IsRotating:1; 112 113 /* 114 ** If this object is current driving to a short range destination, this flag is 115 ** true. A short range destination is either the next cell or the end of the 116 ** current "curvy" track. An object that is driving is not allowed to do anything 117 ** else until it reaches its destination. The exception is when infantry wish to 118 ** head to a different destination, they are allowed to start immediately. 119 */ 120 unsigned IsDriving:1; 121 122 /* 123 ** If this object is unloading from a hover transport, then this flag will be 124 ** set to true. This handles the unusual case of an object disembarking from the 125 ** hover lander yet not necessarily tethered but still located in an overlapping 126 ** position. This flag will be cleared automatically when the object moves to the 127 ** center of a cell. 128 */ 129 unsigned IsUnloading:1; 130 131 /* 132 ** If this object is part of a formation, this bit will be set. The 133 ** formation only occurs when every member of a team is selected, and 134 ** only those members of the team are the ones selected. 135 */ 136 unsigned IsFormationMove:1; 137 138 /* 139 ** If the navigation movement queue is to be looped rather than consumed, then 140 ** this flag will be true. By looping, the unit will travel through the locations 141 ** in the queue indefinately. 142 */ 143 unsigned IsNavQueueLoop:1; 144 145 /* 146 ** If this object is scattering, then this flag will be true. While true, the 147 ** NavCom should not be arbitrarily changed. This flag will automatcially be 148 ** cleared when the object moves one cell. 149 */ 150 unsigned IsScattering:1; 151 152 /* 153 ** If this object is moving onto a bridge, then this flag will be true. 154 */ 155 unsigned IsMovingOntoBridge:1; 156 157 /* 158 ** This is the "throttle setting" of the unit. It is a fractional value with 0 = stop 159 ** and 255 = full speed. 160 */ 161 int Speed; 162 163 /* 164 ** This is the override speed adjuster. Normally, this is a fixed point 165 ** value of 0x0100, but it can be modified by crate powerups. 166 */ 167 fixed SpeedBias; 168 169 /* 170 ** For units in a formation, these values represent the distance from 171 ** the target destination where the unit should move to. For example, 172 ** in a horizontal line formation, XFormOffset would be set to some 173 ** value, and YFormOffset would be zero. 174 */ 175 int XFormOffset; 176 int YFormOffset; 177 178 /* 179 ** 180 ** This is the desired destination of the unit. The unit will attempt to head 181 ** toward this target (avoiding intervening obstacles). 182 */ 183 TARGET NavCom; 184 TARGET SuspendedNavCom; 185 186 /* 187 ** A sequence of move destinations can be given to a unit. The sequence is 188 ** stores as an array of movement targets. The list is terminated with a 189 ** TARGET_NONE. 190 */ 191 TARGET NavQueue[10]; 192 193 /* 194 ** This points to the team that "owns" this object. This pointer is used to 195 ** quickly process the team when this object is the source of the change. An 196 ** example would be if this object were to be destroyed, it would inform the 197 ** team of this fact by using this pointer. 198 */ 199 CCPtr<TeamClass> Team; 200 201 /* 202 ** If this object is part of a pseudo-team that the player is managing, then 203 ** this will be set to the team number (0 - 9). If it is not part of any 204 ** pseudo-team, then the number will be -1. 205 */ 206 unsigned char Group; 207 208 /* 209 ** This points to the next member in the team that this object is part of. This 210 ** is used to quickly process each team member when the team class is the source 211 ** of the change. An example would be if the team decided that everyone is going 212 ** to move to a new location, it would inform each of the objects by chaining 213 ** through this pointer. 214 */ 215 FootClass * Member; 216 217 /* 218 ** Since all objects derived from this class move according to a path list. 219 ** This is the path list. It specifies, as a simple list of facings, the 220 ** path that the object should follow in order to reach its destination. 221 ** This path list is limited in size, so it might require several generations 222 ** of path lists before the ultimate destination is reached. The game logic 223 ** handles regenerating the path list as necessary. 224 */ 225 FacingType Path[CONQUER_PATH_MAX]; 226 227 /* 228 ** This value keeps track of how serious the unit is in trying to reach the 229 ** destination specified. As blockages arise, this threshold will rise 230 ** unit it reaches the point of complete failure. When that event occurs, the 231 ** unit will realize that it cannot get to its specified destination and will 232 ** try to perform some other action instead. 233 */ 234 MoveType PathThreshhold; 235 236 /* 237 ** When there is a complete findpath failure, this timer is initialized so 238 ** that a findpath won't be calculated until this timer expires. 239 */ 240 CDTimerClass<FrameTimerClass> PathDelay; 241 enum {PATH_RETRY=10}; 242 int TryTryAgain; // Number of retry attempts remaining. 243 244 /* 245 ** If the object has recently attacked a base, then this timer will not 246 ** have expired yet. It is used so a building does not keep calling 247 ** for help from the same attacker. 248 */ 249 CDTimerClass<FrameTimerClass> BaseAttackTimer; 250 251 /* 252 ** For formation moves, this will be the override speed. 253 */ 254 SpeedType FormationSpeed; 255 256 /* 257 ** For formation moves, this will be the override maximum speed. 258 */ 259 MPHType FormationMaxSpeed; 260 261 /*--------------------------------------------------------------------- 262 ** Constructors, Destructors, and overloaded operators. 263 */ 264 FootClass(NoInitClass const & x) : TechnoClass(x), Team(x), PathDelay(x), BaseAttackTimer(x) {}; 265 FootClass(RTTIType rtti, int id, HousesType house); 266 267 /*--------------------------------------------------------------------- 268 ** Member function prototypes. 269 */ 270 bool Basic_Path(void); 271 272 virtual RadioMessageType Receive_Message(RadioClass * from, RadioMessageType message, long & param); 273 virtual bool Can_Demolish(void) const; 274 bool Is_Recruitable(HouseClass const * house=NULL) const; 275 bool Is_On_Priority_Mission(void) const; 276 277 /* 278 ** Coordinate inquiry functions. These are used for both display and 279 ** combat purposes. 280 */ 281 virtual COORDINATE Sort_Y(void) const; 282 virtual COORDINATE Likely_Coord(void) const; 283 284 /* 285 ** Driver control support functions. These are used to control cell 286 ** occupation flags and driver instructions. 287 */ 288 COORDINATE Head_To_Coord(void) const {return (HeadToCoord);}; 289 virtual bool Start_Driver(COORDINATE &headto); 290 virtual bool Stop_Driver(void); 291 virtual void Assign_Destination(TARGET target); 292 bool Is_Allowed_To_Leave_Map(void) const; 293 294 /* 295 ** Display and rendering support functionality. Supports imagery and how 296 ** object interacts with the map and thus indirectly controls rendering. 297 */ 298 virtual bool Unlimbo(COORDINATE , DirType dir = DIR_N); 299 virtual bool Mark(MarkType mark=MARK_CHANGE); 300 301 /* 302 ** User I/O. 303 */ 304 virtual void Active_Click_With(ActionType action, ObjectClass * object); 305 virtual void Active_Click_With(ActionType action, CELL cell); 306 307 /* 308 ** Combat related. 309 */ 310 virtual void Stun(void); 311 virtual ResultType Take_Damage(int & damage, int distance, WarheadType warhead, TechnoClass * source=0, bool forced=false); 312 virtual void Death_Announcement(TechnoClass const * source=0) const; 313 314 /* 315 ** AI. 316 */ 317 virtual void AI(void); 318 virtual void Sell_Back(int control); 319 virtual int Offload_Tiberium_Bail(void); 320 virtual TARGET Greatest_Threat(ThreatType method) const; 321 virtual void Detach(TARGET target, bool all); 322 virtual void Detach_All(bool all=true); 323 virtual int Mission_Retreat(void); 324 virtual int Mission_Enter(void); 325 virtual int Mission_Move(void); 326 virtual int Mission_Capture(void); 327 virtual int Mission_Attack(void); 328 virtual int Mission_Guard(void); 329 virtual int Mission_Hunt(void); 330 virtual int Mission_Guard_Area(void); 331 332 /* 333 ** Scenario and debug support. 334 */ 335 #ifdef CHEAT_KEYS 336 virtual void Debug_Dump(MonoClass *mono) const; 337 #endif 338 339 /* 340 ** Movement and animation. 341 */ 342 void Handle_Navigation_List(void); 343 void Queue_Navigation_List(TARGET target); 344 void Clear_Navigation_List(void); 345 virtual void Per_Cell_Process(PCPType why); 346 virtual void Approach_Target(void); 347 virtual void Fixup_Path(PathType *) {}; 348 virtual void Set_Speed(int speed); 349 virtual MoveType Can_Enter_Cell(CELL cell, FacingType from=FACING_NONE) const; 350 int Optimize_Moves(PathType *path, MoveType threshhold); 351 virtual void Override_Mission(MissionType mission, TARGET tarcom, TARGET navcom); 352 virtual bool Restore_Mission(void); 353 CELL Adjust_Dest(CELL cell) const; 354 355 /* 356 ** File I/O. 357 */ 358 virtual void Code_Pointers(void); 359 virtual void Decode_Pointers(void); 360 361 CELL Safety_Point(CELL src, CELL dst, int start, int max); 362 int Rescue_Mission(TARGET tarcom); 363 364 private: 365 int Passable_Cell(CELL cell, FacingType face, int threat, MoveType threshhold); 366 PathType * Find_Path(CELL dest, FacingType *final_moves, int maxlen, MoveType threshhold); 367 void Debug_Draw_Map(char const * txt, CELL start, CELL dest, bool pause); 368 void Debug_Draw_Path(PathType *path); 369 bool Follow_Edge(CELL start, CELL target, PathType *path, FacingType search, FacingType olddir, int threat, int threat_stage, int max_cells, MoveType threshhold); 370 bool Register_Cell(PathType *path, CELL cell, FacingType dir, int cost, MoveType threshhold); 371 bool Unravel_Loop(PathType *path, CELL &cell, FacingType &dir, int sx, int sy, int dx, int dy, MoveType threshhold); 372 373 /* 374 ** This is the coordinate that the unit is heading to 375 ** as an immediate destination. This coordinate is never further 376 ** than once cell (or track) from the unit's location. When this coordinate 377 ** is reached, then the next location in the path list becomes the 378 ** next HeadTo coordinate. 379 */ 380 COORDINATE HeadToCoord; 381 382 /* 383 ** Some additional padding in case we need to add data to the class and maintain backwards compatibility for save/load 384 */ 385 unsigned char SaveLoadPadding[16]; 386 }; 387 388 #endif 389