INFANTRY.H 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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/INFANTRY.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 : INFANTRY.H *
  22. * *
  23. * Programmer : Joe L. Bostic *
  24. * *
  25. * Start Date : August 15, 1994 *
  26. * *
  27. * Last Update : August 15, 1994 [JLB] *
  28. * *
  29. *---------------------------------------------------------------------------------------------*
  30. * Functions: *
  31. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  32. #ifndef INFANTRY_H
  33. #define INFANTRY_H
  34. class InfantryClass : public FootClass
  35. {
  36. public:
  37. CCPtr<InfantryTypeClass> Class;
  38. /*
  39. ** If the infantry is undergoing some choreographed animation sequence, then
  40. ** this holds the particular sequence number. The frame of animation is kept
  41. ** track of by the regular frame tracking system. When performing an animation
  42. ** sequence, the infantry cannot perform anything else (even move).
  43. */
  44. DoType Doing;
  45. /*
  46. ** Certain infantry will either perform some comment or say something after an
  47. ** amount of time has expired subsequent to an significant event. This is the
  48. ** timer the counts down.
  49. */
  50. CDTimerClass<FrameTimerClass> Comment;
  51. /*
  52. ** If this civilian is actually a technician, then this flag will be true.
  53. ** It should only be set for the civilian type infantry. Typically, the
  54. ** technician appears after a building is destroyed.
  55. */
  56. unsigned IsTechnician:1;
  57. /*
  58. ** If the infantry just performed some feat, then it may respond with an action.
  59. ** This flag will be true if an action is to be performed when the Comment timer
  60. ** has expired.
  61. */
  62. unsigned IsStoked:1;
  63. /*
  64. ** This flag indicates if the infantry unit is prone. Prone infantry become that way
  65. ** when they are fired upon. Infantry in the prone position are less vulnerable to
  66. ** combat.
  67. */
  68. unsigned IsProne:1;
  69. /*
  70. ** If the infantry is allowed to move one cell from one zone to another, then this
  71. ** flag will be true. It exists only so that when a bridge is destroyed, the bomb
  72. ** placer is allowed to run from the destroyed bridge cell back onto a real cell.
  73. */
  74. unsigned IsZoneCheat:1;
  75. /*
  76. ** This flag is set for the dogs, when they launch into bullet mode.
  77. ** it's to remember if the unit was selected, and if it was, then
  78. ** when the dog is re-enabled, he'll reselect himself.
  79. */
  80. unsigned WasSelected:1;
  81. /*
  82. ** The fear rating of this infantry unit. The more afraid the infantry, the more
  83. ** likely it is to panic and seek cover.
  84. */
  85. FearType Fear;
  86. /*
  87. ** Track when movement last stopped.
  88. */
  89. long StopDriverFrame;
  90. /*
  91. ** Track the last cell we looked from.
  92. */
  93. CELL LookCell;
  94. /*---------------------------------------------------------------------
  95. ** Constructors, Destructors, and overloaded operators.
  96. */
  97. static void * operator new(size_t size);
  98. static void * operator new(size_t , void * ptr) {return(ptr);};
  99. static void operator delete(void *ptr);
  100. InfantryClass(InfantryType classid, HousesType house);
  101. InfantryClass(NoInitClass const & x) : FootClass(x), Class(x), Comment(x) {};
  102. virtual ~InfantryClass(void);
  103. operator InfantryType(void) const {return Class->Type;};
  104. /*---------------------------------------------------------------------
  105. ** Member function prototypes.
  106. */
  107. static void Init(void);
  108. virtual void Assign_Destination(TARGET);
  109. /*
  110. ** Query functions.
  111. */
  112. virtual bool Is_Ready_To_Random_Animate(void) const;
  113. void const * Get_Image_Data(void) const;
  114. int Shape_Number(WindowNumberType window = WINDOW_MAIN) const;
  115. virtual ObjectTypeClass const & Class_Of(void) const;
  116. virtual int Full_Name(void) const;
  117. /*
  118. ** Object entry and exit from the game system.
  119. */
  120. virtual bool Unlimbo(COORDINATE coord, DirType facing);
  121. virtual bool Paradrop(COORDINATE coord);
  122. virtual bool Limbo(void);
  123. virtual void Detach(TARGET target, bool all);
  124. /*
  125. ** Display and rendering support functionality. Supports imagery and how
  126. ** object interacts with the map and thus indirectly controls rendering.
  127. */
  128. virtual short const * Overlap_List(bool redraw = false) const;
  129. virtual void Draw_It(int x, int y, WindowNumberType window) const;
  130. /*
  131. ** User I/O.
  132. */
  133. virtual void Response_Select(void);
  134. virtual void Response_Move(void);
  135. virtual void Response_Attack(void);
  136. virtual void Active_Click_With(ActionType action, ObjectClass * object);
  137. virtual void Active_Click_With(ActionType action, CELL cell) {FootClass::Active_Click_With(action, cell);}
  138. /*
  139. ** Combat related.
  140. */
  141. virtual ActionType What_Action(ObjectClass const * object) const;
  142. virtual ActionType What_Action(CELL cell) const;
  143. virtual BulletClass * Fire_At(TARGET target, int which);
  144. virtual ResultType Take_Damage(int & damage, int distance, WarheadType warhead, TechnoClass * source=0, bool forced=false);
  145. virtual FireErrorType Can_Fire(TARGET target, int which) const;
  146. virtual COORDINATE Fire_Coord(int which) const;
  147. virtual void Assign_Target(TARGET);
  148. void Set_Occupy_Bit(COORDINATE coord) {Set_Occupy_Bit(Coord_Cell(coord), CellClass::Spot_Index(coord));};
  149. void Set_Occupy_Bit(CELL cell, int spot_index);
  150. void Clear_Occupy_Bit(COORDINATE coord) {Clear_Occupy_Bit(Coord_Cell(coord), CellClass::Spot_Index(coord));};
  151. void Clear_Occupy_Bit(CELL cell, int spot_index);
  152. /*
  153. ** Driver control support functions. These are used to control cell
  154. ** occupation flags and driver instructions.
  155. */
  156. virtual bool Stop_Driver(void);
  157. virtual bool Start_Driver(COORDINATE & coord);
  158. /*
  159. ** AI.
  160. */
  161. virtual void AI(void);
  162. void Fear_AI(void);
  163. virtual TARGET Greatest_Threat(ThreatType threat) const;
  164. virtual int Mission_Attack(void);
  165. bool Edge_Of_World_AI(void);
  166. void Firing_AI(void);
  167. void Doing_AI(void);
  168. void Movement_AI(void);
  169. /*
  170. ** Scenario and debug support.
  171. */
  172. #ifdef CHEAT_KEYS
  173. virtual void Debug_Dump(MonoClass *mono) const;
  174. #endif
  175. /*
  176. ** File I/O.
  177. */
  178. static void Read_INI(CCINIClass & ini);
  179. static void Write_INI(CCINIClass & ini);
  180. static char *INI_Name(void) {return "INFANTRY";};
  181. bool Load(Straw & file);
  182. bool Save(Pipe & file) const;
  183. /*
  184. ** Movement and animation.
  185. */
  186. virtual bool Do_Action(DoType todo, bool force=false);
  187. virtual bool Random_Animate(void);
  188. virtual MoveType Can_Enter_Cell(CELL , FacingType =FACING_NONE) const;
  189. virtual void Per_Cell_Process(PCPType why);
  190. virtual void Enter_Idle_Mode(bool initial=false);
  191. virtual void Scatter(COORDINATE threat, bool forced=false, bool nokidding=false);
  192. virtual void Look(bool incremental=false);
  193. /*
  194. ** Translation table to convert facing into infantry shape number. This special
  195. ** table is needed since several facing stages are reused and flipped about the Y
  196. ** axis.
  197. */
  198. static int const HumanShape[32];
  199. private:
  200. static DoStruct const MasterDoControls[DO_COUNT];
  201. /*
  202. ** Some additional padding in case we need to add data to the class and maintain backwards compatibility for save/load
  203. */
  204. unsigned char SaveLoadPadding[32];
  205. };
  206. #endif