AIRCRAFT.H 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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/AIRCRAFT.H 1 3/03/97 10:24a 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 : AIRCRAFT.H *
  26. * *
  27. * Programmer : Joe L. Bostic *
  28. * *
  29. * Start Date : July 22, 1994 *
  30. * *
  31. * Last Update : November 28, 1994 [JLB] *
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  36. #ifndef AIRCRAFT_H
  37. #define AIRCRAFT_H
  38. #include "radio.h"
  39. #include "fly.h"
  40. #include "target.h"
  41. /*
  42. ** This aircraft class is used for all flying sentient objects. This includes fixed wing
  43. ** aircraft as well as helicopters. It excludes bullets even though some bullets might
  44. ** be considered to be "flying" in a loose interpretatin of the word.
  45. */
  46. class AircraftClass : public FootClass, public FlyClass
  47. {
  48. public:
  49. /*
  50. ** This is a pointer to the class control structure for the aircraft.
  51. */
  52. CCPtr<AircraftTypeClass> Class;
  53. //-----------------------------------------------------------------------------
  54. static void * operator new(size_t);
  55. static void * operator new(size_t, void * ptr) {return(ptr);};
  56. static void operator delete(void *);
  57. operator AircraftType(void) const {return Class->Type;};
  58. AircraftClass(AircraftType classid, HousesType house);
  59. AircraftClass(NoInitClass const & x) : FootClass(x), FlyClass(x), Class(x), SecondaryFacing(x), SightTimer(x) {};
  60. virtual ~AircraftClass(void);
  61. static void Init(void);
  62. virtual int Mission_Attack(void);
  63. virtual int Mission_Unload(void);
  64. virtual int Mission_Hunt(void);
  65. virtual int Mission_Retreat(void);
  66. virtual int Mission_Move(void);
  67. virtual int Mission_Enter(void);
  68. virtual int Mission_Guard(void);
  69. virtual int Mission_Guard_Area(void);
  70. virtual void Assign_Destination(TARGET target);
  71. /*
  72. ** State machine support routines.
  73. */
  74. bool Process_Take_Off(void);
  75. bool Process_Landing(void);
  76. int Process_Fly_To(bool slowdown, TARGET dest);
  77. /*
  78. ** Query functions.
  79. */
  80. virtual LayerType In_Which_Layer(void) const;
  81. virtual DirType Turret_Facing(void) const {return(SecondaryFacing.Current());}
  82. int Shape_Number(void) const;
  83. virtual MoveType Can_Enter_Cell(CELL cell, FacingType facing=FACING_NONE) const;
  84. virtual ObjectTypeClass const & Class_Of(void) const {return *Class;};
  85. virtual ActionType What_Action(ObjectClass const * target) const;
  86. virtual ActionType What_Action(CELL cell) const;
  87. virtual DirType Desired_Load_Dir(ObjectClass * passenger, CELL & moveto) const;
  88. virtual int Pip_Count(void) const;
  89. TARGET Good_Fire_Location(TARGET target) const;
  90. bool Cell_Seems_Ok(CELL cell, bool landing=false) const;
  91. DirType Pose_Dir(void) const;
  92. TARGET Good_LZ(void) const;
  93. virtual DirType Fire_Direction(void) const;
  94. virtual FireErrorType Can_Fire(TARGET target, int which) const;
  95. /*
  96. ** Landing zone support functionality.
  97. */
  98. virtual void Per_Cell_Process(PCPType why);
  99. bool Is_LZ_Clear(TARGET target) const;
  100. TARGET New_LZ(TARGET oldlz) const;
  101. /*
  102. ** Coordinate inquiry functions. These are used for both display and
  103. ** combat purposes.
  104. */
  105. virtual COORDINATE Sort_Y(void) const;
  106. /*
  107. ** Object entry and exit from the game system.
  108. */
  109. virtual bool Unlimbo(COORDINATE , DirType facing = DIR_N);
  110. /*
  111. ** Display and rendering support functionality. Supports imagery and how
  112. ** object interacts with the map and thus indirectly controls rendering.
  113. */
  114. virtual void Look(bool incremental=false);
  115. void Draw_Rotors(int x, int y, WindowNumberType window) const;
  116. virtual int Exit_Object(TechnoClass *);
  117. virtual short const * Overlap_List(bool redraw=false) const;
  118. virtual void Draw_It(int x, int y, WindowNumberType window) const;
  119. virtual void Set_Speed(int speed);
  120. /*
  121. ** User I/O.
  122. */
  123. virtual void Active_Click_With(ActionType action, ObjectClass * object);
  124. virtual void Active_Click_With(ActionType action, CELL cell);
  125. virtual void Player_Assign_Mission(MissionType mission, TARGET target=TARGET_NONE, TARGET destination=TARGET_NONE);
  126. virtual void Response_Select(void);
  127. virtual void Response_Move(void);
  128. virtual void Response_Attack(void);
  129. /*
  130. ** Combat related.
  131. */
  132. virtual ResultType Take_Damage(int & damage, int distance, WarheadType warhead, TechnoClass * source, bool forced=false);
  133. virtual BulletClass * Fire_At(TARGET target, int which);
  134. /*
  135. ** AI.
  136. */
  137. bool Landing_Takeoff_AI(void);
  138. bool Edge_Of_World_AI(void);
  139. void Movement_AI(void);
  140. void Rotation_AI(void);
  141. int Paradrop_Cargo(void);
  142. virtual void AI(void);
  143. virtual void Enter_Idle_Mode(bool initial = false);
  144. virtual RadioMessageType Receive_Message(RadioClass * from, RadioMessageType message, long & param);
  145. virtual void Scatter(COORDINATE threat, bool forced=false, bool nokidding=false);
  146. /*
  147. ** Scenario and debug support.
  148. */
  149. #ifdef CHEAT_KEYS
  150. virtual void Debug_Dump(MonoClass *mono) const;
  151. #endif
  152. /*
  153. ** File I/O.
  154. */
  155. static void Read_INI(CCINIClass & ini);
  156. static char * INI_Name(void) {return "AIRCRAFT";};
  157. bool Load(Straw & file);
  158. bool Save(Pipe & file) const;
  159. public:
  160. /*
  161. ** This is the facing used for the body of the aircraft. Typically, this is the same
  162. ** as the PrimaryFacing, but in the case of helicopters, it can be different.
  163. */
  164. FacingClass SecondaryFacing;
  165. /*
  166. ** If this is a passenger carrying aircraft then this flag will be set. This is
  167. ** necessary because once the passengers are unloaded, the fact that it was a
  168. ** passenger carrier must still be known.
  169. */
  170. bool Passenger;
  171. private:
  172. /*
  173. ** Aircraft can be in either state of landing, taking off, or in steady altitude.
  174. ** These flags are used to control transition between flying and landing. It is
  175. ** necessary to handle the transition in this manner so that it occurs smoothly
  176. ** during the graphic processing section.
  177. */
  178. unsigned IsLanding:1;
  179. unsigned IsTakingOff:1;
  180. /*
  181. ** It is very common for aircraft to be homing in on a target. When this flag is
  182. ** true, the aircraft will constantly adjust its facing toward the TarCom. When the
  183. ** target is very close (one cell away or less), then this flag is automatically cleared.
  184. ** This is because the homing algorithm is designed to get the aircraft to the destination
  185. ** but no more. Checking when this flag is cleared is a way of flagging transition into
  186. ** a new mode. Example: Transport helicopters go into a hovering into correct position
  187. ** mode when the target is reached.
  188. */
  189. unsigned IsHoming:1;
  190. /*
  191. ** Helicopters that are about to land must hover into a position exactly above the landing
  192. ** zone. When this flag is true, the aircraft will be adjusted so that it is exactly over
  193. ** the TarCom. The facing of the aircraft is not altered by this movement. The affect
  194. ** like the helicopter is hovering and shifting sideways to position over the landing
  195. ** zone. When the position is over the landing zone, then this flag is set to false.
  196. */
  197. unsigned IsHovering:1;
  198. /*
  199. ** This is the jitter tracker to be used when the aircraft is a helicopter and
  200. ** is flying. It is most noticeable when the helicopter is hovering.
  201. */
  202. unsigned char Jitter;
  203. private:
  204. /*
  205. ** This timer controls when the aircraft will reveal the terrain around itself.
  206. ** When this timer expires and this aircraft has a sight range, then the
  207. ** look around process will occur.
  208. */
  209. CDTimerClass<FrameTimerClass> SightTimer;
  210. /*
  211. ** Most attack aircraft can make several attack runs. This value contains the
  212. ** number of attack runs the aircraft has left. When this value reaches
  213. ** zero then the aircraft is technically out of ammo.
  214. */
  215. char AttacksRemaining;
  216. };
  217. #endif