FOOT.H 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. /*
  2. ** Command & Conquer(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: F:\projects\c&c\vcs\code\foot.h_v 2.20 16 Oct 1995 16:47:14 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 : FOOT.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 FOOT_H
  37. #define FOOT_H
  38. #include "target.h"
  39. #include "type.h"
  40. #include "techno.h"
  41. #include "ftimer.h"
  42. class UnitClass;
  43. class BuildingClass;
  44. /****************************************************************************
  45. ** Movable objects are handled by this class definition. Moveable objects
  46. ** cover everything except buildings.
  47. */
  48. class FootClass : public TechnoClass
  49. {
  50. public:
  51. /*
  52. ** If this unit has officially joined the team's group, then this flag is
  53. ** true. A newly assigned unit to a team is not considered part of the
  54. ** team until it actually reaches the location where the team is. By
  55. ** using this flag, it allows a team to continue to intelligently attack
  56. ** a target without falling back to regroup the moment a distant member
  57. ** joins.
  58. */
  59. unsigned IsInitiated:1;
  60. /*
  61. ** When the player gives this object a navigation target AND that target
  62. ** does not result in any movement of the unit, then a beep should be
  63. ** sounded. This typically occurs when selecting an invalid location for
  64. ** movement. This flag is cleared if any movement was able to be performed.
  65. ** It never gets set for computer controlled units.
  66. */
  67. unsigned IsNewNavCom:1;
  68. /*
  69. ** There are certain cases where a unit should perform a full scan rather than
  70. ** the more efficient "ring scan". This situation occurs when a unit first
  71. ** appears on the map or when it finishes a multiple cell movement track.
  72. */
  73. unsigned IsPlanningToLook:1;
  74. /*
  75. ** Certain units have the ability to metamorphize into a building. When this
  76. ** operation begins, certain processes must occur. During these operations, this
  77. ** flag will be true. This ensures that any necessary special case code gets
  78. ** properly executed for this unit.
  79. */
  80. unsigned IsDeploying:1;
  81. /*
  82. ** This flag tells the system that the unit is doing a firing animation. This is
  83. ** critical to the firing logic.
  84. */
  85. unsigned IsFiring:1;
  86. /*
  87. ** This unit could be either rotating its body or rotating its turret. During the
  88. ** process of rotation, this flag is set. By examining this flag, unnecessary logic
  89. ** can be avoided.
  90. */
  91. unsigned IsRotating:1;
  92. /*
  93. ** If this object is current driving to a short range destination, this flag is
  94. ** true. A short range destination is either the next cell or the end of the
  95. ** current "curvy" track. An object that is driving is not allowed to do anything
  96. ** else until it reaches its destination. The exception is when infantry wish to
  97. ** head to a different destination, they are allowed to start immediately.
  98. */
  99. unsigned IsDriving:1;
  100. /*
  101. ** If this object is unloading from a hover transport, then this flag will be
  102. ** set to true. This handles the unusual case of an object disembarking from the
  103. ** hover lander yet not necessarily tethered but still located in an overlapping
  104. ** position. This flag will be cleared automatically when the object moves to the
  105. ** center of a cell.
  106. */
  107. unsigned IsUnloading:1;
  108. /*
  109. ** This is the "throttle setting" of the unit. It is a fractional value with 0 = stop
  110. ** and 255 = full speed.
  111. */
  112. unsigned char const Speed;
  113. /*
  114. ** For units in area guard mode, this is the recorded home position. The guarding
  115. ** unit will try to stay near this location in the course of it's maneuvers. This is
  116. ** also used to record a pending transport for those passengers that are waiting for
  117. ** the transport to become available. It is also used by harvesters so that they know
  118. ** where to head back to after unloading.
  119. */
  120. TARGET ArchiveTarget;
  121. /*
  122. **
  123. ** This is the desired destination of the unit. The unit will attempt to head
  124. ** toward this target (avoiding intervening obstacles).
  125. */
  126. TARGET NavCom;
  127. TARGET SuspendedNavCom;
  128. /*
  129. ** This points to the team that "owns" this object. This pointer is used to
  130. ** quickly process the team when this object is the source of the change. An
  131. ** example would be if this object were to be destroyed, it would inform the
  132. ** team of this fact by using this pointer.
  133. */
  134. TeamClass * Team;
  135. /*
  136. ** If this object is part of a pseudo-team that the player is managing, then
  137. ** this will be set to the team number (0 - 9). If it is not part of any
  138. ** pseudo-team, then the number will be -1.
  139. */
  140. unsigned char Group;
  141. /*
  142. ** This points to the next member in the team that this object is part of. This
  143. ** is used to quickly process each team member when the team class is the source
  144. ** of the change. An example would be if the team decided that everyone is going
  145. ** to move to a new location, it would inform each of the objects by chaining
  146. ** through this pointer.
  147. */
  148. FootClass * Member;
  149. /*
  150. ** Since all objects derived from this class move according to a path list.
  151. ** This is the path list. It specifies, as a simple list of facings, the
  152. ** path that the object should follow in order to reach its destination.
  153. ** This path list is limited in size, so it might require several generations
  154. ** of path lists before the ultimate destination is reached. The game logic
  155. ** handles regenerating the path list as necessary.
  156. */
  157. FacingType Path[CONQUER_PATH_MAX];
  158. /*
  159. ** When there is a complete findpath failure, this timer is initialized so
  160. ** that a findpath won't be calculated until this timer expires.
  161. */
  162. TCountDownTimerClass PathDelay;
  163. enum {PATH_DELAY=15,PATH_RETRY=10};
  164. int TryTryAgain; // Number of retry attempts remaining.
  165. /*
  166. ** If the object has recently attacked a base, then this timer will not
  167. ** have expired yet. It is used so a building does not keep calling
  168. ** for help from the same attacker.
  169. */
  170. TCountDownTimerClass BaseAttackTimer;
  171. /*---------------------------------------------------------------------
  172. ** Constructors, Destructors, and overloaded operators.
  173. */
  174. FootClass(void);
  175. virtual ~FootClass(void);
  176. FootClass(HousesType house);
  177. /*---------------------------------------------------------------------
  178. ** Member function prototypes.
  179. */
  180. bool Basic_Path(void);
  181. virtual RadioMessageType Receive_Message(RadioClass * from, RadioMessageType message, long & param);
  182. virtual bool Can_Demolish(void) const;
  183. /*
  184. ** Coordinate inquiry functions. These are used for both display and
  185. ** combat purposes.
  186. */
  187. virtual COORDINATE Sort_Y(void) const;
  188. virtual COORDINATE Likely_Coord(void) const;
  189. /*
  190. ** Driver control support functions. These are used to control cell
  191. ** occupation flags and driver instructions.
  192. */
  193. COORDINATE Head_To_Coord(void) const {return (HeadToCoord);};
  194. virtual bool Start_Driver(COORDINATE &headto);
  195. virtual bool Stop_Driver(void);
  196. virtual void Assign_Destination(TARGET target);
  197. /*
  198. ** Display and rendering support functionality. Supports imagery and how
  199. ** object interacts with the map and thus indirectly controls rendering.
  200. */
  201. virtual bool Unlimbo(COORDINATE , DirType dir = DIR_N);
  202. virtual bool Limbo(void);
  203. virtual bool Mark(MarkType mark);
  204. /*
  205. ** User I/O.
  206. */
  207. virtual void Active_Click_With(ActionType action, ObjectClass * object);
  208. virtual void Active_Click_With(ActionType action, CELL cell);
  209. /*
  210. ** Combat related.
  211. */
  212. virtual void Stun(void);
  213. virtual ResultType Take_Damage(int & damage, int distance, WarheadType warhead, TechnoClass * source=0);
  214. virtual void Death_Announcement(TechnoClass const * source=0) const;
  215. /*
  216. ** AI.
  217. */
  218. virtual void Sell_Back(int control);
  219. virtual int Offload_Tiberium_Bail(void);
  220. virtual TARGET Greatest_Threat(ThreatType method) const;
  221. virtual void Detach(TARGET target, bool all);
  222. virtual void Detach_All(bool all=true);
  223. virtual void Assign_Mission(MissionType order);
  224. virtual int Mission_Enter(void);
  225. virtual int Mission_Move(void);
  226. virtual int Mission_Capture(void);
  227. virtual int Mission_Attack(void);
  228. virtual int Mission_Guard(void);
  229. virtual int Mission_Hunt(void);
  230. virtual int Mission_Timed_Hunt(void);
  231. virtual int Mission_Guard_Area(void);
  232. /*
  233. ** Scenario and debug support.
  234. */
  235. #ifdef CHEAT_KEYS
  236. virtual void Debug_Dump(MonoClass *mono) const;
  237. #endif
  238. /*
  239. ** Movement and animation.
  240. */
  241. virtual void Per_Cell_Process(bool center);
  242. virtual void Approach_Target(void);
  243. virtual void Fixup_Path(PathType *) {};
  244. virtual void Set_Speed(int speed);
  245. virtual MoveType Can_Enter_Cell(CELL , FacingType =FACING_NONE) const;
  246. int Optimize_Moves(PathType *path, MoveType threshhold);
  247. virtual void Override_Mission(MissionType mission, TARGET tarcom, TARGET navcom);
  248. virtual bool Restore_Mission(void);
  249. /*
  250. ** File I/O.
  251. */
  252. virtual void Code_Pointers(void);
  253. virtual void Decode_Pointers(void);
  254. CELL Safety_Point(CELL src, CELL dst, int start, int max);
  255. int Rescue_Mission(TARGET tarcom);
  256. private:
  257. int Passable_Cell(CELL cell, FacingType face, int threat, MoveType threshhold);
  258. PathType * Find_Path(CELL dest, FacingType *final_moves, int maxlen, MoveType threshhold);
  259. void Debug_Draw_Map(char *txt, CELL start, CELL dest, bool pause);
  260. void Debug_Draw_Path(PathType *path);
  261. bool Follow_Edge(CELL start, CELL target, PathType *path, FacingType search, FacingType olddir, int threat, int threat_stage, int max_cells, MoveType threshhold);
  262. bool Register_Cell(PathType *path, CELL cell, FacingType dir, int cost, MoveType threshhold);
  263. bool Unravel_Loop(PathType *path, CELL &cell, FacingType &dir, int sx, int sy, int dx, int dy, MoveType threshhold);
  264. /*
  265. ** This is the coordinate that the unit is heading to
  266. ** as an immediate destination. This coordinate is never further
  267. ** than once cell (or track) from the unit's location. When this coordinate
  268. ** is reached, then the next location in the path list becomes the
  269. ** next HeadTo coordinate.
  270. */
  271. COORDINATE HeadToCoord;
  272. };
  273. #endif