FOOT.H (12150B)
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: F:\projects\c&c\vcs\code\foot.h_v 2.20 16 Oct 1995 16:47:14 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 ** If this unit has officially joined the team's group, then this flag is 56 ** true. A newly assigned unit to a team is not considered part of the 57 ** team until it actually reaches the location where the team is. By 58 ** using this flag, it allows a team to continue to intelligently attack 59 ** a target without falling back to regroup the moment a distant member 60 ** joins. 61 */ 62 unsigned IsInitiated:1; 63 64 /* 65 ** When the player gives this object a navigation target AND that target 66 ** does not result in any movement of the unit, then a beep should be 67 ** sounded. This typically occurs when selecting an invalid location for 68 ** movement. This flag is cleared if any movement was able to be performed. 69 ** It never gets set for computer controlled units. 70 */ 71 unsigned IsNewNavCom:1; 72 73 /* 74 ** There are certain cases where a unit should perform a full scan rather than 75 ** the more efficient "ring scan". This situation occurs when a unit first 76 ** appears on the map or when it finishes a multiple cell movement track. 77 */ 78 unsigned IsPlanningToLook:1; 79 80 /* 81 ** Certain units have the ability to metamorphize into a building. When this 82 ** operation begins, certain processes must occur. During these operations, this 83 ** flag will be true. This ensures that any necessary special case code gets 84 ** properly executed for this unit. 85 */ 86 unsigned IsDeploying:1; 87 88 /* 89 ** This flag tells the system that the unit is doing a firing animation. This is 90 ** critical to the firing logic. 91 */ 92 unsigned IsFiring:1; 93 94 /* 95 ** This unit could be either rotating its body or rotating its turret. During the 96 ** process of rotation, this flag is set. By examining this flag, unnecessary logic 97 ** can be avoided. 98 */ 99 unsigned IsRotating:1; 100 101 /* 102 ** If this object is current driving to a short range destination, this flag is 103 ** true. A short range destination is either the next cell or the end of the 104 ** current "curvy" track. An object that is driving is not allowed to do anything 105 ** else until it reaches its destination. The exception is when infantry wish to 106 ** head to a different destination, they are allowed to start immediately. 107 */ 108 unsigned IsDriving:1; 109 110 /* 111 ** If this object is unloading from a hover transport, then this flag will be 112 ** set to true. This handles the unusual case of an object disembarking from the 113 ** hover lander yet not necessarily tethered but still located in an overlapping 114 ** position. This flag will be cleared automatically when the object moves to the 115 ** center of a cell. 116 */ 117 unsigned IsUnloading:1; 118 119 /* 120 ** This is the "throttle setting" of the unit. It is a fractional value with 0 = stop 121 ** and 255 = full speed. 122 */ 123 unsigned char const Speed; 124 125 /* 126 ** 127 ** This is the desired destination of the unit. The unit will attempt to head 128 ** toward this target (avoiding intervening obstacles). 129 */ 130 TARGET NavCom; 131 TARGET SuspendedNavCom; 132 133 /* 134 ** This points to the team that "owns" this object. This pointer is used to 135 ** quickly process the team when this object is the source of the change. An 136 ** example would be if this object were to be destroyed, it would inform the 137 ** team of this fact by using this pointer. 138 */ 139 TeamClass * Team; 140 141 /* 142 ** If this object is part of a pseudo-team that the player is managing, then 143 ** this will be set to the team number (0 - 9). If it is not part of any 144 ** pseudo-team, then the number will be -1. 145 */ 146 unsigned char Group; 147 148 /* 149 ** This points to the next member in the team that this object is part of. This 150 ** is used to quickly process each team member when the team class is the source 151 ** of the change. An example would be if the team decided that everyone is going 152 ** to move to a new location, it would inform each of the objects by chaining 153 ** through this pointer. 154 */ 155 FootClass * Member; 156 157 /* 158 ** Since all objects derived from this class move according to a path list. 159 ** This is the path list. It specifies, as a simple list of facings, the 160 ** path that the object should follow in order to reach its destination. 161 ** This path list is limited in size, so it might require several generations 162 ** of path lists before the ultimate destination is reached. The game logic 163 ** handles regenerating the path list as necessary. 164 */ 165 FacingType Path[CONQUER_PATH_MAX]; 166 167 /* 168 ** When there is a complete findpath failure, this timer is initialized so 169 ** that a findpath won't be calculated until this timer expires. 170 */ 171 TCountDownTimerClass PathDelay; 172 enum {PATH_DELAY=15,PATH_RETRY=10}; 173 int TryTryAgain; // Number of retry attempts remaining. 174 175 /* 176 ** If the object has recently attacked a base, then this timer will not 177 ** have expired yet. It is used so a building does not keep calling 178 ** for help from the same attacker. 179 */ 180 TCountDownTimerClass BaseAttackTimer; 181 182 /*--------------------------------------------------------------------- 183 ** Constructors, Destructors, and overloaded operators. 184 */ 185 FootClass(void); 186 virtual ~FootClass(void); 187 FootClass(HousesType house); 188 189 /*--------------------------------------------------------------------- 190 ** Member function prototypes. 191 */ 192 bool Basic_Path(void); 193 194 virtual RadioMessageType Receive_Message(RadioClass * from, RadioMessageType message, long & param); 195 virtual bool Can_Demolish(void) const; 196 197 /* 198 ** Coordinate inquiry functions. These are used for both display and 199 ** combat purposes. 200 */ 201 virtual COORDINATE Sort_Y(void) const; 202 virtual COORDINATE Likely_Coord(void) const; 203 204 /* 205 ** Driver control support functions. These are used to control cell 206 ** occupation flags and driver instructions. 207 */ 208 COORDINATE Head_To_Coord(void) const {return (HeadToCoord);}; 209 virtual bool Start_Driver(COORDINATE &headto); 210 virtual bool Stop_Driver(void); 211 virtual void Assign_Destination(TARGET target); 212 213 /* 214 ** Display and rendering support functionality. Supports imagery and how 215 ** object interacts with the map and thus indirectly controls rendering. 216 */ 217 virtual bool Unlimbo(COORDINATE , DirType dir = DIR_N); 218 virtual bool Limbo(void); 219 virtual bool Mark(MarkType mark); 220 221 /* 222 ** User I/O. 223 */ 224 virtual void Active_Click_With(ActionType action, ObjectClass * object); 225 virtual void Active_Click_With(ActionType action, CELL cell); 226 227 /* 228 ** Combat related. 229 */ 230 virtual void Stun(void); 231 virtual ResultType Take_Damage(int & damage, int distance, WarheadType warhead, TechnoClass * source=0); 232 virtual void Death_Announcement(TechnoClass const * source=0) const; 233 234 /* 235 ** AI. 236 */ 237 virtual void Sell_Back(int control); 238 virtual int Offload_Tiberium_Bail(void); 239 virtual TARGET Greatest_Threat(ThreatType method) const; 240 virtual void Detach(TARGET target, bool all); 241 virtual void Detach_All(bool all=true); 242 virtual void Assign_Mission(MissionType order); 243 virtual int Mission_Enter(void); 244 virtual int Mission_Move(void); 245 virtual int Mission_Capture(void); 246 virtual int Mission_Attack(void); 247 virtual int Mission_Guard(void); 248 virtual int Mission_Hunt(void); 249 virtual int Mission_Timed_Hunt(void); 250 virtual int Mission_Guard_Area(void); 251 252 /* 253 ** Scenario and debug support. 254 */ 255 #ifdef CHEAT_KEYS 256 virtual void Debug_Dump(MonoClass *mono) const; 257 #endif 258 259 /* 260 ** Movement and animation. 261 */ 262 virtual void Per_Cell_Process(bool center); 263 virtual void Approach_Target(void); 264 virtual void Fixup_Path(PathType *) {}; 265 virtual void Set_Speed(int speed); 266 virtual MoveType Can_Enter_Cell(CELL , FacingType =FACING_NONE) const; 267 int Optimize_Moves(PathType *path, MoveType threshhold); 268 virtual void Override_Mission(MissionType mission, TARGET tarcom, TARGET navcom); 269 virtual bool Restore_Mission(void); 270 271 /* 272 ** File I/O. 273 */ 274 virtual void Code_Pointers(void); 275 virtual void Decode_Pointers(void); 276 277 CELL Safety_Point(CELL src, CELL dst, int start, int max); 278 int Rescue_Mission(TARGET tarcom); 279 280 private: 281 int Passable_Cell(CELL cell, FacingType face, int threat, MoveType threshhold); 282 PathType * Find_Path(CELL dest, FacingType *final_moves, int maxlen, MoveType threshhold); 283 void Debug_Draw_Map(char *txt, CELL start, CELL dest, bool pause); 284 void Debug_Draw_Path(PathType *path); 285 bool Follow_Edge(CELL start, CELL target, PathType *path, FacingType search, FacingType olddir, int threat, int threat_stage, int max_cells, MoveType threshhold); 286 bool Register_Cell(PathType *path, CELL cell, FacingType dir, int cost, MoveType threshhold); 287 bool Unravel_Loop(PathType *path, CELL &cell, FacingType &dir, int sx, int sy, int dx, int dy, MoveType threshhold); 288 289 /* 290 ** This is the coordinate that the unit is heading to 291 ** as an immediate destination. This coordinate is never further 292 ** than once cell (or track) from the unit's location. When this coordinate 293 ** is reached, then the next location in the path list becomes the 294 ** next HeadTo coordinate. 295 */ 296 COORDINATE HeadToCoord; 297 298 /* 299 ** Some additional padding in case we need to add data to the class and maintain backwards compatibility for save/load 300 */ 301 unsigned char SaveLoadPadding[16]; 302 }; 303 304 #endif