UNIT.H (9614B)
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/UNIT.H 1 3/03/97 10:26a 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 : UNIT.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 UNIT_H 36 #define UNIT_H 37 38 #include "drive.h" 39 #include "radio.h" 40 #include "cargo.h" 41 #include "mission.h" 42 #include "target.h" 43 44 45 /**************************************************************************** 46 ** For each instance of a unit (vehicle) in the game, there is one of 47 ** these structures. This structure holds information that is specific 48 ** and dynamic for a particular unit. 49 */ 50 class UnitClass : public DriveClass 51 { 52 public: 53 54 /* 55 ** This points to the static control data that gives 'this' unit its characteristics. 56 */ 57 CCPtr<UnitTypeClass> Class; 58 59 /* 60 ** This records the house flag that this object is currently carrying. 61 */ 62 HousesType Flagged; 63 64 /* 65 ** This flag is used for when the harvester dumps ore, to track its 66 ** special animation. 67 */ 68 unsigned IsDumping:1; 69 70 /* 71 ** This is a count of the # of loads of the various minerals that the 72 ** unit has harvested. 73 */ 74 unsigned Gold:5; 75 unsigned Gems:5; 76 77 /* 78 ** This flag tells a unit that, if after reaching its destination, it 79 ** should scatter away. It's meant to help a LST unload its units by 80 ** having its previous passengers get out of the way. 81 */ 82 unsigned IsToScatter:1; 83 84 /* 85 ** This records the number of "loads" of Tiberium the unit is carrying. Only 86 ** harvesters use this field. 87 */ 88 int Tiberium; 89 90 /* 91 ** This is the area where a mobile gap generator stores the previously-held 92 ** shroud values for the cells surrounding itself. 93 */ 94 unsigned long ShroudBits; 95 96 /* 97 ** This is the center coordinate for the mobile gap generator, as to 98 ** what cells should be revealed (according to ShroudBits) 99 */ 100 CELL ShroudCenter; 101 102 /* 103 ** This is the timer that controls the reload rate. The MSAM rocket 104 ** launcher is the primary user of this. 105 */ 106 CDTimerClass<FrameTimerClass> Reload; 107 108 /* 109 ** This is the facing of the turret. It can be, and usually is, 110 ** rotated independently of the body it is attached to. 111 */ 112 FacingClass SecondaryFacing; 113 114 /* 115 ** This is the refinery a harvester is interested in unloading at. 116 */ 117 mutable TARGET TiberiumUnloadRefinery; 118 119 /* 120 ** Some additional padding in case we need to add data to the class and maintain backwards compatibility for save/load 121 */ 122 unsigned char SaveLoadPadding[28]; 123 124 /*--------------------------------------------------------------------- 125 ** Constructors, Destructors, and overloaded operators. 126 */ 127 static void * operator new(size_t size); 128 static void * operator new(size_t , void * ptr) {return(ptr);}; 129 static void operator delete(void *ptr); 130 UnitClass(UnitType classid, HousesType house); 131 UnitClass(NoInitClass const & x) : DriveClass(x), Class(x), Reload(x), SecondaryFacing(x) {}; 132 operator UnitType(void) const {return Class->Type;}; 133 virtual ~UnitClass(void); 134 135 /*--------------------------------------------------------------------- 136 ** Member function prototypes. 137 */ 138 virtual ObjectTypeClass const & Class_Of(void) const; 139 static void Init(void); 140 141 bool Goto_Clear_Spot(void); 142 bool Try_To_Deploy(void); 143 virtual void Scatter(COORDINATE threat, bool forced=false, bool nokidding=false); 144 145 int Tiberium_Check(CELL ¢er, int x, int y); 146 bool Flag_Attach(HousesType house); 147 bool Flag_Remove(void); 148 bool Goto_Tiberium(int radius); 149 bool Harvesting(void); 150 void APC_Close_Door(void); 151 void APC_Open_Door(void); 152 153 unsigned int Apply_Temporary_Jamming_Shroud(HouseClass *house_to_apply_for); 154 void Unapply_Temporary_Jamming_Shroud(HouseClass *house_to_unapply_for, unsigned int shroud_bits_applied); 155 156 /* 157 ** Query functions. 158 */ 159 bool Should_Crush_It(TechnoClass const * it) const; 160 int Credit_Load(void) const; 161 virtual DirType Turret_Facing(void) const {if (Class->IsTurretEquipped) return(SecondaryFacing.Current());return(PrimaryFacing.Current());} 162 int Shape_Number(void) const; 163 virtual int Pip_Count(void) const; 164 virtual InfantryType Crew_Type(void) const; 165 virtual DirType Fire_Direction(void) const; 166 virtual bool Ok_To_Move(DirType facing) const; 167 virtual FireErrorType Can_Fire(TARGET target, int which) const; 168 virtual fixed Tiberium_Load(void) const; 169 virtual BuildingClass* Find_Best_Refinery(void) const; 170 171 /* 172 ** Coordinate inquiry functions. These are used for both display and 173 ** combat purposes. 174 */ 175 virtual COORDINATE Sort_Y(void) const; 176 177 /* 178 ** Object entry and exit from the game system. 179 */ 180 virtual bool Limbo(void); 181 virtual bool Unlimbo(COORDINATE , DirType facing=DIR_N); 182 183 /* 184 ** Display and rendering support functionality. Supports imagery and how 185 ** object interacts with the map and thus indirectly controls rendering. 186 */ 187 virtual short const * Overlap_List(bool redraw=false) const; 188 virtual void Draw_It(int x, int y, WindowNumberType window) const; 189 190 /* 191 ** User I/O. 192 */ 193 virtual ActionType What_Action(CELL cell) const; 194 virtual ActionType What_Action(ObjectClass const * object) const; 195 virtual void Active_Click_With(ActionType action, ObjectClass * object); 196 virtual void Active_Click_With(ActionType action, CELL cell); 197 virtual void Player_Assign_Mission(MissionType mission, TARGET target, TARGET destination); 198 199 /* 200 ** Combat related. 201 */ 202 virtual ResultType Take_Damage(int & damage, int distance, WarheadType warhead, TechnoClass * source=0, bool forced=false); 203 virtual BulletClass * Fire_At(TARGET target, int which=0); 204 205 /* 206 ** Driver control support functions. These are used to control cell 207 ** occupation flags and driver instructions. 208 */ 209 virtual bool Start_Driver(COORDINATE & coord); 210 211 /* 212 ** AI. 213 */ 214 virtual TARGET Greatest_Threat(ThreatType threat) const; 215 virtual DirType Desired_Load_Dir(ObjectClass * passenger, CELL & moveto) const; 216 virtual RadioMessageType Receive_Message(RadioClass * from, RadioMessageType message, long & param); 217 virtual void AI(void); 218 virtual int Mission_Guard_Area(void); 219 virtual int Mission_Unload(void); 220 virtual int Mission_Guard(void); 221 virtual int Mission_Harvest(void); 222 virtual int Mission_Hunt(void); 223 virtual int Mission_Repair(void); 224 virtual int Mission_Move(void); 225 virtual int Mission_Enter(void); 226 void Rotation_AI(void); 227 void Firing_AI(void); 228 void Reload_AI(void); 229 bool Edge_Of_World_AI(void); 230 231 /* 232 ** Scenario and debug support. 233 */ 234 #ifdef CHEAT_KEYS 235 virtual void Debug_Dump(MonoClass *mono) const; 236 #endif 237 238 /* 239 ** Movement and animation. 240 */ 241 virtual void Assign_Destination(TARGET target); 242 virtual void Overrun_Square(CELL cell, bool threaten=true); 243 virtual void Approach_Target(void); 244 virtual int Offload_Tiberium_Bail(void); 245 virtual void Enter_Idle_Mode(bool initial=false); 246 virtual MoveType Can_Enter_Cell(CELL cell, FacingType facing=FACING_NONE) const; 247 virtual void Per_Cell_Process(PCPType why); 248 void Exit_Repair(void); 249 void Shroud_Regen(void); 250 251 /* 252 ** File I/O. 253 */ 254 static void Read_INI(CCINIClass & ini); 255 static void Write_INI(CCINIClass & ini); 256 static char *INI_Name(void) {return "UNITS";}; 257 bool Load(Straw & file); 258 bool Save(Pipe & file) const; 259 }; 260 261 #endif