TECHNO.H (14338B)
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\techno.h_v 2.17 16 Oct 1995 16:46:58 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 : TECHNO.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 TECHNO_H 36 #define TECHNO_H 37 38 #include "radio.h" 39 #include "stage.h" 40 #include "cargo.h" 41 #include "flasher.h" 42 #include "house.h" 43 #include "target.h" 44 #include "bullet.h" 45 #include "door.h" 46 #include "crew.h" 47 48 /**************************************************************************** 49 ** This is the common data between building and units. 50 */ 51 class TechnoClass : public RadioClass, 52 public FlasherClass, 53 public StageClass, 54 public CargoClass, 55 public DoorClass, 56 public CrewClass 57 { 58 public: 59 60 /* 61 ** This flag will be true if the object has been damaged with malace. 62 ** Damage received due to friendly fire or wear and tear does not count. 63 ** The computer is not allowed to sell a building unless it has been 64 ** damaged with malace. 65 */ 66 unsigned IsTickedOff:1; 67 68 /* 69 ** If this object has inherited the ability to cloak, then this bit will 70 ** be set to true. 71 */ 72 unsigned IsCloakable:1; 73 74 /* 75 ** If this object is designated as special then this flag will be true. For 76 ** buildings, this means that it is the primary factory. For units, it means 77 ** that the unit is the team leader. 78 */ 79 unsigned IsLeader:1; 80 81 /* 82 ** Certain units are flagged as "loaners". These units are typically transports that 83 ** are created solely for the purpose of delivering reinforcements. Such "loaner" 84 ** units are not owned by the player and thus cannot be directly controlled. These 85 ** units will leave the game as soon as they have fulfilled their purpose. 86 */ 87 unsigned IsALoaner:1; 88 89 /* 90 ** Once a unit enters the map, then this flag is set. This flag is used to make 91 ** sure that a unit doesn't leave the map once it enters the map. 92 */ 93 unsigned IsLocked:1; 94 95 /* 96 ** Buildings and units with turrets usually have a recoil animation when they 97 ** fire. If this flag is true, then the next rendering of the object will be 98 ** in the "recoil state". The flag will then be cleared pending the next 99 ** firing event. 100 */ 101 unsigned IsInRecoilState:1; 102 103 /* 104 ** If this unit is "loosely attached" to another unit it is given special 105 ** processing. A unit is in such a condition when it is in the process of 106 ** unloading from a transport type object. During the unloading process 107 ** the transport object must stay still until the unit is free and clear. 108 ** At that time it radios the transport object and the "tether" is broken - 109 ** freeing both the unit and the transport object. 110 */ 111 unsigned IsTethered:1; 112 113 /* 114 ** Is this object owned by the player? If not, then it is owned by the computer 115 ** or remote opponent. This flag facilitates the many logic differences when dealing 116 ** with player's or computer's units or buildings. 117 */ 118 unsigned IsOwnedByPlayer:1; 119 120 /* 121 ** The more sophisticated game objects must keep track of whether they are discovered 122 ** or not. This is because the state of discovery can often control how the object 123 ** behaves. In addition, this fact is used in radar and user I/O processing. 124 */ 125 unsigned IsDiscoveredByPlayer:1; 126 127 /* 128 ** This is used to control the computer recognizing this object. 129 */ 130 unsigned IsDiscoveredByComputer:1; 131 132 /* 133 ** Some game objects can be of the "lemon" variety. This means that they take damage 134 ** even when everything is ok. This adds a little variety to the game. 135 */ 136 unsigned IsALemon:1; 137 138 /* 139 ** This flag is used to control second shot processing for those units or buildings 140 ** that fire two shots in quick succession. When this flag is true, it indicates that 141 ** the second shot is ready to fire. After this shot is fired, regular rearm timing 142 ** is used rather than the short rearm time. 143 */ 144 unsigned IsSecondShot:1; 145 146 /* 147 ** For units in area guard mode, this is the recorded home position. The guarding 148 ** unit will try to stay near this location in the course of it's maneuvers. This is 149 ** also used to record a pending transport for those passengers that are waiting for 150 ** the transport to become available. It is also used by harvesters so that they know 151 ** where to head back to after unloading. 152 */ 153 TARGET ArchiveTarget; 154 155 /* 156 ** This is the house that the unit belongs to. 157 */ 158 HouseClass * House; 159 160 /* 161 ** This records the current cloak state for this vehicle. 162 */ 163 CloakType Cloak; 164 StageClass CloakingDevice; 165 166 /* (Targeting Computer) 167 ** This is the target value for the item that this vehicle should ATTACK. If this 168 ** is a vehicle with a turret, then it may differ from its movement destination. 169 */ 170 TARGET TarCom; 171 TARGET SuspendedTarCom; 172 173 /* 174 ** This is the visible facing for the unit or building. 175 */ 176 FacingClass PrimaryFacing; 177 178 /* 179 ** This is the arming countdown. It represents the time necessary 180 ** to reload the weapon. 181 */ 182 unsigned char Arm; 183 184 /* 185 ** The number of shot this object can fire before running out of ammo. If this 186 ** value is zero, then firing is not allowed. If -1, then there is no ammunition 187 ** limit. 188 */ 189 int Ammo; 190 191 /* 192 ** Used by the Obelisk laser to cache its laser weapon rendering data. 193 ** Line data is cleared after the specified delay. 194 ** Each line consists of: x, y, x1, y1, color, frame (max frame used to determine duration) 195 */ 196 int Lines[3][5]; 197 int LineCount; 198 int LineFrame; 199 int LineMaxFrames; 200 201 /* 202 ** This is the amount of money spent to produce this object. This value really 203 ** only comes into play for the case of buildings that have special "free" 204 ** objects available when purchased at the more expensive rate. 205 */ 206 int PurchasePrice; 207 208 /* 209 ** Per-player view of whether a techno object is discovered. One bit for each house type. ST - 3/6/2019 11:15AM 210 */ 211 unsigned int IsDiscoveredByPlayerMask; 212 213 /* 214 ** Some additional padding in case we need to add data to the class and maintain backwards compatibility for save/load 215 */ 216 unsigned char SaveLoadPadding[16]; 217 218 /*--------------------------------------------------------------------- 219 ** Constructors, Destructors, and overloaded operators. 220 */ 221 TechnoClass(void); 222 TechnoClass(HousesType house); 223 virtual ~TechnoClass(void) {}; 224 225 /* 226 ** Query functions. 227 */ 228 virtual int Refund_Amount(void) const; 229 virtual CELL Find_Exit_Cell(TechnoClass const * techno) const; 230 virtual BuildingClass * Find_Docking_Bay(StructType b, bool friendly) const; 231 virtual int Threat_Range(int control) const; 232 virtual InfantryType Crew_Type(void) const; 233 TechnoTypeClass const * Techno_Type_Class(void) const {return((TechnoTypeClass const *)&Class_Of());}; 234 CELL Nearby_Location(TechnoClass const * from=NULL) const; 235 virtual unsigned char Get_Ownable(void) const; 236 virtual bool Can_Player_Fire(void) const; 237 virtual bool Can_Player_Move(void) const; 238 virtual bool Is_Weapon_Equipped(void) const; 239 virtual bool Can_Repair(void) const; 240 virtual bool Is_Techno(void) const; 241 virtual HousesType Owner(void) const; 242 virtual int Risk(void) const; 243 virtual int Value(void) const; 244 virtual int Rearm_Delay(bool second=true) const; 245 virtual ActionType What_Action(ObjectClass * target) const; 246 virtual ActionType What_Action(CELL cell) const; 247 virtual int Tiberium_Load(void) const; 248 virtual DirType Desired_Load_Dir(ObjectClass * , CELL & moveto) const; 249 virtual int Pip_Count(void) const; 250 virtual DirType Fire_Direction(void) const; 251 252 /* 253 ** User I/O. 254 */ 255 virtual void Clicked_As_Target(HousesType house, int count=7); // 2019/09/20 JAS - Added record of who clicked on the object 256 virtual bool Select(bool allow_mixed = false); 257 virtual void Response_Select(void); 258 virtual void Response_Move(void); 259 virtual void Response_Attack(void); 260 virtual void Player_Assign_Mission(MissionType order, TARGET target=TARGET_NONE, TARGET destination=TARGET_NONE); 261 262 /* 263 ** Combat related. 264 */ 265 void Base_Is_Attacked(TechnoClass const *enemy); 266 void Kill_Cargo(TechnoClass * source); 267 virtual void Record_The_Kill(TechnoClass * source); 268 virtual bool Target_Something_Nearby(ThreatType threat=THREAT_NORMAL); 269 virtual void Stun(void); 270 virtual bool In_Range(COORDINATE coord, int which=0) const; 271 virtual bool In_Range(TARGET target, int which=0, bool reciprocal_check = true) const; 272 virtual bool In_Range(ObjectClass const * target, int which=0, bool reciprocal_check = true) const; 273 virtual void Death_Announcement(TechnoClass const * source=0) const = 0; 274 virtual FireErrorType Can_Fire(TARGET target, int which=0) const; 275 virtual TARGET Greatest_Threat(ThreatType threat) const; 276 virtual void Assign_Target(TARGET target); 277 virtual void Override_Mission(MissionType mission, TARGET tarcom, TARGET navcom); 278 virtual bool Restore_Mission(void); 279 virtual BulletClass * Fire_At(TARGET target, int which=0); 280 virtual int Weapon_Range(int which) const; 281 virtual bool Captured(HouseClass * newowner); 282 virtual ResultType Take_Damage(int & damage, int distance, WarheadType warhead, TechnoClass * source); 283 bool Evaluate_Cell(ThreatType method, int mask, CELL cell, int range, TechnoClass const ** object, int & value) const; 284 bool Evaluate_Object(ThreatType method, int mask, int range, TechnoClass const * object, int & value) const; 285 bool Is_Cloaked(HousesType house) const; 286 bool Is_Cloaked(HouseClass const * house) const; 287 bool Is_Cloaked(ObjectClass const * object) const; 288 289 /* 290 ** AI. 291 */ 292 virtual void AI(void); 293 virtual bool Revealed(HouseClass * house); 294 virtual RadioMessageType Receive_Message(RadioClass * from, RadioMessageType message, long & param); 295 296 /* 297 ** Scenario and debug support. 298 */ 299 #ifdef CHEAT_KEYS 300 virtual void Debug_Dump(MonoClass *mono) const; 301 #endif 302 303 /* 304 ** File I/O. 305 */ 306 virtual void Code_Pointers(void); 307 virtual void Decode_Pointers(void); 308 309 /* 310 ** Display and rendering support functionality. Supports imagery and how 311 ** object interacts with the map and thus indirectly controls rendering. 312 */ 313 virtual void const * Remap_Table(void); 314 VisualType Visual_Character(bool raw = false); 315 void Techno_Draw_Object(void const * shapefile, int shapenum, int x, int y, WindowNumberType window); 316 317 // Added. ST - 6/20/2019 1:34PM 318 void Techno_Draw_Object_Virtual(void const * shapefile, int shapenum, int x, int y, WindowNumberType window, const char *shape_name); 319 320 virtual void Draw_It(int x, int y, WindowNumberType window); 321 virtual void Draw_Pips(int x, int y, WindowNumberType window); 322 virtual void Hidden(void); 323 virtual bool Mark(MarkType mark); 324 virtual int Exit_Object(TechnoClass *); 325 virtual void Do_Uncloak(void); 326 virtual void Do_Cloak(void); 327 virtual void Do_Shimmer(void); 328 329 /* 330 ** Movement and animation. 331 */ 332 virtual void Random_Animate(void); 333 virtual void Assign_Destination(TARGET target); 334 virtual void Scatter(COORDINATE source = NULL, bool forced=false, bool nokidding=false); 335 virtual void Per_Cell_Process(bool); 336 virtual void Enter_Idle_Mode(bool initial=false); 337 338 /* 339 ** Map entry and exit logic. 340 */ 341 virtual bool Unlimbo(COORDINATE , DirType facing=DIR_N); 342 virtual void Detach(TARGET target, bool all); 343 344 345 346 347 /* 348 ** New functions for per-player discovery for multiplayer. ST - 3/6/2019 11:17AM 349 */ 350 bool Is_Discovered_By_Player(HouseClass *player = NULL) const; 351 void Set_Discovered_By_Player(HouseClass *player = NULL); 352 void Clear_Discovered_By_Players(); 353 bool Is_Owned_By_Player(HouseClass *player = NULL) const; 354 355 356 #ifdef USE_RA_AI 357 /* 358 ** For AI, from Red Alert. ST - 7/16/2019 11:38AM 359 */ 360 int Anti_Air(void) const; 361 int Anti_Armor(void) const; 362 int Anti_Infantry(void) const; 363 #endif // USE_RA_AI 364 365 /* 366 ** Facing translation tables that fix the flaw with 3D studio when 367 ** it renders 45 degree angles. 368 */ 369 static int const BodyShape[32]; 370 // static int const TurretShape[32]; 371 372 373 }; 374 375 #endif