TECHNO.H 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  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. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
  9. // in the hope that it will be useful, but with permitted additional restrictions
  10. // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
  11. // distributed with this program. You should have received a copy of the
  12. // GNU General Public License along with permitted additional restrictions
  13. // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
  14. /* $Header: /CounterStrike/TECHNO.H 1 3/03/97 10:25a Joe_bostic $ */
  15. /***********************************************************************************************
  16. *** 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 ***
  17. ***********************************************************************************************
  18. * *
  19. * Project Name : Command & Conquer *
  20. * *
  21. * File Name : TECHNO.H *
  22. * *
  23. * Programmer : Joe L. Bostic *
  24. * *
  25. * Start Date : April 14, 1994 *
  26. * *
  27. * Last Update : April 14, 1994 [JLB] *
  28. * *
  29. *---------------------------------------------------------------------------------------------*
  30. * Functions: *
  31. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  32. #ifndef TECHNO_H
  33. #define TECHNO_H
  34. #include "radio.h"
  35. #include "stage.h"
  36. #include "cargo.h"
  37. #include "flasher.h"
  38. #include "house.h"
  39. #include "target.h"
  40. #include "bullet.h"
  41. #include "door.h"
  42. #include "crew.h"
  43. /****************************************************************************
  44. ** This is the common data between building and units.
  45. */
  46. class TechnoClass : public RadioClass,
  47. public FlasherClass,
  48. public StageClass,
  49. public CargoClass,
  50. public DoorClass
  51. {
  52. public:
  53. CrewClass Crew;
  54. /*
  55. ** If this techno object has detected that it has outlived its
  56. ** purpose, then this flag will be true. Such object will either
  57. ** be sold or sacrificed at the first opportunity.
  58. */
  59. unsigned IsUseless:1;
  60. /*
  61. ** This flag will be true if the object has been damaged with malice.
  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 malice.
  65. */
  66. unsigned IsTickedOff:1;
  67. /*
  68. ** If this object has inherited the ability to cloak, then this bit will
  69. ** be set to true.
  70. */
  71. unsigned IsCloakable:1;
  72. /*
  73. ** If this object is designated as special then this flag will be true. For
  74. ** buildings, this means that it is the primary factory. For units, it means
  75. ** that the unit is the team leader.
  76. */
  77. unsigned IsLeader:1;
  78. /*
  79. ** Certain units are flagged as "loaners". These units are typically transports that
  80. ** are created solely for the purpose of delivering reinforcements. Such "loaner"
  81. ** units are not owned by the player and thus cannot be directly controlled. These
  82. ** units will leave the game as soon as they have fulfilled their purpose.
  83. */
  84. unsigned IsALoaner:1;
  85. /*
  86. ** Once a unit enters the map, then this flag is set. This flag is used to make
  87. ** sure that a unit doesn't leave the map once it enters the map.
  88. */
  89. unsigned IsLocked:1;
  90. /*
  91. ** Buildings and units with turrets usually have a recoil animation when they
  92. ** fire. If this flag is true, then the next rendering of the object will be
  93. ** in the "recoil state". The flag will then be cleared pending the next
  94. ** firing event.
  95. */
  96. unsigned IsInRecoilState:1;
  97. /*
  98. ** If this unit is "loosely attached" to another unit it is given special
  99. ** processing. A unit is in such a condition when it is in the process of
  100. ** unloading from a transport type object. During the unloading process
  101. ** the transport object must stay still until the unit is free and clear.
  102. ** At that time it radios the transport object and the "tether" is broken -
  103. ** freeing both the unit and the transport object.
  104. */
  105. unsigned IsTethered:1;
  106. /*
  107. ** Is this object owned by the player? If not, then it is owned by the computer
  108. ** or remote opponent. This flag facilitates the many logic differences when dealing
  109. ** with player's or computer's units or buildings.
  110. */
  111. unsigned IsOwnedByPlayer:1;
  112. /*
  113. ** The more sophisticated game objects must keep track of whether they are discovered
  114. ** or not. This is because the state of discovery can often control how the object
  115. ** behaves. In addition, this fact is used in radar and user I/O processing.
  116. */
  117. unsigned IsDiscoveredByPlayer:1;
  118. /*
  119. ** This is used to control the computer recognizing this object.
  120. */
  121. unsigned IsDiscoveredByComputer:1;
  122. /*
  123. ** Some game objects can be of the "lemon" variety. This means that they take damage
  124. ** even when everything is ok. This adds a little variety to the game.
  125. */
  126. unsigned IsALemon:1;
  127. /*
  128. ** This flag is used to control second shot processing for those units or buildings
  129. ** that fire two shots in quick succession. When this flag is true, it indicates that
  130. ** the second shot is ready to fire. After this shot is fired, regular rearm timing
  131. ** is used rather than the short rearm time.
  132. */
  133. unsigned IsSecondShot:1;
  134. /*
  135. ** This is the firepower and armor modifiers for this techno object. Normally,
  136. ** these values are fixed at 0x0100, but they can be modified by certain
  137. ** crate powerups.
  138. */
  139. fixed ArmorBias;
  140. fixed FirepowerBias;
  141. /*
  142. ** Idle animations (if any are supported by the object type) are regulated by
  143. ** this timer. When the timer expires an idle animation occurs. Then the
  144. ** timer is reinitialized to some random (bounded) setting.
  145. */
  146. CDTimerClass<FrameTimerClass> IdleTimer;
  147. /*
  148. ** This timer keeps track of how long the unit is under the influence
  149. ** of the iron curtain.
  150. */
  151. CDTimerClass<FrameTimerClass> IronCurtainCountDown;
  152. /*
  153. ** This is a list of bits of which houses are spying on this building,
  154. ** if in fact this is a building.
  155. */
  156. unsigned SpiedBy;
  157. /*
  158. ** For units in area guard mode, this is the recorded home position. The guarding
  159. ** unit will try to stay near this location in the course of it's maneuvers. This is
  160. ** also used to record a pending transport for those passengers that are waiting for
  161. ** the transport to become available. It is also used by harvesters so that they know
  162. ** where to head back to after unloading.
  163. */
  164. TARGET ArchiveTarget;
  165. /*
  166. ** This is the house that the unit belongs to.
  167. */
  168. CCPtr<HouseClass> House;
  169. /*
  170. ** This records the current cloak state for this vehicle.
  171. */
  172. CloakType Cloak;
  173. StageClass CloakingDevice;
  174. CDTimerClass<FrameTimerClass> CloakDelay;
  175. /* (Targeting Computer)
  176. ** This is the target value for the item that this vehicle should ATTACK. If this
  177. ** is a vehicle with a turret, then it may differ from its movement destination.
  178. */
  179. TARGET TarCom;
  180. TARGET SuspendedTarCom;
  181. /*
  182. ** This is the visible facing for the unit or building.
  183. */
  184. FacingClass PrimaryFacing;
  185. /*
  186. ** This is the arming countdown. It represents the time necessary
  187. ** to reload the weapon.
  188. */
  189. CDTimerClass<FrameTimerClass> Arm;
  190. /*
  191. ** The number of shot this object can fire before running out of ammo. If this
  192. ** value is zero, then firing is not allowed. If -1, then there is no ammunition
  193. ** limit.
  194. */
  195. int Ammo;
  196. /*
  197. ** Used by the tesla to handle electric zap
  198. */
  199. int ElectricZapDelay;
  200. COORDINATE ElectricZapTarget;
  201. int ElectricZapWhich;
  202. /*
  203. ** This is the amount of money spent to produce this object. This value really
  204. ** only comes into play for the case of buildings that have special "free"
  205. ** objects available when purchased at the more expensive rate.
  206. */
  207. int PurchasePrice;
  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. ** Some additional padding in case we need to add data to the class and maintain backwards compatibility for save/load
  214. */
  215. unsigned char SaveLoadPadding[16];
  216. /*---------------------------------------------------------------------
  217. ** Constructors, Destructors, and overloaded operators.
  218. */
  219. TechnoClass(RTTIType rtti, int id, HousesType house=HOUSE_NONE);
  220. #ifdef FIXIT_MULTI_SAVE
  221. TechnoClass(NoInitClass const & x) : RadioClass(x), FlasherClass(x), StageClass(x), CargoClass(x), DoorClass(x), IdleTimer(x), IronCurtainCountDown(x), House(x), Crew(x), CloakDelay(x), PrimaryFacing(x), Arm(x) {};
  222. #else
  223. TechnoClass(NoInitClass const & x) : RadioClass(x), FlasherClass(x), StageClass(x), CargoClass(x), DoorClass(x), IronCurtainCountDown(x), House(x), Crew(x), CloakDelay(x), PrimaryFacing(x), Arm(x) {};
  224. #endif
  225. virtual ~TechnoClass(void) {House=0;};
  226. /*
  227. ** Query functions.
  228. */
  229. bool Is_Allowed_To_Retaliate(TechnoClass const * source) const;
  230. bool Can_Teleport_Here(CELL cell) const;
  231. bool Is_In_Same_Zone(CELL cell) const;
  232. virtual bool Is_Players_Army(void) const;
  233. int Combat_Damage(int which=-1) const;
  234. bool Is_Ready_To_Cloak(void) const;
  235. virtual int How_Many_Survivors(void) const;
  236. virtual DirType Turret_Facing(void) const {return(PrimaryFacing.Current());}
  237. CELL Nearby_Location(TechnoClass const * from=NULL, int locationmod=0) const;
  238. TechnoTypeClass * Techno_Type_Class(void) const {return((TechnoTypeClass *)&Class_Of());};
  239. bool Is_Visible_On_Radar(void) const;
  240. int Anti_Air(void) const;
  241. int Anti_Armor(void) const;
  242. int Anti_Infantry(void) const;
  243. int What_Weapon_Should_I_Use(TARGET target) const;
  244. virtual ActionType What_Action(CELL cell) const;
  245. virtual ActionType What_Action(ObjectClass const * target) const;
  246. virtual BuildingClass * Find_Docking_Bay(StructType b, bool friendly) const;
  247. virtual CELL Find_Exit_Cell(TechnoClass const * techno) const;
  248. virtual FireDataType Fire_Data(int) const;
  249. virtual COORDINATE Fire_Coord(int which) const;
  250. virtual DirType Desired_Load_Dir(ObjectClass * , CELL & moveto) const;
  251. virtual DirType Fire_Direction(void) const;
  252. virtual HousesType Owner(void) const;
  253. virtual InfantryType Crew_Type(void) const;
  254. virtual bool Can_Player_Fire(void) const;
  255. virtual bool Can_Player_Move(void) const;
  256. virtual bool Is_Allowed_To_Recloak(void) const;
  257. virtual bool Can_Repair(void) const;
  258. virtual bool Is_Weapon_Equipped(void) const;
  259. virtual fixed Tiberium_Load(void) const;
  260. virtual int Pip_Count(void) const;
  261. virtual int Rearm_Delay(bool second=true, int which=0) const;
  262. virtual int Refund_Amount(void) const;
  263. virtual int Risk(void) const;
  264. virtual int Threat_Range(int control) const;
  265. virtual int Value(void) const;
  266. virtual int Get_Ownable(void) const;
  267. /*
  268. ** User I/O.
  269. */
  270. virtual void Clicked_As_Target(HousesType house, int count = 7); // 2019/09/20 JAS - Added record of who clicked on the object
  271. virtual bool Select(bool allow_mixed = false);
  272. virtual void Response_Select(void);
  273. virtual void Response_Move(void);
  274. virtual void Response_Attack(void);
  275. virtual void Player_Assign_Mission(MissionType order, TARGET target=TARGET_NONE, TARGET destination=TARGET_NONE);
  276. /*
  277. ** Combat related.
  278. */
  279. fixed Area_Modify(CELL cell) const;
  280. virtual int Made_A_Kill(void) {return(Crew.Made_A_Kill());}
  281. void Base_Is_Attacked(TechnoClass const *enemy);
  282. void Kill_Cargo(TechnoClass * source);
  283. virtual void Record_The_Kill(TechnoClass * source);
  284. virtual bool Target_Something_Nearby(ThreatType threat=THREAT_NORMAL);
  285. virtual void Stun(void);
  286. virtual bool In_Range(COORDINATE coord, int which=0) const;
  287. virtual bool In_Range(TARGET target, int which=0, bool reciprocal_check = true) const;
  288. virtual bool In_Range(ObjectClass const * target, int which=0, bool reciprocal_check = true) const;
  289. virtual void Death_Announcement(TechnoClass const * source=0) const = 0;
  290. virtual FireErrorType Can_Fire(TARGET target, int which=0) const;
  291. virtual TARGET Greatest_Threat(ThreatType threat) const;
  292. virtual void Assign_Target(TARGET target);
  293. virtual void Override_Mission(MissionType mission, TARGET tarcom, TARGET navcom);
  294. virtual bool Restore_Mission(void);
  295. virtual BulletClass * Fire_At(TARGET target, int which=0);
  296. virtual int Weapon_Range(int which) const;
  297. virtual bool Captured(HouseClass * newowner);
  298. virtual ResultType Take_Damage(int & damage, int distance, WarheadType warhead, TechnoClass * source=0, bool forced=false);
  299. bool Evaluate_Cell(ThreatType method, int mask, CELL cell, int range, TechnoClass const ** object, int & value, int zone=0) const;
  300. bool Evaluate_Object(ThreatType method, int mask, int range, TechnoClass const * object, int & value, int zone=-1) const;
  301. int Evaluate_Just_Cell(CELL cell) const;
  302. virtual bool Electric_Zap (COORDINATE target_coord, int which, WindowNumberType window, COORDINATE source_coord=0L, unsigned char * remap=NULL) const;
  303. bool Is_Cloaked(HousesType house, bool check_invisible=false) const;
  304. bool Is_Cloaked(HouseClass const * house, bool check_invisible=false) const;
  305. bool Is_Cloaked(ObjectClass const * object, bool check_invisible=false) const;
  306. /*
  307. ** AI.
  308. */
  309. virtual void Renovate(void);
  310. virtual void AI(void);
  311. virtual bool Revealed(HouseClass * house);
  312. virtual RadioMessageType Receive_Message(RadioClass * from, RadioMessageType message, long & param);
  313. void Cloaking_AI(void);
  314. /*
  315. ** Scenario and debug support.
  316. */
  317. #ifdef CHEAT_KEYS
  318. virtual void Debug_Dump(MonoClass *mono) const;
  319. #endif
  320. /*
  321. ** File I/O.
  322. */
  323. virtual void Code_Pointers(void);
  324. virtual void Decode_Pointers(void);
  325. /*
  326. ** Display and rendering support functionality. Supports imagery and how
  327. ** object interacts with the map and thus indirectly controls rendering.
  328. */
  329. virtual void const * Remap_Table(void) const;
  330. VisualType Visual_Character(bool raw = false) const;
  331. void Techno_Draw_Object(void const * shapefile, int shapenum, int x, int y, WindowNumberType window, DirType rotation=DIR_N, int scale=0x0100) const;
  332. // Added. ST - 8/1/2019 5:37PM
  333. void Techno_Draw_Object_Virtual(void const * shapefile, int shapenum, int x, int y, WindowNumberType window, DirType rotation=DIR_N, int scale=0x0100, const char *shape_name = NULL) const;
  334. virtual void Draw_It(int x, int y, WindowNumberType window) const;
  335. virtual void Draw_Pips(int x, int y, WindowNumberType window) const;
  336. virtual void Hidden(void);
  337. virtual bool Mark(MarkType mark=MARK_CHANGE);
  338. virtual int Exit_Object(TechnoClass *);
  339. virtual void Do_Uncloak(void);
  340. virtual void Do_Cloak(void);
  341. virtual void Do_Shimmer(void);
  342. /*
  343. ** Movement and animation.
  344. */
  345. virtual bool Is_Ready_To_Random_Animate(void) const;
  346. virtual bool Random_Animate(void) {return(false);}
  347. virtual void Assign_Destination(TARGET target);
  348. virtual void Per_Cell_Process(PCPType why);
  349. virtual void Enter_Idle_Mode(bool initial=false);
  350. virtual void Look(bool incremental=false);
  351. /*
  352. ** Map entry and exit logic.
  353. */
  354. virtual bool Unlimbo(COORDINATE , DirType facing=DIR_N);
  355. virtual void Detach(TARGET target, bool all);
  356. /*
  357. ** New functions for per-player discovery for multiplayer. ST - 3/6/2019 11:17AM
  358. */
  359. bool Is_Discovered_By_Player(HouseClass *player = NULL) const;
  360. void Set_Discovered_By_Player(HouseClass *player = NULL);
  361. void Clear_Discovered_By_Players();
  362. bool Is_Owned_By_Player(HouseClass *player = NULL) const;
  363. virtual unsigned Spied_By() const;
  364. /*
  365. ** Facing translation tables that fix the flaw with 3D studio when
  366. ** it renders 45 degree angles.
  367. */
  368. static int const BodyShape[32];
  369. };
  370. #endif