1 /* $Id: effects.c,v 1.6 2004-08-28 23:17:45 schaffner 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.
27 static char rcsid[] = "$Id: effects.c,v 1.6 2004-08-28 23:17:45 schaffner Exp $";
48 eclip Effects[MAX_EFFECTS];
50 void init_special_effects()
54 for (i=0;i<Num_effects;i++)
55 Effects[i].time_left = Effects[i].vc.frame_time;
58 void reset_special_effects()
62 for (i=0;i<Num_effects;i++) {
63 Effects[i].segnum = -1; //clear any active one-shots
64 Effects[i].flags &= ~(EF_STOPPED|EF_ONE_SHOT); //restart any stopped effects
66 //reset bitmap, which could have been changed by a crit_clip
67 if (Effects[i].changing_wall_texture != -1)
68 Textures[Effects[i].changing_wall_texture] = Effects[i].vc.frames[Effects[i].frame_count];
70 if (Effects[i].changing_object_texture != -1)
71 ObjBitmaps[Effects[i].changing_object_texture] = Effects[i].vc.frames[Effects[i].frame_count];
76 void do_special_effects()
81 for (i=0,ec=Effects;i<Num_effects;i++,ec++) {
83 if ((Effects[i].changing_wall_texture == -1) && (Effects[i].changing_object_texture==-1) )
86 if (ec->flags & EF_STOPPED)
89 ec->time_left -= FrameTime;
91 while (ec->time_left < 0) {
93 ec->time_left += ec->vc.frame_time;
96 if (ec->frame_count >= ec->vc.num_frames) {
97 if (ec->flags & EF_ONE_SHOT) {
98 Assert(ec->segnum!=-1);
99 Assert(ec->sidenum>=0 && ec->sidenum<6);
100 Assert(ec->dest_bm_num!=0 && Segments[ec->segnum].sides[ec->sidenum].tmap_num2!=0);
101 Segments[ec->segnum].sides[ec->sidenum].tmap_num2 = ec->dest_bm_num | (Segments[ec->segnum].sides[ec->sidenum].tmap_num2&0xc000); //replace with destoyed
102 ec->flags &= ~EF_ONE_SHOT;
103 ec->segnum = -1; //done with this
110 if (ec->flags & EF_CRITICAL)
113 if (ec->crit_clip!=-1 && Control_center_destroyed) {
114 int n = ec->crit_clip;
116 //*ec->bm_ptr = &GameBitmaps[Effects[n].vc.frames[Effects[n].frame_count].index];
117 if (ec->changing_wall_texture != -1)
118 Textures[ec->changing_wall_texture] = Effects[n].vc.frames[Effects[n].frame_count];
120 if (ec->changing_object_texture != -1)
121 ObjBitmaps[ec->changing_object_texture] = Effects[n].vc.frames[Effects[n].frame_count];
125 // *ec->bm_ptr = &GameBitmaps[ec->vc.frames[ec->frame_count].index];
126 if (ec->changing_wall_texture != -1)
127 Textures[ec->changing_wall_texture] = ec->vc.frames[ec->frame_count];
129 if (ec->changing_object_texture != -1)
130 ObjBitmaps[ec->changing_object_texture] = ec->vc.frames[ec->frame_count];
136 void restore_effect_bitmap_icons()
140 for (i=0;i<Num_effects;i++)
141 if (! (Effects[i].flags & EF_CRITICAL)) {
142 if (Effects[i].changing_wall_texture != -1)
143 Textures[Effects[i].changing_wall_texture] = Effects[i].vc.frames[0];
145 if (Effects[i].changing_object_texture != -1)
146 ObjBitmaps[Effects[i].changing_object_texture] = Effects[i].vc.frames[0];
148 //if (Effects[i].bm_ptr != -1)
149 // *Effects[i].bm_ptr = &GameBitmaps[Effects[i].vc.frames[0].index];
152 //stop an effect from animating. Show first frame.
153 void stop_effect(int effect_num)
155 eclip *ec = &Effects[effect_num];
157 //Assert(ec->bm_ptr != -1);
159 ec->flags |= EF_STOPPED;
162 //*ec->bm_ptr = &GameBitmaps[ec->vc.frames[0].index];
164 if (ec->changing_wall_texture != -1)
165 Textures[ec->changing_wall_texture] = ec->vc.frames[0];
167 if (ec->changing_object_texture != -1)
168 ObjBitmaps[ec->changing_object_texture] = ec->vc.frames[0];
172 //restart a stopped effect
173 void restart_effect(int effect_num)
175 Effects[effect_num].flags &= ~EF_STOPPED;
177 //Assert(Effects[effect_num].bm_ptr != -1);
182 * reads n eclip structs from a CFILE
184 int eclip_read_n(eclip *ec, int n, CFILE *fp)
188 for (i = 0; i < n; i++) {
189 vclip_read_n(&ec[i].vc, 1, fp);
190 ec[i].time_left = cfile_read_fix(fp);
191 ec[i].frame_count = cfile_read_int(fp);
192 ec[i].changing_wall_texture = cfile_read_short(fp);
193 ec[i].changing_object_texture = cfile_read_short(fp);
194 ec[i].flags = cfile_read_int(fp);
195 ec[i].crit_clip = cfile_read_int(fp);
196 ec[i].dest_bm_num = cfile_read_int(fp);
197 ec[i].dest_vclip = cfile_read_int(fp);
198 ec[i].dest_eclip = cfile_read_int(fp);
199 ec[i].dest_size = cfile_read_fix(fp);
200 ec[i].sound_num = cfile_read_int(fp);
201 ec[i].segnum = cfile_read_int(fp);
202 ec[i].sidenum = cfile_read_int(fp);