Debian Codegraph @

Descent3/fireball.h

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/main/fireball.h $
21 * $Revision: 69 $
22 * $Date: 10/12/99 11:01a $
23 * $Author: Jeff $
24 *
25 * Header for fireball.cpp
26 *
27 * $Log: /DescentIII/main/fireball.h $
28 *
29 * 69 10/12/99 11:01a Jeff
30 * added grey lightning
31 *
32 * 68 9/21/99 2:54p Jeff
33 * added grey spark fireball (for multicolored sparks)
34 *
35 * 67 5/10/99 1:53a Jason
36 * add blackshark explosion
37 *
38 * 66 4/23/99 12:29a Matt
39 * Moved the code that plays an object's explosion sound into a function.
40 *
41 * 65 4/17/99 6:15p Samir
42 * replaced gr.h with grdefs.h and fixed resulting compile bugs.
43 *
44 * 64 4/06/99 1:50p Jason
45 * added new mass driver effect
46 *
47 * 63 4/05/99 4:39p Jason
48 * added groovy new smoke trails
49 *
50 * 62 3/28/99 5:55p Matt
51 * Added prototype
52 *
53 * 61 2/25/99 10:58a Matt
54 * Added new explosion system.
55 *
56 * 60 2/09/99 2:39p Jason
57 * added destroyable faces
58 *
59 * 59 1/26/99 6:39p Jason
60 * added wall effects code
61 *
62 * 58 1/24/99 8:17p Chris
63 * Updated AI and OSIRIS. Externalized fireball constants for spew and
64 * sparks. Added CreateRandomSparks to OSIRIS, renamed a bunch of AI
65 * Notify names to use underscores. Fixed a memory access leak in the
66 * matcen effect code.
67 *
68 * 57 12/11/98 5:08p Jason
69 * changed mass driver effect
70 *
71 * 56 11/19/98 6:37p Jason
72 * made a better black shark effect
73 *
74 * 55 11/18/98 2:53p Jason
75 * added snow effect
76 *
77 * 54 10/29/98 6:01p Jason
78 * added multiple coronas
79 *
80 * 53 9/29/98 7:15p Jason
81 * added axis billboards
82 *
83 * 52 9/29/98 12:49p Jason
84 * worked on matcen effects and lightning
85 *
86 * 51 9/17/98 3:03p Jason
87 * added lightning and invul hit effects
88 *
89 * 50 9/09/98 4:28p Jason
90 * added better weapon effects
91 *
92 * 49 8/17/98 10:48a Jason
93 * added more lightning code
94 *
95 * 48 7/24/98 4:45p Jason
96 * added DrawSphere
97 *
98 * 47 6/25/98 12:19p Jason
99 * made gravity effect do different damage in single vs multiplayer
100 *
101 * 46 6/23/98 3:34p Jason
102 * added cool lighting effect to gravity field
103 *
104 * 45 6/22/98 6:26p Jason
105 * added gravity field effect for weapons
106 *
107 * 44 5/19/98 4:42a Chris
108 * Added shockwave's -- enjoy. :)
109 *
110 * 43 4/30/98 6:45p Jason
111 * more changes for weather
112 *
113 * 42 4/30/98 12:22p Jason
114 * did some lo-res model optimizations
115 *
116 * 41 4/29/98 11:38a Jason
117 * added some weather effects (first pass)
118 *
119 * 40 4/17/98 12:45p Jason
120 * various changes for multiplayer
121 *
122 * 39 4/15/98 3:28p Jason
123 * changed glow stuff to work with new system
124 *
125 * 38 4/10/98 2:17p Jason
126 * added afterburner fireball
127 *
128 * 37 4/07/98 3:31p Jason
129 * got particle effects working with weapons
130 *
131 * 36 4/02/98 6:42p Jason
132 * added blue blast ring effect
133 *
134 * 35 3/20/98 5:51p Jason
135 * more changes for multiplayer
136 *
137 * 34 3/09/98 5:58p Jason
138 * draw powerups with saturated alpha rings
139 *
140 * 33 2/04/98 9:28p Jason
141 * added some new weapons effects
142 *
143 * 32 2/04/98 6:09p Matt
144 * Changed object room number to indicate a terrain cell via a flag. Got
145 * rid of the object flag which used to indicate terrain.
146 *
147 */
148
149 #ifndef FIREBALL_H
150
151 #define FIREBALL_H
152
153 #include "fireball_external.h"
154 #include "object.h"
155 #include "vecmat.h"
156 #include "manage.h"
157 #include "grdefs.h"
158 #include "DeathInfo.h"
159
160 #define PARTICLE_LIFE .5
161 #define DEBRIS_LIFE 2.0
162
163 #define FF_MOVES 1
164
165 #define VISUAL_FIREBALL 0 // This fireball is for looks only
166 #define REAL_FIREBALL 1 // This fireball can actually burn things
167
168 // The alpha for a fireball
169 #define FIREBALL_ALPHA .9f
170 // Smoke alpha
171 #define SMOKE_ALPHA .3f
172
173 #define MAX_FIREBALL_SIZE 80.0
174
175 // The lifetime of the blast ring
176 #define DAMAGE_RING_TIME 1.5f
177
178 #define NUM_FIREBALLS 52
179
180 struct fireball {
181 char name[PAGENAME_LEN]; // The filename of this animation
182
183 uint8_t type; // type of fireball, see above
184 uint8_t tex_size; // What size texture to use for this animation
185 float total_life; // How long this animation should last (in seconds)
186 float size; // How big this explosion is
187 int16_t bm_handle; // The handle to the vlip
188 };
189
190 extern fireball Fireballs[];
191
192 // Initalizes the explosion system
193 void InitFireballs();
194
195 // Given an object, renders the representation of this fireball
196 void DrawFireballObject(object *obj);
197
198 // Creates a fireball
199 // Returns object number on success, else -1 on error
200 // If vis_effect is non-zero, then this is a visual effect only
201 int CreateFireball(vector *pos, int fireball_num, int roomnum, int realtype = VISUAL_FIREBALL);
202
203 // Creates a fireball vis effect for the specified object
204 // The explosion size is twice the object size times size_scale
205 // The fireball type will be randomly selected based on the object size times size_scale
206 // Returns the visnum of the fireball
207 int CreateObjectFireball(object *objp, float size_scale = 1.0);
208
209 // Control code for debris
210 void DoDebrisFrame(object *obj);
211
212 // Process a dying object for one frame
213 void DoDyingFrame(object *objp);
214
215 // A quick way to see where a weapon hits. Weapons make debris.
216 void CreateWeaponDebris(object *obj);
217
218 // Creates a concussive blast (physics based -- no visuals)
219 void MakeShockwave(object *explode_obj_ptr, int parent_handle);
220
221 void DoConcussiveForce(object *explode_obj_ptr, int parent_handle, float player_scalar = 1);
222
223 // Creates a gravity field that sucks objects into it
224 extern int CreateGravityField(vector *pos, int roomnum, float size, float time, int parent_handle);
225
226 // Control code for explosions
227 void DoExplosionFrame(object *obj);
228
229 // Destroy an object immediately
230 void DestroyObject(object *objp, float explosion_mag, int death_flags);
231
232 // Creates a debris piece that goes off in a given direction, with a given magnitude
233 object *CreateSubobjectDebrisDirected(object *parent, int subobj_num, vector *dir, float explosion_mag,
234 int death_flags = DF_DEBRIS_SMOKES);
235
236 // Creates nifty splinters that shoot out from the body, I figure.
237 void CreateSplintersFromBody(object *obj, float explosion_mag, float lifetime);
238
239 // Creates a blast ring to be drawn
240 int CreateBlastRing(vector *pos, int index, float lifetime, float max_size, int roomnum, int force_blue = 0);
241
242 // Creates a standard blast ring for an object
243 int CreateObjectBlastRing(object *objp);
244
245 // Creates a smolding smoke to be drawn
246 int CreateSmolderingObject(vector *pos, int index, float lifetime, float max_size, int roomnum);
247
248 // Draws a blast ring
249 void DrawBlastRingObject(object *obj);
250
251 // Draws a colored alpha disk...useful for cool lighting effects
252 void DrawColoredDisk(vector *pos, float r, float g, float b, float inner_alpha, float outer_alpha, float size,
253 uint8_t saturate = 0, uint8_t lod = 1);
254
255 // Draws a colored alpha ring...useful for cool lighting effects
256 void DrawColoredRing(vector *pos, float r, float g, float b, float inner_alpha, float outer_alpha, float size,
257 float inner_ring_ratio, uint8_t saturate = 0, uint8_t lod = 1);
258
259 // Creates a blast ring from an event
260 void DoBlastRingEvent(int eventnum, void *data);
261
262 // Makes a fireball have a custom vclip
263 int CreateCustomFireballObject(vector *pos, int fireball_num, int tex_handle, int roomnum);
264
265 // Creates an explosion
266 void DoExplosionEvent(int eventnum, void *data);
267
268 // An event handler that simply draws an alpha blended poly on top of the screen
269 // Takes a 4 element array of floats int r,g,b,a format
270 void DrawAlphaEvent(int eventnum, void *data);
271
272 // Returns a random medium sized explosion
273 int GetRandomMediumExplosion();
274
275 // Returns a random small explosion
276 int GetRandomSmallExplosion();
277
278 // Returns a random small explosion
279 int GetRandomBillowingExplosion();
280
281 // Draws a sphere with the appropriate texture. If texture=-1, then uses rgb as colors
282 void DrawSphere(vector *pos, float r, float g, float b, float alpha, float size, int texture, uint8_t saturate = 1);
283
284 // Creates end points that simulate lightning
285 void CreateLightningRodPositions(vector *src, vector *dest, vector *world_vecs, int num_segments, float rand_mag,
286 bool do_flat);
287
288 // Draws a glowing cone of light using a bitmap
289 void DrawColoredGlow(vector *pos, float r, float g, float b, float size);
290
291 void CreateElectricalBolts(object *objp, int num_bolts);
292
293 // Play the explosion sound for this object
294 void PlayObjectExplosionSound(object *objp);
295
296 #endif