home *** CD-ROM | disk | FTP | other *** search
/ Amiga ACS 1998 #6 / amigaacscoverdisc1998-061998.iso / games / descent / source / main / effects.c < prev    next >
Text File  |  1998-06-08  |  7KB  |  253 lines

  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.  
  96.  
  97. #pragma off (unreferenced)
  98. static char rcsid[] = "$Id: effects.c 2.0 1995/02/27 11:32:49 john Exp $";
  99. #pragma on (unreferenced)
  100.  
  101. #include <stdio.h>
  102. #include <stdlib.h>
  103. #include <stdarg.h>
  104. #include <conio.h>
  105. #include <string.h>
  106.  
  107. #include "gr.h"
  108. #include "inferno.h"
  109. #include "game.h"
  110. #include "vclip.h"
  111. #include "effects.h"
  112. #include "bm.h"
  113. #include "mono.h"
  114. #include "mem.h"
  115. #include "textures.h"
  116. #include "fuelcen.h"
  117. #include "error.h"
  118.  
  119. int Num_effects;
  120. eclip Effects[MAX_EFFECTS];
  121.  
  122. void init_special_effects() 
  123. {
  124.     int i;
  125.  
  126.     for (i=0;i<Num_effects;i++)
  127.         Effects[i].time_left = Effects[i].vc.frame_time;
  128. }
  129.  
  130. void reset_special_effects()
  131. {
  132.     int i;
  133.  
  134.     for (i=0;i<Num_effects;i++) {
  135.         Effects[i].segnum = -1;                    //clear any active one-shots
  136.         Effects[i].flags &= ~(EF_STOPPED|EF_ONE_SHOT);        //restart any stopped effects
  137.  
  138.         //reset bitmap, which could have been changed by a crit_clip
  139.         if (Effects[i].changing_wall_texture != -1)
  140.             Textures[Effects[i].changing_wall_texture] = Effects[i].vc.frames[Effects[i].frame_count];
  141.  
  142.         if (Effects[i].changing_object_texture != -1)
  143.             ObjBitmaps[Effects[i].changing_object_texture] = Effects[i].vc.frames[Effects[i].frame_count];
  144.  
  145.     }
  146. }
  147.  
  148. void do_special_effects()
  149. {
  150.     int i;
  151.     eclip *ec;
  152.  
  153.     for (i=0,ec=Effects;i<Num_effects;i++,ec++) {
  154.  
  155.         if ((Effects[i].changing_wall_texture == -1) && (Effects[i].changing_object_texture==-1) )
  156.             continue;
  157.  
  158.         if (ec->flags & EF_STOPPED)
  159.             continue;
  160.  
  161.         ec->time_left -= FrameTime;
  162.  
  163.         while (ec->time_left < 0) {
  164.  
  165.             ec->time_left += ec->vc.frame_time;
  166.             
  167.             ec->frame_count++;
  168.             if (ec->frame_count >= ec->vc.num_frames) {
  169.                 if (ec->flags & EF_ONE_SHOT) {
  170.                     Assert(ec->segnum!=-1);
  171.                     Assert(ec->sidenum>=0 && ec->sidenum<6);
  172.                     Assert(ec->dest_bm_num!=0 && Segments[ec->segnum].sides[ec->sidenum].tmap_num2!=0);
  173.                     Segments[ec->segnum].sides[ec->sidenum].tmap_num2 = ec->dest_bm_num | (Segments[ec->segnum].sides[ec->sidenum].tmap_num2&0xc000);        //replace with destoyed
  174.                     ec->flags &= ~EF_ONE_SHOT;
  175.                     ec->segnum = -1;        //done with this
  176.                 }
  177.  
  178.                 ec->frame_count = 0;
  179.             }
  180.         }
  181.  
  182.         if (ec->flags & EF_CRITICAL)
  183.             continue;
  184.  
  185.         if (ec->crit_clip!=-1 && Fuelcen_control_center_destroyed) {
  186.             int n = ec->crit_clip;
  187.  
  188.             //*ec->bm_ptr = &GameBitmaps[Effects[n].vc.frames[Effects[n].frame_count].index];
  189.             if (ec->changing_wall_texture != -1)
  190.                 Textures[ec->changing_wall_texture] = Effects[n].vc.frames[Effects[n].frame_count];
  191.  
  192.             if (ec->changing_object_texture != -1)
  193.                 ObjBitmaps[ec->changing_object_texture] = Effects[n].vc.frames[Effects[n].frame_count];
  194.  
  195.         }
  196.         else    {
  197.             // *ec->bm_ptr = &GameBitmaps[ec->vc.frames[ec->frame_count].index];
  198.             if (ec->changing_wall_texture != -1)
  199.                 Textures[ec->changing_wall_texture] = ec->vc.frames[ec->frame_count];
  200.     
  201.             if (ec->changing_object_texture != -1)
  202.                 ObjBitmaps[ec->changing_object_texture] = ec->vc.frames[ec->frame_count];
  203.         }
  204.  
  205.     }
  206. }
  207.  
  208. void restore_effect_bitmap_icons()
  209. {
  210.     int i;
  211.     
  212.     for (i=0;i<Num_effects;i++)
  213.         if (! (Effects[i].flags & EF_CRITICAL))    {
  214.             if (Effects[i].changing_wall_texture != -1)
  215.                 Textures[Effects[i].changing_wall_texture] = Effects[i].vc.frames[0];
  216.     
  217.             if (Effects[i].changing_object_texture != -1)
  218.                 ObjBitmaps[Effects[i].changing_object_texture] = Effects[i].vc.frames[0];
  219.         }
  220.             //if (Effects[i].bm_ptr != -1)
  221.             //    *Effects[i].bm_ptr = &GameBitmaps[Effects[i].vc.frames[0].index];
  222. }
  223.  
  224. //stop an effect from animating.  Show first frame.
  225. void stop_effect(int effect_num)
  226. {
  227.     eclip *ec = &Effects[effect_num];
  228.     
  229.     //Assert(ec->bm_ptr != -1);
  230.  
  231.     ec->flags |= EF_STOPPED;
  232.  
  233.     ec->frame_count = 0;
  234.     //*ec->bm_ptr = &GameBitmaps[ec->vc.frames[0].index];
  235.  
  236.     if (ec->changing_wall_texture != -1)
  237.         Textures[ec->changing_wall_texture] = ec->vc.frames[0];
  238.     
  239.     if (ec->changing_object_texture != -1)
  240.         ObjBitmaps[ec->changing_object_texture] = ec->vc.frames[0];
  241.  
  242. }
  243.  
  244. //restart a stopped effect
  245. void restart_effect(int effect_num)
  246. {
  247.     Effects[effect_num].flags &= ~EF_STOPPED;
  248.  
  249.     //Assert(Effects[effect_num].bm_ptr != -1);
  250. }
  251.  
  252. 
  253.