INFANTRY.H 8.4 KB

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