ANIM.CPP 59 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296
  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. /* $Header: /CounterStrike/ANIM.CPP 1 3/03/97 10:24a Joe_bostic $ */
  15. /***********************************************************************************************
  16. *** 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 ***
  17. ***********************************************************************************************
  18. * *
  19. * Project Name : Dune *
  20. * *
  21. * File Name : ANIM.CPP *
  22. * *
  23. * Programmer : Joe L. Bostic *
  24. * *
  25. * Start Date : June 3, 1991 *
  26. * *
  27. *---------------------------------------------------------------------------------------------*
  28. * Functions: *
  29. * AnimClass::AI -- This is the low level anim processor. *
  30. * AnimClass::AnimClass -- The constructor for animation objects. *
  31. * AnimClass::Attach_To -- Attaches animation to object specified. *
  32. * AnimClass::Sort_Above -- Sorts the animation above the target specified. *
  33. * AnimClass::Center_Coord -- Determine center of animation. *
  34. * AnimClass::Detach -- Remove animation if attached to target. *
  35. * AnimClass::Do_Atom_Damage -- Do atom bomb damage centered around the cell specified. *
  36. * AnimClass::Draw_It -- Draws the animation at the location specified. *
  37. * AnimClass::In_Which_Layer -- Determines what render layer the anim should be in. *
  38. * AnimClass::Init -- Performs pre-scenario initialization. *
  39. * AnimClass::Mark -- Signals to map that redrawing is necessary. *
  40. * AnimClass::Middle -- Processes any middle events. *
  41. * AnimClass::Occupy_List -- Determines the occupy list for the animation. *
  42. * AnimClass::Overlap_List -- Determines the overlap list for the animation. *
  43. * AnimClass::Render -- Draws an animation object. *
  44. * AnimClass::Sort_Y -- Returns with the sorting coordinate for the animation. *
  45. * AnimClass::Start -- Processes initial animation side effects. *
  46. * AnimClass::delete -- Returns an anim object back to the free pool. *
  47. * AnimClass::new -- Allocates an anim object from the pool. *
  48. * AnimClass::~AnimClass -- Destructor for anim objects. *
  49. * Anim_From_Name -- Given a name, this finds the corresponding anim type. *
  50. * Shorten_Attached_Anims -- Reduces attached animation durations. *
  51. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  52. #include "function.h"
  53. #define VIC 1
  54. /***********************************************************************************************
  55. * Anim_From_Name -- Given a name, this finds the corresponding anim type. *
  56. * *
  57. * This routine will convert the supplied ASCII name into the animation type that it *
  58. * represents. *
  59. * *
  60. * INPUT: name -- Pointer to the ASCII name to convert. *
  61. * *
  62. * OUTPUT: Returns with the animation type that matches the name specified. If no match could *
  63. * be found, then ANIM_NONE is returned. *
  64. * *
  65. * WARNINGS: none *
  66. * *
  67. * HISTORY: *
  68. * 07/06/1996 JLB : Created. *
  69. *=============================================================================================*/
  70. AnimType Anim_From_Name(char const * name)
  71. {
  72. #ifdef VIC
  73. if (name == NULL) return(ANIM_NONE);
  74. for (int anim = ANIM_FIRST; anim < ANIM_COUNT; anim++) {
  75. if (stricmp(AnimTypeClass::As_Reference((AnimType)anim).IniName, name) == 0) {
  76. return((AnimType)anim);
  77. }
  78. }
  79. #endif
  80. return(ANIM_NONE);
  81. }
  82. /***********************************************************************************************
  83. * Shorten_Attached_Anims -- Reduces attached animation durations. *
  84. * *
  85. * This routine is used to reduce the amount of time any attached animations will process. *
  86. * Typical use of this is when an object is on fire and the object should now be destroyed *
  87. * but the attached animations are to run until completion before destruction can follow. *
  88. * This routine will make the animation appear to run its course, but in as short of time *
  89. * as possible. The shortening effect is achieved by reducing the number of times the *
  90. * animation will loop. *
  91. * *
  92. * INPUT: obj -- Pointer to the object that all attached animations will be processed. *
  93. * *
  94. * OUTPUT: none *
  95. * *
  96. * WARNINGS: none *
  97. * *
  98. * HISTORY: *
  99. * 12/11/1994 JLB : Created. *
  100. *=============================================================================================*/
  101. void Shorten_Attached_Anims(ObjectClass * obj)
  102. {
  103. if (obj != NULL) {
  104. for (int index = 0; index < Anims.Count(); index++) {
  105. AnimClass & anim = * Anims.Ptr(index);
  106. if (As_Object(anim.xObject) == obj) {
  107. anim.Loops = 0;
  108. }
  109. }
  110. }
  111. }
  112. /***********************************************************************************************
  113. * AnimClass::Sort_Y -- Returns with the sorting coordinate for the animation. *
  114. * *
  115. * This routine is used by the sorting system. Animations that are located in the ground *
  116. * layer will be sorted by this the value returned from this function. *
  117. * *
  118. * INPUT: none *
  119. * *
  120. * OUTPUT: Returns with the sort coordinate to use for this animation. *
  121. * *
  122. * WARNINGS: none *
  123. * *
  124. * HISTORY: *
  125. * 10/17/1994 JLB : Created. *
  126. * 12/15/1994 JLB : Handles flat anims (infantry decay anims). *
  127. *=============================================================================================*/
  128. COORDINATE AnimClass::Sort_Y(void) const
  129. {
  130. #ifdef VIC
  131. assert(Anims.ID(this) == ID);
  132. assert(IsActive);
  133. if (xObject != TARGET_NONE) {
  134. return(Coord_Add(As_Object(xObject)->Sort_Y(), 0x00010000L));
  135. }
  136. if (Target_Legal(SortTarget)) {
  137. ObjectClass * obj = As_Object(SortTarget);
  138. if (obj && obj->IsActive) {
  139. return(Coord_Add(obj->Sort_Y(), 0x00010000L));
  140. }
  141. }
  142. if (*this == ANIM_MOVE_FLASH) {
  143. return(Coord_Add(Center_Coord(), XYP_COORD(0, -24)));
  144. }
  145. if (Class->IsGroundLayer || *this == ANIM_LZ_SMOKE) {
  146. return(Coord_Add(Center_Coord(), XYP_COORD(0, 14)));
  147. }
  148. #endif
  149. return(Coord);
  150. }
  151. /***********************************************************************************************
  152. * AnimClass::Center_Coord -- Determine center of animation. *
  153. * *
  154. * This support function will return the "center" of the animation. The actual coordinate *
  155. * of the animation may be dependant on if the the animation is attached to an object. *
  156. * In such a case, it must factor in the object's location. *
  157. * *
  158. * INPUT: none *
  159. * *
  160. * OUTPUT: Returns the coordinate of the center of the animation. The coordinate is in real *
  161. * game coordinates -- taking into consideration if the animation is attached. *
  162. * *
  163. * WARNINGS: none *
  164. * *
  165. * HISTORY: *
  166. * 09/19/1994 JLB : Created. *
  167. * 02/02/1996 JLB : Coordinate based on visual center of object. *
  168. *=============================================================================================*/
  169. COORDINATE AnimClass::Center_Coord(void) const
  170. {
  171. #ifdef VIC
  172. assert(Anims.ID(this) == ID);
  173. assert(IsActive);
  174. if (xObject != TARGET_NONE) {
  175. return(Coord_Add(Coord, As_Object(xObject)->Target_Coord()));
  176. }
  177. #endif
  178. return(Coord);
  179. }
  180. /***********************************************************************************************
  181. * AnimClass::Render -- Draws an animation object. *
  182. * *
  183. * This is the working routine that renders the animation shape. It gets called once *
  184. * per animation per frame. It needs to be fast. *
  185. * *
  186. * INPUT: bool; Should the animation be rendered in spite of render flag? *
  187. * *
  188. * OUTPUT: bool; Was the animation rendered? *
  189. * *
  190. * WARNINGS: none *
  191. * *
  192. * HISTORY: *
  193. * 05/31/1994 JLB : Created. *
  194. *=============================================================================================*/
  195. bool AnimClass::Render(bool forced) const
  196. {
  197. #ifdef VIC
  198. assert(Anims.ID(this) == ID);
  199. assert(IsActive);
  200. if (Delay) return(false);
  201. if (Map[Center_Coord()].IsVisible) {
  202. const_cast<AnimClass*>(this)->IsToDisplay = true; // const_cast. ST - 5/8/2019
  203. }
  204. #endif
  205. return(ObjectClass::Render(forced));
  206. }
  207. /***********************************************************************************************
  208. * AnimClass::Draw_It -- Draws the animation at the location specified. *
  209. * *
  210. * This routine is used to render the animation object at the location specified. This is *
  211. * how the map imagery gets updated. *
  212. * *
  213. * INPUT: x,y -- The pixel coordinates to draw the animation at. *
  214. * *
  215. * window -- The to base the draw coordinates upon. *
  216. * *
  217. * OUTPUT: none *
  218. * *
  219. * WARNINGS: none *
  220. * *
  221. * HISTORY: *
  222. * 09/24/1994 JLB : Created. *
  223. * 05/19/1995 JLB : Added white translucent effect. *
  224. *=============================================================================================*/
  225. void AnimClass::Draw_It(int x, int y, WindowNumberType window) const
  226. {
  227. #ifdef VIC
  228. assert(Anims.ID(this) == ID);
  229. assert(IsActive);
  230. bool render_legacy = !IsInvisible && (Class->VirtualAnim == ANIM_NONE || window != WINDOW_VIRTUAL);
  231. bool render_virtual = Target_Legal(VirtualAnimTarget) && window == WINDOW_VIRTUAL;
  232. if (render_legacy) {
  233. BStart(BENCH_ANIMS);
  234. IsTheaterShape = Class->IsTheater;
  235. void const * shapefile = Get_Image_Data();
  236. if (shapefile != NULL) {
  237. void const * transtable = NULL;
  238. int shapenum = Class->Start + Fetch_Stage();
  239. void const * remap = NULL;
  240. ShapeFlags_Type flags = SHAPE_CENTER|SHAPE_WIN_REL;
  241. bool alt = false;
  242. int width = 0;
  243. int height = 0;
  244. /*
  245. ** Some animations require special fixups.
  246. */
  247. switch (Class->Type) {
  248. case ANIM_ATOM_BLAST:
  249. transtable = Map.UnitShadow;
  250. break;
  251. case ANIM_FLAG:
  252. x += (ICON_PIXEL_W / 2) - 2;
  253. y += (3 * ICON_PIXEL_H / 4) - Get_Build_Frame_Height(shapefile);
  254. transtable = Map.UnitShadow;
  255. alt = true;
  256. break;
  257. case ANIM_BEACON_VIRTUAL:
  258. width = 29;
  259. height = 39;
  260. flags = flags | SHAPE_BOTTOM | SHAPE_COMPACT;
  261. break;
  262. }
  263. /*
  264. ** If the translucent table hasn't been determined yet, then check to see if it
  265. ** should use the white or normal translucent tables.
  266. */
  267. if (transtable == NULL && Class->IsWhiteTrans) transtable = DisplayClass::WhiteTranslucentTable;
  268. if (transtable == NULL && Class->IsTranslucent) transtable = DisplayClass::TranslucentTable;
  269. /*
  270. ** Set the shape flags to properly take into account any fading or ghosting
  271. ** table necessary.
  272. */
  273. if (alt) {
  274. flags = flags | SHAPE_FADING;
  275. if (OwnerHouse != HOUSE_NONE) {
  276. remap = HouseClass::As_Pointer(OwnerHouse)->Remap_Table(false);
  277. } else {
  278. remap = ColorRemaps[PCOLOR_GOLD].RemapTable;
  279. }
  280. }
  281. if (transtable != NULL) flags = flags | SHAPE_GHOST;
  282. /*
  283. ** Draw the animation shape, but ignore legacy if beyond normal stage count.
  284. */
  285. if ((window == WINDOW_VIRTUAL) || (Fetch_Stage() < Class->Stages)) {
  286. // Add 'this' parameter to call new shape draw intercept. ST - 5/22/2019
  287. CC_Draw_Shape(this, shapefile, shapenum, x, y, window, flags, remap, transtable, DIR_N, Class->VirtualScale, width, height);
  288. }
  289. }
  290. IsTheaterShape = false;
  291. BEnd(BENCH_ANIMS);
  292. }
  293. if (render_virtual) {
  294. AnimClass* virtual_anim = As_Animation(VirtualAnimTarget);
  295. virtual_anim->Make_Visible();
  296. virtual_anim->Draw_It(x, y, window);
  297. virtual_anim->Make_Invisible();
  298. }
  299. #endif
  300. }
  301. /***********************************************************************************************
  302. * AnimClass::Mark -- Signals to map that redrawing is necessary. *
  303. * *
  304. * This routine is used by the animation logic system to inform the map that the cells *
  305. * under the animation must be rerendered. *
  306. * *
  307. * INPUT: *
  308. * *
  309. * OUTPUT: none *
  310. * *
  311. * WARNINGS: none *
  312. * *
  313. * HISTORY: *
  314. * 05/31/1994 JLB : Created. *
  315. *=============================================================================================*/
  316. bool AnimClass::Mark(MarkType mark)
  317. {
  318. #ifdef VIC
  319. assert(Anims.ID(this) == ID);
  320. assert(IsActive);
  321. if (ObjectClass::Mark(mark)) {
  322. Map.Refresh_Cells(Coord_Cell(Center_Coord()), Overlap_List());
  323. // ObjectClass::Mark(mark);
  324. return(true);
  325. }
  326. #endif
  327. return(false);
  328. }
  329. /***********************************************************************************************
  330. * AnimClass::Overlap_List -- Determines the overlap list for the animation. *
  331. * *
  332. * Use this routine to fetch the overlap list for the animation. This overlap list is the *
  333. * cells that this animation spills over. *
  334. * *
  335. * INPUT: none *
  336. * *
  337. * OUTPUT: Returns a pointer to the overlap list for this particular instance of the *
  338. * animation. *
  339. * *
  340. * WARNINGS: none *
  341. * *
  342. * HISTORY: *
  343. * 03/19/1995 JLB : Created. *
  344. *=============================================================================================*/
  345. short const * AnimClass::Overlap_List(void) const
  346. {
  347. #ifdef VIC
  348. assert(Anims.ID(this) == ID);
  349. assert(IsActive);
  350. static short const OverlapAtom[] = {
  351. (-MAP_CELL_W * 2) - 1, (-MAP_CELL_W * 2), (-MAP_CELL_W * 2) + 1,
  352. (-MAP_CELL_W * 1) - 1, (-MAP_CELL_W * 1), (-MAP_CELL_W * 1) + 1,
  353. (-MAP_CELL_W * 0) - 1, (-MAP_CELL_W * 0), (-MAP_CELL_W * 0) + 1,
  354. ( MAP_CELL_W * 1) - 1, ( MAP_CELL_W * 1), ( MAP_CELL_W * 1) + 1,
  355. ( MAP_CELL_W * 2) - 1, ( MAP_CELL_W * 2), ( MAP_CELL_W * 2) + 1,
  356. REFRESH_EOL
  357. };
  358. static short const OverlapFlag[] = { 0, 1, -MAP_CELL_W, -(MAP_CELL_W-1), MAP_CELL_W, MAP_CELL_W+1, REFRESH_EOL };
  359. if (IsToDelete) {
  360. static short const _list[] = {REFRESH_EOL};
  361. return(_list);
  362. }
  363. if (Class->Type == ANIM_ATOM_BLAST) {
  364. return(OverlapAtom);
  365. }
  366. if (Class->Type == ANIM_FLAG) {
  367. return(OverlapFlag);
  368. }
  369. #ifdef PARTIAL
  370. IsTheaterShape = Class->IsTheater;
  371. if (Class->Get_Image_Data() != NULL) {
  372. int shapenum = Class->Start + Fetch_Stage();
  373. int count = Get_Build_Frame_Count(Class->Get_Image_Data());
  374. shapenum = min(shapenum, count-1);
  375. if (Class->DimensionData == NULL) {
  376. Class->DimensionData = new Rect [count];
  377. }
  378. if (Class->DimensionData != NULL && !Class->DimensionData[shapenum].Is_Valid()) {
  379. Class->DimensionData[shapenum] = Shape_Dimensions(Class->Get_Image_Data(), shapenum);
  380. IsTheaterShape = false;
  381. return(Coord_Spillage_List(Center_Coord(), Class->DimensionData[shapenum]));
  382. }
  383. }
  384. IsTheaterShape = false;
  385. #endif
  386. #endif
  387. return(Coord_Spillage_List(Center_Coord(), Class->Size));
  388. }
  389. /***********************************************************************************************
  390. * AnimClass::Occupy_List -- Determines the occupy list for the animation. *
  391. * *
  392. * Animations always occupy only the cell that their center is located over. As such, this *
  393. * routine always returns a simple (center cell) occupation list. *
  394. * *
  395. * INPUT: none *
  396. * *
  397. * OUTPUT: Returns with the occupation list for the animation. *
  398. * *
  399. * WARNINGS: none *
  400. * *
  401. * HISTORY: *
  402. * 03/19/1995 JLB : Created. *
  403. *=============================================================================================*/
  404. short const * AnimClass::Occupy_List(bool) const
  405. {
  406. #ifdef VIC
  407. assert(Anims.ID(this) == ID);
  408. assert(IsActive);
  409. static short _simple[] = {REFRESH_EOL};
  410. #endif
  411. return(_simple);
  412. }
  413. /***********************************************************************************************
  414. * AnimClass::Init -- Performs pre-scenario initialization. *
  415. * *
  416. * This routine is used to initialize the animation system prior to a scenario being loaded *
  417. * or reloaded. It effectively removes all animations from the system. *
  418. * *
  419. * INPUT: none *
  420. * *
  421. * OUTPUT: none *
  422. * *
  423. * WARNINGS: none *
  424. * *
  425. * HISTORY: *
  426. * 05/31/1994 JLB : Created. *
  427. *=============================================================================================*/
  428. void AnimClass::Init(void)
  429. {
  430. Anims.Free_All();
  431. }
  432. /***********************************************************************************************
  433. * AnimClass::new -- Allocates an anim object from the pool. *
  434. * *
  435. * This routine is used to allocate a free anim class object from the preallocated pool *
  436. * in the near heap. If there are no free animation objects, then null is returned. *
  437. * *
  438. * INPUT: none *
  439. * *
  440. * OUTPUT: Returns with a pointer to a free anim object. *
  441. * *
  442. * WARNINGS: none *
  443. * *
  444. * HISTORY: *
  445. * 05/31/1994 JLB : Created. *
  446. *=============================================================================================*/
  447. void * AnimClass::operator new(size_t)
  448. {
  449. void * ptr = Anims.Allocate();
  450. if (ptr != NULL) {
  451. ((AnimClass *)ptr)->Set_Active();
  452. } else {
  453. GlyphX_Debug_Print("AnimClass::operator new FAILED");
  454. }
  455. return(ptr);
  456. }
  457. /***********************************************************************************************
  458. * AnimClass::delete -- Returns an anim object back to the free pool. *
  459. * *
  460. * This routine is used to return an anim object back to the pool of free anim objects. *
  461. * Anim objects so returned are available to be reallocated for the next animation. *
  462. * *
  463. * INPUT: ptr -- Pointer to the anim object to return to the pool. *
  464. * *
  465. * OUTPUT: none *
  466. * *
  467. * WARNINGS: none *
  468. * *
  469. * HISTORY: *
  470. * 05/31/1994 JLB : Created. *
  471. *=============================================================================================*/
  472. void AnimClass::operator delete(void * ptr)
  473. {
  474. if (ptr != NULL) {
  475. ((AnimClass *)ptr)->IsActive = false;
  476. }
  477. Anims.Free((AnimClass *)ptr);
  478. }
  479. /***********************************************************************************************
  480. * AnimClass::AnimClass -- The constructor for animation objects. *
  481. * *
  482. * This routine is used as the constructor of animation objects. It initializes and adds *
  483. * the animation object to the display and logic systems. *
  484. * *
  485. * INPUT: animnum -- The animation number to start. *
  486. * *
  487. * coord -- The location of the animation. *
  488. * *
  489. * timedelay-- The delay before the animation starts. *
  490. * *
  491. * loop -- The number of times to loop this animation. *
  492. * *
  493. * OUTPUT: none *
  494. * *
  495. * WARNINGS: none *
  496. * *
  497. * HISTORY: *
  498. * 05/31/1994 JLB : Created. *
  499. * 08/03/1994 JLB : Added a delayed affect parameter. *
  500. *=============================================================================================*/
  501. AnimClass::AnimClass(AnimType animnum, COORDINATE coord, unsigned char timedelay, char loop) :
  502. ObjectClass(RTTI_ANIM, Anims.ID(this)),
  503. Class(AnimTypes.Ptr((int)animnum)),
  504. xObject(TARGET_NONE),
  505. SortTarget(TARGET_NONE),
  506. OwnerHouse(HOUSE_NONE),
  507. Loops(1),
  508. IsToDelete(false),
  509. IsBrandNew(true),
  510. IsInvisible(false),
  511. Delay(timedelay),
  512. Accum(0),
  513. AttachLayer(LAYER_NONE),
  514. KillTime(0ULL)
  515. {
  516. #ifdef VIC
  517. if (Class->Stages == -1) {
  518. IsTheaterShape = Class->IsTheater;
  519. ((int&)Class->Stages) = Get_Build_Frame_Count(Class->Get_Image_Data());
  520. IsTheaterShape = false;
  521. }
  522. if (Class->LoopEnd == -1) {
  523. ((int&)Class->LoopEnd) = Class->Stages;
  524. }
  525. if (Class->IsNormalized) {
  526. Set_Rate(Options.Normalize_Delay(Class->Delay));
  527. } else {
  528. Set_Rate(Class->Delay);
  529. }
  530. Set_Stage(0);
  531. if (Class->IsGroundLayer) {
  532. Height = FLIGHT_LEVEL;
  533. }
  534. AnimClass::Unlimbo(coord);
  535. VisibleFlags = static_cast<unsigned int>(-1);
  536. /*
  537. ** Drop zone smoke always reveals the map around itself.
  538. */
  539. if (*this == ANIM_LZ_SMOKE) {
  540. // Added PlayerPtr here as Sight_From now needs to know who to perform the action for. This should be OK as long as it's not used in MP. ST - 8/2/2019 2:34PM
  541. Map.Sight_From(Coord_Cell(coord), Rule.DropZoneRadius / CELL_LEPTON_W, PlayerPtr, false);
  542. }
  543. if (Class->Loops >= 0) {
  544. Loops = (char)(max(loop, 1) * Class->Loops);
  545. Loops = (char)max(Loops, 1);
  546. } else {
  547. Loops = Class->Loops;
  548. }
  549. /*
  550. ** If the animation starts immediately, then play the associated sound effect now.
  551. */
  552. if (!Delay) {
  553. Start();
  554. }
  555. /*
  556. ** Check for a virtual animation
  557. */
  558. if (Class->VirtualAnim != ANIM_NONE) {
  559. AnimClass* virtual_anim = new AnimClass(Class->VirtualAnim, Coord, timedelay, loop);
  560. if (virtual_anim != NULL) {
  561. virtual_anim->Make_Invisible();
  562. VirtualAnimTarget = virtual_anim->As_Target();
  563. } else {
  564. VirtualAnimTarget = TARGET_NONE;
  565. }
  566. } else {
  567. VirtualAnimTarget = TARGET_NONE;
  568. }
  569. #endif
  570. }
  571. /***********************************************************************************************
  572. * AnimClass::~AnimClass -- Destructor for anim objects. *
  573. * *
  574. * This destructor handles removing the animation object from the system. It might require *
  575. * informing any object this animation is attached to that it is no longer attached. *
  576. * *
  577. * INPUT: none *
  578. * *
  579. * OUTPUT: none *
  580. * *
  581. * WARNINGS: none *
  582. * *
  583. * HISTORY: *
  584. * 11/29/1994 JLB : Created. *
  585. *=============================================================================================*/
  586. AnimClass::~AnimClass(void)
  587. {
  588. #ifdef VIC
  589. assert(Anims.ID(this) == ID);
  590. assert(IsActive);
  591. if (GameActive) {
  592. /*
  593. ** If this anim is attached to another object
  594. ** then check to see if this is the last anim attached to it. If this
  595. ** is the case, then inform the object that it is no longer attached to
  596. ** an animation.
  597. */
  598. if (Target_Legal(xObject) && As_Object(xObject) != NULL) {
  599. ObjectClass * to = As_Object(xObject);
  600. /*
  601. ** Remove the object from the appropriate display list.
  602. */
  603. Map.Remove(this, In_Which_Layer());
  604. /*
  605. ** Scan for any other animations that are attached to the object that
  606. ** this animation is attached to. If there are no others, then inform the
  607. ** attached object of this fact.
  608. */
  609. int index;
  610. for (index = 0; index < Anims.Count(); index++) {
  611. if (Anims.Ptr(index) != this && Anims.Ptr(index)->xObject == xObject) break;
  612. }
  613. /*
  614. ** Tell the object that it is no longer being damaged.
  615. */
  616. if (index == Anims.Count()) {
  617. to->Fire_Out();
  618. if (to->In_Which_Layer() == LAYER_GROUND) to->Mark(MARK_OVERLAP_UP);
  619. to->IsAnimAttached = false;
  620. if (to->In_Which_Layer() == LAYER_GROUND) to->Mark(MARK_OVERLAP_DOWN);
  621. }
  622. Coord = Coord_Add(to->Center_Coord(), Coord);
  623. xObject = TARGET_NONE;
  624. }
  625. Limbo();
  626. }
  627. xObject = TARGET_NONE;
  628. Class = 0;
  629. ID = -1;
  630. #endif
  631. }
  632. /***********************************************************************************************
  633. * AnimClass::AI -- This is the low level anim processor. *
  634. * *
  635. * This routine is called once per frame per animation. It handles transition between *
  636. * animation frames and marks the map for redraw as necessary. *
  637. * *
  638. * INPUT: none *
  639. * *
  640. * OUTPUT: none *
  641. * *
  642. * WARNINGS: Speed is of upmost importance. *
  643. * *
  644. * HISTORY: *
  645. * 05/31/1994 JLB : Created. *
  646. *=============================================================================================*/
  647. void AnimClass::AI(void)
  648. {
  649. #ifdef VIC
  650. assert(Anims.ID(this) == ID);
  651. assert(IsActive);
  652. /*
  653. ** For ground level based animations (ones that can run slowly as well as
  654. ** occur behind other ground objects) always cause the cell to be redrawn.
  655. */
  656. #ifdef PARTIAL
  657. if (!Delay && Class->IsGroundLayer) {
  658. Map.Refresh_Cells(Coord_Cell(Center_Coord()), Overlap_List());
  659. }
  660. #else
  661. Map.Refresh_Cells(Coord_Cell(Center_Coord()), Overlap_List());
  662. #endif
  663. /*
  664. ** Special case check to make sure that building on top of a smoke marker
  665. ** causes the smoke marker to vanish.
  666. */
  667. if (Class->Type == ANIM_LZ_SMOKE && Map[Center_Coord()].Cell_Building()) {
  668. IsToDelete = true;
  669. }
  670. /*
  671. ** Don't allow corpses on rocks, rivers, and water (looks really weird).
  672. */
  673. if (Class->Type >= ANIM_CORPSE1 && Class->Type <= ANIM_CORPSE3) {
  674. LandType land = Map[Center_Coord()].Land_Type();
  675. if (land == LAND_ROCK || land == LAND_WATER || land == LAND_RIVER) {
  676. IsToDelete = true;
  677. }
  678. }
  679. /*
  680. ** Check the kill time.
  681. */
  682. if (KillTime > 0ULL) {
  683. FILETIME ft;
  684. GetSystemTimeAsFileTime(&ft);
  685. unsigned long long now = (unsigned long long)ft.dwLowDateTime + ((unsigned long long)ft.dwHighDateTime << 32ULL);
  686. if (now >= KillTime) {
  687. IsToDelete = true;
  688. }
  689. }
  690. /*
  691. ** Delete this animation and bail early if the animation is flagged to be deleted
  692. ** immediately.
  693. */
  694. if (IsToDelete) {
  695. delete this;
  696. return;
  697. }
  698. /*
  699. ** If this is a brand new animation, then don't process it the first logic pass
  700. ** since it might end up skipping the first animation frame before it has had a
  701. ** chance to draw it.
  702. */
  703. if (IsBrandNew) {
  704. IsBrandNew = false;
  705. return;
  706. }
  707. #ifdef FIXIT_MULTI_SAVE
  708. if (Class->Stages == -1) {
  709. IsTheaterShape = Class->IsTheater;
  710. ((int&)Class->Stages) = Get_Build_Frame_Count(Class->Get_Image_Data());
  711. IsTheaterShape = false;
  712. }
  713. if (Class->LoopEnd == -1) {
  714. ((int&)Class->LoopEnd) = Class->Stages;
  715. }
  716. #endif
  717. if (Delay) {
  718. Delay--;
  719. if (!Delay) {
  720. Start();
  721. }
  722. } else {
  723. #ifdef FIXIT_MULTI_SAVE
  724. if (Class->Stages == -1) {
  725. IsTheaterShape = Class->IsTheater;
  726. ((int&)Class->Stages) = Get_Build_Frame_Count(Class->Get_Image_Data());
  727. IsTheaterShape = false;
  728. }
  729. if (Class->LoopEnd == -1) {
  730. ((int&)Class->LoopEnd) = Class->Stages;
  731. }
  732. #endif
  733. /*
  734. ** This is necessary because there is no recording of animations on the map
  735. ** and thus the animation cannot be intelligently flagged for redraw. Most
  736. ** animations move fast enough that they would need to be redrawn every
  737. ** game frame anyway so this isn't TOO bad.
  738. */
  739. Mark(MARK_CHANGE);
  740. if (StageClass::Graphic_Logic()) {
  741. int stage = Fetch_Stage();
  742. /*
  743. ** If this animation is attached to another object and it is a
  744. ** damaging kind of animation, then do the damage to the other
  745. ** object.
  746. */
  747. if (xObject != TARGET_NONE && Class->Damage > 0 && stage < Class->Stages) {
  748. Accum += Class->Damage;
  749. if (Accum >= 1) {
  750. /*
  751. ** Administer the damage. If the object was destroyed by this anim,
  752. ** then the attached damaging anim is also destroyed.
  753. */
  754. int damage = Accum;
  755. Accum -= damage;
  756. if (As_Object(xObject)->Take_Damage(damage, 0, WARHEAD_FIRE) == RESULT_DESTROYED) {
  757. if (Target_Legal(VirtualAnimTarget)) {
  758. delete As_Animation(VirtualAnimTarget);
  759. }
  760. delete this;
  761. return;
  762. }
  763. }
  764. }
  765. /*
  766. ** During the biggest stage (covers the most ground), perform any ground altering
  767. ** action required. This masks craters and scorch marks, so that they appear
  768. ** naturally rather than "popping" into existence while in plain sight.
  769. */
  770. if (Class->Biggest && Class->Start+stage == Class->Biggest) {
  771. Middle();
  772. }
  773. /*
  774. ** Check to see if the last frame has been displayed. If so, then the
  775. ** animation either ends or loops.
  776. */
  777. if ((Loops <= 1 && stage >= Class->Stages) || (Loops > 1 && stage >= Class->LoopEnd-Class->Start)) {
  778. /*
  779. ** Determine if this animation should loop another time. If so, then start the loop
  780. ** but if not, then proceed into the animation termination handler.
  781. */
  782. if (Loops > 0) Loops--;
  783. if (Loops != 0) {
  784. Set_Stage(Class->LoopStart);
  785. } else {
  786. if (Class->VirtualAnim != ANIM_NONE) {
  787. Make_Invisible();
  788. if (!Target_Legal(VirtualAnimTarget)) {
  789. if (Class->ChainTo != ANIM_NONE) {
  790. Chain();
  791. }
  792. else {
  793. delete this;
  794. }
  795. }
  796. }
  797. else {
  798. if ((Class->VirtualStages < 0) || (stage >= Class->VirtualStages)) {
  799. if (Class->ChainTo != ANIM_NONE) {
  800. Chain();
  801. }
  802. else {
  803. delete this;
  804. }
  805. }
  806. }
  807. }
  808. }
  809. }
  810. }
  811. #endif
  812. }
  813. /***********************************************************************************************
  814. * AnimClass::Attach_To -- Attaches animation to object specified. *
  815. * *
  816. * An animation can be "attached" to an object. In such cases, the animation is rendered *
  817. * as an offset from the center of the object it is attached to. This allows affects such *
  818. * as fire or smoke to be consistently placed on the vehicle it is associated with. *
  819. * *
  820. * INPUT: obj -- Pointer to the object to attach the animation to. *
  821. * *
  822. * OUTPUT: none *
  823. * *
  824. * WARNINGS: none *
  825. * *
  826. * HISTORY: *
  827. * 09/19/1994 JLB : Created. *
  828. *=============================================================================================*/
  829. void AnimClass::Attach_To(ObjectClass * obj)
  830. {
  831. #ifdef VIC
  832. assert(Anims.ID(this) == ID);
  833. assert(IsActive);
  834. if (obj == NULL) return;
  835. assert(obj->IsActive);
  836. if (obj->In_Which_Layer() == LAYER_GROUND) obj->Mark(MARK_OVERLAP_UP);
  837. obj->IsAnimAttached = true;
  838. if (obj->In_Which_Layer() == LAYER_GROUND) obj->Mark(MARK_OVERLAP_DOWN);
  839. Limbo();
  840. xObject = obj->As_Target();
  841. Unlimbo(Coord);
  842. AttachLayer = In_Which_Layer();
  843. Height = (AttachLayer == LAYER_GROUND) ? FLIGHT_LEVEL : 0;
  844. Coord = Coord_Sub(Coord, obj->Target_Coord());
  845. #endif
  846. }
  847. /***********************************************************************************************
  848. * AnimClass::Sort_Above -- Sorts the animation right above the specified target. *
  849. * *
  850. * Allows an animation to always be sorted above a particular target. Typically used *
  851. * for explosions and other effects that look weird beneath those objects. *
  852. * *
  853. * INPUT: target -- Target to sort above. *
  854. * *
  855. * OUTPUT: none *
  856. * *
  857. * WARNINGS: none *
  858. * *
  859. * HISTORY: *
  860. * 08/14/2019 SKY : Created. *
  861. *=============================================================================================*/
  862. void AnimClass::Sort_Above(TARGET target)
  863. {
  864. #ifdef VIC
  865. SortTarget = target;
  866. #endif
  867. }
  868. /***********************************************************************************************
  869. * AnimClass::In_Which_Layer -- Determines what render layer the anim should be in. *
  870. * *
  871. * Use this routine to find out which display layer (ground or air) that the animation *
  872. * should be in. This information is used to place the animation into the correct display *
  873. * list. *
  874. * *
  875. * INPUT: none *
  876. * *
  877. * OUTPUT: Returns with the layer that the animation should exist in. *
  878. * *
  879. * WARNINGS: none *
  880. * *
  881. * HISTORY: *
  882. * 12/25/1994 JLB : Created. *
  883. *=============================================================================================*/
  884. LayerType AnimClass::In_Which_Layer(void) const
  885. {
  886. #ifdef VIC
  887. assert(Anims.ID(this) == ID);
  888. assert(IsActive);
  889. if (AttachLayer != LAYER_NONE) {
  890. return AttachLayer;
  891. }
  892. if (Class->Type >= ANIM_CORPSE1 && Class->Type <= ANIM_CORPSE3) {
  893. return(LAYER_SURFACE);
  894. }
  895. if (Target_Legal(xObject)) {
  896. return As_Object(xObject)->In_Which_Layer();
  897. }
  898. if (Class->IsGroundLayer) {
  899. return(LAYER_GROUND);
  900. }
  901. #endif
  902. return(LAYER_AIR);
  903. }
  904. /***********************************************************************************************
  905. * AnimClass::Start -- Processes initial animation side effects. *
  906. * *
  907. * This routine is called when the animation first starts. Sometimes there are side effects *
  908. * associated with this animation that must occur immediately. Typically, this is the *
  909. * sound effect assigned to this animation. If this animation is supposed to attach itself *
  910. * to any object at its location, then do so at this time as well. *
  911. * *
  912. * INPUT: none *
  913. * *
  914. * OUTPUT: none *
  915. * *
  916. * WARNINGS: none *
  917. * *
  918. * HISTORY: *
  919. * 06/30/1995 JLB : Created. *
  920. *=============================================================================================*/
  921. void AnimClass::Start(void)
  922. {
  923. #ifdef VIC
  924. assert(Anims.ID(this) == ID);
  925. assert(IsActive);
  926. Mark();
  927. /*
  928. ** Play the sound effect for this animation.
  929. */
  930. Sound_Effect(Class->Sound, Coord);
  931. /*
  932. ** If the stage where collateral effects occur is the first stage of the animation, then
  933. ** perform this action now. Subsequent checks against this stage value starts with the
  934. ** second frame of the animation.
  935. */
  936. if (!Class->Biggest) {
  937. Middle();
  938. }
  939. #endif
  940. }
  941. /***********************************************************************************************
  942. * AnimClass::Middle -- Processes any middle events. *
  943. * *
  944. * This routine is called when the animation as reached its largest stage. Typically, this *
  945. * routine is used to cause scorches or craters to appear at a cosmetically pleasing *
  946. * moment. *
  947. * *
  948. * INPUT: none *
  949. * *
  950. * OUTPUT: none *
  951. * *
  952. * WARNINGS: none *
  953. * *
  954. * HISTORY: *
  955. * 06/30/1995 JLB : Created. *
  956. * 10/17/1995 JLB : Ion camera added. *
  957. *=============================================================================================*/
  958. void AnimClass::Middle(void)
  959. {
  960. #ifdef VIC
  961. assert(Anims.ID(this) == ID);
  962. assert(IsActive);
  963. CELL cell = Coord_Cell(Center_Coord());
  964. CellClass * cellptr = &Map[cell];
  965. if (Class->Type == ANIM_ATOM_BLAST) {
  966. Do_Atom_Damage(OwnerHouse, cell);
  967. }
  968. /*
  969. ** If this animation leaves scorch marks (e.g., napalm), then do so at this time.
  970. */
  971. if (Class->IsScorcher) {
  972. new SmudgeClass(Random_Pick(SMUDGE_SCORCH1, SMUDGE_SCORCH6), Center_Coord());
  973. }
  974. /*
  975. ** Some animations leave a crater when they occur. Artillery is a good example.
  976. ** Craters always remove the Tiberium where they occur.
  977. */
  978. if (Class->IsCraterForming) {
  979. /*
  980. ** Craters reduce the level of Tiberium in the cell.
  981. */
  982. cellptr->Reduce_Tiberium(6);
  983. /*
  984. ** If there already is a crater in the cell, then just expand the
  985. ** crater.
  986. */
  987. new SmudgeClass(SMUDGE_CRATER1, Center_Coord());
  988. }
  989. AnimClass * newanim;
  990. /*
  991. ** If this animation spawns side effects during its lifetime, then
  992. ** do so now. Usually, these side effects are in the form of other
  993. ** animations.
  994. */
  995. switch (Class->Type) {
  996. case ANIM_NAPALM1:
  997. case ANIM_NAPALM2:
  998. case ANIM_NAPALM3:
  999. new AnimClass(ANIM_FIRE_SMALL, Map.Closest_Free_Spot(Coord_Scatter(Center_Coord(), 0x0040), true), 0, Random_Pick(1, 2));
  1000. if (Percent_Chance(50)) {
  1001. new AnimClass(ANIM_FIRE_SMALL, Map.Closest_Free_Spot(Coord_Scatter(Center_Coord(), 0x00A0), true), 0, Random_Pick(1, 2));
  1002. }
  1003. if (Percent_Chance(50)) {
  1004. new AnimClass(ANIM_FIRE_MED, Map.Closest_Free_Spot(Coord_Scatter(Center_Coord(), 0x0070), true), 0, Random_Pick(1, 2));
  1005. }
  1006. break;
  1007. case ANIM_FIRE_MED:
  1008. case ANIM_FIRE_MED2:
  1009. newanim = new AnimClass(ANIM_FIRE_SMALL, Center_Coord(), 0, Random_Pick(1, 2));
  1010. if (newanim != NULL && xObject != TARGET_NONE) {
  1011. newanim->Attach_To(As_Object(xObject));
  1012. }
  1013. break;
  1014. default:
  1015. break;
  1016. }
  1017. #endif
  1018. }
  1019. void AnimClass::Chain(void)
  1020. {
  1021. /*
  1022. ** The animation should end now, but first check to see if
  1023. ** it needs to chain into another animation. If so, then the
  1024. ** animation isn't technically over. It metamorphoses into the
  1025. ** new form.
  1026. */
  1027. if (Class->ChainTo != ANIM_NONE) {
  1028. Class = (AnimTypeClass *)&AnimTypeClass::As_Reference(Class->ChainTo);
  1029. if (Class->Stages == -1) {
  1030. IsTheaterShape = Class->IsTheater;
  1031. ((int&)Class->Stages) = Get_Build_Frame_Count(Class->Get_Image_Data());
  1032. IsTheaterShape = false;
  1033. }
  1034. if (Class->LoopEnd == -1) {
  1035. ((int&)Class->LoopEnd) = Class->Stages;
  1036. }
  1037. IsToDelete = false;
  1038. Loops = Class->Loops;
  1039. Accum = 0;
  1040. if (Class->IsNormalized) {
  1041. Set_Rate(Options.Normalize_Delay(Class->Delay));
  1042. } else {
  1043. Set_Rate(Class->Delay);
  1044. }
  1045. Set_Stage(Class->Start);
  1046. Start();
  1047. }
  1048. }
  1049. /***********************************************************************************************
  1050. * AnimClass::Detach -- Remove animation if attached to target. *
  1051. * *
  1052. * This routine is called when the specified target is being removed from the game. If this *
  1053. * animation happens to be attached to this object, then the animation must be remove as *
  1054. * well. *
  1055. * *
  1056. * INPUT: target -- The target that is about to be destroyed. *
  1057. * *
  1058. * all -- Is the target being destroyed RIGHT NOW? If not, then it will be *
  1059. * destroyed soon. In that case, the animation should continue to remain *
  1060. * attached for cosmetic reasons. *
  1061. * *
  1062. * OUTPUT: none *
  1063. * *
  1064. * WARNINGS: none *
  1065. * *
  1066. * HISTORY: *
  1067. * 06/30/1995 JLB : Created. *
  1068. * 07/02/1995 JLB : Detach is a precursor to animation destruction. *
  1069. *=============================================================================================*/
  1070. void AnimClass::Detach(TARGET target, bool all)
  1071. {
  1072. #ifdef VIC
  1073. assert(Anims.ID(this) == ID);
  1074. assert(IsActive);
  1075. if (all) {
  1076. if (Target_Legal(VirtualAnimTarget) && VirtualAnimTarget == target) {
  1077. VirtualAnimTarget = TARGET_NONE;
  1078. if (IsInvisible) {
  1079. IsToDelete = true;
  1080. Mark(MARK_UP);
  1081. }
  1082. }
  1083. if (xObject == target) {
  1084. Map.Remove(this, In_Which_Layer());
  1085. xObject = TARGET_NONE;
  1086. AttachLayer = LAYER_NONE;
  1087. IsToDelete = true;
  1088. Mark(MARK_UP);
  1089. }
  1090. }
  1091. #endif
  1092. }
  1093. /***********************************************************************************************
  1094. * AnimClass::Do_Atom_Damage -- Do atom bomb damage centered around the cell specified. *
  1095. * *
  1096. * This routine will apply damage around the ground-zero cell specified. *
  1097. * *
  1098. * INPUT: ownerhouse -- The owner of this atom bomb. *
  1099. * *
  1100. * cell -- The ground zero location to apply the atom bomb damage. *
  1101. * *
  1102. * OUTPUT: none *
  1103. * *
  1104. * WARNINGS: none *
  1105. * *
  1106. * HISTORY: *
  1107. * 07/06/1996 JLB : Created. *
  1108. *=============================================================================================*/
  1109. void AnimClass::Do_Atom_Damage(HousesType ownerhouse, CELL cell)
  1110. {
  1111. #ifdef VIC
  1112. /*
  1113. ** Find someone to blame the explosion on. This is necessary in
  1114. ** order to properly enact retribution and record the kill for
  1115. ** score purposes.
  1116. */
  1117. BuildingClass * building = NULL;
  1118. TechnoClass * backup = NULL;
  1119. if (ownerhouse != HOUSE_NONE) {
  1120. for (int index = 0; index < Logic.Count(); index++) {
  1121. ObjectClass * obj = Logic[index];
  1122. if (obj != NULL && obj->Is_Techno() && obj->Owner() == ownerhouse) {
  1123. backup = (TechnoClass *)obj;
  1124. if (obj->What_Am_I() == RTTI_BUILDING && *((BuildingClass *)obj) == STRUCT_MSLO) {
  1125. building = (BuildingClass *)obj;
  1126. break;
  1127. }
  1128. }
  1129. }
  1130. if (building == NULL) building = (BuildingClass *)backup;
  1131. }
  1132. int radius;
  1133. int rawdamage;
  1134. if (Session.Type == GAME_NORMAL) {
  1135. radius = 4;
  1136. rawdamage = Rule.AtomDamage;
  1137. //WhitePalette.Set(FADE_PALETTE_SLOW, Call_Back); //TO_FIX. ST 5/8/2019
  1138. } else {
  1139. radius = 3;
  1140. rawdamage = Rule.AtomDamage/5;
  1141. }
  1142. Wide_Area_Damage(Cell_Coord(cell), radius * CELL_LEPTON_W, rawdamage, building, WARHEAD_FIRE);
  1143. Shake_The_Screen(3);
  1144. if (Session.Type == GAME_NORMAL) {
  1145. //GamePalette.Set(FADE_PALETTE_SLOW, Call_Back); //TO_FIX. ST 5/8/2019
  1146. }
  1147. #endif
  1148. }
  1149. void AnimClass::Set_Owner(HousesType owner)
  1150. {
  1151. OwnerHouse = owner;
  1152. if (Target_Legal(VirtualAnimTarget)) {
  1153. As_Animation(VirtualAnimTarget)->Set_Owner(owner);
  1154. }
  1155. }
  1156. void AnimClass::Set_Visible_Flags(unsigned flags)
  1157. {
  1158. VisibleFlags = flags;
  1159. if (Target_Legal(VirtualAnimTarget)) {
  1160. As_Animation(VirtualAnimTarget)->Set_Visible_Flags(flags);
  1161. }
  1162. }