VORTEX.H 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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. /***********************************************************************************************
  19. *** 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 ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Command & Conquer - Red Alert *
  23. * *
  24. * File Name : VORTEX.H *
  25. * *
  26. * Programmer : Steve Tall *
  27. * *
  28. * Start Date : 8/12/96 *
  29. * *
  30. * Last Update : August 29th, 1996 [ST] *
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Overview: *
  34. * Definition of ChronalVortexClass. The Chronal vortex sometimes appears when the *
  35. * chronosphere is used. *
  36. * *
  37. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  38. #ifndef VORTEX_H
  39. #define VORTEX_H
  40. #define MAX_REMAP_SHADES 16 //Number of lookup tables required for vortex shading.
  41. #define VORTEX_FRAMES 16 //Number of frames in one complete rotation of the vortex.
  42. class ChronalVortexClass {
  43. public:
  44. /*
  45. ** Constructor and destructor.
  46. */
  47. ChronalVortexClass(void);
  48. ~ChronalVortexClass(void);
  49. void Detach(TARGET target);
  50. /*
  51. ** Makes the vortex appear at the specified coordinate.
  52. */
  53. void Appear (COORDINATE coordinate);
  54. /*
  55. ** Makes the vortex go away.
  56. */
  57. void Disappear (void);
  58. /*
  59. ** Call this every frame.
  60. */
  61. void AI (void);
  62. /*
  63. ** Render the vortex
  64. */
  65. void Render (void);
  66. /*
  67. ** Flags cells under the vortex to be redrawn
  68. */
  69. void Set_Redraw (void);
  70. /*
  71. ** Call whenever the theater changes to recalculate the shading lookup tables
  72. */
  73. void Setup_Remap_Tables (TheaterType theater);
  74. /*
  75. ** Functions to load and save the vortex.
  76. */
  77. void Load(Straw &file);
  78. void Save(Pipe &file);
  79. /*
  80. ** Returns true of vortex is currently active.
  81. */
  82. bool Is_Active(void) {return (Active);};
  83. /*
  84. ** Makes the vortex attack the specified target. Target must be in range of the vortex.
  85. */
  86. void Set_Target (ObjectClass *target);
  87. /*
  88. ** Disables the vortex.
  89. */
  90. void Stop(void);
  91. /*
  92. ** Members to allow read access to private data
  93. */
  94. int Get_Range (void) {return (Range);};
  95. int Get_Speed (void) {return (Speed);};
  96. int Get_Damage (void) {return (Damage);};
  97. /*
  98. ** Members to allow write access to private data.
  99. */
  100. void Set_Range (int range) {Range = range;};
  101. void Set_Speed (int speed) {Speed = speed;};
  102. void Set_Damage (int damage) {Damage = damage;};
  103. /*
  104. ** Possible states the vortex can be in.
  105. */
  106. typedef enum AnimStateType{
  107. STATE_GROW, //Vortex has just appeared and is growing larger
  108. STATE_ROTATE, //Vortex is rotating
  109. STATE_SHRINK //Vortex is shrinking and about to disappear
  110. }AnimStateType;
  111. private:
  112. /*
  113. ** Members for setting up the lookup tables.
  114. */
  115. void Build_Fading_Table (PaletteClass const & palette, void * dest, int color, int frac);
  116. void Coordinate_Remap ( GraphicViewPortClass *inbuffer, int x, int y, int width, int height, unsigned char *remap_table);
  117. /*
  118. ** Misc internal functions
  119. */
  120. void Attack(void);
  121. void Zap_Target(void);
  122. void Movement(void);
  123. void Hide(void);
  124. void Show(void);
  125. /*
  126. ** Position of the top left of the vortex
  127. */
  128. COORDINATE Position;
  129. /*
  130. ** Direction of rotation
  131. */
  132. int AnimateDir;
  133. /*
  134. ** Current frame of animation
  135. */
  136. int AnimateFrame;
  137. /*
  138. ** Animation flag. When 0 vortex will animate 1 frame.
  139. */
  140. int Animate;
  141. /*
  142. ** State of vortex. See ENUM for info.
  143. */
  144. AnimStateType State;
  145. /*
  146. ** Color lookup tables for shading on vortex.
  147. */
  148. unsigned char VortexRemapTables [MAX_REMAP_SHADES][256];
  149. /*
  150. ** Color lookup table to make the blue lightning orange.
  151. */
  152. unsigned char LightningRemap[256];
  153. /*
  154. ** Is vortex currently active?
  155. */
  156. int Active : 1;
  157. /*
  158. ** Is the vortex winding down?
  159. */
  160. int StartShutdown : 1;
  161. /*
  162. ** Is the vortex about to hide from view?
  163. */
  164. int StartHiding : 1;
  165. /*
  166. ** Is the vortex active but hidden?
  167. */
  168. int Hidden : 1;
  169. /*
  170. ** Theater that lookup table is good for.
  171. */
  172. TheaterType Theater;
  173. /*
  174. ** Last frame that vortex attacked on
  175. */
  176. int LastAttackFrame;
  177. /*
  178. ** How many times lightning has zapped on this attack
  179. */
  180. int ZapFrame;
  181. /*
  182. ** Ptr to object that the vortex is zapping
  183. */
  184. TARGET TargetObject;
  185. // ObjectClass *TargetObject;
  186. /*
  187. ** Distance to the target object
  188. */
  189. int TargetDistance;
  190. /*
  191. ** Game frame that vortex hid on.
  192. */
  193. int HiddenFrame;
  194. /*
  195. ** Direction vortex is going in.
  196. */
  197. int XDir;
  198. int YDir;
  199. /*
  200. ** Direction vortex should be going in
  201. */
  202. int DesiredXDir;
  203. int DesiredYDir;
  204. /*
  205. ** Range in cells of the vortex lightning
  206. */
  207. int Range;
  208. /*
  209. ** Max speed in leptons per frame of the vortex.
  210. */
  211. int Speed;
  212. /*
  213. ** Damge of vortex lightning zap.
  214. */
  215. int Damage;
  216. /*
  217. ** Offscreen buffer to render vortex into. This is needed so we can handle clipping.
  218. */
  219. GraphicBufferClass *RenderBuffer;
  220. };
  221. #endif