1 /*
2 ===========================================================================
3 Copyright (C) 2000 - 2013, Raven Software, Inc.
4 Copyright (C) 2001 - 2013, Activision, Inc.
5 Copyright (C) 2013 - 2015, OpenJK contributors
6
7 This file is part of the OpenJK source code.
8
9 OpenJK is free software; you can redistribute it and/or modify it
10 under the terms of the GNU General Public License version 2 as
11 published by the Free Software Foundation.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, see <http://www.gnu.org/licenses/>.
20 ===========================================================================
21 */
22
23 // Filename:- g_functions.cpp
24 //
25
26 #include "g_headers.h"
27
28 // This file contains the 8 (so far) function calls that replace the 8 function ptrs in the gentity_t structure
29
30 #include "g_local.h"
31 #include "../cgame/cg_local.h"
32 #include "g_functions.h"
33
GEntity_ThinkFunc(gentity_t * self)34 void GEntity_ThinkFunc(gentity_t *self)
35 {
36 //#define THINKCASE(blah) case thinkF_ ## blah: blah(self); OutputDebugString(va("%s\n",#blah));break;
37 #define THINKCASE(blah) case thinkF_ ## blah: blah(self); break;
38
39 switch (self->e_ThinkFunc)
40 {
41 case thinkF_NULL:
42 break;
43
44 THINKCASE( funcBBrushDieGo )
45 THINKCASE( ExplodeDeath )
46 THINKCASE( RespawnItem )
47 THINKCASE( G_FreeEntity )
48 THINKCASE( FinishSpawningItem )
49 THINKCASE( locateCamera )
50 THINKCASE( G_RunObject )
51 THINKCASE( ReturnToPos1 )
52 THINKCASE( Use_BinaryMover_Go )
53 THINKCASE( Think_MatchTeam )
54 THINKCASE( Think_BeginMoving )
55 THINKCASE( Think_SetupTrainTargets )
56 THINKCASE( Think_SpawnNewDoorTrigger )
57 THINKCASE( ref_link )
58 THINKCASE( Think_Target_Delay )
59 THINKCASE( target_laser_think )
60 THINKCASE( target_laser_start )
61 THINKCASE( target_location_linkup )
62 THINKCASE( scriptrunner_run )
63 THINKCASE( multi_wait )
64 THINKCASE( multi_trigger_run )
65 THINKCASE( trigger_always_think )
66 THINKCASE( AimAtTarget )
67 THINKCASE( func_timer_think )
68 THINKCASE( NPC_RemoveBody )
69 THINKCASE( Disappear )
70 THINKCASE( NPC_Think )
71 THINKCASE( NPC_Spawn_Go )
72 THINKCASE( NPC_Begin )
73 THINKCASE( moverCallback )
74 THINKCASE( anglerCallback )
75 THINKCASE( RemoveOwner )
76 THINKCASE( MakeOwnerInvis )
77 THINKCASE( MakeOwnerEnergy )
78 THINKCASE( func_usable_think )
79 THINKCASE( misc_dlight_think )
80 THINKCASE( health_think )
81 THINKCASE( ammo_think )
82 THINKCASE( trigger_teleporter_find_closest_portal )
83 THINKCASE( thermalDetonatorExplode )
84 THINKCASE( WP_ThermalThink )
85 THINKCASE( trigger_hurt_reset )
86 THINKCASE( turret_base_think )
87 THINKCASE( turret_head_think )
88 THINKCASE( laser_arm_fire )
89 THINKCASE( laser_arm_start )
90 THINKCASE( trigger_visible_check_player_visibility )
91 THINKCASE( target_relay_use_go )
92 THINKCASE( trigger_cleared_fire )
93 THINKCASE( MoveOwner )
94 THINKCASE( SolidifyOwner )
95 THINKCASE( cycleCamera )
96 THINKCASE( spawn_ammo_crystal_trigger )
97 THINKCASE( NPC_ShySpawn )
98 THINKCASE( func_wait_return_solid )
99 THINKCASE( InflateOwner )
100 THINKCASE( mega_ammo_think )
101 THINKCASE( misc_replicator_item_finish_spawn )
102 THINKCASE( fx_runner_link )
103 THINKCASE( fx_runner_think )
104 THINKCASE( removeBoltSurface)
105 THINKCASE( set_MiscAnim)
106 THINKCASE( LimbThink )
107 THINKCASE( laserTrapThink )
108 THINKCASE( TieFighterThink )
109 THINKCASE( rocketThink )
110 THINKCASE( prox_mine_think )
111 THINKCASE( emplaced_blow )
112 THINKCASE( WP_Explode )
113 THINKCASE( pas_think ) // personal assault sentry
114 THINKCASE( ion_cannon_think )
115 THINKCASE( maglock_link )
116 THINKCASE( WP_flechette_alt_blow )
117 THINKCASE( WP_prox_mine_think )
118 THINKCASE( camera_aim )
119 THINKCASE( fx_explosion_trail_link )
120 THINKCASE( fx_explosion_trail_think )
121 THINKCASE( fx_target_beam_link )
122 THINKCASE( fx_target_beam_think )
123 THINKCASE( spotlight_think )
124 THINKCASE( spotlight_link )
125 THINKCASE( trigger_push_checkclear )
126 THINKCASE( DEMP2_AltDetonate )
127 THINKCASE( DEMP2_AltRadiusDamage )
128 THINKCASE( panel_turret_think )
129 THINKCASE( welder_think )
130 THINKCASE( gas_random_jet )
131 THINKCASE( poll_converter ) // dumb loop sound handling
132 THINKCASE( spawn_rack_goods ) // delay spawn of goods to help on ents
133
134 default:
135 Com_Error(ERR_DROP, "GEntity_ThinkFunc: case %d not handled!\n",self->e_ThinkFunc);
136 break;
137 }
138 }
139
140 // note different switch-case code for CEntity as opposed to GEntity (CEntity goes through parent GEntity first)...
141 //
CEntity_ThinkFunc(centity_s * cent)142 void CEntity_ThinkFunc(centity_s *cent)
143 {
144 //#define CLTHINKCASE(blah) case clThinkF_ ## blah: blah(cent); OutputDebugString(va("%s\n",#blah));break;
145 #define CLTHINKCASE(blah) case clThinkF_ ## blah: blah(cent); break;
146
147 switch (cent->gent->e_clThinkFunc)
148 {
149 case clThinkF_NULL:
150 break;
151
152 CLTHINKCASE( CG_DLightThink )
153 CLTHINKCASE( CG_MatrixEffect )
154 CLTHINKCASE( CG_Limb )
155
156 default:
157 Com_Error(ERR_DROP, "CEntity_ThinkFunc: case %d not handled!\n",cent->gent->e_clThinkFunc);
158 break;
159 }
160 }
161
162
GEntity_ReachedFunc(gentity_t * self)163 void GEntity_ReachedFunc(gentity_t *self)
164 {
165 //#define REACHEDCASE(blah) case reachedF_ ## blah: blah(self); OutputDebugString(va("%s\n",#blah));break;
166 #define REACHEDCASE(blah) case reachedF_ ## blah: blah(self); break;
167
168 switch (self->e_ReachedFunc)
169 {
170 case reachedF_NULL:
171 break;
172
173 REACHEDCASE( Reached_BinaryMover )
174 REACHEDCASE( Reached_Train )
175 REACHEDCASE( moverCallback )
176 REACHEDCASE( moveAndRotateCallback )
177
178 default:
179 Com_Error(ERR_DROP, "GEntity_ReachedFunc: case %d not handled!\n",self->e_ReachedFunc);
180 break;
181 }
182 }
183
184
185
GEntity_BlockedFunc(gentity_t * self,gentity_t * other)186 void GEntity_BlockedFunc(gentity_t *self, gentity_t *other)
187 {
188 //#define BLOCKEDCASE(blah) case blockedF_ ## blah: blah(self,other); OutputDebugString(va("%s\n",#blah));break;
189 #define BLOCKEDCASE(blah) case blockedF_ ## blah: blah(self,other); break;
190
191 switch (self->e_BlockedFunc)
192 {
193 case blockedF_NULL:
194 break;
195
196 BLOCKEDCASE( Blocked_Door )
197 BLOCKEDCASE( Blocked_Mover )
198
199 default:
200 Com_Error(ERR_DROP, "GEntity_BlockedFunc: case %d not handled!\n",self->e_BlockedFunc);
201 break;
202 }
203 }
204
GEntity_TouchFunc(gentity_t * self,gentity_t * other,trace_t * trace)205 void GEntity_TouchFunc(gentity_t *self, gentity_t *other, trace_t *trace)
206 {
207 //#define TOUCHCASE(blah) case touchF_ ## blah: blah(self,other,trace); OutputDebugString(va("%s\n",#blah));break;
208 #define TOUCHCASE(blah) case touchF_ ## blah: blah(self,other,trace); break;
209
210 switch (self->e_TouchFunc)
211 {
212 case touchF_NULL:
213 break;
214
215 TOUCHCASE( Touch_Item )
216 TOUCHCASE( teleporter_touch )
217 TOUCHCASE( charge_stick )
218 TOUCHCASE( Touch_DoorTrigger )
219 TOUCHCASE( Touch_PlatCenterTrigger )
220 TOUCHCASE( Touch_Plat )
221 TOUCHCASE( Touch_Button )
222 TOUCHCASE( Touch_Multi )
223 TOUCHCASE( trigger_push_touch )
224 TOUCHCASE( trigger_teleporter_touch )
225 TOUCHCASE( hurt_touch )
226 TOUCHCASE( NPC_Touch )
227 TOUCHCASE( touch_ammo_crystal_tigger )
228 TOUCHCASE( funcBBrushTouch )
229 TOUCHCASE( touchLaserTrap )
230 TOUCHCASE( prox_mine_stick )
231 TOUCHCASE( func_rotating_touch )
232
233 default:
234 Com_Error(ERR_DROP, "GEntity_TouchFunc: case %d not handled!\n",self->e_TouchFunc);
235 }
236 }
237
GEntity_UseFunc(gentity_t * self,gentity_t * other,gentity_t * activator)238 void GEntity_UseFunc(gentity_t *self, gentity_t *other, gentity_t *activator)
239 {
240 if ( !self || (self->svFlags&SVF_INACTIVE) )
241 {
242 return;
243 }
244 //#define USECASE(blah) case useF_ ## blah: blah(self,other,activator); OutputDebugString(va("%s\n",#blah));break;
245 #define USECASE(blah) case useF_ ## blah: blah(self,other,activator); break;
246
247 switch (self->e_UseFunc)
248 {
249 case useF_NULL:
250 break;
251
252 USECASE( funcBBrushUse )
253 USECASE( misc_model_use )
254 USECASE( Use_Item )
255 USECASE( Use_Shooter )
256 USECASE( GoExplodeDeath )
257 USECASE( Use_BinaryMover )
258 USECASE( use_wall )
259 USECASE( Use_Target_Give )
260 USECASE( Use_Target_Delay )
261 USECASE( Use_Target_Score )
262 USECASE( Use_Target_Print )
263 USECASE( Use_Target_Speaker )
264 USECASE( target_laser_use )
265 USECASE( target_relay_use )
266 USECASE( target_kill_use )
267 USECASE( target_counter_use )
268 USECASE( target_random_use )
269 USECASE( target_scriptrunner_use )
270 USECASE( target_gravity_change_use )
271 USECASE( target_friction_change_use )
272 USECASE( target_teleporter_use )
273 USECASE( Use_Multi )
274 USECASE( Use_target_push )
275 USECASE( hurt_use )
276 USECASE( func_timer_use )
277 USECASE( trigger_entdist_use )
278 USECASE( func_usable_use )
279 USECASE( target_activate_use )
280 USECASE( target_deactivate_use )
281 USECASE( NPC_Use )
282 USECASE( NPC_Spawn )
283 USECASE( misc_dlight_use )
284 USECASE( health_use )
285 USECASE( ammo_use )
286 USECASE( mega_ammo_use )
287 USECASE( target_level_change_use )
288 USECASE( target_change_parm_use )
289 USECASE( turret_base_use )
290 USECASE( laser_arm_use )
291 USECASE( func_static_use )
292 USECASE( target_play_music_use )
293 USECASE( misc_model_useup )
294 USECASE( misc_portal_use )
295 USECASE( target_autosave_use )
296 USECASE( switch_models )
297 USECASE( misc_replicator_item_spawn )
298 USECASE( misc_replicator_item_remove )
299 USECASE( target_secret_use)
300 USECASE( func_bobbing_use )
301 USECASE( func_rotating_use )
302 USECASE( fx_runner_use )
303 USECASE( funcGlassUse )
304 USECASE( TrainUse )
305 USECASE( misc_trip_mine_activate )
306 USECASE( emplaced_gun_use )
307 USECASE( shield_power_converter_use )
308 USECASE( ammo_power_converter_use )
309 USECASE( security_panel_use )
310 USECASE( ion_cannon_use )
311 USECASE( camera_use )
312 USECASE( fx_explosion_trail_use )
313 USECASE( fx_target_beam_use )
314 USECASE( sentry_use )
315 USECASE( spotlight_use )
316 USECASE( misc_atst_use )
317 USECASE( panel_turret_use )
318 USECASE( welder_use )
319 USECASE( jabba_cam_use )
320 USECASE( misc_use )
321 USECASE( pas_use )
322 USECASE( item_spawn_use )
323
324 default:
325 Com_Error(ERR_DROP, "GEntity_UseFunc: case %d not handled!\n",self->e_UseFunc);
326 }
327 }
328
GEntity_PainFunc(gentity_t * self,gentity_t * inflictor,gentity_t * attacker,vec3_t point,int damage,int mod,int hitLoc)329 void GEntity_PainFunc(gentity_t *self, gentity_t *inflictor, gentity_t *attacker, vec3_t point, int damage, int mod,int hitLoc)
330 {
331 //#define PAINCASE(blah) case painF_ ## blah: blah(self,attacker,damage); OutputDebugString(va("%s\n",#blah));break;
332 #define PAINCASE(blah) case painF_ ## blah: blah(self,inflictor,attacker,point,damage,mod,hitLoc); break;
333
334 switch (self->e_PainFunc)
335 {
336 case painF_NULL:
337 break;
338
339 PAINCASE( funcBBrushPain )
340 PAINCASE( misc_model_breakable_pain )
341 PAINCASE( NPC_Pain )
342 PAINCASE( station_pain )
343 PAINCASE( func_usable_pain )
344 PAINCASE( NPC_ATST_Pain )
345 PAINCASE( NPC_ST_Pain )
346 PAINCASE( NPC_Jedi_Pain )
347 PAINCASE( NPC_Droid_Pain )
348 PAINCASE( NPC_Probe_Pain )
349 PAINCASE( NPC_MineMonster_Pain )
350 PAINCASE( NPC_Howler_Pain )
351 PAINCASE( NPC_Seeker_Pain )
352 PAINCASE( NPC_Remote_Pain )
353 PAINCASE( emplaced_gun_pain )
354 PAINCASE( NPC_Mark1_Pain )
355 PAINCASE( NPC_GM_Pain )
356 PAINCASE( NPC_Sentry_Pain )
357 PAINCASE( NPC_Mark2_Pain )
358 PAINCASE( PlayerPain )
359 PAINCASE( GasBurst )
360 PAINCASE( CrystalCratePain )
361 PAINCASE( TurretPain )
362
363 default:
364 Com_Error(ERR_DROP, "GEntity_PainFunc: case %d not handled!\n",self->e_PainFunc);
365 }
366 }
367
368
GEntity_DieFunc(gentity_t * self,gentity_t * inflictor,gentity_t * attacker,int damage,int mod,int dFlags,int hitLoc)369 void GEntity_DieFunc(gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int mod, int dFlags, int hitLoc)
370 {
371 //#define DIECASE(blah) case dieF_ ## blah: blah(self,inflictor,attacker,damage,mod); OutputDebugString(va("%s\n",#blah));break;
372 #define DIECASE(blah) case dieF_ ## blah: blah(self,inflictor,attacker,damage,mod,dFlags,hitLoc); break;
373
374 switch (self->e_DieFunc)
375 {
376 case dieF_NULL:
377 break;
378
379 DIECASE( funcBBrushDie )
380 DIECASE( misc_model_breakable_die )
381 DIECASE( misc_model_cargo_die )
382 DIECASE( func_train_die )
383 DIECASE( player_die )
384 DIECASE( ExplodeDeath_Wait )
385 DIECASE( ExplodeDeath )
386 DIECASE( func_usable_die )
387 DIECASE( turret_die )
388 DIECASE( funcGlassDie )
389 // DIECASE( laserTrapDelayedExplode )
390 DIECASE( emplaced_gun_die )
391 DIECASE( WP_ExplosiveDie )
392 DIECASE( ion_cannon_die )
393 DIECASE( maglock_die )
394 DIECASE( camera_die )
395 DIECASE( Mark1_die )
396 DIECASE( Interrogator_die )
397 DIECASE( misc_atst_die )
398 DIECASE( misc_panel_turret_die )
399 DIECASE( thermal_die )
400
401 default:
402 Com_Error(ERR_DROP, "GEntity_DieFunc: case %d not handled!\n",self->e_DieFunc);
403 }
404 }
405
406 //////////////////// eof /////////////////////
407
408