1 /* $Id: effects.c,v 1.5 2003-10-10 09:36:34 btb Exp $ */
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
17 * Special effects, such as rotating fans, electrical walls, and
18 * other cool animations.
21 * Revision 1.1 1995/05/16 15:24:25 allender
24 * Revision 2.0 1995/02/27 11:32:49 john
25 * New version 2.0, which has no anonymous unions, builds with
26 * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
28 * Revision 1.21 1995/02/13 20:35:06 john
31 * Revision 1.20 1994/12/10 16:44:50 matt
32 * Added debugging code to track down door that turns into rock
34 * Revision 1.19 1994/12/06 16:27:14 matt
35 * Fixed horrible bug that was referencing segment -1
37 * Revision 1.18 1994/12/02 23:20:51 matt
38 * Reset bitmaps possibly changed by crit clips
40 * Revision 1.17 1994/11/14 14:00:19 matt
43 * Revision 1.16 1994/11/14 12:42:43 matt
44 * Allow holes in effects list
46 * Revision 1.15 1994/11/08 21:11:52 matt
47 * Added functions to stop & start effects
49 * Revision 1.14 1994/10/04 18:59:08 matt
50 * Exploding eclips now play eclip while exploding, then switch to static bm
52 * Revision 1.13 1994/10/04 15:17:42 matt
53 * Took out references to unused constant
55 * Revision 1.12 1994/09/29 11:00:01 matt
56 * Made eclips (wall animations) not frame-rate dependent (for now)
58 * Revision 1.11 1994/09/25 00:40:24 matt
59 * Added the ability to make eclips (monitors, fans) which can be blown up
61 * Revision 1.10 1994/08/14 23:15:14 matt
62 * Added animating bitmap hostages, and cleaned up vclips a bit
64 * Revision 1.9 1994/08/05 15:56:04 matt
65 * Cleaned up effects system, and added alternate effects for after mine
68 * Revision 1.8 1994/08/01 23:17:21 matt
69 * Add support for animating textures on robots
71 * Revision 1.7 1994/05/23 15:10:46 yuan
72 * Make Eclips read directly...
73 * No more need for $EFFECTS list.
75 * Revision 1.6 1994/04/06 14:42:44 yuan
76 * Adding new powerups.
78 * Revision 1.5 1994/03/15 16:31:54 yuan
79 * Cleaned up bm-loading code.
82 * Revision 1.4 1994/03/04 17:09:09 yuan
85 * Revision 1.3 1994/01/11 11:18:50 yuan
88 * Revision 1.2 1994/01/11 10:38:55 yuan
89 * Special effects new implementation
91 * Revision 1.1 1994/01/10 09:45:29 yuan
102 static char rcsid[] = "$Id: effects.c,v 1.5 2003-10-10 09:36:34 btb Exp $";
118 #include "textures.h"
119 #include "cntrlcen.h"
123 eclip Effects[MAX_EFFECTS];
125 void init_special_effects()
129 for (i=0;i<Num_effects;i++)
130 Effects[i].time_left = Effects[i].vc.frame_time;
133 void reset_special_effects()
137 for (i=0;i<Num_effects;i++) {
138 Effects[i].segnum = -1; //clear any active one-shots
139 Effects[i].flags &= ~(EF_STOPPED|EF_ONE_SHOT); //restart any stopped effects
141 //reset bitmap, which could have been changed by a crit_clip
142 if (Effects[i].changing_wall_texture != -1)
143 Textures[Effects[i].changing_wall_texture] = Effects[i].vc.frames[Effects[i].frame_count];
145 if (Effects[i].changing_object_texture != -1)
146 ObjBitmaps[Effects[i].changing_object_texture] = Effects[i].vc.frames[Effects[i].frame_count];
151 void do_special_effects()
156 for (i=0,ec=Effects;i<Num_effects;i++,ec++) {
158 if ((Effects[i].changing_wall_texture == -1) && (Effects[i].changing_object_texture==-1) )
161 if (ec->flags & EF_STOPPED)
164 ec->time_left -= FrameTime;
166 while (ec->time_left < 0) {
168 ec->time_left += ec->vc.frame_time;
171 if (ec->frame_count >= ec->vc.num_frames) {
172 if (ec->flags & EF_ONE_SHOT) {
173 Assert(ec->segnum!=-1);
174 Assert(ec->sidenum>=0 && ec->sidenum<6);
175 Assert(ec->dest_bm_num!=0 && Segments[ec->segnum].sides[ec->sidenum].tmap_num2!=0);
176 Segments[ec->segnum].sides[ec->sidenum].tmap_num2 = ec->dest_bm_num | (Segments[ec->segnum].sides[ec->sidenum].tmap_num2&0xc000); //replace with destoyed
177 ec->flags &= ~EF_ONE_SHOT;
178 ec->segnum = -1; //done with this
185 if (ec->flags & EF_CRITICAL)
188 if (ec->crit_clip!=-1 && Control_center_destroyed) {
189 int n = ec->crit_clip;
191 //*ec->bm_ptr = &GameBitmaps[Effects[n].vc.frames[Effects[n].frame_count].index];
192 if (ec->changing_wall_texture != -1)
193 Textures[ec->changing_wall_texture] = Effects[n].vc.frames[Effects[n].frame_count];
195 if (ec->changing_object_texture != -1)
196 ObjBitmaps[ec->changing_object_texture] = Effects[n].vc.frames[Effects[n].frame_count];
200 // *ec->bm_ptr = &GameBitmaps[ec->vc.frames[ec->frame_count].index];
201 if (ec->changing_wall_texture != -1)
202 Textures[ec->changing_wall_texture] = ec->vc.frames[ec->frame_count];
204 if (ec->changing_object_texture != -1)
205 ObjBitmaps[ec->changing_object_texture] = ec->vc.frames[ec->frame_count];
211 void restore_effect_bitmap_icons()
215 for (i=0;i<Num_effects;i++)
216 if (! (Effects[i].flags & EF_CRITICAL)) {
217 if (Effects[i].changing_wall_texture != -1)
218 Textures[Effects[i].changing_wall_texture] = Effects[i].vc.frames[0];
220 if (Effects[i].changing_object_texture != -1)
221 ObjBitmaps[Effects[i].changing_object_texture] = Effects[i].vc.frames[0];
223 //if (Effects[i].bm_ptr != -1)
224 // *Effects[i].bm_ptr = &GameBitmaps[Effects[i].vc.frames[0].index];
227 //stop an effect from animating. Show first frame.
228 void stop_effect(int effect_num)
230 eclip *ec = &Effects[effect_num];
232 //Assert(ec->bm_ptr != -1);
234 ec->flags |= EF_STOPPED;
237 //*ec->bm_ptr = &GameBitmaps[ec->vc.frames[0].index];
239 if (ec->changing_wall_texture != -1)
240 Textures[ec->changing_wall_texture] = ec->vc.frames[0];
242 if (ec->changing_object_texture != -1)
243 ObjBitmaps[ec->changing_object_texture] = ec->vc.frames[0];
247 //restart a stopped effect
248 void restart_effect(int effect_num)
250 Effects[effect_num].flags &= ~EF_STOPPED;
252 //Assert(Effects[effect_num].bm_ptr != -1);
257 * reads n eclip structs from a CFILE
259 int eclip_read_n(eclip *ec, int n, CFILE *fp)
263 for (i = 0; i < n; i++) {
264 vclip_read_n(&ec[i].vc, 1, fp);
265 ec[i].time_left = cfile_read_fix(fp);
266 ec[i].frame_count = cfile_read_int(fp);
267 ec[i].changing_wall_texture = cfile_read_short(fp);
268 ec[i].changing_object_texture = cfile_read_short(fp);
269 ec[i].flags = cfile_read_int(fp);
270 ec[i].crit_clip = cfile_read_int(fp);
271 ec[i].dest_bm_num = cfile_read_int(fp);
272 ec[i].dest_vclip = cfile_read_int(fp);
273 ec[i].dest_eclip = cfile_read_int(fp);
274 ec[i].dest_size = cfile_read_fix(fp);
275 ec[i].sound_num = cfile_read_int(fp);
276 ec[i].segnum = cfile_read_int(fp);
277 ec[i].sidenum = cfile_read_int(fp);