VORTEX.H 7.0 KB

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