Debian Codegraph @

Descent3/spew.cpp

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/spew.cpp $
21 * $Revision: 28 $
22 * $Date: 10/31/99 5:41p $
23 * $Author: Chris $
24 *
25 * Source file for spew system
26 *
27 * $Log: /DescentIII/main/spew.cpp $
28 *
29 * 28 10/31/99 5:41p Chris
30 * Fixed a problem with spewers on attached objects
31 *
32 * 27 5/02/99 2:52a Jeff
33 * fixed spewers for turrets/rotaters
34 *
35 * 26 4/30/99 8:32p Jeff
36 * more info on mprintf
37 *
38 * 25 4/29/99 7:50p Jason
39 * fixed spew errors
40 *
41 * 24 4/29/99 5:09p Jeff
42 * fixed spewers on animated objects
43 *
44 * 23 4/22/99 8:29p Kevin
45 * made psrand.h come after stdlib.h
46 *
47 * 22 4/21/99 11:05a Kevin
48 * new ps_rand and ps_srand to replace rand & srand
49 *
50 * 21 4/19/99 3:17p Jason
51 * made real vis effects work
52 *
53 * 20 4/15/99 1:42a Jeff
54 * changes for linux compile
55 *
56 * 19 1/21/99 11:15p Jeff
57 * pulled out some structs and defines from header files and moved them
58 * into seperate header files so that multiplayer dlls don't require major
59 * game headers, just those new headers. Side effect is a shorter build
60 * time. Also cleaned up some header file #includes that weren't needed.
61 * This affected polymodel.h, object.h, player.h, vecmat.h, room.h,
62 * manage.h and multi.h
63 *
64 * 18 1/13/99 2:32p Jeff
65 * added error checking on create...returns -1 on error
66 *
67 * 17 10/18/98 9:15p Jeff
68 * ok....it's sped up now
69 *
70 * 16 10/18/98 9:04p Jeff
71 * sped up spew by saving values?
72 *
73 * 15 8/19/98 5:36p Samir
74 * moved some stuff from source to header file.
75 *
76 * 14 7/27/98 6:26p Jeff
77 * added an mprintf for my sanity
78 *
79 * 13 2/16/98 2:33p Jeff
80 * Now passing real flag when creating a spew
81 *
82 * 12 2/04/98 6:09p Matt
83 * Changed object room number to indicate a terrain cell via a flag. Got
84 * rid of the object flag which used to indicate terrain.
85 *
86 * 11 2/02/98 5:05p Luke
87 *
88 * 10 2/02/98 4:38p Jeff
89 * fixed handle system (stupid bug)
90 *
91 * 9 2/02/98 3:10p Jeff
92 * new handle system, makes more reliable
93 *
94 * 8 1/27/98 10:49a Jeff
95 * commented out mprintfs
96 *
97 * 7 1/26/98 4:20p Jeff
98 * added some debugging mprintfs
99 *
100 * 6 1/26/98 11:01a Jeff
101 * changed spew struct to use object handles
102 *
103 * 5 1/23/98 7:00p Jeff
104 * checked object before using it bug fixed
105 *
106 * 4 1/23/98 5:18p Jeff
107 * Added in new timer and 3/5 of the random flags
108 *
109 * 3 1/23/98 3:03p Jeff
110 * Added mass into spew structure
111 *
112 * 2 1/23/98 12:14p Jeff
113 * Took out an mprintf
114 *
115 * 1 1/23/98 12:07p Jeff
116 *
117 * 2 1/23/98 11:50a Jeff
118 * Creation of Spew system
119 *
120 * $NoKeywords: $
121 */
122
123 // ancillary includes
124 #include "game.h"cxx . . $ `<file>/Descent3/game.h`/
125 #include "vecmat.h"cxx . . $ `<file>/lib/vecmat.h`/
126 #include "ddio.h"cxx . . $ `<file>/ddio/ddio.h`/
127 #include "pserror.h"cxx . . $ `<file>/misc/pserror.h`/
128 #include "object.h"cxx . . $ `<file>/Descent3/object.h`/
129 #include "damage.h"cxx . . $ `<file>/Descent3/damage.h`/
130 #include "viseffect.h"cxx . . $ `<file>/Descent3/viseffect.h`/
131 #include "fireball.h"cxx . . $ `<file>/Descent3/fireball.h`/
132 #include "spew.h"cxx . . $ `<file>/Descent3/spew.h`/
133 #include "weapon.h"cxx . . $ `<file>/Descent3/weapon.h`/
134 #include "polymodel.h"cxx . . $ `<file>/model/polymodel.h`/
135
136 // ANSI C includes
137 #include <stdlib.h>
138 #include <math.h>
139 #include <string.h>
140
141 #include "psrand.h"cxx . . $ `<file>/misc/psrand.h`/
142
143 #define MAX_SPEWS_PER_FRAMEcxx . . $ `Descent3/spew.cpp:143:9`! 5 // maximum number of spews 1 can emit per frame
144
145 static inline int FORM_HANDLEcxx . . $ FORM_HANDLE(9b79fb6aee4c0440).(int counter, int slot) { return (((counter & 0xFF) << 16) + (slot & 0xFF)); }
146
147 static inline int GET_SLOTcxx . . $ GET_SLOT(7864480464b09eea).(int handle) { return (handle & 0xFF); }
148
149 spewinfocxx . . $ spewinfo# SpewEffectscxx . . $ SpewEffects.[MAX_SPEW_EFFECTScxx . . $ `Descent3/spew.h:131:9`!];
150 int spew_countcxx . . $ spew_count.;
151
152 bool SpewObjectNeedsEveryFrameUpdatecxx . . $ SpewObjectNeedsEveryFrameUpdate(9985ed114f2bfc78).(objectcxx . . $ object# *obj, int gunpoint);
153
154 // Initializes the Spew system
155 void SpewInitcxx . . $ SpewInit(49f6e7a06ebc5aa8).() {
156 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Initializing Spew System\n");
157 int count;
158 spew_countcxx . . $ spew_count. = 0;
159
160 for (count = 0; count < MAX_SPEW_EFFECTScxx . . $ `Descent3/spew.h:131:9`!; count++) {
161 SpewClearEventcxx . . $ SpewClearEvent(918ebd27a9ddbad3).(count, true);
162 }
163 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Done Initializing Spew System\n");
164 }
165
166 // Creates a Spew effect
167 // spew -> Pointer to spewinfo structure (that is filled out)...may be deleted after function call
168 // returns a handle to the spew effect
169 int SpewCreatecxx . . $ SpewCreate(a164fa5b42524a40).(spewinfocxx . . $ spewinfo# *spew) {
170 int count;
171 spewinfocxx . . $ spewinfo# *veffect;
172
173 ASSERTcxx . . $ `misc/pserror.h:246:9`!(spew);
174
175 if (spew->dragcxx . . $ spewinfo#drag. < 0)
176 spew->dragcxx . . $ spewinfo#drag. = 0;
177 if (spew->effect_typecxx . . $ spewinfo#effect_type. < 0 || spew->effect_typecxx . . $ spewinfo#effect_type. >= NUM_FIREBALLScxx . . $ `Descent3/fireball.h:178:9`!)
178 return -1;
179 if (spew->lifetimecxx . . $ spewinfo#lifetime. < 0)
180 spew->lifetimecxx . . $ spewinfo#lifetime. = 0;
181 if (spew->longevitycxx . . $ spewinfo#longevity. < 0)
182 spew->longevitycxx . . $ spewinfo#longevity. = 0;
183 if (spew->masscxx . . $ spewinfo#mass. < 0)
184 spew->masscxx . . $ spewinfo#mass. = 0;
185 if (spew->sizecxx . . $ spewinfo#size. < 1)
186 spew->sizecxx . . $ spewinfo#size. = 1;
187 if (spew->speedcxx . . $ spewinfo#speed. < 0)
188 spew->speedcxx . . $ spewinfo#speed. = 0;
189 if (spew->time_intcxx . . $ spewinfo#time_int. <= 0)
190 spew->time_intcxx . . $ spewinfo#time_int. = 0.001f;
191 if (spew->use_gunpointcxx . . $ spewinfo#use_gunpoint.) {
192 // make sure all the object data is valid
193 objectcxx . . $ object# *obj = ObjGetcxx . . $ ObjGet(11672e354c0b263a).(spew->gpcxx . . $ spewinfo#$anonymous_type_0#gp..obj_handlecxx . . $ guninfo#obj_handle.);
194 if (!obj)
195 return -1;
196
197 poly_modelcxx . . $ poly_model# *pm = &Poly_modelscxx . . $ Poly_models.[obj->rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..model_numcxx . . $ polyobj_info#model_num.];
198 if (spew->gpcxx . . $ spewinfo#$anonymous_type_0#gp..gunpointcxx . . $ guninfo#gunpoint. < 0 || spew->gpcxx . . $ spewinfo#$anonymous_type_0#gp..gunpointcxx . . $ guninfo#gunpoint. >= pm->n_gunscxx . . $ poly_model#n_guns.)
199 return -1;
200 }
201
202 for (count = 0; count < MAX_SPEW_EFFECTScxx . . $ `Descent3/spew.h:131:9`!; count++) {
203 if (SpewEffectscxx . . $ SpewEffects.[count].inusecxx . . $ spewinfo#inuse. == false) {
204 spew_countcxx . . $ spew_count.++;
205 // we found an open handle
206 veffect = &SpewEffectscxx . . $ SpewEffects.[count];
207
208 // fill in the info
209 veffect->inusecxx . . $ spewinfo#inuse. = true;
210 veffect->randomcxx . . $ spewinfo#random. = spew->randomcxx . . $ spewinfo#random.;
211 veffect->use_gunpointcxx . . $ spewinfo#use_gunpoint. = spew->use_gunpointcxx . . $ spewinfo#use_gunpoint.;
212 veffect->real_objcxx . . $ spewinfo#real_obj. = spew->real_objcxx . . $ spewinfo#real_obj.;
213 veffect->flagscxx . . $ spewinfo#flags. = 0;
214
215 if (veffect->use_gunpointcxx . . $ spewinfo#use_gunpoint.) {
216 veffect->gpcxx . . $ spewinfo#$anonymous_type_0#gp..obj_handlecxx . . $ guninfo#obj_handle. = spew->gpcxx . . $ spewinfo#$anonymous_type_0#gp..obj_handlecxx . . $ guninfo#obj_handle.;
217
218 // WHAT IS THIS? it used to be "if(veffect->gp.obj_handle==NULL)"
219 if (veffect->gpcxx . . $ spewinfo#$anonymous_type_0#gp..obj_handlecxx . . $ guninfo#obj_handle. == OBJECT_HANDLE_NONEcxx . . $ `Descent3/object_external.h:156:9`!) {
220 SpewClearEventcxx . . $ SpewClearEvent(918ebd27a9ddbad3).(count, false);
221 return -1;
222 }
223 veffect->gpcxx . . $ spewinfo#$anonymous_type_0#gp..gunpointcxx . . $ guninfo#gunpoint. = spew->gpcxx . . $ spewinfo#$anonymous_type_0#gp..gunpointcxx . . $ guninfo#gunpoint.;
224 veffect->flagscxx . . $ spewinfo#flags. |= SF_FORCEUPDATEcxx . . $ `Descent3/spew.h:81:9`!; // force an update so it has some values
225
226 objectcxx . . $ object# *obj = ObjGetcxx . . $ ObjGet(11672e354c0b263a).(spew->gpcxx . . $ spewinfo#$anonymous_type_0#gp..obj_handlecxx . . $ guninfo#obj_handle.);
227 ASSERTcxx . . $ `misc/pserror.h:246:9`!(obj);
228
229 if (obj) {
230 if (SpewObjectNeedsEveryFrameUpdatecxx . . $ SpewObjectNeedsEveryFrameUpdate(9985ed114f2bfc78).(obj, spew->gpcxx . . $ spewinfo#$anonymous_type_0#gp..gunpointcxx . . $ guninfo#gunpoint.)) {
231 veffect->flagscxx . . $ spewinfo#flags. |= SF_UPDATEEVERYFRAMEcxx . . $ `Descent3/spew.h:83:9`!;
232 }
233 }
234 } else {
235 veffect->ptcxx . . $ spewinfo#$anonymous_type_0#pt..origincxx . . $ pointinfo#origin. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). spew->ptcxx . . $ spewinfo#$anonymous_type_0#pt..origincxx . . $ pointinfo#origin.;
236 veffect->ptcxx . . $ spewinfo#$anonymous_type_0#pt..normalcxx . . $ pointinfo#normal. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). spew->ptcxx . . $ spewinfo#$anonymous_type_0#pt..normalcxx . . $ pointinfo#normal.;
237 veffect->ptcxx . . $ spewinfo#$anonymous_type_0#pt..room_numcxx . . $ pointinfo#room_num. = spew->ptcxx . . $ spewinfo#$anonymous_type_0#pt..room_numcxx . . $ pointinfo#room_num.;
238 }
239
240 veffect->effect_typecxx . . $ spewinfo#effect_type. = spew->effect_typecxx . . $ spewinfo#effect_type.;
241 veffect->phys_infocxx . . $ spewinfo#phys_info. = spew->phys_infocxx . . $ spewinfo#phys_info.;
242 veffect->dragcxx . . $ spewinfo#drag. = spew->dragcxx . . $ spewinfo#drag.;
243 veffect->masscxx . . $ spewinfo#mass. = spew->masscxx . . $ spewinfo#mass.;
244 veffect->time_until_next_blobcxx . . $ spewinfo#time_until_next_blob. = veffect->time_intcxx . . $ spewinfo#time_int. = spew->time_intcxx . . $ spewinfo#time_int.;
245 veffect->longevitycxx . . $ spewinfo#longevity. = spew->longevitycxx . . $ spewinfo#longevity.;
246 veffect->lifetimecxx . . $ spewinfo#lifetime. = spew->lifetimecxx . . $ spewinfo#lifetime.;
247 veffect->sizecxx . . $ spewinfo#size. = spew->sizecxx . . $ spewinfo#size.;
248 veffect->speedcxx . . $ spewinfo#speed. = spew->speedcxx . . $ spewinfo#speed.;
249
250 veffect->handlecxx . . $ spewinfo#handle. = FORM_HANDLEcxx . . $ FORM_HANDLE(9b79fb6aee4c0440).(spew_countcxx . . $ spew_count., count);
251
252 veffect->start_timecxx . . $ spewinfo#start_time. = Gametimecxx . . $ Gametime.;
253
254 // mprintf(0,"Creating Spew Effect (%d)\n",veffect->handle);
255
256 return veffect->handlecxx . . $ spewinfo#handle.; // return the handle
257 }
258
259 if (count == MAX_SPEW_EFFECTScxx . . $ `Descent3/spew.h:131:9`! - 1)
260 return -1; // we didn't find any open handles
261 }
262 return -1;
263 }
264
265 // Does a step in a spew system
266 void SpewEmitAllcxx . . $ SpewEmitAll(49f6e7a06ebc5aa8).(void) {
267 spewinfocxx . . $ spewinfo# *spew;
268 int count;
269
270 float size, speed, lifetime;
271
272 for (count = 0; count < MAX_SPEW_EFFECTScxx . . $ `Descent3/spew.h:131:9`!; count++) {
273
274 if (SpewEffectscxx . . $ SpewEffects.[count].inusecxx . . $ spewinfo#inuse.) {
275 spew = &SpewEffectscxx . . $ SpewEffects.[count];
276
277 spew->time_until_next_blobcxx . . $ spewinfo#time_until_next_blob. -= Frametimecxx . . $ Frametime.; // account for the current frame
278
279 // no randomness if it's a real object!
280 if (spew->real_objcxx . . $ spewinfo#real_obj.)
281 spew->randomcxx . . $ spewinfo#random. = 0;
282
283 if (spew->time_until_next_blobcxx . . $ spewinfo#time_until_next_blob. >= 0) {
284 // ok, since we won't be in the following while loop at all
285 // this frame for the spew, we need to force an update on
286 // it's gunpoint (IF it's a gunpoint) that way we can be sure
287 // it has the correct position, in case we miss the obj->flags&OF_MOVED_THIS_FRAME
288 if (spew->use_gunpointcxx . . $ spewinfo#use_gunpoint.) {
289 objectcxx . . $ object# *obj = ObjGetcxx . . $ ObjGet(11672e354c0b263a).(spew->gpcxx . . $ spewinfo#$anonymous_type_0#gp..obj_handlecxx . . $ guninfo#obj_handle.);
290 if (obj) {
291
292 if ((obj->flagscxx . . $ object#flags. & OF_MOVED_THIS_FRAMEcxx . . $ `Descent3/object_external.h:274:9`!) ||
293 ((obj->flagscxx . . $ object#flags. & OF_ATTACHEDcxx . . $ `Descent3/object_external.h:273:9`!) && ObjGetcxx . . $ ObjGet(11672e354c0b263a).(obj->attach_ultimate_handlecxx . . $ object#attach_ultimate_handle.) &&
294 ObjGetcxx . . $ ObjGet(11672e354c0b263a).(obj->attach_ultimate_handlecxx . . $ object#attach_ultimate_handle.)->movement_typecxx . . $ object#movement_type. == MT_PHYSICScxx . . $ `Descent3/object_external.h:234:9`! &&
295 (ObjGetcxx . . $ ObjGet(11672e354c0b263a).(obj->attach_ultimate_handlecxx . . $ object#attach_ultimate_handle.)->flagscxx . . $ object#flags. & OF_MOVED_THIS_FRAMEcxx . . $ `Descent3/object_external.h:274:9`!)))
296 spew->flagscxx . . $ spewinfo#flags. |= SF_FORCEUPDATEcxx . . $ `Descent3/spew.h:81:9`!;
297
298 // check to see if it is an animated polymodel, which means update everyframe
299 if (obj->flagscxx . . $ object#flags. & OF_POLYGON_OBJECTcxx . . $ `Descent3/object_external.h:281:9`!) {
300 if (obj->rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..anim_end_framecxx . . $ polyobj_info#anim_end_frame. != obj->rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..anim_start_framecxx . . $ polyobj_info#anim_start_frame.) {
301 spew->flagscxx . . $ spewinfo#flags. |= SF_FORCEUPDATEcxx . . $ `Descent3/spew.h:81:9`!;
302 }
303 }
304 } else {
305 // well, this spewer is dead, kill it
306 SpewClearEventcxx . . $ SpewClearEvent(918ebd27a9ddbad3).(spew->handlecxx . . $ spewinfo#handle., true);
307 }
308 }
309 }
310
311 if (spew->flagscxx . . $ spewinfo#flags. & SF_UPDATEEVERYFRAMEcxx . . $ `Descent3/spew.h:83:9`!)
312 spew->flagscxx . . $ spewinfo#flags. |= SF_FORCEUPDATEcxx . . $ `Descent3/spew.h:81:9`!;
313
314 // turn this off, we will turn this on the first time we calc
315 spew->flagscxx . . $ spewinfo#flags. &= ~SF_UPDATEDFORFRAMEcxx . . $ `Descent3/spew.h:82:9`!;
316
317 // if time_until_next_blob is negative, it's time to spew
318 int num_spewed = MAX_SPEWS_PER_FRAMEcxx . . $ `Descent3/spew.cpp:143:9`!;
319
320 while (spew->time_until_next_blobcxx . . $ spewinfo#time_until_next_blob. < 0.0 && (num_spewed--)) {
321
322 // do random computations
323 if ((spew->randomcxx . . $ spewinfo#random. & SPEW_RAND_SIZEcxx . . $ `Descent3/spew.h:127:9`!) != 0) {
324 size = spew->sizecxx . . $ spewinfo#size. + (((D3_RAND_MAXcxx . . $ `misc/psrand.h:41:9`! >> 1) - ps_randcxx . . $ ps_rand(b126dc7c1de90089).()) / (float)D3_RAND_MAXcxx . . $ `misc/psrand.h:41:9`!) * spew->sizecxx . . $ spewinfo#size. * 0.5f;
325 } else
326 size = spew->sizecxx . . $ spewinfo#size.;
327
328 if ((spew->randomcxx . . $ spewinfo#random. & SPEW_RAND_SPEEDcxx . . $ `Descent3/spew.h:126:9`!) != 0) {
329 speed = spew->speedcxx . . $ spewinfo#speed. + (((D3_RAND_MAXcxx . . $ `misc/psrand.h:41:9`! >> 1) - ps_randcxx . . $ ps_rand(b126dc7c1de90089).()) / (float)D3_RAND_MAXcxx . . $ `misc/psrand.h:41:9`!) * spew->speedcxx . . $ spewinfo#speed. * 0.5f;
330 } else
331 speed = spew->speedcxx . . $ spewinfo#speed.;
332
333 if ((spew->randomcxx . . $ spewinfo#random. & SPEW_RAND_LIFETIMEcxx . . $ `Descent3/spew.h:129:9`!) != 0) {
334 lifetime = spew->lifetimecxx . . $ spewinfo#lifetime. + (((D3_RAND_MAXcxx . . $ `misc/psrand.h:41:9`! >> 1) - ps_randcxx . . $ ps_rand(b126dc7c1de90089).()) / (float)D3_RAND_MAXcxx . . $ `misc/psrand.h:41:9`!) * spew->lifetimecxx . . $ spewinfo#lifetime. * 0.5f;
335 } else
336 lifetime = spew->lifetimecxx . . $ spewinfo#lifetime.;
337
338 // move this code to within the following if statement and else
339 if ((spew->randomcxx . . $ spewinfo#random. & SPEW_RAND_WIGGLEcxx . . $ `Descent3/spew.h:125:9`!) != 0) {
340
341 } else {
342 }
343 if ((spew->randomcxx . . $ spewinfo#random. & SPEW_RAND_SLIDEcxx . . $ `Descent3/spew.h:128:9`!) != 0) {
344
345 } else {
346 }
347
348 if (spew->use_gunpointcxx . . $ spewinfo#use_gunpoint.) {
349 vectorcxx . . $ vector# vel_vector;
350 objectcxx . . $ object# *obj;
351
352 obj = ObjGetcxx . . $ ObjGet(11672e354c0b263a).(spew->gpcxx . . $ spewinfo#$anonymous_type_0#gp..obj_handlecxx . . $ guninfo#obj_handle.);
353 if (obj) {
354 if (!(spew->flagscxx . . $ spewinfo#flags. & SF_UPDATEDFORFRAMEcxx . . $ `Descent3/spew.h:82:9`!)) {
355
356 if ((obj->flagscxx . . $ object#flags. & OF_MOVED_THIS_FRAMEcxx . . $ `Descent3/object_external.h:274:9`!) ||
357 ((obj->flagscxx . . $ object#flags. & OF_ATTACHEDcxx . . $ `Descent3/object_external.h:273:9`!) && ObjGetcxx . . $ ObjGet(11672e354c0b263a).(obj->attach_ultimate_handlecxx . . $ object#attach_ultimate_handle.) &&
358 ObjGetcxx . . $ ObjGet(11672e354c0b263a).(obj->attach_ultimate_handlecxx . . $ object#attach_ultimate_handle.)->movement_typecxx . . $ object#movement_type. == MT_PHYSICScxx . . $ `Descent3/object_external.h:234:9`! &&
359 (ObjGetcxx . . $ ObjGet(11672e354c0b263a).(obj->attach_ultimate_handlecxx . . $ object#attach_ultimate_handle.)->flagscxx . . $ object#flags. & OF_MOVED_THIS_FRAMEcxx . . $ `Descent3/object_external.h:274:9`!))) {
360 // since the object moved this frame, force an update
361 spew->flagscxx . . $ spewinfo#flags. |= SF_FORCEUPDATEcxx . . $ `Descent3/spew.h:81:9`!;
362 }
363
364 // check to see if it is an animated polymodel, which means update everyframe
365 if (obj->flagscxx . . $ object#flags. & OF_POLYGON_OBJECTcxx . . $ `Descent3/object_external.h:281:9`!) {
366 if (obj->rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..anim_end_framecxx . . $ polyobj_info#anim_end_frame. != obj->rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..anim_start_framecxx . . $ polyobj_info#anim_start_frame.) {
367 spew->flagscxx . . $ spewinfo#flags. |= SF_FORCEUPDATEcxx . . $ `Descent3/spew.h:81:9`!;
368 }
369 }
370
371 if (spew->flagscxx . . $ spewinfo#flags. & SF_UPDATEEVERYFRAMEcxx . . $ `Descent3/spew.h:83:9`!)
372 spew->flagscxx . . $ spewinfo#flags. |= SF_FORCEUPDATEcxx . . $ `Descent3/spew.h:81:9`!;
373 }
374
375 // see if we need to recalc info
376 if ((spew->flagscxx . . $ spewinfo#flags. & SF_FORCEUPDATEcxx . . $ `Descent3/spew.h:81:9`!) && (!(spew->flagscxx . . $ spewinfo#flags. & SF_UPDATEDFORFRAMEcxx . . $ `Descent3/spew.h:82:9`!))) {
377 // recalculate
378 // Returns the position and the normal of a gun point
379 WeaponCalcGuncxx . . $ WeaponCalcGun(85e3752e9562a225).(&spew->gun_pointcxx . . $ spewinfo#gun_point., &spew->gp_normalcxx . . $ spewinfo#gp_normal., obj, spew->gpcxx . . $ spewinfo#$anonymous_type_0#gp..gunpointcxx . . $ guninfo#gunpoint.);
380 spew->flagscxx . . $ spewinfo#flags. &= ~SF_FORCEUPDATEcxx . . $ `Descent3/spew.h:81:9`!;
381 spew->flagscxx . . $ spewinfo#flags. |= SF_UPDATEDFORFRAMEcxx . . $ `Descent3/spew.h:82:9`!;
382 }
383
384 // calc velocity vector
385 vel_vector =cxx . . $ vector#`operator=`(c0842353a20857d). spew->gp_normalcxx . . $ spewinfo#gp_normal. *cxx . . $ `operator*`(252247219a31502c). speed;
386
387 // Create the viseffect
388 VisEffectCreateControlledcxx . . $ VisEffectCreateControlled(2aaf2e89dfc906a6).(VIS_FIREBALLcxx . . $ `Descent3/viseffect_external.h:61:9`!, obj, (int)spew->effect_typecxx . . $ spewinfo#effect_type., obj->roomnumcxx . . $ object#roomnum., &spew->gun_pointcxx . . $ spewinfo#gun_point.,
389 lifetime, &vel_vector, spew->phys_infocxx . . $ spewinfo#phys_info., size, spew->dragcxx . . $ spewinfo#drag., spew->masscxx . . $ spewinfo#mass.,
390 spew->real_objcxx . . $ spewinfo#real_obj.);
391 } else {
392 // object no longer exists
393 SpewClearEventcxx . . $ SpewClearEvent(918ebd27a9ddbad3).(spew->handlecxx . . $ spewinfo#handle., true);
394 }
395 } else {
396 vectorcxx . . $ vector# vel_vector;
397
398 // mprintf(0,"Emitting Point based Spew %d\n",count);
399
400 // calc velocity vector
401 vel_vector =cxx . . $ vector#`operator=`(c0842353a20857d). spew->ptcxx . . $ spewinfo#$anonymous_type_0#pt..normalcxx . . $ pointinfo#normal. *cxx . . $ `operator*`(252247219a31502c). speed;
402
403 // Create the viseffect
404 VisEffectCreateControlledcxx . . $ VisEffectCreateControlled(2aaf2e89dfc906a6).(VIS_FIREBALLcxx . . $ `Descent3/viseffect_external.h:61:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, (int)spew->effect_typecxx . . $ spewinfo#effect_type., spew->ptcxx . . $ spewinfo#$anonymous_type_0#pt..room_numcxx . . $ pointinfo#room_num., &spew->ptcxx . . $ spewinfo#$anonymous_type_0#pt..origincxx . . $ pointinfo#origin.,
405 lifetime, &vel_vector, spew->phys_infocxx . . $ spewinfo#phys_info., size, spew->dragcxx . . $ spewinfo#drag., spew->masscxx . . $ spewinfo#mass.,
406 spew->real_objcxx . . $ spewinfo#real_obj.);
407
408 } // end else
409
410 spew->time_until_next_blobcxx . . $ spewinfo#time_until_next_blob. += spew->time_intcxx . . $ spewinfo#time_int.;
411 } // end while
412
413 if (num_spewed == 0) {
414 mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Max spews per frame hit! Handle=%d Interval=%f Lifetime=%f Longevity=%f\n",
415 spew->handle,
416 spew->time_int,
417 spew->lifetime,
418 spew->longevity);
419 spew->time_until_next_blobcxx . . $ spewinfo#time_until_next_blob. = spew->time_intcxx . . $ spewinfo#time_int.;
420 }
421
422 // see if this effect is done
423 if (spew->longevitycxx . . $ spewinfo#longevity. > 0.0f)
424 if (Gametimecxx . . $ Gametime. - spew->start_timecxx . . $ spewinfo#start_time. >= spew->longevitycxx . . $ spewinfo#longevity.) {
425 SpewClearEventcxx . . $ SpewClearEvent(918ebd27a9ddbad3).(spew->handlecxx . . $ spewinfo#handle., true);
426 }
427
428 } // end if
429 } // end for
430 }
431
432 // Clears a Spew Event given a handle to it
433 void SpewClearEventcxx . . $ SpewClearEvent(918ebd27a9ddbad3).(int handle, bool force) {
434 spewinfocxx . . $ spewinfo# *vis;
435
436 int slot = GET_SLOTcxx . . $ GET_SLOT(7864480464b09eea).(handle);
437
438 if ((slot < 0) || (slot > MAX_SPEW_EFFECTScxx . . $ `Descent3/spew.h:131:9`!))
439 return;
440
441 // mprintf(0,"Clearing spew event %d - %d....",handle,slot);
442
443 vis = &SpewEffectscxx . . $ SpewEffects.[slot];
444
445 if ((!force) && (handle != vis->handlecxx . . $ spewinfo#handle.))
446 return;
447
448 // mprintf(0,"handle OK\n");
449
450 vis->inusecxx . . $ spewinfo#inuse. = vis->randomcxx . . $ spewinfo#random. = vis->use_gunpointcxx . . $ spewinfo#use_gunpoint. = vis->real_objcxx . . $ spewinfo#real_obj. = false;
451 vis->ptcxx . . $ spewinfo#$anonymous_type_0#pt..origincxx . . $ pointinfo#origin..xcxx . . $ vector#x. = vis->ptcxx . . $ spewinfo#$anonymous_type_0#pt..origincxx . . $ pointinfo#origin..ycxx . . $ vector#y. = vis->ptcxx . . $ spewinfo#$anonymous_type_0#pt..origincxx . . $ pointinfo#origin..zcxx . . $ vector#z. = 0.0f;
452 vis->ptcxx . . $ spewinfo#$anonymous_type_0#pt..room_numcxx . . $ pointinfo#room_num. = 0;
453 vis->ptcxx . . $ spewinfo#$anonymous_type_0#pt..normalcxx . . $ pointinfo#normal..xcxx . . $ vector#x. = vis->ptcxx . . $ spewinfo#$anonymous_type_0#pt..normalcxx . . $ pointinfo#normal..ycxx . . $ vector#y. = vis->ptcxx . . $ spewinfo#$anonymous_type_0#pt..normalcxx . . $ pointinfo#normal..zcxx . . $ vector#z. = 0.0f;
454 vis->effect_typecxx . . $ spewinfo#effect_type. = MED_SMOKE_INDEXcxx . . $ `Descent3/fireball_external.h:29:9`!;
455 vis->phys_infocxx . . $ spewinfo#phys_info. = PF_FIXED_VELOCITYcxx . . $ `Descent3/object_external.h:324:9`!;
456 vis->dragcxx . . $ spewinfo#drag. = vis->masscxx . . $ spewinfo#mass. = vis->time_intcxx . . $ spewinfo#time_int. = vis->longevitycxx . . $ spewinfo#longevity. = vis->lifetimecxx . . $ spewinfo#lifetime. = vis->sizecxx . . $ spewinfo#size. = vis->speedcxx . . $ spewinfo#speed. = 0.0f;
457 vis->time_until_next_blobcxx . . $ spewinfo#time_until_next_blob. = vis->start_timecxx . . $ spewinfo#start_time. = 0.0f;
458 vis->handlecxx . . $ spewinfo#handle. = 0;
459 vis->flagscxx . . $ spewinfo#flags. = 0;
460 }
461
462 bool SpewObjectNeedsEveryFrameUpdatecxx . . $ SpewObjectNeedsEveryFrameUpdate(9985ed114f2bfc78).(objectcxx . . $ object# *obj, int gun_num) {
463 poly_modelcxx . . $ poly_model# *pm;
464 vectorcxx . . $ vector# pnt;
465 vectorcxx . . $ vector# normal;
466 int mn; // submodel number
467 float normalized_time[MAX_SUBOBJECTScxx . . $ `lib/polymodel_external.h:76:9`!];
468
469 if (!(obj->flagscxx . . $ object#flags. & OF_POLYGON_OBJECTcxx . . $ `Descent3/object_external.h:281:9`!)) {
470 return false;
471 }
472
473 pm = &Poly_modelscxx . . $ Poly_models.[obj->rtypecxx . . $ object#rtype..pobj_infocxx . . $ object#$anonymous_type_10#pobj_info..model_numcxx . . $ polyobj_info#model_num.];
474
475 if (pm->n_gunscxx . . $ poly_model#n_guns. == 0) {
476 return false;
477 }
478
479 SetNormalizedTimeObjcxx . . $ SetNormalizedTimeObj(8af4de573afdac78).(obj, normalized_time);
480 SetModelAnglesAndPoscxx . . $ SetModelAnglesAndPos(a00e94110fc4ea4c).(pm, normalized_time);
481
482 if (gun_num < 0 || gun_num >= pm->n_gunscxx . . $ poly_model#n_guns.) {
483 return false;
484 }
485
486 pnt =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). pm->gun_slotscxx . . $ poly_model#gun_slots.[gun_num].pntcxx . . $ w_bank#pnt.;
487 normal =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). pm->gun_slotscxx . . $ poly_model#gun_slots.[gun_num].normcxx . . $ w_bank#norm.;
488 mn = pm->gun_slotscxx . . $ poly_model#gun_slots.[gun_num].parentcxx . . $ w_bank#parent.;
489
490 // Instance up the tree for this gun
491 while (mn != -1) {
492 if (pm->submodelcxx . . $ poly_model#submodel.[mn].flagscxx . . $ bsp_info#flags. & (SOF_ROTATEcxx . . $ `lib/polymodel_external.h:80:9`! | SOF_TURRETcxx . . $ `lib/polymodel_external.h:81:9`!)) {
493 return true;
494 }
495
496 mn = pm->submodelcxx . . $ poly_model#submodel.[mn].parentcxx . . $ bsp_info#parent.;
497 }
498
499 return false;
500 }