EFFECTS.C 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. /*
  2. THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  3. SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
  4. END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  5. ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  6. IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  7. SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  8. FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  9. CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
  10. AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
  11. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
  12. */
  13. /*
  14. * $Source: f:/miner/source/main/rcs/effects.c $
  15. * $Revision: 2.0 $
  16. * $Author: john $
  17. * $Date: 1995/02/27 11:32:49 $
  18. *
  19. * Special effects, such as rotating fans, electrical walls, and
  20. * other cool animations.
  21. *
  22. * $Log: effects.c $
  23. * Revision 2.0 1995/02/27 11:32:49 john
  24. * New version 2.0, which has no anonymous unions, builds with
  25. * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
  26. *
  27. * Revision 1.21 1995/02/13 20:35:06 john
  28. * Lintized
  29. *
  30. * Revision 1.20 1994/12/10 16:44:50 matt
  31. * Added debugging code to track down door that turns into rock
  32. *
  33. * Revision 1.19 1994/12/06 16:27:14 matt
  34. * Fixed horrible bug that was referencing segment -1
  35. *
  36. * Revision 1.18 1994/12/02 23:20:51 matt
  37. * Reset bitmaps possibly changed by crit clips
  38. *
  39. * Revision 1.17 1994/11/14 14:00:19 matt
  40. * Fixed stupid bug
  41. *
  42. * Revision 1.16 1994/11/14 12:42:43 matt
  43. * Allow holes in effects list
  44. *
  45. * Revision 1.15 1994/11/08 21:11:52 matt
  46. * Added functions to stop & start effects
  47. *
  48. * Revision 1.14 1994/10/04 18:59:08 matt
  49. * Exploding eclips now play eclip while exploding, then switch to static bm
  50. *
  51. * Revision 1.13 1994/10/04 15:17:42 matt
  52. * Took out references to unused constant
  53. *
  54. * Revision 1.12 1994/09/29 11:00:01 matt
  55. * Made eclips (wall animations) not frame-rate dependent (for now)
  56. *
  57. * Revision 1.11 1994/09/25 00:40:24 matt
  58. * Added the ability to make eclips (monitors, fans) which can be blown up
  59. *
  60. * Revision 1.10 1994/08/14 23:15:14 matt
  61. * Added animating bitmap hostages, and cleaned up vclips a bit
  62. *
  63. * Revision 1.9 1994/08/05 15:56:04 matt
  64. * Cleaned up effects system, and added alternate effects for after mine
  65. * destruction.
  66. *
  67. * Revision 1.8 1994/08/01 23:17:21 matt
  68. * Add support for animating textures on robots
  69. *
  70. * Revision 1.7 1994/05/23 15:10:46 yuan
  71. * Make Eclips read directly...
  72. * No more need for $EFFECTS list.
  73. *
  74. * Revision 1.6 1994/04/06 14:42:44 yuan
  75. * Adding new powerups.
  76. *
  77. * Revision 1.5 1994/03/15 16:31:54 yuan
  78. * Cleaned up bm-loading code.
  79. * (And structures)
  80. *
  81. * Revision 1.4 1994/03/04 17:09:09 yuan
  82. * New door stuff.
  83. *
  84. * Revision 1.3 1994/01/11 11:18:50 yuan
  85. * Fixed frame_count
  86. *
  87. * Revision 1.2 1994/01/11 10:38:55 yuan
  88. * Special effects new implementation
  89. *
  90. * Revision 1.1 1994/01/10 09:45:29 yuan
  91. * Initial revision
  92. *
  93. *
  94. */
  95. #pragma off (unreferenced)
  96. static char rcsid[] = "$Id: effects.c 2.0 1995/02/27 11:32:49 john Exp $";
  97. #pragma on (unreferenced)
  98. #include <stdio.h>
  99. #include <stdlib.h>
  100. #include <stdarg.h>
  101. #include <conio.h>
  102. #include <string.h>
  103. #include "gr.h"
  104. #include "inferno.h"
  105. #include "game.h"
  106. #include "vclip.h"
  107. #include "effects.h"
  108. #include "bm.h"
  109. #include "mono.h"
  110. #include "mem.h"
  111. #include "textures.h"
  112. #include "fuelcen.h"
  113. #include "error.h"
  114. int Num_effects;
  115. eclip Effects[MAX_EFFECTS];
  116. void init_special_effects()
  117. {
  118. int i;
  119. for (i=0;i<Num_effects;i++)
  120. Effects[i].time_left = Effects[i].vc.frame_time;
  121. }
  122. void reset_special_effects()
  123. {
  124. int i;
  125. for (i=0;i<Num_effects;i++) {
  126. Effects[i].segnum = -1; //clear any active one-shots
  127. Effects[i].flags &= ~(EF_STOPPED|EF_ONE_SHOT); //restart any stopped effects
  128. //reset bitmap, which could have been changed by a crit_clip
  129. if (Effects[i].changing_wall_texture != -1)
  130. Textures[Effects[i].changing_wall_texture] = Effects[i].vc.frames[Effects[i].frame_count];
  131. if (Effects[i].changing_object_texture != -1)
  132. ObjBitmaps[Effects[i].changing_object_texture] = Effects[i].vc.frames[Effects[i].frame_count];
  133. }
  134. }
  135. void do_special_effects()
  136. {
  137. int i;
  138. eclip *ec;
  139. for (i=0,ec=Effects;i<Num_effects;i++,ec++) {
  140. if ((Effects[i].changing_wall_texture == -1) && (Effects[i].changing_object_texture==-1) )
  141. continue;
  142. if (ec->flags & EF_STOPPED)
  143. continue;
  144. ec->time_left -= FrameTime;
  145. while (ec->time_left < 0) {
  146. ec->time_left += ec->vc.frame_time;
  147. ec->frame_count++;
  148. if (ec->frame_count >= ec->vc.num_frames) {
  149. if (ec->flags & EF_ONE_SHOT) {
  150. Assert(ec->segnum!=-1);
  151. Assert(ec->sidenum>=0 && ec->sidenum<6);
  152. Assert(ec->dest_bm_num!=0 && Segments[ec->segnum].sides[ec->sidenum].tmap_num2!=0);
  153. Segments[ec->segnum].sides[ec->sidenum].tmap_num2 = ec->dest_bm_num | (Segments[ec->segnum].sides[ec->sidenum].tmap_num2&0xc000); //replace with destoyed
  154. ec->flags &= ~EF_ONE_SHOT;
  155. ec->segnum = -1; //done with this
  156. }
  157. ec->frame_count = 0;
  158. }
  159. }
  160. if (ec->flags & EF_CRITICAL)
  161. continue;
  162. if (ec->crit_clip!=-1 && Fuelcen_control_center_destroyed) {
  163. int n = ec->crit_clip;
  164. //*ec->bm_ptr = &GameBitmaps[Effects[n].vc.frames[Effects[n].frame_count].index];
  165. if (ec->changing_wall_texture != -1)
  166. Textures[ec->changing_wall_texture] = Effects[n].vc.frames[Effects[n].frame_count];
  167. if (ec->changing_object_texture != -1)
  168. ObjBitmaps[ec->changing_object_texture] = Effects[n].vc.frames[Effects[n].frame_count];
  169. }
  170. else {
  171. // *ec->bm_ptr = &GameBitmaps[ec->vc.frames[ec->frame_count].index];
  172. if (ec->changing_wall_texture != -1)
  173. Textures[ec->changing_wall_texture] = ec->vc.frames[ec->frame_count];
  174. if (ec->changing_object_texture != -1)
  175. ObjBitmaps[ec->changing_object_texture] = ec->vc.frames[ec->frame_count];
  176. }
  177. }
  178. }
  179. void restore_effect_bitmap_icons()
  180. {
  181. int i;
  182. for (i=0;i<Num_effects;i++)
  183. if (! (Effects[i].flags & EF_CRITICAL)) {
  184. if (Effects[i].changing_wall_texture != -1)
  185. Textures[Effects[i].changing_wall_texture] = Effects[i].vc.frames[0];
  186. if (Effects[i].changing_object_texture != -1)
  187. ObjBitmaps[Effects[i].changing_object_texture] = Effects[i].vc.frames[0];
  188. }
  189. //if (Effects[i].bm_ptr != -1)
  190. // *Effects[i].bm_ptr = &GameBitmaps[Effects[i].vc.frames[0].index];
  191. }
  192. //stop an effect from animating. Show first frame.
  193. void stop_effect(int effect_num)
  194. {
  195. eclip *ec = &Effects[effect_num];
  196. //Assert(ec->bm_ptr != -1);
  197. ec->flags |= EF_STOPPED;
  198. ec->frame_count = 0;
  199. //*ec->bm_ptr = &GameBitmaps[ec->vc.frames[0].index];
  200. if (ec->changing_wall_texture != -1)
  201. Textures[ec->changing_wall_texture] = ec->vc.frames[0];
  202. if (ec->changing_object_texture != -1)
  203. ObjBitmaps[ec->changing_object_texture] = ec->vc.frames[0];
  204. }
  205. //restart a stopped effect
  206. void restart_effect(int effect_num)
  207. {
  208. Effects[effect_num].flags &= ~EF_STOPPED;
  209. //Assert(Effects[effect_num].bm_ptr != -1);
  210. }
  211.