OBJECT.H 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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/OBJECT.H 1 3/03/97 10:25a 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 : OBJECT.H *
  26. * *
  27. * Programmer : Joe L. Bostic *
  28. * *
  29. * Start Date : April 29, 1994 *
  30. * *
  31. * Last Update : April 29, 1994 [JLB] *
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  36. #ifndef OBJECT_H
  37. #define OBJECT_H
  38. #include "abstract.h"
  39. class ObjectClass;
  40. class TechnoClass;
  41. class ObjectTypeClass;
  42. class HouseClass;
  43. class BuildingClass;
  44. class RadioClass;
  45. class TriggerClass;
  46. /**********************************************************************
  47. ** Every game object (that can exist on the map) is ultimately derived from this object
  48. ** class. It holds the common information between all objects. This is primarily the
  49. ** object unique ID number and its location in the world. All common operations between
  50. ** game objects are represented by virtual functions in this class.
  51. */
  52. class ObjectClass : public AbstractClass
  53. {
  54. public:
  55. /*
  56. ** The object can be in one of two states -- placed down on the map, or not. If the
  57. ** object is placed down on the map, then this flag will be true.
  58. */
  59. unsigned IsDown:1;
  60. /*
  61. ** This is a support flag that is only used while building a list of objects to
  62. ** be damaged by a proximity affect (explosion). When this flag is set, this object
  63. ** will not be added to the list of units to damage. When damage is applied to the
  64. ** object, this flag is cleared again. This process ensures that an object is never
  65. ** subject to "double jeopardy".
  66. */
  67. unsigned IsToDamage:1;
  68. /*
  69. ** Is this object flagged to be displayed during the next rendering process? This
  70. ** flag could be set by many different circumstances. It is automatically cleared
  71. ** when the object is rerendered.
  72. */
  73. unsigned IsToDisplay:1;
  74. /*
  75. ** An object in the game may be valid yet held in a state of "limbo". Units are in such
  76. ** a state if they are being transported or are otherwise "inside" another unit. They can
  77. ** also be in limbo if they have been created but are being held until the proper time
  78. ** for delivery.
  79. */
  80. unsigned IsInLimbo:1;
  81. /*
  82. ** When an object is "selected" it is given a floating bar graph or other graphic imagery
  83. ** to display this fact. When the player performs I/O, the actions may have a direct
  84. ** bearing on the actions of the currently selected object. For quick checking purposes,
  85. ** if this object is the one that is "selected", this flag will be true.
  86. */
  87. unsigned IsSelected:1;
  88. /*
  89. ** If an animation is attached to this object, then this flag will be true.
  90. */
  91. unsigned IsAnimAttached:1;
  92. /*
  93. ** If this object should process falling logic, then this flag will be true. Such
  94. ** objects might be ballistic projectiles, grenades, or parachuters.
  95. */
  96. unsigned IsFalling:1;
  97. int Riser;
  98. /*
  99. ** Several objects could exist in the same cell list. This is a pointer to the
  100. ** next object in the cell list. The objects in this list are not in any
  101. ** significant order.
  102. */
  103. SmartPtr<ObjectClass> Next;
  104. /*
  105. ** Every object can be assigned a trigger; the same trigger can be assigned
  106. ** to multiple objects.
  107. */
  108. CCPtr<TriggerClass> Trigger;
  109. /*
  110. ** This is the current strength of this object.
  111. */
  112. short Strength;
  113. /*-----------------------------------------------------------------------------------
  114. ** Constructor & destructors.
  115. */
  116. ObjectClass(RTTIType rtti, int id);
  117. ObjectClass(NoInitClass const & x) : AbstractClass(x), Next(x), Trigger(x) {};
  118. virtual ~ObjectClass(void) {Next = 0;};
  119. int operator < (ObjectClass const & object) const {return Sort_Y() < object.Sort_Y();};
  120. int operator > (ObjectClass const & object) const {return Sort_Y() > object.Sort_Y();};
  121. /*
  122. ** Object selection control.
  123. */
  124. static void Init(void);
  125. /*
  126. ** Query functions.
  127. */
  128. virtual bool Is_Players_Army(void) const {return(false);}
  129. virtual void const * Get_Image_Data(void) const;
  130. virtual ActionType What_Action(ObjectClass const *) const;
  131. virtual ActionType What_Action(CELL) const;
  132. virtual LayerType In_Which_Layer(void) const;
  133. bool Is_Infantry(void) const {return(RTTI == RTTI_INFANTRY);};
  134. bool Is_Foot(void) const {return(RTTI == RTTI_INFANTRY || RTTI == RTTI_UNIT || RTTI == RTTI_VESSEL || RTTI == RTTI_AIRCRAFT);};
  135. bool Is_Techno(void) const {return(RTTI == RTTI_BUILDING || RTTI == RTTI_UNIT || RTTI == RTTI_INFANTRY || RTTI == RTTI_VESSEL || RTTI == RTTI_AIRCRAFT);};
  136. virtual int Get_Ownable(void) const;
  137. virtual ObjectTypeClass const & Class_Of(void) const = 0;
  138. virtual char const * Name(void) const;
  139. virtual int Full_Name(void) const;
  140. virtual bool Can_Repair(void) const;
  141. virtual bool Can_Demolish(void) const;
  142. virtual bool Can_Player_Fire(void) const;
  143. virtual bool Can_Player_Move(void) const;
  144. /*
  145. ** Coordinate inquiry functions. These are used for both display and
  146. ** combat purposes.
  147. */
  148. virtual COORDINATE Docking_Coord(void) const;
  149. virtual COORDINATE Target_Coord(void) const;
  150. virtual COORDINATE Center_Coord(void) const;
  151. virtual COORDINATE Render_Coord(void) const;
  152. virtual COORDINATE Sort_Y(void) const;
  153. virtual COORDINATE Fire_Coord(int which) const;
  154. virtual COORDINATE Exit_Coord(void) const;
  155. /*
  156. ** Object entry and exit from the game system.
  157. */
  158. virtual bool Limbo(void);
  159. virtual bool Unlimbo(COORDINATE , DirType facing = DIR_N);
  160. virtual void Detach(TARGET target, bool all=true);
  161. virtual void Detach_All(bool all=true);
  162. virtual void Record_The_Kill(TechnoClass * );
  163. virtual bool Paradrop(COORDINATE coord);
  164. bool Attach_Trigger(TriggerClass * trigger);
  165. /*
  166. ** Display and rendering support functionality. Supports imagery and how
  167. ** object interacts with the map and thus indirectly controls rendering.
  168. */
  169. virtual void Do_Shimmer(void);
  170. virtual int Exit_Object(TechnoClass *);
  171. virtual bool Render(bool forced) const;
  172. virtual short const * Occupy_List(bool placement=false) const;
  173. virtual short const * Overlap_List(bool redraw=false) const;
  174. virtual fixed Health_Ratio(void) const;
  175. virtual void Draw_It(int x, int y, WindowNumberType ) const = 0;
  176. virtual void Hidden(void);
  177. virtual void Look(bool incremental=false);
  178. virtual bool Mark(MarkType=MARK_CHANGE);
  179. private:
  180. virtual void Mark_For_Redraw(void);
  181. public:
  182. /*
  183. ** User I/O.
  184. */
  185. virtual void Active_Click_With(ActionType , ObjectClass *);
  186. virtual void Active_Click_With(ActionType , CELL );
  187. virtual void Clicked_As_Target(int = 7);
  188. virtual bool Select(void);
  189. virtual void Unselect(void);
  190. /*
  191. ** Combat related.
  192. */
  193. virtual bool In_Range(COORDINATE , int=0) const;
  194. virtual int Weapon_Range(int =0) const;
  195. virtual ResultType Take_Damage(int & damage, int distance, WarheadType warhead, TechnoClass * source=0, bool forced=false);
  196. virtual void Scatter(COORDINATE , bool forced=false, bool nokidding=false);
  197. virtual bool Catch_Fire(void);
  198. virtual void Fire_Out(void);
  199. virtual int Value(void) const;
  200. virtual MissionType Get_Mission(void) const;
  201. /*
  202. ** AI.
  203. */
  204. virtual void Per_Cell_Process(PCPType) {}
  205. virtual BuildingClass * Who_Can_Build_Me(bool intheory, bool legal) const;
  206. virtual RadioMessageType Receive_Message(RadioClass * from, RadioMessageType message, long & param);
  207. virtual bool Revealed(HouseClass * house);
  208. virtual void Repair(int );
  209. virtual void Sell_Back(int );
  210. virtual void AI(void);
  211. /*
  212. ** File I/O.
  213. */
  214. virtual void Code_Pointers(void);
  215. virtual void Decode_Pointers(void);
  216. /*
  217. ** Scenario and debug support.
  218. */
  219. #ifdef CHEAT_KEYS
  220. virtual void Debug_Dump(MonoClass *mono) const;
  221. #endif
  222. virtual void Move(FacingType);
  223. enum {FLIGHT_LEVEL=256};
  224. };
  225. #endif