TECHNO.H 15 KB

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