AIRCRAFT.H 9.8 KB

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