UNIT.H 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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\unit.h_v 2.19 16 Oct 1995 16:45:56 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 : UNIT.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 UNIT_H
  37. #define UNIT_H
  38. #include "tarcom.h"
  39. #include "radio.h"
  40. #include "cargo.h"
  41. #include "mission.h"
  42. #include "target.h"
  43. /****************************************************************************
  44. ** For each instance of a unit (vehicle) in the game, there is one of
  45. ** these structures. This structure holds information that is specific
  46. ** and dynamic for a particular unit.
  47. */
  48. class UnitClass : public TarComClass
  49. {
  50. public:
  51. /*
  52. ** This records the house flag that this object is currently carrying.
  53. */
  54. HousesType Flagged;
  55. /*---------------------------------------------------------------------
  56. ** Constructors, Destructors, and overloaded operators.
  57. */
  58. static void * operator new(size_t size);
  59. static void operator delete(void *ptr);
  60. UnitClass(void) {};
  61. UnitClass(UnitType classid, HousesType house);
  62. operator UnitType(void) const {return Class->Type;};
  63. virtual ~UnitClass(void);
  64. virtual RTTIType What_Am_I(void) const;
  65. /*---------------------------------------------------------------------
  66. ** Member function prototypes.
  67. */
  68. static void Init(void);
  69. bool Goto_Clear_Spot(void);
  70. bool Try_To_Deploy(void);
  71. bool Tiberium_Check(CELL &center, int x, int y);
  72. bool Flag_Attach(HousesType house);
  73. bool Flag_Remove(void);
  74. void Find_LZ(void);
  75. bool Unload_Hovercraft_Process(void);
  76. bool Goto_Tiberium(void);
  77. bool Harvesting(void);
  78. void APC_Close_Door(void);
  79. void APC_Open_Door(void);
  80. /*
  81. ** Query functions.
  82. */
  83. virtual bool Can_Player_Move(void) const;
  84. virtual int Pip_Count(void) const;
  85. virtual InfantryType Crew_Type(void) const;
  86. /*
  87. ** Coordinate inquiry functions. These are used for both display and
  88. ** combat purposes.
  89. */
  90. virtual COORDINATE Sort_Y(void) const;
  91. /*
  92. ** Object entry and exit from the game system.
  93. */
  94. virtual bool Unlimbo(COORDINATE , DirType facing=DIR_N);
  95. virtual bool Limbo(void);
  96. /*
  97. ** Display and rendering support functionality. Supports imagery and how
  98. ** object interacts with the map and thus indirectly controls rendering.
  99. */
  100. virtual void const * Remap_Table(void);
  101. virtual void Look(bool incremental=false);
  102. virtual short const * Overlap_List(void) const;
  103. virtual void Draw_It(int x, int y, WindowNumberType window);
  104. /*
  105. ** User I/O.
  106. */
  107. virtual ActionType What_Action(CELL cell) const;
  108. virtual ActionType What_Action(ObjectClass * object) const;
  109. virtual void Active_Click_With(ActionType action, ObjectClass * object);
  110. virtual void Active_Click_With(ActionType action, CELL cell);
  111. virtual void Response_Select(void);
  112. virtual void Response_Move(void);
  113. virtual void Response_Attack(void);
  114. /*
  115. ** Combat related.
  116. */
  117. virtual COORDINATE Target_Coord(void) const;
  118. virtual ResultType Take_Damage(int & damage, int distance, WarheadType warhead, TechnoClass * source=0);
  119. virtual TARGET As_Target(void) const;
  120. virtual void Stun(void);
  121. /*
  122. ** Driver control support functions. These are used to control cell
  123. ** occupation flags and driver instructions.
  124. */
  125. virtual bool Stop_Driver(void);
  126. virtual bool Start_Driver(COORDINATE & coord);
  127. /*
  128. ** AI.
  129. */
  130. virtual DirType Desired_Load_Dir(ObjectClass * passenger, CELL & moveto) const;
  131. virtual RadioMessageType Receive_Message(RadioClass * from, RadioMessageType message, long & param);
  132. virtual void AI(void);
  133. virtual int Mission_Attack(void);
  134. virtual int Mission_Unload(void);
  135. virtual int Mission_Guard(void);
  136. virtual int Mission_Harvest(void);
  137. virtual int Mission_Hunt(void);
  138. virtual int UnitClass::Mission_Move(void);
  139. virtual FireErrorType Can_Fire(TARGET, int which) const;
  140. /*
  141. ** Scenario and debug support.
  142. */
  143. #ifdef CHEAT_KEYS
  144. virtual void Debug_Dump(MonoClass *mono) const;
  145. #endif
  146. /*
  147. ** Movement and animation.
  148. */
  149. virtual void Enter_Idle_Mode(bool initial=false);
  150. virtual MoveType Can_Enter_Cell(CELL cell, FacingType facing=FACING_NONE) const;
  151. virtual void Per_Cell_Process(bool center);
  152. virtual void Scatter(COORDINATE threat, bool forced=false);
  153. void Exit_Repair(void);
  154. // MoveType Blocking_Object(TechnoClass const *techno, CELL cell) const;
  155. /*
  156. ** File I/O.
  157. */
  158. static void Read_INI(char *buffer);
  159. static void Write_INI(char *buffer);
  160. static char *INI_Name(void) {return "UNITS";};
  161. bool Load(FileClass & file);
  162. bool Save(FileClass & file);
  163. virtual void Code_Pointers(void);
  164. virtual void Decode_Pointers(void);
  165. /*
  166. ** Dee-buggin' support.
  167. */
  168. int Validate(void) const;
  169. private:
  170. /*
  171. ** This contains the value of the Virtual Function Table Pointer
  172. */
  173. static void * VTable;
  174. };
  175. #endif