doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Misc.cpp
Go to the documentation of this file.
1 /*
2 ===========================================================================
3 
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
8 
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
21 
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
23 
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
25 
26 ===========================================================================
27 */
28 /*
29 
30 Various utility objects and functions.
31 
32 */
33 
34 #include "../idlib/precompiled.h"
35 #pragma hdrstop
36 
37 #include "Game_local.h"
38 
39 /*
40 ===============================================================================
41 
42 idSpawnableEntity
43 
44 A simple, spawnable entity with a model and no functionable ability of it's own.
45 For example, it can be used as a placeholder during development, for marking
46 locations on maps for script, or for simple placed models without any behavior
47 that can be bound to other entities. Should not be subclassed.
48 ===============================================================================
49 */
50 
53 
54 /*
55 ======================
56 idSpawnableEntity::Spawn
57 ======================
58 */
59 void idSpawnableEntity::Spawn() {
60  // this just holds dict information
61 }
62 
63 /*
64 ===============================================================================
65 
66  idPlayerStart
67 
68 ===============================================================================
69 */
70 
71 const idEventDef EV_TeleportStage( "<TeleportStage>", "e" );
72 
74  EVENT( EV_Activate, idPlayerStart::Event_TeleportPlayer )
75  EVENT( EV_TeleportStage, idPlayerStart::Event_TeleportStage )
77 
78 /*
79 ===============
80 idPlayerStart::idPlayerStart
81 ================
82 */
84  teleportStage = 0;
85 }
86 
87 /*
88 ===============
89 idPlayerStart::Spawn
90 ================
91 */
92 void idPlayerStart::Spawn( void ) {
93  teleportStage = 0;
94 }
95 
96 /*
97 ================
98 idPlayerStart::Save
99 ================
100 */
101 void idPlayerStart::Save( idSaveGame *savefile ) const {
102  savefile->WriteInt( teleportStage );
103 }
104 
105 /*
106 ================
107 idPlayerStart::Restore
108 ================
109 */
111  savefile->ReadInt( teleportStage );
112 }
113 
114 /*
115 ================
116 idPlayerStart::ClientReceiveEvent
117 ================
118 */
119 bool idPlayerStart::ClientReceiveEvent( int event, int time, const idBitMsg &msg ) {
120  int entityNumber;
121 
122  switch( event ) {
123  case EVENT_TELEPORTPLAYER: {
124  entityNumber = msg.ReadBits( GENTITYNUM_BITS );
125  idPlayer *player = static_cast<idPlayer *>( gameLocal.entities[entityNumber] );
126  if ( player != NULL && player->IsType( idPlayer::Type ) ) {
127  Event_TeleportPlayer( player );
128  }
129  return true;
130  }
131  default: {
132  return idEntity::ClientReceiveEvent( event, time, msg );
133  }
134  }
135  return false;
136 }
137 
138 /*
139 ===============
140 idPlayerStart::Event_TeleportStage
141 
142 FIXME: add functionality to fx system ( could be done with player scripting too )
143 ================
144 */
146  idPlayer *player;
147  if ( !_player->IsType( idPlayer::Type ) ) {
148  common->Warning( "idPlayerStart::Event_TeleportStage: entity is not an idPlayer\n" );
149  return;
150  }
151  player = static_cast<idPlayer*>(_player);
152  float teleportDelay = spawnArgs.GetFloat( "teleportDelay" );
153  switch ( teleportStage ) {
154  case 0:
155  player->playerView.Flash( colorWhite, 125 );
157  player->SetInfluenceView( spawnArgs.GetString( "mtr_teleportFx" ), NULL, 0.0f, NULL );
158  gameSoundWorld->FadeSoundClasses( 0, -20.0f, teleportDelay );
159  player->StartSound( "snd_teleport_start", SND_CHANNEL_BODY2, 0, false, NULL );
160  teleportStage++;
161  PostEventSec( &EV_TeleportStage, teleportDelay, player );
162  break;
163  case 1:
164  gameSoundWorld->FadeSoundClasses( 0, 0.0f, 0.25f );
165  teleportStage++;
166  PostEventSec( &EV_TeleportStage, 0.25f, player );
167  break;
168  case 2:
169  player->SetInfluenceView( NULL, NULL, 0.0f, NULL );
170  TeleportPlayer( player );
171  player->StopSound( SND_CHANNEL_BODY2, false );
173  teleportStage = 0;
174  break;
175  default:
176  break;
177  }
178 }
179 
180 /*
181 ===============
182 idPlayerStart::TeleportPlayer
183 ================
184 */
186  float pushVel = spawnArgs.GetFloat( "push", "300" );
187  float f = spawnArgs.GetFloat( "visualEffect", "0" );
188  const char *viewName = spawnArgs.GetString( "visualView", "" );
189  idEntity *ent = viewName ? gameLocal.FindEntity( viewName ) : NULL;
190 
191 #ifdef _D3XP
192  SetTimeState ts( player->timeGroup );
193 #endif
194 
195  if ( f && ent ) {
196  // place in private camera view for some time
197  // the entity needs to teleport to where the camera view is to have the PVS right
198  player->Teleport( ent->GetPhysics()->GetOrigin(), ang_zero, this );
199  player->StartSound( "snd_teleport_enter", SND_CHANNEL_ANY, 0, false, NULL );
200  player->SetPrivateCameraView( static_cast<idCamera*>(ent) );
201  // the player entity knows where to spawn from the previous Teleport call
202  if ( !gameLocal.isClient ) {
203  player->PostEventSec( &EV_Player_ExitTeleporter, f );
204  }
205  } else {
206  // direct to exit, Teleport will take care of the killbox
207  player->Teleport( GetPhysics()->GetOrigin(), GetPhysics()->GetAxis().ToAngles(), NULL );
208 
209  // multiplayer hijacked this entity, so only push the player in multiplayer
210  if ( gameLocal.isMultiplayer ) {
211  player->GetPhysics()->SetLinearVelocity( GetPhysics()->GetAxis()[0] * pushVel );
212  }
213  }
214 }
215 
216 /*
217 ===============
218 idPlayerStart::Event_TeleportPlayer
219 ================
220 */
222  idPlayer *player;
223 
224  if ( activator->IsType( idPlayer::Type ) ) {
225  player = static_cast<idPlayer*>( activator );
226  } else {
227  player = gameLocal.GetLocalPlayer();
228  }
229  if ( player ) {
230  if ( spawnArgs.GetBool( "visualFx" ) ) {
231 
232  teleportStage = 0;
233  Event_TeleportStage( player );
234 
235  } else {
236 
237  if ( gameLocal.isServer ) {
238  idBitMsg msg;
239  byte msgBuf[MAX_EVENT_PARAM_SIZE];
240 
241  msg.Init( msgBuf, sizeof( msgBuf ) );
242  msg.BeginWriting();
243  msg.WriteBits( player->entityNumber, GENTITYNUM_BITS );
244  ServerSendEvent( EVENT_TELEPORTPLAYER, &msg, false, -1 );
245  }
246 
247  TeleportPlayer( player );
248  }
249  }
250 }
251 
252 /*
253 ===============================================================================
254 
255  idActivator
256 
257 ===============================================================================
258 */
259 
261  EVENT( EV_Activate, idActivator::Event_Activate )
262 END_CLASS
263 
264 /*
265 ===============
266 idActivator::Save
267 ================
268 */
269 void idActivator::Save( idSaveGame *savefile ) const {
270  savefile->WriteBool( stay_on );
271 }
272 
273 /*
274 ===============
275 idActivator::Restore
276 ================
277 */
279  savefile->ReadBool( stay_on );
280 
281  if ( stay_on ) {
283  }
284 }
285 
286 /*
287 ===============
288 idActivator::Spawn
289 ================
290 */
291 void idActivator::Spawn( void ) {
292  bool start_off;
293 
294  spawnArgs.GetBool( "stay_on", "0", stay_on );
295  spawnArgs.GetBool( "start_off", "0", start_off );
296 
297  GetPhysics()->SetClipBox( idBounds( vec3_origin ).Expand( 4 ), 1.0f );
298  GetPhysics()->SetContents( 0 );
299 
300  if ( !start_off ) {
302  }
303 }
304 
305 /*
306 ===============
307 idActivator::Think
308 ================
309 */
310 void idActivator::Think( void ) {
311  RunPhysics();
312  if ( thinkFlags & TH_THINK ) {
313  if ( TouchTriggers() ) {
314  if ( !stay_on ) {
315  BecomeInactive( TH_THINK );
316  }
317  }
318  }
319  Present();
320 }
321 
322 /*
323 ===============
324 idActivator::Activate
325 ================
326 */
328  if ( thinkFlags & TH_THINK ) {
329  BecomeInactive( TH_THINK );
330  } else {
331  BecomeActive( TH_THINK );
332  }
333 }
334 
335 
336 /*
337 ===============================================================================
338 
339 idPathCorner
340 
341 ===============================================================================
342 */
343 
345  EVENT( AI_RandomPath, idPathCorner::Event_RandomPath )
346 END_CLASS
347 
348 /*
349 =====================
350 idPathCorner::Spawn
351 =====================
352 */
353 void idPathCorner::Spawn( void ) {
354 }
355 
356 /*
357 =====================
358 idPathCorner::DrawDebugInfo
359 =====================
360 */
362  idEntity *ent;
363  idBounds bnds( idVec3( -4.0, -4.0f, -8.0f ), idVec3( 4.0, 4.0f, 64.0f ) );
364 
365  for( ent = gameLocal.spawnedEntities.Next(); ent != NULL; ent = ent->spawnNode.Next() ) {
366  if ( !ent->IsType( idPathCorner::Type ) ) {
367  continue;
368  }
369 
370  idVec3 org = ent->GetPhysics()->GetOrigin();
371  gameRenderWorld->DebugBounds( colorRed, bnds, org, 0 );
372  }
373 }
374 
375 /*
376 ============
377 idPathCorner::RandomPath
378 ============
379 */
381  int i;
382  int num;
383  int which;
384  idEntity *ent;
386 
387  num = 0;
388  for( i = 0; i < source->targets.Num(); i++ ) {
389  ent = source->targets[ i ].GetEntity();
390  if ( ent && ( ent != ignore ) && ent->IsType( idPathCorner::Type ) ) {
391  path[ num++ ] = static_cast<idPathCorner *>( ent );
392  if ( num >= MAX_GENTITIES ) {
393  break;
394  }
395  }
396  }
397 
398  if ( !num ) {
399  return NULL;
400  }
401 
402  which = gameLocal.random.RandomInt( num );
403  return path[ which ];
404 }
405 
406 /*
407 =====================
408 idPathCorner::Event_RandomPath
409 =====================
410 */
413 
414  path = RandomPath( this, NULL );
415  idThread::ReturnEntity( path );
416 }
417 
418 /*
419 ===============================================================================
420 
421  idDamagable
422 
423 ===============================================================================
424 */
425 
426 const idEventDef EV_RestoreDamagable( "<RestoreDamagable>" );
427 
429  EVENT( EV_Activate, idDamagable::Event_BecomeBroken )
430  EVENT( EV_RestoreDamagable, idDamagable::Event_RestoreDamagable )
431 END_CLASS
432 
433 /*
434 ================
435 idDamagable::idDamagable
436 ================
437 */
439  count = 0;
440  nextTriggerTime = 0;
441 }
442 
443 /*
444 ================
445 idDamagable::Save
446 ================
447 */
448 void idDamagable::Save( idSaveGame *savefile ) const {
449  savefile->WriteInt( count );
450  savefile->WriteInt( nextTriggerTime );
451 }
452 
453 /*
454 ================
455 idDamagable::Restore
456 ================
457 */
459  savefile->ReadInt( count );
460  savefile->ReadInt( nextTriggerTime );
461 }
462 
463 /*
464 ================
465 idDamagable::Spawn
466 ================
467 */
468 void idDamagable::Spawn( void ) {
469  idStr broken;
470 
471  health = spawnArgs.GetInt( "health", "5" );
472  spawnArgs.GetInt( "count", "1", count );
473  nextTriggerTime = 0;
474 
475  // make sure the model gets cached
476  spawnArgs.GetString( "broken", "", broken );
477  if ( broken.Length() && !renderModelManager->CheckModel( broken ) ) {
478  gameLocal.Error( "idDamagable '%s' at (%s): cannot load broken model '%s'", name.c_str(), GetPhysics()->GetOrigin().ToString(0), broken.c_str() );
479  }
480 
481  fl.takedamage = true;
483 }
484 
485 /*
486 ================
487 idDamagable::BecomeBroken
488 ================
489 */
491  float forceState;
492  int numStates;
493  int cycle;
494  float wait;
495 
496  if ( gameLocal.time < nextTriggerTime ) {
497  return;
498  }
499 
500  spawnArgs.GetFloat( "wait", "0.1", wait );
501  nextTriggerTime = gameLocal.time + SEC2MS( wait );
502  if ( count > 0 ) {
503  count--;
504  if ( !count ) {
505  fl.takedamage = false;
506  } else {
507  health = spawnArgs.GetInt( "health", "5" );
508  }
509  }
510 
511  idStr broken;
512 
513  spawnArgs.GetString( "broken", "", broken );
514  if ( broken.Length() ) {
515  SetModel( broken );
516  }
517 
518  // offset the start time of the shader to sync it to the gameLocal time
520 
521  spawnArgs.GetInt( "numstates", "1", numStates );
522  spawnArgs.GetInt( "cycle", "0", cycle );
523  spawnArgs.GetFloat( "forcestate", "0", forceState );
524 
525  // set the state parm
526  if ( cycle ) {
528  if ( renderEntity.shaderParms[ SHADERPARM_MODE ] > numStates ) {
530  }
531  } else if ( forceState ) {
532  renderEntity.shaderParms[ SHADERPARM_MODE ] = forceState;
533  } else {
535  }
536 
538 
539  ActivateTargets( activator );
540 
541  if ( spawnArgs.GetBool( "hideWhenBroken" ) ) {
542  Hide();
545  }
546 }
547 
548 /*
549 ================
550 idDamagable::Killed
551 ================
552 */
553 void idDamagable::Killed( idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location ) {
554  if ( gameLocal.time < nextTriggerTime ) {
555  health += damage;
556  return;
557  }
558 
559  BecomeBroken( attacker );
560 }
561 
562 #ifdef _D3XP
563 /*
564 ================
565 idDamagable::Hide
566 ================
567 */
568 void idDamagable::Hide( void ) {
569  idEntity::Hide();
570  GetPhysics()->SetContents( 0 );
571 }
572 
573 /*
574 ================
575 idDamagable::Show
576 ================
577 */
578 void idDamagable::Show( void ) {
579  idEntity::Show();
581 }
582 #endif
583 
584 /*
585 ================
586 idDamagable::Event_BecomeBroken
587 ================
588 */
590  BecomeBroken( activator );
591 }
592 
593 /*
594 ================
595 idDamagable::Event_RestoreDamagable
596 ================
597 */
599  health = spawnArgs.GetInt( "health", "5" );
600  Show();
601 }
602 
603 
604 /*
605 ===============================================================================
606 
607  idExplodable
608 
609 ===============================================================================
610 */
611 
613  EVENT( EV_Activate, idExplodable::Event_Explode )
614 END_CLASS
615 
616 /*
617 ================
618 idExplodable::Spawn
619 ================
620 */
621 void idExplodable::Spawn( void ) {
622  Hide();
623 }
624 
625 /*
626 ================
627 idExplodable::Event_Explode
628 ================
629 */
631  const char *temp;
632 
633  if ( spawnArgs.GetString( "def_damage", "damage_explosion", &temp ) ) {
634  gameLocal.RadiusDamage( GetPhysics()->GetOrigin(), activator, activator, this, this, temp );
635  }
636 
637  StartSound( "snd_explode", SND_CHANNEL_ANY, 0, false, NULL );
638 
639  // Show() calls UpdateVisuals, so we don't need to call it ourselves after setting the shaderParms
646  Show();
647 
648  PostEventMS( &EV_Remove, 2000 );
649 
650  ActivateTargets( activator );
651 }
652 
653 
654 /*
655 ===============================================================================
656 
657  idSpring
658 
659 ===============================================================================
660 */
661 
663  EVENT( EV_PostSpawn, idSpring::Event_LinkSpring )
664 END_CLASS
665 
666 /*
667 ================
668 idSpring::Think
669 ================
670 */
671 void idSpring::Think( void ) {
672  idVec3 start, end, origin;
673  idMat3 axis;
674 
675  // run physics
676  RunPhysics();
677 
678  if ( thinkFlags & TH_THINK ) {
679  // evaluate force
680  spring.Evaluate( gameLocal.time );
681 
682  start = p1;
683  if ( ent1->GetPhysics() ) {
684  axis = ent1->GetPhysics()->GetAxis();
685  origin = ent1->GetPhysics()->GetOrigin();
686  start = origin + start * axis;
687  }
688 
689  end = p2;
690  if ( ent2->GetPhysics() ) {
691  axis = ent2->GetPhysics()->GetAxis();
692  origin = ent2->GetPhysics()->GetOrigin();
693  end = origin + p2 * axis;
694  }
695 
696  gameRenderWorld->DebugLine( idVec4(1, 1, 0, 1), start, end, 0, true );
697  }
698 
699  Present();
700 }
701 
702 /*
703 ================
704 idSpring::Event_LinkSpring
705 ================
706 */
708  idStr name1, name2;
709 
710  spawnArgs.GetString( "ent1", "", name1 );
711  spawnArgs.GetString( "ent2", "", name2 );
712 
713  if ( name1.Length() ) {
714  ent1 = gameLocal.FindEntity( name1 );
715  if ( !ent1 ) {
716  gameLocal.Error( "idSpring '%s' at (%s): cannot find first entity '%s'", name.c_str(), GetPhysics()->GetOrigin().ToString(0), name1.c_str() );
717  }
718  }
719  else {
721  }
722 
723  if ( name2.Length() ) {
724  ent2 = gameLocal.FindEntity( name2 );
725  if ( !ent2 ) {
726  gameLocal.Error( "idSpring '%s' at (%s): cannot find second entity '%s'", name.c_str(), GetPhysics()->GetOrigin().ToString(0), name2.c_str() );
727  }
728  }
729  else {
731  }
734 }
735 
736 /*
737 ================
738 idSpring::Spawn
739 ================
740 */
741 void idSpring::Spawn( void ) {
742  float Kstretch, damping, restLength;
743 
744  spawnArgs.GetInt( "id1", "0", id1 );
745  spawnArgs.GetInt( "id2", "0", id2 );
746  spawnArgs.GetVector( "point1", "0 0 0", p1 );
747  spawnArgs.GetVector( "point2", "0 0 0", p2 );
748  spawnArgs.GetFloat( "constant", "100.0f", Kstretch );
749  spawnArgs.GetFloat( "damping", "10.0f", damping );
750  spawnArgs.GetFloat( "restlength", "0.0f", restLength );
751 
752  spring.InitSpring( Kstretch, 0.0f, damping, restLength );
753 
754  ent1 = ent2 = NULL;
755 
756  PostEventMS( &EV_PostSpawn, 0 );
757 }
758 
759 /*
760 ===============================================================================
761 
762  idForceField
763 
764 ===============================================================================
765 */
766 
767 const idEventDef EV_Toggle( "Toggle", NULL );
768 
770  EVENT( EV_Activate, idForceField::Event_Activate )
771  EVENT( EV_Toggle, idForceField::Event_Toggle )
772  EVENT( EV_FindTargets, idForceField::Event_FindTargets )
773 END_CLASS
774 
775 /*
776 ===============
777 idForceField::Toggle
778 ================
779 */
780 void idForceField::Toggle( void ) {
781  if ( thinkFlags & TH_THINK ) {
782  BecomeInactive( TH_THINK );
783  } else {
784  BecomeActive( TH_THINK );
785  }
786 }
787 
788 /*
789 ================
790 idForceField::Think
791 ================
792 */
793 void idForceField::Think( void ) {
794  if ( thinkFlags & TH_THINK ) {
795  // evaluate force
797  }
798  Present();
799 }
800 
801 /*
802 ================
803 idForceField::Save
804 ================
805 */
806 void idForceField::Save( idSaveGame *savefile ) const {
807  savefile->WriteStaticObject( forceField );
808 }
809 
810 /*
811 ================
812 idForceField::Restore
813 ================
814 */
816  savefile->ReadStaticObject( forceField );
817 }
818 
819 /*
820 ================
821 idForceField::Spawn
822 ================
823 */
824 void idForceField::Spawn( void ) {
825  idVec3 uniform;
826  float explosion, implosion, randomTorque;
827 
828  if ( spawnArgs.GetVector( "uniform", "0 0 0", uniform ) ) {
829  forceField.Uniform( uniform );
830  } else if ( spawnArgs.GetFloat( "explosion", "0", explosion ) ) {
831  forceField.Explosion( explosion );
832  } else if ( spawnArgs.GetFloat( "implosion", "0", implosion ) ) {
833  forceField.Implosion( implosion );
834  }
835 
836  if ( spawnArgs.GetFloat( "randomTorque", "0", randomTorque ) ) {
837  forceField.RandomTorque( randomTorque );
838  }
839 
840  if ( spawnArgs.GetBool( "applyForce", "0" ) ) {
842  } else if ( spawnArgs.GetBool( "applyImpulse", "0" ) ) {
844  } else {
846  }
847 
848  forceField.SetPlayerOnly( spawnArgs.GetBool( "playerOnly", "0" ) );
849  forceField.SetMonsterOnly( spawnArgs.GetBool( "monsterOnly", "0" ) );
850 
851  // set the collision model on the force field
852  forceField.SetClipModel( new idClipModel( GetPhysics()->GetClipModel() ) );
853 
854  // remove the collision model from the physics object
855  GetPhysics()->SetClipModel( NULL, 1.0f );
856 
857  if ( spawnArgs.GetBool( "start_on" ) ) {
859  }
860 }
861 
862 /*
863 ===============
864 idForceField::Event_Toggle
865 ================
866 */
868  Toggle();
869 }
870 
871 /*
872 ================
873 idForceField::Event_Activate
874 ================
875 */
877  float wait;
878 
879  Toggle();
880  if ( spawnArgs.GetFloat( "wait", "0.01", wait ) ) {
881  PostEventSec( &EV_Toggle, wait );
882  }
883 }
884 
885 /*
886 ================
887 idForceField::Event_FindTargets
888 ================
889 */
891  FindTargets();
893  if ( targets.Num() ) {
894  forceField.Uniform( targets[0].GetEntity()->GetPhysics()->GetOrigin() - GetPhysics()->GetOrigin() );
895  }
896 }
897 
898 
899 /*
900 ===============================================================================
901 
902  idAnimated
903 
904 ===============================================================================
905 */
906 
907 const idEventDef EV_Animated_Start( "<start>" );
908 const idEventDef EV_LaunchMissiles( "launchMissiles", "ssssdf" );
909 const idEventDef EV_LaunchMissilesUpdate( "<launchMissiles>", "dddd" );
910 const idEventDef EV_AnimDone( "<AnimDone>", "d" );
911 const idEventDef EV_StartRagdoll( "startRagdoll" );
912 #ifdef _D3XP
913 const idEventDef EV_SetAnimation( "setAnimation", "s" );
914 const idEventDef EV_GetAnimationLength( "getAnimationLength", NULL, 'f' );
915 #endif
916 
918  EVENT( EV_Activate, idAnimated::Event_Activate )
919  EVENT( EV_Animated_Start, idAnimated::Event_Start )
920  EVENT( EV_StartRagdoll, idAnimated::Event_StartRagdoll )
921  EVENT( EV_AnimDone, idAnimated::Event_AnimDone )
922  EVENT( EV_Footstep, idAnimated::Event_Footstep )
923  EVENT( EV_FootstepLeft, idAnimated::Event_Footstep )
924  EVENT( EV_FootstepRight, idAnimated::Event_Footstep )
925  EVENT( EV_LaunchMissiles, idAnimated::Event_LaunchMissiles )
926  EVENT( EV_LaunchMissilesUpdate, idAnimated::Event_LaunchMissilesUpdate )
927 #ifdef _D3XP
928  EVENT( EV_SetAnimation, idAnimated::Event_SetAnimation )
929  EVENT( EV_GetAnimationLength, idAnimated::Event_GetAnimationLength )
930 #endif
931 END_CLASS
932 
933 /*
934 ===============
935 idAnimated::idAnimated
936 ================
937 */
939  anim = 0;
940  blendFrames = 0;
942  activated = false;
943  combatModel = NULL;
944  activator = NULL;
945  current_anim_index = 0;
946  num_anims = 0;
947 
948 }
949 
950 /*
951 ===============
952 idAnimated::idAnimated
953 ================
954 */
956  delete combatModel;
957  combatModel = NULL;
958 }
959 
960 /*
961 ===============
962 idAnimated::Save
963 ================
964 */
965 void idAnimated::Save( idSaveGame *savefile ) const {
966  savefile->WriteInt( current_anim_index );
967  savefile->WriteInt( num_anims );
968  savefile->WriteInt( anim );
969  savefile->WriteInt( blendFrames );
970  savefile->WriteJoint( soundJoint );
971  activator.Save( savefile );
972  savefile->WriteBool( activated );
973 }
974 
975 /*
976 ===============
977 idAnimated::Restore
978 ================
979 */
981  savefile->ReadInt( current_anim_index );
982  savefile->ReadInt( num_anims );
983  savefile->ReadInt( anim );
984  savefile->ReadInt( blendFrames );
985  savefile->ReadJoint( soundJoint );
986  activator.Restore( savefile );
987  savefile->ReadBool( activated );
988 }
989 
990 /*
991 ===============
992 idAnimated::Spawn
993 ================
994 */
995 void idAnimated::Spawn( void ) {
996  idStr animname;
997  int anim2;
998  float wait;
999  const char *joint;
1000 
1001  joint = spawnArgs.GetString( "sound_bone", "origin" );
1002  soundJoint = animator.GetJointHandle( joint );
1003  if ( soundJoint == INVALID_JOINT ) {
1004  gameLocal.Warning( "idAnimated '%s' at (%s): cannot find joint '%s' for sound playback", name.c_str(), GetPhysics()->GetOrigin().ToString(0), joint );
1005  }
1006 
1007  LoadAF();
1008 
1009  // allow bullets to collide with a combat model
1010  if ( spawnArgs.GetBool( "combatModel", "0" ) ) {
1012  }
1013 
1014  // allow the entity to take damage
1015  if ( spawnArgs.GetBool( "takeDamage", "0" ) ) {
1016  fl.takedamage = true;
1017  }
1018 
1019  blendFrames = 0;
1020 
1021  current_anim_index = 0;
1022  spawnArgs.GetInt( "num_anims", "0", num_anims );
1023 
1024  blendFrames = spawnArgs.GetInt( "blend_in" );
1025 
1026  animname = spawnArgs.GetString( num_anims ? "anim1" : "anim" );
1027  if ( !animname.Length() ) {
1028  anim = 0;
1029  } else {
1030  anim = animator.GetAnim( animname );
1031  if ( !anim ) {
1032  gameLocal.Error( "idAnimated '%s' at (%s): cannot find anim '%s'", name.c_str(), GetPhysics()->GetOrigin().ToString(0), animname.c_str() );
1033  }
1034  }
1035 
1036  if ( spawnArgs.GetBool( "hide" ) ) {
1037  Hide();
1038 
1039  if ( !num_anims ) {
1040  blendFrames = 0;
1041  }
1042  } else if ( spawnArgs.GetString( "start_anim", "", animname ) ) {
1043  anim2 = animator.GetAnim( animname );
1044  if ( !anim2 ) {
1045  gameLocal.Error( "idAnimated '%s' at (%s): cannot find anim '%s'", name.c_str(), GetPhysics()->GetOrigin().ToString(0), animname.c_str() );
1046  }
1048  } else if ( anim ) {
1049  // init joints to the first frame of the animation
1051 
1052  if ( !num_anims ) {
1053  blendFrames = 0;
1054  }
1055  }
1056 
1057  spawnArgs.GetFloat( "wait", "-1", wait );
1058 
1059  if ( wait >= 0 ) {
1060  PostEventSec( &EV_Activate, wait, this );
1061  }
1062 }
1063 
1064 /*
1065 ===============
1066 idAnimated::LoadAF
1067 ===============
1068 */
1069 bool idAnimated::LoadAF( void ) {
1070  idStr fileName;
1071 
1072  if ( !spawnArgs.GetString( "ragdoll", "*unknown*", fileName ) ) {
1073  return false;
1074  }
1075  af.SetAnimator( GetAnimator() );
1076  return af.Load( this, fileName );
1077 }
1078 
1079 /*
1080 ===============
1081 idAnimated::GetPhysicsToSoundTransform
1082 ===============
1083 */
1086  axis = renderEntity.axis;
1087  return true;
1088 }
1089 
1090 /*
1091 ================
1092 idAnimated::StartRagdoll
1093 ================
1094 */
1096  // if no AF loaded
1097  if ( !af.IsLoaded() ) {
1098  return false;
1099  }
1100 
1101  // if the AF is already active
1102  if ( af.IsActive() ) {
1103  return true;
1104  }
1105 
1106  // disable any collision model used
1107  GetPhysics()->DisableClip();
1108 
1109  // start using the AF
1110  af.StartFromCurrentPose( spawnArgs.GetInt( "velocityTime", "0" ) );
1111 
1112  return true;
1113 }
1114 
1115 /*
1116 =====================
1117 idAnimated::PlayNextAnim
1118 =====================
1119 */
1121  const char *animname;
1122  int len;
1123  int cycle;
1124 
1125  if ( current_anim_index >= num_anims ) {
1126  Hide();
1127  if ( spawnArgs.GetBool( "remove" ) ) {
1128  PostEventMS( &EV_Remove, 0 );
1129  } else {
1130  current_anim_index = 0;
1131  }
1132  return;
1133  }
1134 
1135  Show();
1137 
1138  spawnArgs.GetString( va( "anim%d", current_anim_index ), NULL, &animname );
1139  if ( !animname ) {
1140  anim = 0;
1142  return;
1143  }
1144 
1145  anim = animator.GetAnim( animname );
1146  if ( !anim ) {
1147  gameLocal.Warning( "missing anim '%s' on %s", animname, name.c_str() );
1148  return;
1149  }
1150 
1151  if ( g_debugCinematic.GetBool() ) {
1152  gameLocal.Printf( "%d: '%s' start anim '%s'\n", gameLocal.framenum, GetName(), animname );
1153  }
1154 
1155  spawnArgs.GetInt( "cycle", "1", cycle );
1156  if ( ( current_anim_index == num_anims ) && spawnArgs.GetBool( "loop_last_anim" ) ) {
1157  cycle = -1;
1158  }
1159 
1162 
1164  if ( len >= 0 ) {
1165  PostEventMS( &EV_AnimDone, len, current_anim_index );
1166  }
1167 
1168  // offset the start time of the shader to sync it to the game time
1170 
1172  UpdateAnimation();
1173  UpdateVisuals();
1174  Present();
1175 }
1176 
1177 /*
1178 ===============
1179 idAnimated::Event_StartRagdoll
1180 ================
1181 */
1183  StartRagdoll();
1184 }
1185 
1186 /*
1187 ===============
1188 idAnimated::Event_AnimDone
1189 ================
1190 */
1191 void idAnimated::Event_AnimDone( int animindex ) {
1192  if ( g_debugCinematic.GetBool() ) {
1193  const idAnim *animPtr = animator.GetAnim( anim );
1194  gameLocal.Printf( "%d: '%s' end anim '%s'\n", gameLocal.framenum, GetName(), animPtr ? animPtr->Name() : "" );
1195  }
1196 
1197  if ( ( animindex >= num_anims ) && spawnArgs.GetBool( "remove" ) ) {
1198  Hide();
1199  PostEventMS( &EV_Remove, 0 );
1200  } else if ( spawnArgs.GetBool( "auto_advance" ) ) {
1201  PlayNextAnim();
1202  } else {
1203  activated = false;
1204  }
1205 
1207 }
1208 
1209 /*
1210 ===============
1211 idAnimated::Event_Activate
1212 ================
1213 */
1215  if ( num_anims ) {
1216  PlayNextAnim();
1217  activator = _activator;
1218  return;
1219  }
1220 
1221  if ( activated ) {
1222  // already activated
1223  return;
1224  }
1225 
1226  activated = true;
1227  activator = _activator;
1228  ProcessEvent( &EV_Animated_Start );
1229 }
1230 
1231 /*
1232 ===============
1233 idAnimated::Event_Start
1234 ================
1235 */
1237  int cycle;
1238  int len;
1239 
1240  Show();
1241 
1242  if ( num_anims ) {
1243  PlayNextAnim();
1244  return;
1245  }
1246 
1247  if ( anim ) {
1248  if ( g_debugCinematic.GetBool() ) {
1249  const idAnim *animPtr = animator.GetAnim( anim );
1250  gameLocal.Printf( "%d: '%s' start anim '%s'\n", gameLocal.framenum, GetName(), animPtr ? animPtr->Name() : "" );
1251  }
1252  spawnArgs.GetInt( "cycle", "1", cycle );
1255 
1257  if ( len >= 0 ) {
1258  PostEventMS( &EV_AnimDone, len, 1 );
1259  }
1260  }
1261 
1262  // offset the start time of the shader to sync it to the game time
1264 
1266  UpdateAnimation();
1267  UpdateVisuals();
1268  Present();
1269 }
1270 
1271 /*
1272 ===============
1273 idAnimated::Event_Footstep
1274 ===============
1275 */
1277  StartSound( "snd_footstep", SND_CHANNEL_BODY, 0, false, NULL );
1278 }
1279 
1280 /*
1281 =====================
1282 idAnimated::Event_LaunchMissilesUpdate
1283 =====================
1284 */
1285 void idAnimated::Event_LaunchMissilesUpdate( int launchjoint, int targetjoint, int numshots, int framedelay ) {
1286  idVec3 launchPos;
1287  idVec3 targetPos;
1288  idMat3 axis;
1289  idVec3 dir;
1290  idEntity * ent;
1291  idProjectile * projectile;
1292  const idDict * projectileDef;
1293  const char * projectilename;
1294 
1295  projectilename = spawnArgs.GetString( "projectilename" );
1296  projectileDef = gameLocal.FindEntityDefDict( projectilename, false );
1297  if ( !projectileDef ) {
1298  gameLocal.Warning( "idAnimated '%s' at (%s): 'launchMissiles' called with unknown projectile '%s'", name.c_str(), GetPhysics()->GetOrigin().ToString(0), projectilename );
1299  return;
1300  }
1301 
1302  StartSound( "snd_missile", SND_CHANNEL_WEAPON, 0, false, NULL );
1303 
1304  animator.GetJointTransform( ( jointHandle_t )launchjoint, gameLocal.time, launchPos, axis );
1305  launchPos = renderEntity.origin + launchPos * renderEntity.axis;
1306 
1307  animator.GetJointTransform( ( jointHandle_t )targetjoint, gameLocal.time, targetPos, axis );
1308  targetPos = renderEntity.origin + targetPos * renderEntity.axis;
1309 
1310  dir = targetPos - launchPos;
1311  dir.Normalize();
1312 
1313  gameLocal.SpawnEntityDef( *projectileDef, &ent, false );
1314  if ( !ent || !ent->IsType( idProjectile::Type ) ) {
1315  gameLocal.Error( "idAnimated '%s' at (%s): in 'launchMissiles' call '%s' is not an idProjectile", name.c_str(), GetPhysics()->GetOrigin().ToString(0), projectilename );
1316  }
1317  projectile = ( idProjectile * )ent;
1318  projectile->Create( this, launchPos, dir );
1319  projectile->Launch( launchPos, dir, vec3_origin );
1320 
1321  if ( numshots > 0 ) {
1322  PostEventMS( &EV_LaunchMissilesUpdate, FRAME2MS( framedelay ), launchjoint, targetjoint, numshots - 1, framedelay );
1323  }
1324 }
1325 
1326 /*
1327 =====================
1328 idAnimated::Event_LaunchMissiles
1329 =====================
1330 */
1331 void idAnimated::Event_LaunchMissiles( const char *projectilename, const char *sound, const char *launchjoint, const char *targetjoint, int numshots, int framedelay ) {
1332  const idDict * projectileDef;
1333  jointHandle_t launch;
1334  jointHandle_t target;
1335 
1336  projectileDef = gameLocal.FindEntityDefDict( projectilename, false );
1337  if ( !projectileDef ) {
1338  gameLocal.Warning( "idAnimated '%s' at (%s): unknown projectile '%s'", name.c_str(), GetPhysics()->GetOrigin().ToString(0), projectilename );
1339  return;
1340  }
1341 
1342  launch = animator.GetJointHandle( launchjoint );
1343  if ( launch == INVALID_JOINT ) {
1344  gameLocal.Warning( "idAnimated '%s' at (%s): unknown launch joint '%s'", name.c_str(), GetPhysics()->GetOrigin().ToString(0), launchjoint );
1345  gameLocal.Error( "Unknown joint '%s'", launchjoint );
1346  }
1347 
1348  target = animator.GetJointHandle( targetjoint );
1349  if ( target == INVALID_JOINT ) {
1350  gameLocal.Warning( "idAnimated '%s' at (%s): unknown target joint '%s'", name.c_str(), GetPhysics()->GetOrigin().ToString(0), targetjoint );
1351  }
1352 
1353  spawnArgs.Set( "projectilename", projectilename );
1354  spawnArgs.Set( "missilesound", sound );
1355 
1356  CancelEvents( &EV_LaunchMissilesUpdate );
1357  ProcessEvent( &EV_LaunchMissilesUpdate, launch, target, numshots - 1, framedelay );
1358 }
1359 
1360 #ifdef _D3XP
1361 /*
1362 =====================
1363 idAnimated::Event_SetAnimation
1364 =====================
1365 */
1366 void idAnimated::Event_SetAnimation( const char *animName ) {
1367 
1368  //BSM Nerve: Need to add some error checking so we don't change the animation
1369  //in the middle of the existing animation
1370  anim = animator.GetAnim( animName );
1371  if ( !anim ) {
1372  gameLocal.Error( "idAnimated '%s' at (%s): cannot find anim '%s'", name.c_str(), GetPhysics()->GetOrigin().ToString(0), animName );
1373  }
1374 
1375 }
1376 
1377 /*
1378 =====================
1379 idAnimated::Event_GetAnimationLength
1380 =====================
1381 */
1382 void idAnimated::Event_GetAnimationLength() {
1383  float length = 0;
1384 
1385  if(anim) {
1386  length = (float)(animator.AnimLength( anim )) / 1000.f;
1387  }
1388 
1389  idThread::ReturnFloat(length);
1390 }
1391 #endif
1392 
1393 /*
1394 ===============================================================================
1395 
1396  idStaticEntity
1397 
1398  Some static entities may be optimized into inline geometry by dmap
1399 
1400 ===============================================================================
1401 */
1402 
1404  EVENT( EV_Activate, idStaticEntity::Event_Activate )
1405 END_CLASS
1406 
1407 /*
1408 ===============
1409 idStaticEntity::idStaticEntity
1410 ===============
1411 */
1413  spawnTime = 0;
1414  active = false;
1415  fadeFrom.Set( 1, 1, 1, 1 );
1416  fadeTo.Set( 1, 1, 1, 1 );
1417  fadeStart = 0;
1418  fadeEnd = 0;
1419  runGui = false;
1420 }
1421 
1422 /*
1423 ===============
1424 idStaticEntity::Save
1425 ===============
1426 */
1427 void idStaticEntity::Save( idSaveGame *savefile ) const {
1428  savefile->WriteInt( spawnTime );
1429  savefile->WriteBool( active );
1430  savefile->WriteVec4( fadeFrom );
1431  savefile->WriteVec4( fadeTo );
1432  savefile->WriteInt( fadeStart );
1433  savefile->WriteInt( fadeEnd );
1434  savefile->WriteBool( runGui );
1435 }
1436 
1437 /*
1438 ===============
1439 idStaticEntity::Restore
1440 ===============
1441 */
1443  savefile->ReadInt( spawnTime );
1444  savefile->ReadBool( active );
1445  savefile->ReadVec4( fadeFrom );
1446  savefile->ReadVec4( fadeTo );
1447  savefile->ReadInt( fadeStart );
1448  savefile->ReadInt( fadeEnd );
1449  savefile->ReadBool( runGui );
1450 }
1451 
1452 /*
1453 ===============
1454 idStaticEntity::Spawn
1455 ===============
1456 */
1458  bool solid;
1459  bool hidden;
1460 
1461  // an inline static model will not do anything at all
1462  if ( spawnArgs.GetBool( "inline" ) || gameLocal.world->spawnArgs.GetBool( "inlineAllStatics" ) ) {
1463  Hide();
1464  return;
1465  }
1466 
1467  solid = spawnArgs.GetBool( "solid" );
1468  hidden = spawnArgs.GetBool( "hide" );
1469 
1470  if ( solid && !hidden ) {
1472  } else {
1473  GetPhysics()->SetContents( 0 );
1474  }
1475 
1477  active = false;
1478 
1479  idStr model = spawnArgs.GetString( "model" );
1480  if ( model.Find( ".prt" ) >= 0 ) {
1481  // we want the parametric particles out of sync with each other
1483  }
1484 
1485  fadeFrom.Set( 1, 1, 1, 1 );
1486  fadeTo.Set( 1, 1, 1, 1 );
1487  fadeStart = 0;
1488  fadeEnd = 0;
1489 
1490  // NOTE: this should be used very rarely because it is expensive
1491  runGui = spawnArgs.GetBool( "runGui" );
1492  if ( runGui ) {
1494  }
1495 }
1496 
1497 /*
1498 ================
1499 idStaticEntity::ShowEditingDialog
1500 ================
1501 */
1504 }
1505 /*
1506 ================
1507 idStaticEntity::Think
1508 ================
1509 */
1511  idEntity::Think();
1512  if ( thinkFlags & TH_THINK ) {
1513  if ( runGui && renderEntity.gui[0] ) {
1514  idPlayer *player = gameLocal.GetLocalPlayer();
1515  if ( player ) {
1516  if ( !player->objectiveSystemOpen ) {
1518  if ( renderEntity.gui[1] ) {
1520  }
1521  if ( renderEntity.gui[2] ) {
1523  }
1524  }
1525  }
1526  }
1527  if ( fadeEnd > 0 ) {
1528  idVec4 color;
1529  if ( gameLocal.time < fadeEnd ) {
1530  color.Lerp( fadeFrom, fadeTo, ( float )( gameLocal.time - fadeStart ) / ( float )( fadeEnd - fadeStart ) );
1531  } else {
1532  color = fadeTo;
1533  fadeEnd = 0;
1534  BecomeInactive( TH_THINK );
1535  }
1536  SetColor( color );
1537  }
1538  }
1539 }
1540 
1541 /*
1542 ================
1543 idStaticEntity::Fade
1544 ================
1545 */
1546 void idStaticEntity::Fade( const idVec4 &to, float fadeTime ) {
1547  GetColor( fadeFrom );
1548  fadeTo = to;
1550  fadeEnd = gameLocal.time + SEC2MS( fadeTime );
1552 }
1553 
1554 /*
1555 ================
1556 idStaticEntity::Hide
1557 ================
1558 */
1559 void idStaticEntity::Hide( void ) {
1560  idEntity::Hide();
1561  GetPhysics()->SetContents( 0 );
1562 }
1563 
1564 /*
1565 ================
1566 idStaticEntity::Show
1567 ================
1568 */
1569 void idStaticEntity::Show( void ) {
1570  idEntity::Show();
1571  if ( spawnArgs.GetBool( "solid" ) ) {
1573  }
1574 }
1575 
1576 /*
1577 ================
1578 idStaticEntity::Event_Activate
1579 ================
1580 */
1582  idStr activateGui;
1583 
1585  active = !active;
1586 
1587  const idKeyValue *kv = spawnArgs.FindKey( "hide" );
1588  if ( kv ) {
1589  if ( IsHidden() ) {
1590  Show();
1591  } else {
1592  Hide();
1593  }
1594  }
1595 
1598  // this change should be a good thing, it will automatically turn on
1599  // lights etc.. when triggered so that does not have to be specifically done
1600  // with trigger parms.. it MIGHT break things so need to keep an eye on it
1603 }
1604 
1605 /*
1606 ================
1607 idStaticEntity::WriteToSnapshot
1608 ================
1609 */
1611  GetPhysics()->WriteToSnapshot( msg );
1612  WriteBindToSnapshot( msg );
1613  WriteColorToSnapshot( msg );
1614  WriteGUIToSnapshot( msg );
1615  msg.WriteBits( IsHidden()?1:0, 1 );
1616 }
1617 
1618 /*
1619 ================
1620 idStaticEntity::ReadFromSnapshot
1621 ================
1622 */
1624  bool hidden;
1625 
1626  GetPhysics()->ReadFromSnapshot( msg );
1627  ReadBindFromSnapshot( msg );
1628  ReadColorFromSnapshot( msg );
1629  ReadGUIFromSnapshot( msg );
1630  hidden = msg.ReadBits( 1 ) == 1;
1631  if ( hidden != IsHidden() ) {
1632  if ( hidden ) {
1633  Hide();
1634  } else {
1635  Show();
1636  }
1637  }
1638  if ( msg.HasChanged() ) {
1639  UpdateVisuals();
1640  }
1641 }
1642 
1643 
1644 /*
1645 ===============================================================================
1646 
1647 idFuncEmitter
1648 
1649 ===============================================================================
1650 */
1651 
1652 
1654 EVENT( EV_Activate, idFuncEmitter::Event_Activate )
1655 END_CLASS
1656 
1657 /*
1658 ===============
1659 idFuncEmitter::idFuncEmitter
1660 ===============
1661 */
1663  hidden = false;
1664 }
1665 
1666 /*
1667 ===============
1668 idFuncEmitter::Spawn
1669 ===============
1670 */
1671 void idFuncEmitter::Spawn( void ) {
1672  if ( spawnArgs.GetBool( "start_off" ) ) {
1673  hidden = true;
1675  UpdateVisuals();
1676  } else {
1677  hidden = false;
1678  }
1679 }
1680 
1681 /*
1682 ===============
1683 idFuncEmitter::Save
1684 ===============
1685 */
1686 void idFuncEmitter::Save( idSaveGame *savefile ) const {
1687  savefile->WriteBool( hidden );
1688 }
1689 
1690 /*
1691 ===============
1692 idFuncEmitter::Restore
1693 ===============
1694 */
1696  savefile->ReadBool( hidden );
1697 }
1698 
1699 /*
1700 ================
1701 idFuncEmitter::Event_Activate
1702 ================
1703 */
1705  if ( hidden || spawnArgs.GetBool( "cycleTrigger" ) ) {
1708  hidden = false;
1709  } else {
1711  hidden = true;
1712  }
1713  UpdateVisuals();
1714 }
1715 
1716 /*
1717 ================
1718 idFuncEmitter::WriteToSnapshot
1719 ================
1720 */
1722  msg.WriteBits( hidden ? 1 : 0, 1 );
1725 }
1726 
1727 /*
1728 ================
1729 idFuncEmitter::ReadFromSnapshot
1730 ================
1731 */
1733  hidden = msg.ReadBits( 1 ) != 0;
1736  if ( msg.HasChanged() ) {
1737  UpdateVisuals();
1738  }
1739 }
1740 
1741 
1742 /*
1743 ===============================================================================
1744 
1745 idFuncSplat
1746 
1747 ===============================================================================
1748 */
1749 
1750 
1751 const idEventDef EV_Splat( "<Splat>" );
1753 EVENT( EV_Activate, idFuncSplat::Event_Activate )
1754 EVENT( EV_Splat, idFuncSplat::Event_Splat )
1755 END_CLASS
1756 
1757 /*
1758 ===============
1759 idFuncSplat::idFuncSplat
1760 ===============
1761 */
1763 }
1764 
1765 /*
1766 ===============
1767 idFuncSplat::Spawn
1768 ===============
1769 */
1770 void idFuncSplat::Spawn( void ) {
1771 }
1772 
1773 /*
1774 ================
1775 idFuncSplat::Event_Splat
1776 ================
1777 */
1779  const char *splat = NULL;
1780  int count = spawnArgs.GetInt( "splatCount", "1" );
1781  for ( int i = 0; i < count; i++ ) {
1782  splat = spawnArgs.RandomPrefix( "mtr_splat", gameLocal.random );
1783  if ( splat && *splat ) {
1784  float size = spawnArgs.GetFloat( "splatSize", "128" );
1785  float dist = spawnArgs.GetFloat( "splatDistance", "128" );
1786  float angle = spawnArgs.GetFloat( "splatAngle", "0" );
1787  gameLocal.ProjectDecal( GetPhysics()->GetOrigin(), GetPhysics()->GetAxis()[2], dist, true, size, splat, angle );
1788  }
1789  }
1790  StartSound( "snd_splat", SND_CHANNEL_ANY, 0, false, NULL );
1791 }
1792 
1793 /*
1794 ================
1795 idFuncSplat::Event_Activate
1796 ================
1797 */
1799  idFuncEmitter::Event_Activate( activator );
1800  PostEventSec( &EV_Splat, spawnArgs.GetFloat( "splatDelay", "0.25" ) );
1801  StartSound( "snd_spurt", SND_CHANNEL_ANY, 0, false, NULL );
1802 }
1803 
1804 /*
1805 ===============================================================================
1806 
1807 idFuncSmoke
1808 
1809 ===============================================================================
1810 */
1811 
1813 EVENT( EV_Activate, idFuncSmoke::Event_Activate )
1814 END_CLASS
1815 
1816 /*
1817 ===============
1818 idFuncSmoke::idFuncSmoke
1819 ===============
1820 */
1822  smokeTime = 0;
1823  smoke = NULL;
1824  restart = false;
1825 }
1826 
1827 /*
1828 ===============
1829 idFuncSmoke::Save
1830 ===============
1831 */
1832 void idFuncSmoke::Save( idSaveGame *savefile ) const {
1833  savefile->WriteInt( smokeTime );
1834  savefile->WriteParticle( smoke );
1835  savefile->WriteBool( restart );
1836 }
1837 
1838 /*
1839 ===============
1840 idFuncSmoke::Restore
1841 ===============
1842 */
1844  savefile->ReadInt( smokeTime );
1845  savefile->ReadParticle( smoke );
1846  savefile->ReadBool( restart );
1847 }
1848 
1849 /*
1850 ===============
1851 idFuncSmoke::Spawn
1852 ===============
1853 */
1854 void idFuncSmoke::Spawn( void ) {
1855  const char *smokeName = spawnArgs.GetString( "smoke" );
1856  if ( *smokeName != '\0' ) {
1857  smoke = static_cast<const idDeclParticle *>( declManager->FindType( DECL_PARTICLE, smokeName ) );
1858  } else {
1859  smoke = NULL;
1860  }
1861  if ( spawnArgs.GetBool( "start_off" ) ) {
1862  smokeTime = 0;
1863  restart = false;
1864  } else if ( smoke ) {
1867  restart = true;
1868  }
1869  GetPhysics()->SetContents( 0 );
1870 }
1871 
1872 /*
1873 ================
1874 idFuncSmoke::Event_Activate
1875 ================
1876 */
1878  if ( thinkFlags & TH_UPDATEPARTICLES ) {
1879  restart = false;
1880  return;
1881  } else {
1882  BecomeActive( TH_UPDATEPARTICLES );
1883  restart = true;
1885  }
1886 }
1887 
1888 /*
1889 ===============
1890 idFuncSmoke::Think
1891 ================
1892 */
1893 void idFuncSmoke::Think( void ) {
1894 
1895  // if we are completely closed off from the player, don't do anything at all
1896  if ( CheckDormant() || smoke == NULL || smokeTime == -1 ) {
1897  return;
1898  }
1899 
1900  if ( ( thinkFlags & TH_UPDATEPARTICLES) && !IsHidden() ) {
1902  if ( restart ) {
1904  } else {
1905  smokeTime = 0;
1906  BecomeInactive( TH_UPDATEPARTICLES );
1907  }
1908  }
1909  }
1910 
1911 }
1912 
1913 
1914 /*
1915 ===============================================================================
1916 
1917  idTextEntity
1918 
1919 ===============================================================================
1920 */
1921 
1923 END_CLASS
1924 
1925 /*
1926 ================
1927 idTextEntity::Spawn
1928 ================
1929 */
1930 void idTextEntity::Spawn( void ) {
1931  // these are cached as the are used each frame
1932  text = spawnArgs.GetString( "text" );
1933  playerOriented = spawnArgs.GetBool( "playerOriented" );
1934  bool force = spawnArgs.GetBool( "force" );
1935  if ( developer.GetBool() || force ) {
1936  BecomeActive(TH_THINK);
1937  }
1938 }
1939 
1940 /*
1941 ================
1942 idTextEntity::Save
1943 ================
1944 */
1945 void idTextEntity::Save( idSaveGame *savefile ) const {
1946  savefile->WriteString( text );
1947  savefile->WriteBool( playerOriented );
1948 }
1949 
1950 /*
1951 ================
1952 idTextEntity::Restore
1953 ================
1954 */
1956  savefile->ReadString( text );
1957  savefile->ReadBool( playerOriented );
1958 }
1959 
1960 /*
1961 ================
1962 idTextEntity::Think
1963 ================
1964 */
1965 void idTextEntity::Think( void ) {
1966  if ( thinkFlags & TH_THINK ) {
1968  for ( int i = 0; i < targets.Num(); i++ ) {
1969  if ( targets[i].GetEntity() ) {
1970  gameRenderWorld->DebugArrow( colorBlue, GetPhysics()->GetOrigin(), targets[i].GetEntity()->GetPhysics()->GetOrigin(), 1 );
1971  }
1972  }
1973  } else {
1975  }
1976 }
1977 
1978 
1979 /*
1980 ===============================================================================
1981 
1982  idVacuumSeperatorEntity
1983 
1984  Can be triggered to let vacuum through a portal (blown out window)
1985 
1986 ===============================================================================
1987 */
1988 
1990  EVENT( EV_Activate, idVacuumSeparatorEntity::Event_Activate )
1991 END_CLASS
1992 
1993 
1994 /*
1995 ================
1996 idVacuumSeparatorEntity::idVacuumSeparatorEntity
1997 ================
1998 */
2000  portal = 0;
2001 }
2002 
2003 /*
2004 ================
2005 idVacuumSeparatorEntity::Save
2006 ================
2007 */
2009  savefile->WriteInt( (int)portal );
2010  savefile->WriteInt( gameRenderWorld->GetPortalState( portal ) );
2011 }
2012 
2013 /*
2014 ================
2015 idVacuumSeparatorEntity::Restore
2016 ================
2017 */
2019  int state;
2020 
2021  savefile->ReadInt( (int &)portal );
2022  savefile->ReadInt( state );
2023 
2024  gameLocal.SetPortalState( portal, state );
2025 }
2026 
2027 /*
2028 ================
2029 idVacuumSeparatorEntity::Spawn
2030 ================
2031 */
2033  idBounds b;
2034 
2035  b = idBounds( spawnArgs.GetVector( "origin" ) ).Expand( 16 );
2037  if ( !portal ) {
2038  gameLocal.Warning( "VacuumSeparator '%s' didn't contact a portal", spawnArgs.GetString( "name" ) );
2039  return;
2040  }
2042 }
2043 
2044 /*
2045 ================
2046 idVacuumSeparatorEntity::Event_Activate
2047 ================
2048 */
2050  if ( !portal ) {
2051  return;
2052  }
2054 }
2055 
2056 
2057 /*
2058 ===============================================================================
2059 
2060 idLocationSeparatorEntity
2061 
2062 ===============================================================================
2063 */
2064 
2066 END_CLASS
2067 
2068 /*
2069 ================
2070 idLocationSeparatorEntity::Spawn
2071 ================
2072 */
2074  idBounds b;
2075 
2076  b = idBounds( spawnArgs.GetVector( "origin" ) ).Expand( 16 );
2077  qhandle_t portal = gameRenderWorld->FindPortal( b );
2078  if ( !portal ) {
2079  gameLocal.Warning( "LocationSeparator '%s' didn't contact a portal", spawnArgs.GetString( "name" ) );
2080  }
2082 }
2083 
2084 
2085 /*
2086 ===============================================================================
2087 
2088  idVacuumEntity
2089 
2090  Levels should only have a single vacuum entity.
2091 
2092 ===============================================================================
2093 */
2094 
2096 END_CLASS
2097 
2098 /*
2099 ================
2100 idVacuumEntity::Spawn
2101 ================
2102 */
2103 void idVacuumEntity::Spawn() {
2104  if ( gameLocal.vacuumAreaNum != -1 ) {
2105  gameLocal.Warning( "idVacuumEntity::Spawn: multiple idVacuumEntity in level" );
2106  return;
2107  }
2108 
2109  idVec3 org = spawnArgs.GetVector( "origin" );
2110 
2112 }
2113 
2114 
2115 /*
2116 ===============================================================================
2117 
2118 idLocationEntity
2119 
2120 ===============================================================================
2121 */
2122 
2124 END_CLASS
2125 
2126 /*
2127 ======================
2128 idLocationEntity::Spawn
2129 ======================
2130 */
2131 void idLocationEntity::Spawn() {
2132  idStr realName;
2133 
2134  // this just holds dict information
2135 
2136  // if "location" not already set, use the entity name.
2137  if ( !spawnArgs.GetString( "location", "", realName ) ) {
2138  spawnArgs.Set( "location", name );
2139  }
2140 }
2141 
2142 /*
2143 ======================
2144 idLocationEntity::GetLocation
2145 ======================
2146 */
2147 const char *idLocationEntity::GetLocation( void ) const {
2148  return spawnArgs.GetString( "location" );
2149 }
2150 
2151 /*
2152 ===============================================================================
2153 
2154  idBeam
2155 
2156 ===============================================================================
2157 */
2158 
2160  EVENT( EV_PostSpawn, idBeam::Event_MatchTarget )
2161  EVENT( EV_Activate, idBeam::Event_Activate )
2162 END_CLASS
2163 
2164 /*
2165 ===============
2166 idBeam::idBeam
2167 ===============
2168 */
2170  target = NULL;
2171  master = NULL;
2172 }
2173 
2174 /*
2175 ===============
2176 idBeam::Save
2177 ===============
2178 */
2179 void idBeam::Save( idSaveGame *savefile ) const {
2180  target.Save( savefile );
2181  master.Save( savefile );
2182 }
2183 
2184 /*
2185 ===============
2186 idBeam::Restore
2187 ===============
2188 */
2189 void idBeam::Restore( idRestoreGame *savefile ) {
2190  target.Restore( savefile );
2191  master.Restore( savefile );
2192 }
2193 
2194 /*
2195 ===============
2196 idBeam::Spawn
2197 ===============
2198 */
2199 void idBeam::Spawn( void ) {
2200  float width;
2201 
2202  if ( spawnArgs.GetFloat( "width", "0", width ) ) {
2204  }
2205 
2206  SetModel( "_BEAM" );
2207  Hide();
2208  PostEventMS( &EV_PostSpawn, 0 );
2209 }
2210 
2211 /*
2212 ================
2213 idBeam::Think
2214 ================
2215 */
2216 void idBeam::Think( void ) {
2217  idBeam *masterEnt;
2218 
2219  if ( !IsHidden() && !target.GetEntity() ) {
2220  // hide if our target is removed
2221  Hide();
2222  }
2223 
2224  RunPhysics();
2225 
2226  masterEnt = master.GetEntity();
2227  if ( masterEnt ) {
2228  const idVec3 &origin = GetPhysics()->GetOrigin();
2229  masterEnt->SetBeamTarget( origin );
2230  }
2231  Present();
2232 }
2233 
2234 /*
2235 ================
2236 idBeam::SetMaster
2237 ================
2238 */
2239 void idBeam::SetMaster( idBeam *masterbeam ) {
2240  master = masterbeam;
2241 }
2242 
2243 /*
2244 ================
2245 idBeam::SetBeamTarget
2246 ================
2247 */
2248 void idBeam::SetBeamTarget( const idVec3 &origin ) {
2253  UpdateVisuals();
2254  }
2255 }
2256 
2257 /*
2258 ================
2259 idBeam::Show
2260 ================
2261 */
2262 void idBeam::Show( void ) {
2263  idBeam *targetEnt;
2264 
2265  idEntity::Show();
2266 
2267  targetEnt = target.GetEntity();
2268  if ( targetEnt ) {
2269  const idVec3 &origin = targetEnt->GetPhysics()->GetOrigin();
2270  SetBeamTarget( origin );
2271  }
2272 }
2273 
2274 /*
2275 ================
2276 idBeam::Event_MatchTarget
2277 ================
2278 */
2280  int i;
2281  idEntity *targetEnt;
2282  idBeam *targetBeam;
2283 
2284  if ( !targets.Num() ) {
2285  return;
2286  }
2287 
2288  targetBeam = NULL;
2289  for( i = 0; i < targets.Num(); i++ ) {
2290  targetEnt = targets[ i ].GetEntity();
2291  if ( targetEnt && targetEnt->IsType( idBeam::Type ) ) {
2292  targetBeam = static_cast<idBeam *>( targetEnt );
2293  break;
2294  }
2295  }
2296 
2297  if ( !targetBeam ) {
2298  gameLocal.Error( "Could not find valid beam target for '%s'", name.c_str() );
2299  }
2300 
2301  target = targetBeam;
2302  targetBeam->SetMaster( this );
2303  if ( !spawnArgs.GetBool( "start_off" ) ) {
2304  Show();
2305  }
2306 }
2307 
2308 /*
2309 ================
2310 idBeam::Event_Activate
2311 ================
2312 */
2313 void idBeam::Event_Activate( idEntity *activator ) {
2314  if ( IsHidden() ) {
2315  Show();
2316  } else {
2317  Hide();
2318  }
2319 }
2320 
2321 /*
2322 ================
2323 idBeam::WriteToSnapshot
2324 ================
2325 */
2327  GetPhysics()->WriteToSnapshot( msg );
2328  WriteBindToSnapshot( msg );
2329  WriteColorToSnapshot( msg );
2333 }
2334 
2335 /*
2336 ================
2337 idBeam::ReadFromSnapshot
2338 ================
2339 */
2341  GetPhysics()->ReadFromSnapshot( msg );
2342  ReadBindFromSnapshot( msg );
2343  ReadColorFromSnapshot( msg );
2347  if ( msg.HasChanged() ) {
2348  UpdateVisuals();
2349  }
2350 }
2351 
2352 
2353 /*
2354 ===============================================================================
2355 
2356  idLiquid
2357 
2358 ===============================================================================
2359 */
2360 
2362  EVENT( EV_Touch, idLiquid::Event_Touch )
2363 END_CLASS
2364 
2365 /*
2366 ================
2367 idLiquid::Save
2368 ================
2369 */
2370 void idLiquid::Save( idSaveGame *savefile ) const {
2371  // Nothing to save
2372 }
2373 
2374 /*
2375 ================
2376 idLiquid::Restore
2377 ================
2378 */
2380  //FIXME: NO!
2381  Spawn();
2382 }
2383 
2384 /*
2385 ================
2386 idLiquid::Spawn
2387 ================
2388 */
2390 /*
2391  model = dynamic_cast<idRenderModelLiquid *>( renderEntity.hModel );
2392  if ( !model ) {
2393  gameLocal.Error( "Entity '%s' must have liquid model", name.c_str() );
2394  }
2395  model->Reset();
2396  GetPhysics()->SetContents( CONTENTS_TRIGGER );
2397 */
2398 }
2399 
2400 /*
2401 ================
2402 idLiquid::Event_Touch
2403 ================
2404 */
2405 void idLiquid::Event_Touch( idEntity *other, trace_t *trace ) {
2406  // FIXME: for QuakeCon
2407 /*
2408  idVec3 pos;
2409 
2410  pos = other->GetPhysics()->GetOrigin() - GetPhysics()->GetOrigin();
2411  model->IntersectBounds( other->GetPhysics()->GetBounds().Translate( pos ), -10.0f );
2412 */
2413 }
2414 
2415 
2416 /*
2417 ===============================================================================
2418 
2419  idShaking
2420 
2421 ===============================================================================
2422 */
2423 
2425  EVENT( EV_Activate, idShaking::Event_Activate )
2426 END_CLASS
2427 
2428 /*
2429 ===============
2430 idShaking::idShaking
2431 ===============
2432 */
2434  active = false;
2435 }
2436 
2437 /*
2438 ===============
2439 idShaking::Save
2440 ===============
2441 */
2442 void idShaking::Save( idSaveGame *savefile ) const {
2443  savefile->WriteBool( active );
2444  savefile->WriteStaticObject( physicsObj );
2445 }
2446 
2447 /*
2448 ===============
2449 idShaking::Restore
2450 ===============
2451 */
2453  savefile->ReadBool( active );
2454  savefile->ReadStaticObject( physicsObj );
2456 }
2457 
2458 /*
2459 ===============
2460 idShaking::Spawn
2461 ===============
2462 */
2463 void idShaking::Spawn( void ) {
2464  physicsObj.SetSelf( this );
2465  physicsObj.SetClipModel( new idClipModel( GetPhysics()->GetClipModel() ), 1.0f );
2466  physicsObj.SetOrigin( GetPhysics()->GetOrigin() );
2467  physicsObj.SetAxis( GetPhysics()->GetAxis() );
2469  SetPhysics( &physicsObj );
2470 
2471  active = false;
2472  if ( !spawnArgs.GetBool( "start_off" ) ) {
2473  BeginShaking();
2474  }
2475 }
2476 
2477 /*
2478 ================
2479 idShaking::BeginShaking
2480 ================
2481 */
2483  int phase;
2484  idAngles shake;
2485  int period;
2486 
2487  active = true;
2488  phase = gameLocal.random.RandomInt( 1000 );
2489  shake = spawnArgs.GetAngles( "shake", "0.5 0.5 0.5" );
2490  period = spawnArgs.GetFloat( "period", "0.05" ) * 1000;
2491  physicsObj.SetAngularExtrapolation( extrapolation_t(EXTRAPOLATION_DECELSINE|EXTRAPOLATION_NOSTOP), phase, period * 0.25f, GetPhysics()->GetAxis().ToAngles(), shake, ang_zero );
2492 }
2493 
2494 /*
2495 ================
2496 idShaking::Event_Activate
2497 ================
2498 */
2500  if ( !active ) {
2501  BeginShaking();
2502  } else {
2503  active = false;
2505  }
2506 }
2507 
2508 /*
2509 ===============================================================================
2510 
2511  idEarthQuake
2512 
2513 ===============================================================================
2514 */
2515 
2517  EVENT( EV_Activate, idEarthQuake::Event_Activate )
2518 END_CLASS
2519 
2520 /*
2521 ===============
2522 idEarthQuake::idEarthQuake
2523 ===============
2524 */
2526  wait = 0.0f;
2527  random = 0.0f;
2528  nextTriggerTime = 0;
2529  shakeStopTime = 0;
2530  triggered = false;
2531  playerOriented = false;
2532  disabled = false;
2533  shakeTime = 0.0f;
2534 }
2535 
2536 /*
2537 ===============
2538 idEarthQuake::Save
2539 ===============
2540 */
2541 void idEarthQuake::Save( idSaveGame *savefile ) const {
2542  savefile->WriteInt( nextTriggerTime );
2543  savefile->WriteInt( shakeStopTime );
2544  savefile->WriteFloat( wait );
2545  savefile->WriteFloat( random );
2546  savefile->WriteBool( triggered );
2547  savefile->WriteBool( playerOriented );
2548  savefile->WriteBool( disabled );
2549  savefile->WriteFloat( shakeTime );
2550 }
2551 
2552 /*
2553 ===============
2554 idEarthQuake::Restore
2555 ===============
2556 */
2558  savefile->ReadInt( nextTriggerTime );
2559  savefile->ReadInt( shakeStopTime );
2560  savefile->ReadFloat( wait );
2561  savefile->ReadFloat( random );
2562  savefile->ReadBool( triggered );
2563  savefile->ReadBool( playerOriented );
2564  savefile->ReadBool( disabled );
2565  savefile->ReadFloat( shakeTime );
2566 
2567  if ( shakeStopTime > gameLocal.time ) {
2569  }
2570 }
2571 
2572 /*
2573 ===============
2574 idEarthQuake::Spawn
2575 ===============
2576 */
2577 void idEarthQuake::Spawn( void ) {
2578  nextTriggerTime = 0;
2579  shakeStopTime = 0;
2580  wait = spawnArgs.GetFloat( "wait", "15" );
2581  random = spawnArgs.GetFloat( "random", "5" );
2582  triggered = spawnArgs.GetBool( "triggered" );
2583  playerOriented = spawnArgs.GetBool( "playerOriented" );
2584  disabled = false;
2585  shakeTime = spawnArgs.GetFloat( "shakeTime", "0" );
2586 
2587  if ( !triggered ){
2588  PostEventSec( &EV_Activate, spawnArgs.GetFloat( "wait" ), this );
2589  }
2591 }
2592 
2593 /*
2594 ================
2595 idEarthQuake::Event_Activate
2596 ================
2597 */
2599 
2600  if ( nextTriggerTime > gameLocal.time ) {
2601  return;
2602  }
2603 
2604  if ( disabled && activator == this ) {
2605  return;
2606  }
2607 
2608  idPlayer *player = gameLocal.GetLocalPlayer();
2609  if ( player == NULL ) {
2610  return;
2611  }
2612 
2613  nextTriggerTime = 0;
2614 
2615  if ( !triggered && activator != this ){
2616  // if we are not triggered ( i.e. random ), disable or enable
2617  disabled ^= 1;
2618  if (disabled) {
2619  return;
2620  } else {
2621  PostEventSec( &EV_Activate, wait + random * gameLocal.random.CRandomFloat(), this );
2622  }
2623  }
2624 
2625  ActivateTargets( activator );
2626 
2627  const idSoundShader *shader = declManager->FindSound( spawnArgs.GetString( "snd_quake" ) );
2628  if ( playerOriented ) {
2629  player->StartSoundShader( shader, SND_CHANNEL_ANY, SSF_GLOBAL, false, NULL );
2630  } else {
2631  StartSoundShader( shader, SND_CHANNEL_ANY, SSF_GLOBAL, false, NULL );
2632  }
2633 
2634  if ( shakeTime > 0.0f ) {
2637  }
2638 
2639  if ( wait > 0.0f ) {
2640  if ( !triggered ) {
2641  PostEventSec( &EV_Activate, wait + random * gameLocal.random.CRandomFloat(), this );
2642  } else {
2644  }
2645  } else if ( shakeTime == 0.0f ) {
2646  PostEventMS( &EV_Remove, 0 );
2647  }
2648 }
2649 
2650 
2651 /*
2652 ===============
2653 idEarthQuake::Think
2654 ================
2655 */
2656 void idEarthQuake::Think( void ) {
2657  if ( thinkFlags & TH_THINK ) {
2658  if ( gameLocal.time > shakeStopTime ) {
2659  BecomeInactive( TH_THINK );
2660  if ( wait <= 0.0f ) {
2661  PostEventMS( &EV_Remove, 0 );
2662  }
2663  return;
2664  }
2666  gameLocal.RadiusPush( GetPhysics()->GetOrigin(), 256, 1500 * shakeVolume, this, this, 1.0f, true );
2667  }
2669 }
2670 
2671 /*
2672 ===============================================================================
2673 
2674  idFuncPortal
2675 
2676 ===============================================================================
2677 */
2678 
2680  EVENT( EV_Activate, idFuncPortal::Event_Activate )
2681 END_CLASS
2682 
2683 /*
2684 ===============
2685 idFuncPortal::idFuncPortal
2686 ===============
2687 */
2689  portal = 0;
2690  state = false;
2691 }
2692 
2693 /*
2694 ===============
2695 idFuncPortal::Save
2696 ===============
2697 */
2698 void idFuncPortal::Save( idSaveGame *savefile ) const {
2699  savefile->WriteInt( (int)portal );
2700  savefile->WriteBool( state );
2701 }
2702 
2703 /*
2704 ===============
2705 idFuncPortal::Restore
2706 ===============
2707 */
2709  savefile->ReadInt( (int &)portal );
2710  savefile->ReadBool( state );
2712 }
2713 
2714 /*
2715 ===============
2716 idFuncPortal::Spawn
2717 ===============
2718 */
2719 void idFuncPortal::Spawn( void ) {
2720  portal = gameRenderWorld->FindPortal( GetPhysics()->GetAbsBounds().Expand( 32.0f ) );
2721  if ( portal > 0 ) {
2722  state = spawnArgs.GetBool( "start_on" );
2724  }
2725 }
2726 
2727 /*
2728 ================
2729 idFuncPortal::Event_Activate
2730 ================
2731 */
2733  if ( portal > 0 ) {
2734  state = !state;
2736  }
2737 }
2738 
2739 /*
2740 ===============================================================================
2741 
2742  idFuncAASPortal
2743 
2744 ===============================================================================
2745 */
2746 
2748  EVENT( EV_Activate, idFuncAASPortal::Event_Activate )
2749 END_CLASS
2750 
2751 /*
2752 ===============
2753 idFuncAASPortal::idFuncAASPortal
2754 ===============
2755 */
2757  state = false;
2758 }
2759 
2760 /*
2761 ===============
2762 idFuncAASPortal::Save
2763 ===============
2764 */
2765 void idFuncAASPortal::Save( idSaveGame *savefile ) const {
2766  savefile->WriteBool( state );
2767 }
2768 
2769 /*
2770 ===============
2771 idFuncAASPortal::Restore
2772 ===============
2773 */
2775  savefile->ReadBool( state );
2777 }
2778 
2779 /*
2780 ===============
2781 idFuncAASPortal::Spawn
2782 ===============
2783 */
2785  state = spawnArgs.GetBool( "start_on" );
2787 }
2788 
2789 /*
2790 ================
2791 idFuncAASPortal::Event_Activate
2792 ================
2793 */
2795  state ^= 1;
2797 }
2798 
2799 /*
2800 ===============================================================================
2801 
2802  idFuncAASObstacle
2803 
2804 ===============================================================================
2805 */
2806 
2808  EVENT( EV_Activate, idFuncAASObstacle::Event_Activate )
2809 END_CLASS
2810 
2811 /*
2812 ===============
2813 idFuncAASObstacle::idFuncAASObstacle
2814 ===============
2815 */
2817  state = false;
2818 }
2819 
2820 /*
2821 ===============
2822 idFuncAASObstacle::Save
2823 ===============
2824 */
2825 void idFuncAASObstacle::Save( idSaveGame *savefile ) const {
2826  savefile->WriteBool( state );
2827 }
2828 
2829 /*
2830 ===============
2831 idFuncAASObstacle::Restore
2832 ===============
2833 */
2835  savefile->ReadBool( state );
2837 }
2838 
2839 /*
2840 ===============
2841 idFuncAASObstacle::Spawn
2842 ===============
2843 */
2845  state = spawnArgs.GetBool( "start_on" );
2847 }
2848 
2849 /*
2850 ================
2851 idFuncAASObstacle::Event_Activate
2852 ================
2853 */
2855  state ^= 1;
2857 }
2858 
2859 
2860 
2861 /*
2862 ===============================================================================
2863 
2864 idFuncRadioChatter
2865 
2866 ===============================================================================
2867 */
2868 
2869 const idEventDef EV_ResetRadioHud( "<resetradiohud>", "e" );
2870 
2871 
2873 EVENT( EV_Activate, idFuncRadioChatter::Event_Activate )
2874 EVENT( EV_ResetRadioHud, idFuncRadioChatter::Event_ResetRadioHud )
2875 END_CLASS
2876 
2877 /*
2878 ===============
2879 idFuncRadioChatter::idFuncRadioChatter
2880 ===============
2881 */
2883  time = 0.0;
2884 }
2885 
2886 /*
2887 ===============
2888 idFuncRadioChatter::Save
2889 ===============
2890 */
2891 void idFuncRadioChatter::Save( idSaveGame *savefile ) const {
2892  savefile->WriteFloat( time );
2893 }
2894 
2895 /*
2896 ===============
2897 idFuncRadioChatter::Restore
2898 ===============
2899 */
2901  savefile->ReadFloat( time );
2902 }
2903 
2904 /*
2905 ===============
2906 idFuncRadioChatter::Spawn
2907 ===============
2908 */
2910  time = spawnArgs.GetFloat( "time", "5.0" );
2911 }
2912 
2913 /*
2914 ================
2915 idFuncRadioChatter::Event_Activate
2916 ================
2917 */
2919  idPlayer *player;
2920  const char *sound;
2921  const idSoundShader *shader;
2922  int length;
2923 
2924  if ( activator->IsType( idPlayer::Type ) ) {
2925  player = static_cast<idPlayer *>( activator );
2926  } else {
2927  player = gameLocal.GetLocalPlayer();
2928  }
2929 
2930  player->hud->HandleNamedEvent( "radioChatterUp" );
2931 
2932  sound = spawnArgs.GetString( "snd_radiochatter", "" );
2933  if ( sound && *sound ) {
2934  shader = declManager->FindSound( sound );
2935  player->StartSoundShader( shader, SND_CHANNEL_RADIO, SSF_GLOBAL, false, &length );
2936  time = MS2SEC( length + 150 );
2937  }
2938  // we still put the hud up because this is used with no sound on
2939  // certain frame commands when the chatter is triggered
2940  PostEventSec( &EV_ResetRadioHud, time, player );
2941 
2942 }
2943 
2944 /*
2945 ================
2946 idFuncRadioChatter::Event_ResetRadioHud
2947 ================
2948 */
2950  idPlayer *player = ( activator->IsType( idPlayer::Type ) ) ? static_cast<idPlayer *>( activator ) : gameLocal.GetLocalPlayer();
2951  player->hud->HandleNamedEvent( "radioChatterDown" );
2952  ActivateTargets( activator );
2953 }
2954 
2955 
2956 /*
2957 ===============================================================================
2958 
2959  idPhantomObjects
2960 
2961 ===============================================================================
2962 */
2963 
2965  EVENT( EV_Activate, idPhantomObjects::Event_Activate )
2966 END_CLASS
2967 
2968 /*
2969 ===============
2970 idPhantomObjects::idPhantomObjects
2971 ===============
2972 */
2974  target = NULL;
2975  end_time = 0;
2976  throw_time = 0.0f;
2977  shake_time = 0.0f;
2978  shake_ang.Zero();
2979  speed = 0.0f;
2980  min_wait = 0;
2981  max_wait = 0;
2982  fl.neverDormant = false;
2983 }
2984 
2985 /*
2986 ===============
2987 idPhantomObjects::Save
2988 ===============
2989 */
2990 void idPhantomObjects::Save( idSaveGame *savefile ) const {
2991  int i;
2992 
2993  savefile->WriteInt( end_time );
2994  savefile->WriteFloat( throw_time );
2995  savefile->WriteFloat( shake_time );
2996  savefile->WriteVec3( shake_ang );
2997  savefile->WriteFloat( speed );
2998  savefile->WriteInt( min_wait );
2999  savefile->WriteInt( max_wait );
3000  target.Save( savefile );
3001 
3002  savefile->WriteInt( targetTime.Num() );
3003  for( i = 0; i < targetTime.Num(); i++ ) {
3004  savefile->WriteInt( targetTime[ i ] );
3005  }
3006  for( i = 0; i < lastTargetPos.Num(); i++ ) {
3007  savefile->WriteVec3( lastTargetPos[ i ] );
3008  }
3009 }
3010 
3011 /*
3012 ===============
3013 idPhantomObjects::Restore
3014 ===============
3015 */
3017  int num;
3018  int i;
3019 
3020  savefile->ReadInt( end_time );
3021  savefile->ReadFloat( throw_time );
3022  savefile->ReadFloat( shake_time );
3023  savefile->ReadVec3( shake_ang );
3024  savefile->ReadFloat( speed );
3025  savefile->ReadInt( min_wait );
3026  savefile->ReadInt( max_wait );
3027  target.Restore( savefile );
3028 
3029  savefile->ReadInt( num );
3031  targetTime.SetNum( num );
3033  lastTargetPos.SetNum( num );
3034 
3035  for( i = 0; i < num; i++ ) {
3036  savefile->ReadInt( targetTime[ i ] );
3037  }
3038  for( i = 0; i < num; i++ ) {
3039  savefile->ReadVec3( lastTargetPos[ i ] );
3040  }
3041 }
3042 
3043 /*
3044 ===============
3045 idPhantomObjects::Spawn
3046 ===============
3047 */
3049  throw_time = spawnArgs.GetFloat( "time", "5" );
3050  speed = spawnArgs.GetFloat( "speed", "1200" );
3051  shake_time = spawnArgs.GetFloat( "shake_time", "1" );
3053  if ( throw_time < 0.0f ) {
3054  throw_time = 0.0f;
3055  }
3056  min_wait = SEC2MS( spawnArgs.GetFloat( "min_wait", "1" ) );
3057  max_wait = SEC2MS( spawnArgs.GetFloat( "max_wait", "3" ) );
3058 
3059  shake_ang = spawnArgs.GetVector( "shake_ang", "65 65 65" );
3060  Hide();
3061  GetPhysics()->SetContents( 0 );
3062 }
3063 
3064 /*
3065 ================
3066 idPhantomObjects::Event_Activate
3067 ================
3068 */
3070  int i;
3071  float time;
3072  float frac;
3073  float scale;
3074 
3075  if ( thinkFlags & TH_THINK ) {
3076  BecomeInactive( TH_THINK );
3077  return;
3078  }
3079 
3081  if ( !targets.Num() ) {
3082  return;
3083  }
3084 
3085  if ( !activator || !activator->IsType( idActor::Type ) ) {
3087  } else {
3088  target = static_cast<idActor *>( activator );
3089  }
3090 
3091  end_time = gameLocal.time + SEC2MS( spawnArgs.GetFloat( "end_time", "0" ) );
3092 
3095 
3096  const idVec3 &toPos = target.GetEntity()->GetEyePosition();
3097 
3098  // calculate the relative times of all the objects
3099  time = 0.0f;
3100  for( i = 0; i < targetTime.Num(); i++ ) {
3101  targetTime[ i ] = SEC2MS( time );
3102  lastTargetPos[ i ] = toPos;
3103 
3104  frac = 1.0f - ( float )i / ( float )targetTime.Num();
3105  time += ( gameLocal.random.RandomFloat() + 1.0f ) * 0.5f * frac + 0.1f;
3106  }
3107 
3108  // scale up the times to fit within throw_time
3109  scale = throw_time / time;
3110  for( i = 0; i < targetTime.Num(); i++ ) {
3112  }
3113 
3114  BecomeActive( TH_THINK );
3115 }
3116 
3117 /*
3118 ===============
3119 idPhantomObjects::Think
3120 ================
3121 */
3123  int i;
3124  int num;
3125  float time;
3126  idVec3 vel;
3127  idVec3 ang;
3128  idEntity *ent;
3129  idActor *targetEnt;
3130  idPhysics *entPhys;
3131  trace_t tr;
3132 
3133  // if we are completely closed off from the player, don't do anything at all
3134  if ( CheckDormant() ) {
3135  return;
3136  }
3137 
3138  if ( !( thinkFlags & TH_THINK ) ) {
3139  BecomeInactive( thinkFlags & ~TH_THINK );
3140  return;
3141  }
3142 
3143  targetEnt = target.GetEntity();
3144  if ( !targetEnt || ( targetEnt->health <= 0 ) || ( end_time && ( gameLocal.time > end_time ) ) || gameLocal.inCinematic ) {
3145  BecomeInactive( TH_THINK );
3146  }
3147 
3148  const idVec3 &toPos = targetEnt->GetEyePosition();
3149 
3150  num = 0;
3151  for ( i = 0; i < targets.Num(); i++ ) {
3152  ent = targets[ i ].GetEntity();
3153  if ( !ent ) {
3154  continue;
3155  }
3156 
3157  if ( ent->fl.hidden ) {
3158  // don't throw hidden objects
3159  continue;
3160  }
3161 
3162  if ( !targetTime[ i ] ) {
3163  // already threw this object
3164  continue;
3165  }
3166 
3167  num++;
3168 
3169  time = MS2SEC( targetTime[ i ] - gameLocal.time );
3170  if ( time > shake_time ) {
3171  continue;
3172  }
3173 
3174  entPhys = ent->GetPhysics();
3175  const idVec3 &entOrg = entPhys->GetOrigin();
3176 
3177  gameLocal.clip.TracePoint( tr, entOrg, toPos, MASK_OPAQUE, ent );
3178  if ( tr.fraction >= 1.0f || ( gameLocal.GetTraceEntity( tr ) == targetEnt ) ) {
3179  lastTargetPos[ i ] = toPos;
3180  }
3181 
3182  if ( time < 0.0f ) {
3183  idAI::PredictTrajectory( entPhys->GetOrigin(), lastTargetPos[ i ], speed, entPhys->GetGravity(),
3184  entPhys->GetClipModel(), entPhys->GetClipMask(), 256.0f, ent, targetEnt, ai_debugTrajectory.GetBool() ? 1 : 0, vel );
3185  vel *= speed;
3186  entPhys->SetLinearVelocity( vel );
3187  if ( !end_time ) {
3188  targetTime[ i ] = 0;
3189  } else {
3191  }
3192  if ( ent->IsType( idMoveable::Type ) ) {
3193  idMoveable *ment = static_cast<idMoveable*>( ent );
3194  ment->EnableDamage( true, 2.5f );
3195  }
3196  } else {
3197  // this is not the right way to set the angular velocity, but the effect is nice, so I'm keeping it. :)
3199  ang *= ( 1.0f - time / shake_time );
3200  entPhys->SetAngularVelocity( ang );
3201  }
3202  }
3203 
3204  if ( !num ) {
3205  BecomeInactive( TH_THINK );
3206  }
3207 }
3208 
3209 #ifdef _D3XP
3210 /*
3211 ===============================================================================
3212 
3213 idShockwave
3214 
3215 ===============================================================================
3216 */
3217 CLASS_DECLARATION( idEntity, idShockwave )
3218 EVENT( EV_Activate, idShockwave::Event_Activate )
3219 END_CLASS
3220 
3221 /*
3222 ===============
3223 idShockwave::idShockwave
3224 ===============
3225 */
3226 idShockwave::idShockwave() {
3227  isActive = false;
3228  startTime = 0;
3229  duration = 0;
3230  startSize = 0.f;
3231  endSize = 0.f;
3232  currentSize = 0.f;
3233  magnitude = 0.f;
3234 
3235  height = 0.0f;
3236  playerDamaged = false;
3237  playerDamageSize = 0.0f;
3238 }
3239 
3240 /*
3241 ===============
3242 idShockwave::~idShockwave
3243 ===============
3244 */
3245 idShockwave::~idShockwave() {
3246 }
3247 
3248 /*
3249 ===============
3250 idShockwave::Save
3251 ===============
3252 */
3253 void idShockwave::Save( idSaveGame *savefile ) const {
3254  savefile->WriteBool( isActive );
3255  savefile->WriteInt( startTime );
3256  savefile->WriteInt( duration );
3257 
3258  savefile->WriteFloat( startSize );
3259  savefile->WriteFloat( endSize );
3260  savefile->WriteFloat( currentSize );
3261 
3262  savefile->WriteFloat( magnitude );
3263 
3264  savefile->WriteFloat( height );
3265  savefile->WriteBool( playerDamaged );
3266  savefile->WriteFloat( playerDamageSize );
3267 }
3268 
3269 /*
3270 ===============
3271 idShockwave::Restore
3272 ===============
3273 */
3274 void idShockwave::Restore( idRestoreGame *savefile ) {
3275  savefile->ReadBool( isActive );
3276  savefile->ReadInt( startTime );
3277  savefile->ReadInt( duration );
3278 
3279  savefile->ReadFloat( startSize );
3280  savefile->ReadFloat( endSize );
3281  savefile->ReadFloat( currentSize );
3282 
3283  savefile->ReadFloat( magnitude );
3284 
3285  savefile->ReadFloat( height );
3286  savefile->ReadBool( playerDamaged );
3287  savefile->ReadFloat( playerDamageSize );
3288 
3289 }
3290 
3291 /*
3292 ===============
3293 idShockwave::Spawn
3294 ===============
3295 */
3296 void idShockwave::Spawn() {
3297 
3298  spawnArgs.GetInt( "duration", "1000", duration );
3299  spawnArgs.GetFloat( "startsize", "8", startSize );
3300  spawnArgs.GetFloat( "endsize", "512", endSize );
3301  spawnArgs.GetFloat( "magnitude", "100", magnitude );
3302 
3303  spawnArgs.GetFloat( "height", "0", height);
3304  spawnArgs.GetFloat( "player_damage_size", "20", playerDamageSize);
3305 
3306  if ( spawnArgs.GetBool( "start_on" ) ) {
3307  ProcessEvent( &EV_Activate, this );
3308  }
3309 }
3310 
3311 /*
3312 ===============
3313 idShockwave::Think
3314 ===============
3315 */
3316 void idShockwave::Think() {
3317  int endTime;
3318 
3319  if ( !isActive ) {
3320  BecomeInactive( TH_THINK );
3321  return;
3322  }
3323 
3324  endTime = startTime + duration;
3325 
3326  if ( gameLocal.time < endTime ) {
3327  float u;
3328  float newSize;
3329 
3330  // Expand shockwave
3331  u = (float)(gameLocal.time - startTime) / (float)duration;
3332  newSize = startSize + u * (endSize - startSize);
3333 
3334  // Find all clipmodels between currentSize and newSize
3335  idVec3 pos, end;
3336  idClipModel *clipModelList[ MAX_GENTITIES ];
3337  idClipModel *clip;
3338  idEntity *ent;
3339  int i, listedClipModels;
3340 
3341  // Set bounds
3342  pos = GetPhysics()->GetOrigin();
3343 
3344  float zVal;
3345  if(!height) {
3346  zVal = newSize;
3347  } else {
3348  zVal = height/2.0f;
3349  }
3350 
3351  //Expand in a sphere
3352  end = pos + idVec3( newSize, newSize, zVal );
3353  idBounds bounds( end );
3354  end = pos + idVec3( -newSize, -newSize, -zVal );
3355  bounds.AddPoint( end );
3356 
3357  if(g_debugShockwave.GetBool()) {
3359  }
3360 
3361  listedClipModels = gameLocal.clip.ClipModelsTouchingBounds( bounds, -1, clipModelList, MAX_GENTITIES );
3362 
3363  for ( i = 0; i < listedClipModels; i++ ) {
3364  clip = clipModelList[ i ];
3365  ent = clip->GetEntity();
3366 
3367  if ( ent->IsHidden() ) {
3368  continue;
3369  }
3370 
3371  if ( !ent->IsType( idMoveable::Type ) && !ent->IsType( idAFEntity_Base::Type ) && !ent->IsType( idPlayer::Type )) {
3372  continue;
3373  }
3374 
3375  idVec3 point = ent->GetPhysics()->GetOrigin();
3376  idVec3 force = point - pos;
3377 
3378  float dist = force.Normalize();
3379 
3380  if(ent->IsType( idPlayer::Type )) {
3381 
3382  if(ent->GetPhysics()->GetAbsBounds().IntersectsBounds(bounds)) {
3383 
3384  //For player damage we check the current radius and a specified player damage ring size
3385  if ( dist <= newSize && dist > newSize-playerDamageSize ) {
3386 
3387  idStr damageDef = spawnArgs.GetString("def_player_damage", "");
3388  if(damageDef.Length() > 0 && !playerDamaged) {
3389 
3390  playerDamaged = true; //Only damage once per shockwave
3391  idPlayer* player = static_cast< idPlayer* >( ent );
3392  idVec3 dir = ent->GetPhysics()->GetOrigin() - pos;
3393  dir.NormalizeFast();
3394  player->Damage(NULL, NULL, dir, damageDef, 1.0f, INVALID_JOINT);
3395  }
3396  }
3397  }
3398 
3399  } else {
3400 
3401  // If the object is inside the current expansion...
3402  if ( dist <= newSize && dist > currentSize ) {
3403  force.z += 4.f;
3404  force.NormalizeFast();
3405 
3406  if ( ent->IsType( idAFEntity_Base::Type ) ) {
3407  force = force * (ent->GetPhysics()->GetMass() * magnitude * 0.01f);
3408  } else {
3409  force = force * ent->GetPhysics()->GetMass() * magnitude;
3410  }
3411 
3412  // Kick it up, move force point off object origin
3413  float rad = ent->GetPhysics()->GetBounds().GetRadius();
3414  point.x += gameLocal.random.CRandomFloat() * rad;
3415  point.y += gameLocal.random.CRandomFloat() * rad;
3416 
3417  int j;
3418  for( j=0; j < ent->GetPhysics()->GetNumClipModels(); j++ ) {
3419  ent->GetPhysics()->AddForce( j, point, force );
3420  }
3421  }
3422  }
3423  }
3424 
3425  // Update currentSize for next frame
3426  currentSize = newSize;
3427 
3428  } else {
3429 
3430  // turn off
3431  isActive = false;
3432  }
3433 }
3434 
3435 /*
3436 ===============
3437 idShockwave::Event_Activate
3438 ===============
3439 */
3440 void idShockwave::Event_Activate( idEntity *activator ) {
3441 
3442  isActive = true;
3443  startTime = gameLocal.time;
3444  playerDamaged = false;
3445 
3446  BecomeActive( TH_THINK );
3447 }
3448 
3449 
3450 /*
3451 ===============================================================================
3452 
3453 idFuncMountedObject
3454 
3455 ===============================================================================
3456 */
3457 
3458 CLASS_DECLARATION( idEntity, idFuncMountedObject )
3459 EVENT( EV_Touch, idFuncMountedObject::Event_Touch )
3460 EVENT( EV_Activate, idFuncMountedObject::Event_Activate )
3461 END_CLASS
3462 
3463 /*
3464 ===============
3465 idFuncMountedObject::idFuncMountedObject
3466 ===============
3467 */
3468 idFuncMountedObject::idFuncMountedObject() {
3469  isMounted = false;
3470  scriptFunction = NULL;
3471  mountedPlayer = NULL;
3472  harc = 0;
3473  varc = 0;
3474 }
3475 
3476 /*
3477 ===============
3478 idFuncMountedObject::idFuncMountedObject
3479 ===============
3480 */
3481 idFuncMountedObject::~idFuncMountedObject() {
3482 }
3483 
3484 /*
3485 ===============
3486 idFuncMountedObject::Spawn
3487 ===============
3488 */
3489 void idFuncMountedObject::Spawn( void ) {
3490  // Get viewOffset
3491  spawnArgs.GetInt( "harc", "45", harc );
3492  spawnArgs.GetInt( "varc", "30", varc );
3493 
3494  // Get script function
3495  idStr funcName = spawnArgs.GetString( "call", "" );
3496  if ( funcName.Length() ) {
3497  scriptFunction = gameLocal.program.FindFunction( funcName );
3498  if ( scriptFunction == NULL ) {
3499  gameLocal.Warning( "idFuncMountedObject '%s' at (%s) calls unknown function '%s'\n", name.c_str(), GetPhysics()->GetOrigin().ToString(0), funcName.c_str() );
3500  }
3501  }
3502 
3503  BecomeActive( TH_THINK );
3504 }
3505 
3506 /*
3507 ================
3508 idFuncMountedObject::Think
3509 ================
3510 */
3511 void idFuncMountedObject::Think( void ) {
3512 
3513  idEntity::Think();
3514 }
3515 
3516 /*
3517 ================
3518 idFuncMountedObject::GetViewInfo
3519 ================
3520 */
3521 void idFuncMountedObject::GetAngleRestrictions( int &yaw_min, int &yaw_max, int &pitch ) {
3522  idMat3 axis;
3523  idAngles angs;
3524 
3525  axis = GetPhysics()->GetAxis();
3526  angs = axis.ToAngles();
3527 
3528  yaw_min = angs.yaw - harc;
3529  yaw_min = idMath::AngleNormalize180( yaw_min );
3530 
3531  yaw_max = angs.yaw + harc;
3532  yaw_max = idMath::AngleNormalize180( yaw_max );
3533 
3534  pitch = varc;
3535 }
3536 
3537 /*
3538 ================
3539 idFuncMountedObject::Event_Touch
3540 ================
3541 */
3542 void idFuncMountedObject::Event_Touch( idEntity *other, trace_t *trace ) {
3543 
3544  ProcessEvent( &EV_Activate, other );
3545 }
3546 
3547 /*
3548 ================
3549 idFuncMountedObject::Event_Activate
3550 ================
3551 */
3552 void idFuncMountedObject::Event_Activate( idEntity *activator ) {
3553  if ( !isMounted && activator->IsType( idPlayer::Type ) ) {
3554  idPlayer *client = (idPlayer *)activator;
3555 
3556  mountedPlayer = client;
3557 
3558  /*
3559  // Place player at path_corner targeted by mounted object
3560  int i;
3561  idPathCorner *spot;
3562 
3563  for ( i = 0; i < targets.Num(); i++ ) {
3564  if ( targets[i]->IsType( idPathCorner::Type ) ) {
3565  spot = (idPathCorner*)targets[i];
3566  break;
3567  }
3568  }
3569 
3570  mountedPlayer->GetPhysics()->SetOrigin( spot->GetPhysics()->GetOrigin() );
3571  mountedPlayer->GetPhysics()->SetAxis( spot->GetPhysics()->GetAxis() );
3572  */
3573 
3574  mountedPlayer->Bind( this, true );
3575  mountedPlayer->mountedObject = this;
3576 
3577  // Call a script function
3578  idThread *mountthread;
3579  if ( scriptFunction ) {
3580  mountthread = new idThread( scriptFunction );
3581  mountthread->DelayedStart( 0 );
3582  }
3583 
3584  isMounted = true;
3585  }
3586 }
3587 
3588 /*
3589 ===============================================================================
3590 
3591 idFuncMountedWeapon
3592 
3593 ===============================================================================
3594 */
3595 CLASS_DECLARATION( idFuncMountedObject, idFuncMountedWeapon )
3596 EVENT( EV_PostSpawn, idFuncMountedWeapon::Event_PostSpawn )
3597 END_CLASS
3598 
3599 idFuncMountedWeapon::idFuncMountedWeapon() {
3600  turret = NULL;
3601  weaponLastFireTime = 0;
3602  weaponFireDelay = 0;
3603  projectile = NULL;
3604 }
3605 
3606 idFuncMountedWeapon::~idFuncMountedWeapon() {
3607 }
3608 
3609 
3610 void idFuncMountedWeapon::Spawn( void ) {
3611 
3612  // Get projectile info
3613  projectile = gameLocal.FindEntityDefDict( spawnArgs.GetString( "def_projectile" ), false );
3614  if ( !projectile ) {
3615  gameLocal.Warning( "Invalid projectile on func_mountedweapon." );
3616  }
3617 
3618  float firerate;
3619  spawnArgs.GetFloat( "firerate", "3", firerate );
3620  weaponFireDelay = 1000.f / firerate;
3621 
3622  // Get the firing sound
3623  idStr fireSound;
3624  spawnArgs.GetString( "snd_fire", "", fireSound );
3625  soundFireWeapon = declManager->FindSound( fireSound );
3626 
3627  PostEventMS( &EV_PostSpawn, 0 );
3628 }
3629 
3630 void idFuncMountedWeapon::Think( void ) {
3631 
3632  if ( isMounted && turret ) {
3633  idVec3 vec = mountedPlayer->viewAngles.ToForward();
3634  idAngles ang = mountedPlayer->GetLocalVector( vec ).ToAngles();
3635 
3636  turret->GetPhysics()->SetAxis( ang.ToMat3() );
3637  turret->UpdateVisuals();
3638 
3639  // Check for firing
3640  if ( mountedPlayer->usercmd.buttons & BUTTON_ATTACK && ( gameLocal.time > weaponLastFireTime + weaponFireDelay ) ) {
3641  // FIRE!
3642  idEntity *ent;
3643  idProjectile *proj;
3644  idBounds projBounds;
3645  idVec3 dir;
3646 
3647  gameLocal.SpawnEntityDef( *projectile, &ent );
3648  if ( !ent || !ent->IsType( idProjectile::Type ) ) {
3649  const char *projectileName = spawnArgs.GetString( "def_projectile" );
3650  gameLocal.Error( "'%s' is not an idProjectile", projectileName );
3651  }
3652 
3653  mountedPlayer->GetViewPos( muzzleOrigin, muzzleAxis );
3654 
3655  muzzleOrigin += ( muzzleAxis[0] * 128 );
3656  muzzleOrigin -= ( muzzleAxis[2] * 20 );
3657 
3658  dir = muzzleAxis[0];
3659 
3660  proj = static_cast<idProjectile *>(ent);
3661  proj->Create( this, muzzleOrigin, dir );
3662 
3663  projBounds = proj->GetPhysics()->GetBounds().Rotate( proj->GetPhysics()->GetAxis() );
3664 
3665  proj->Launch( muzzleOrigin, dir, vec3_origin );
3666  StartSoundShader( soundFireWeapon, SND_CHANNEL_WEAPON, SSF_GLOBAL, false, NULL );
3667 
3668  weaponLastFireTime = gameLocal.time;
3669  }
3670  }
3671 
3672  idFuncMountedObject::Think();
3673 }
3674 
3675 void idFuncMountedWeapon::Event_PostSpawn( void ) {
3676 
3677  if ( targets.Num() >= 1 ) {
3678  for ( int i=0; i < targets.Num(); i++ ) {
3679  if ( targets[i].GetEntity()->IsType( idStaticEntity::Type ) ) {
3680  turret = targets[i].GetEntity();
3681  break;
3682  }
3683  }
3684  } else {
3685  gameLocal.Warning( "idFuncMountedWeapon::Spawn: Please target one model for a turret\n" );
3686  }
3687 }
3688 
3689 
3690 
3691 
3692 
3693 
3694 /*
3695 ===============================================================================
3696 
3697 idPortalSky
3698 
3699 ===============================================================================
3700 */
3701 
3702 CLASS_DECLARATION( idEntity, idPortalSky )
3703  EVENT( EV_PostSpawn, idPortalSky::Event_PostSpawn )
3704  EVENT( EV_Activate, idPortalSky::Event_Activate )
3705 END_CLASS
3706 
3707 /*
3708 ===============
3709 idPortalSky::idPortalSky
3710 ===============
3711 */
3712 idPortalSky::idPortalSky( void ) {
3713 
3714 }
3715 
3716 /*
3717 ===============
3718 idPortalSky::~idPortalSky
3719 ===============
3720 */
3721 idPortalSky::~idPortalSky( void ) {
3722 
3723 }
3724 
3725 /*
3726 ===============
3727 idPortalSky::Spawn
3728 ===============
3729 */
3730 void idPortalSky::Spawn( void ) {
3731  if ( !spawnArgs.GetBool( "triggered" ) ) {
3732  PostEventMS( &EV_PostSpawn, 1 );
3733  }
3734 }
3735 
3736 /*
3737 ================
3738 idPortalSky::Event_PostSpawn
3739 ================
3740 */
3741 void idPortalSky::Event_PostSpawn() {
3742  gameLocal.SetPortalSkyEnt( this );
3743 }
3744 
3745 /*
3746 ================
3747 idPortalSky::Event_Activate
3748 ================
3749 */
3750 void idPortalSky::Event_Activate( idEntity *activator ) {
3751  gameLocal.SetPortalSkyEnt( this );
3752 }
3753 #endif /* _D3XP */
idList< int > targetTime
Definition: Misc.h:770
virtual const idVec3 & GetOrigin(int id=0) const =0
void Save(idSaveGame *savefile) const
Definition: Misc.cpp:2541
jointHandle_t
Definition: Model.h:156
idPlayer * GetLocalPlayer() const
float wait
Definition: Misc.h:622
int ClipModelsTouchingBounds(const idBounds &bounds, int contentMask, idClipModel **clipModelList, int maxCount) const
Definition: Clip.cpp:804
int blendFrames
Definition: Misc.h:284
idEntity * GetEntity(void) const
Definition: Clip.h:178
bool TouchTriggers(void) const
Definition: Entity.cpp:3696
int vacuumAreaNum
Definition: Game_local.h:322
void Spawn(void)
Definition: Misc.cpp:2719
byte color[4]
Definition: MegaTexture.cpp:54
renderEntity_t renderEntity
Definition: Entity.h:371
void BeginWriting(void)
Definition: BitMsg.h:265
bool TracePoint(trace_t &results, const idVec3 &start, const idVec3 &end, int contentMask, const idEntity *passEntity)
Definition: Clip.h:333
void SetPlayerOnly(bool set)
Definition: Force_Field.h:73
int fadeStart
Definition: Misc.h:339
float GetFloat(const char *key, const char *defaultString="0") const
Definition: Dict.h:248
void Restore(idRestoreGame *savefile)
Definition: Misc.cpp:458
void Restore(idRestoreGame *savefile)
Definition: Misc.cpp:1442
Definition: Misc.h:206
void Event_Activate(idEntity *activator)
Definition: Misc.cpp:3069
bool GetJointTransform(jointHandle_t jointHandle, int currenttime, idVec3 &offset, idMat3 &axis)
void SetClipModel(idClipModel *clipModel)
void WriteString(const char *string)
Definition: SaveGame.cpp:231
float throw_time
Definition: Misc.h:763
float Normalize(void)
Definition: Vector.h:646
bool EmitSmoke(const idDeclParticle *smoke, const int startTime, const float diversity, const idVec3 &origin, const idMat3 &axis, int timeGroup)
void SetCycleCount(int count)
virtual void Show(void)
Definition: Misc.cpp:1569
int GetInt(const char *key, const char *defaultString="0") const
Definition: Dict.h:252
int qhandle_t
Definition: Lib.h:81
bool PostEventSec(const idEventDef *ev, float time)
Definition: Class.cpp:747
virtual void InitTool(const toolFlag_t tool, const idDict *dict)=0
void WriteBindToSnapshot(idBitMsgDelta &msg) const
Definition: Entity.cpp:4756
virtual void Think(void)
Definition: Misc.cpp:793
void Restore(idRestoreGame *savefile)
Definition: Misc.cpp:110
virtual const idSoundShader * FindSound(const char *name, bool makeDefault=true)=0
virtual void StateChanged(int time, bool redraw=false)=0
const idDict * FindEntityDefDict(const char *name, bool makeDefault=true) const
void ReadParticle(const idDeclParticle *&particle)
Definition: SaveGame.cpp:1164
void Restore(idRestoreGame *savefile)
Definition: Game_local.h:661
void Spawn(void)
Definition: Misc.cpp:741
void Event_Explode(idEntity *activator)
Definition: Misc.cpp:630
const int SHADERPARM_DIVERSITY
Definition: RenderWorld.h:52
extrapolation_t
Definition: Extrapolate.h:40
void SetInfluenceLevel(int level)
virtual int GetClipMask(int id=-1) const =0
float random
Definition: Misc.h:623
virtual void SetContents(int contents, int id=-1)=0
const idEventDef EV_PostSpawn("<postspawn>", NULL)
virtual void DebugArrow(const idVec4 &color, const idVec3 &start, const idVec3 &end, int size, const int lifetime=0)=0
void Spawn(void)
Definition: Misc.cpp:824
const idMat3 & GetAxis(int id=0) const
idClip clip
Definition: Game_local.h:296
void Restore(idRestoreGame *savefile)
Definition: Misc.cpp:2557
void Event_LaunchMissilesUpdate(int launchjoint, int targetjoint, int numshots, int framedelay)
Definition: Misc.cpp:1285
idVec4 colorWhite
Definition: Lib.cpp:116
virtual void Launch(const idVec3 &start, const idVec3 &dir, const idVec3 &pushVelocity, const float timeSinceFire=0.0f, const float launchPower=1.0f, const float dmgPower=1.0f)
Definition: Projectile.cpp:306
void Printf(const char *fmt,...) const id_attribute((format(printf
Definition: Game_local.cpp:699
void Event_Activate(idEntity *activator)
Definition: Misc.cpp:1581
qhandle_t portal
Definition: Misc.h:653
struct idEntity::entityFlags_s fl
#define MAX_GENTITIES
Definition: Game_local.h:83
void Event_MatchTarget(void)
Definition: Misc.cpp:2279
void SetAngularExtrapolation(extrapolation_t type, int time, int duration, const idAngles &base, const idAngles &speed, const idAngles &baseSpeed)
void Event_TeleportStage(idEntity *player)
Definition: Misc.cpp:145
void Bind(idEntity *master, bool orientated)
Definition: Entity.cpp:1896
type * GetEntity(void) const
Definition: Game_local.h:695
virtual void WriteToSnapshot(idBitMsgDelta &msg) const
Definition: Misc.cpp:1610
void DelayedStart(int delay)
const int MAX_EVENT_PARAM_SIZE
Definition: Game_local.h:132
void SetBeamTarget(const idVec3 &origin)
Definition: Misc.cpp:2248
virtual void SetClipBox(const idBounds &bounds, float density)
Definition: Physics.cpp:67
virtual bool ClientReceiveEvent(int event, int time, const idBitMsg &msg)
Definition: Misc.cpp:119
idForce_Spring spring
Definition: Misc.h:221
idVec4 fadeTo
Definition: Misc.h:338
void Save(idSaveGame *savefile) const
Definition: Misc.cpp:2442
idSmokeParticles * smokeParticles
Definition: Game_local.h:307
const int SHADERPARM_BEAM_END_Z
Definition: RenderWorld.h:65
void RandomTorque(float force)
void Restore(idRestoreGame *savefile)
Definition: Misc.cpp:2900
void SetNum(int newnum, bool resize=true)
Definition: List.h:289
void Event_Footstep(void)
Definition: Misc.cpp:1276
const idEventDef EV_Activate("activate","e")
void Uniform(const idVec3 &force)
GLint location
Definition: glext.h:3631
void Save(idSaveGame *savefile) const
Definition: Misc.cpp:2990
virtual void WriteToSnapshot(idBitMsgDelta &msg) const
Definition: Misc.cpp:1721
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:4804
idMat3 Transpose(void) const
Definition: Matrix.h:677
idRandom random
Definition: Game_local.h:291
int Length(void) const
Definition: Str.h:702
void void void void void Error(const char *fmt,...) const id_attribute((format(printf
Definition: Game_local.cpp:783
const int ANIMCHANNEL_ALL
Definition: Anim.h:41
const idDeclParticle * smoke
Definition: Misc.h:398
bool isMultiplayer
Definition: Game_local.h:325
idAngles GetAngles(const char *key, const char *defaultString=NULL) const
Definition: Dict.h:278
idAnimated()
Definition: Misc.cpp:938
bool IsType(const idTypeInfo &c) const
Definition: Class.h:337
idVec3 p1
Definition: Misc.h:219
void Set(const float x, const float y, const float z)
Definition: Vector.h:409
static idPathCorner * RandomPath(const idEntity *source, const idEntity *ignore)
Definition: Misc.cpp:380
void WriteVec4(const idVec4 &vec)
Definition: SaveGame.cpp:262
idEntity * FindEntity(const char *name) const
idList< idEntityPtr< idEntity > > targets
Definition: Entity.h:132
bool disabled
Definition: Misc.h:626
void SetApplyType(const forceFieldApplyType type)
Definition: Force_Field.h:71
float z
Definition: Vector.h:320
#define MASK_SOLID
Definition: Game_local.h:735
bool ProcessEvent(const idEventDef *ev)
Definition: Class.cpp:858
void Spawn(void)
Definition: Misc.cpp:1457
virtual int GetNumClipModels(void) const =0
void WriteBits(int value, int numBits)
Definition: BitMsg.cpp:648
const idEventDef EV_Player_ExitTeleporter("exitTeleporter")
#define AREACONTENTS_OBSTACLE
Definition: AASFile.h:81
void SetGranularity(int newgranularity)
Definition: List.h:305
void Event_Activate(idEntity *activator)
Definition: Misc.cpp:1798
void RadiusDamage(const idVec3 &origin, idEntity *inflictor, idEntity *attacker, idEntity *ignoreDamage, idEntity *ignorePush, const char *damageDefName, float dmgPower=1.0f)
virtual void ReadFromSnapshot(const idBitMsgDelta &msg)
Definition: Misc.cpp:2340
int max_wait
Definition: Misc.h:768
int fadeEnd
Definition: Misc.h:340
jointHandle_t GetJointHandle(const char *name) const
void TeleportPlayer(idPlayer *player)
Definition: Misc.cpp:185
~idAnimated()
Definition: Misc.cpp:955
void Event_Activate(idEntity *activator)
Definition: Misc.cpp:1704
void Event_Splat()
Definition: Misc.cpp:1778
void SetMaster(idBeam *masterbeam)
Definition: Misc.cpp:2239
bool isClient
Definition: Game_local.h:327
Definition: Vector.h:316
void ReadJoint(jointHandle_t &value)
Definition: SaveGame.cpp:931
void Event_Touch(idEntity *other, trace_t *trace)
Definition: Misc.cpp:2405
case const float
Definition: Callbacks.cpp:62
void ReadBool(bool &value)
Definition: SaveGame.cpp:976
void Spawn(void)
Definition: Misc.cpp:2844
idAngles ang_zero(0.0f, 0.0f, 0.0f)
const char * GetLocation(void) const
Definition: Misc.cpp:2147
bool isServer
Definition: Game_local.h:326
const int SHADERPARM_BEAM_END_Y
Definition: RenderWorld.h:64
void WriteStaticObject(const idClass &obj)
Definition: SaveGame.cpp:348
void Event_RestoreDamagable(void)
Definition: Misc.cpp:598
virtual void HandleNamedEvent(const char *eventName)=0
int teleportStage
Definition: Misc.h:85
const int SHADERPARM_GREEN
Definition: RenderWorld.h:47
void Save(idSaveGame *savefile) const
Definition: Misc.cpp:2825
virtual void WriteToSnapshot(idBitMsgDelta &msg) const
Definition: Misc.cpp:2326
void Event_Activate(idEntity *activator)
Definition: Misc.cpp:2049
virtual void SetLinearVelocity(const idVec3 &newLinearVelocity, int id=0)=0
void Restore(idRestoreGame *savefile)
Definition: Misc.cpp:815
virtual void Think(void)
Definition: Misc.cpp:310
void SetInfluenceView(const char *mtr, const char *skinname, float radius, idEntity *ent)
void Create(idEntity *owner, const idVec3 &start, const idVec3 &dir)
Definition: Projectile.cpp:218
void Event_Activate(idEntity *activator)
Definition: Misc.cpp:2918
const idEventDef EV_Toggle("Toggle", NULL)
const int SHADERPARM_BEAM_END_X
Definition: RenderWorld.h:63
idCVar ai_debugTrajectory("ai_debugTrajectory","0", CVAR_GAME|CVAR_BOOL,"draws trajectory tests for monsters")
void WriteFloat(float f)
Definition: BitMsg.h:558
#define MASK_OPAQUE
Definition: Game_local.h:740
float GetRadius(void) const
Definition: Bounds.cpp:39
void Restore(idRestoreGame *savefile)
Definition: Misc.cpp:2189
GLenum GLsizei len
Definition: glext.h:3472
void Set(const char *key, const char *value)
Definition: Dict.cpp:275
void Spawn(void)
Definition: Misc.cpp:2909
int ReadBits(int numBits) const
Definition: BitMsg.cpp:709
const int SHADERPARM_BEAM_WIDTH
Definition: RenderWorld.h:66
void Save(idSaveGame *savefile) const
Definition: Misc.cpp:2008
void Restore(idRestoreGame *savefile)
Definition: Misc.cpp:2834
float x
Definition: Vector.h:318
idDict spawnArgs
Definition: Entity.h:122
int i
Definition: process.py:33
void Restore(idRestoreGame *savefile)
Definition: Misc.cpp:2452
qhandle_t portal
Definition: Misc.h:492
void Spawn(void)
Definition: Misc.cpp:2389
void SetAnimator(idAnimator *a)
Definition: AF.h:63
int min_wait
Definition: Misc.h:767
GLuint GLuint num
Definition: glext.h:5390
void WriteVec3(const idVec3 &vec)
Definition: SaveGame.cpp:253
bool HasChanged(void) const
Definition: BitMsg.h:534
bool activated
Definition: Misc.h:287
void Event_RandomPath(void)
Definition: Misc.cpp:411
virtual void SetModel(const char *modelname)
Definition: Entity.cpp:1150
idSoundWorld * gameSoundWorld
Definition: Game_local.cpp:56
bool CheckDormant(void)
Definition: Entity.cpp:946
idVec3 shake_ang
Definition: Misc.h:765
idPhysics_Parametric physicsObj
Definition: Misc.h:590
const int SHADERPARM_ALPHA
Definition: RenderWorld.h:49
#define EVENT(event, function)
Definition: Class.h:53
void SetAxis(const idMat3 &newAxis, int id=-1)
void Explosion(float force)
void Init(byte *data, int length)
Definition: BitMsg.h:155
float shakeTime
Definition: Misc.h:627
bool Load(idEntity *ent, const char *fileName)
Definition: AF.cpp:795
idClipModel * combatModel
Definition: AFEntity.h:193
void Killed(idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location)
Definition: Misc.cpp:553
float fraction
void ShowEditingDialog(void)
Definition: Misc.cpp:1502
void WriteJoint(const jointHandle_t value)
Definition: SaveGame.cpp:177
idProgram program
Definition: Game_local.h:293
void WriteBool(const bool value)
Definition: SaveGame.cpp:222
idCVar developer("developer","0", CVAR_GAME|CVAR_BOOL,"")
idVec4 colorRed
Definition: Lib.cpp:117
const int BUTTON_ATTACK
Definition: UsercmdGen.h:44
bool restart
Definition: Misc.h:399
void Spawn(void)
Definition: Misc.cpp:995
void Event_ResetRadioHud(idEntity *activator)
Definition: Misc.cpp:2949
void Flash(idVec4 color, int time)
Definition: PlayerView.cpp:604
idAnimator animator
Definition: Entity.h:534
void Save(idSaveGame *savefile) const
Definition: Misc.cpp:2891
void SetClipModel(idClipModel *model, float density, int id=0, bool freeOld=true)
bool IsHidden(void) const
Definition: Entity.cpp:1217
void Spawn(void)
Definition: Misc.cpp:468
virtual void GetColor(idVec3 &out) const
Definition: Entity.cpp:1104
const idEventDef EV_TeleportStage("<TeleportStage>","e")
void void void Warning(const char *fmt,...) const id_attribute((format(printf
Definition: Game_local.cpp:735
void Event_Toggle(void)
Definition: Misc.cpp:867
GLsizei GLsizei GLcharARB * source
Definition: glext.h:3633
virtual const idBounds & GetBounds(int id=-1) const =0
virtual void Think(void)
Definition: Misc.cpp:2216
bool StartSoundShader(const idSoundShader *shader, const s_channelType channel, int soundShaderFlags, bool broadcast, int *length)
Definition: Entity.cpp:1656
const int SHADERPARM_BLUE
Definition: RenderWorld.h:48
void SetPortalState(qhandle_t portal, int blockingBits)
void Save(idSaveGame *savefile) const
Definition: Misc.cpp:448
class idPlayerView playerView
Definition: Player.h:251
int smokeTime
Definition: Misc.h:397
virtual void AddForce(const int id, const idVec3 &point, const idVec3 &force)=0
void Save(idSaveGame *savefile) const
Definition: Misc.cpp:806
int RandomInt(void)
Definition: Random.h:70
virtual void Show(void)
Definition: Entity.cpp:1239
virtual void Think(void)
Definition: Entity.cpp:891
idVec3 GetEyePosition(void) const
Definition: Actor.cpp:1454
void SetSelf(idEntity *e)
void WriteColorToSnapshot(idBitMsgDelta &msg) const
Definition: Entity.cpp:4817
GLuint GLuint GLsizei count
Definition: glext.h:2845
void Event_AnimDone(int animIndex)
Definition: Misc.cpp:1191
bool triggered
Definition: Misc.h:624
virtual float CurrentShakeAmplitudeForPosition(const int time, const idVec3 &listenerPosition)=0
virtual void Think(void)
Definition: Misc.cpp:2656
void Event_Activate(idEntity *activator)
Definition: Misc.cpp:327
const idEventDef EV_FootstepLeft("leftFoot")
float speed
Definition: Misc.h:766
virtual void ReadFromSnapshot(const idBitMsgDelta &msg)=0
idCVar g_debugCinematic("g_debugCinematic","0", CVAR_GAME|CVAR_BOOL,"")
int PlayLength(void) const
idPhysics * GetPhysics(void) const
Definition: Entity.cpp:2607
virtual void DebugLine(const idVec4 &color, const idVec3 &start, const idVec3 &end, const int lifetime=0, const bool depthTest=false)=0
bool playerOriented
Definition: Misc.h:625
const int SHADERPARM_MODE
Definition: RenderWorld.h:53
const char * GetString(const char *key, const char *defaultString="") const
Definition: Dict.h:240
bool SpawnEntityDef(const idDict &args, idEntity **ent=NULL, bool setDefaults=true)
void ReadFloat(float &value)
Definition: SaveGame.cpp:967
Definition: Vector.h:808
idWorldspawn * world
Definition: Game_local.h:280
jointHandle_t soundJoint
Definition: Misc.h:285
void Event_Activate(idEntity *activator)
Definition: Misc.cpp:876
void Spawn(void)
Definition: Misc.cpp:2199
float RandomFloat(void)
Definition: Random.h:82
bool StartSound(const char *soundName, const s_channelType channel, int soundShaderFlags, bool broadcast, int *length)
Definition: Entity.cpp:1622
void Spawn(void)
Definition: Misc.cpp:2784
idVec3 vec3_origin(0.0f, 0.0f, 0.0f)
void SetOrigin(const idVec3 &newOrigin, int id=-1)
bool runGui
Definition: Misc.h:341
void SetPhysics(idPhysics *phys)
Definition: Entity.cpp:2574
virtual void Damage(idEntity *inflictor, idEntity *attacker, const idVec3 &dir, const char *damageDefName, const float damageScale, const int location)
GLuint GLuint end
Definition: glext.h:2845
int anim
Definition: Misc.h:283
idEntityPtr< idBeam > master
Definition: Misc.h:539
void WriteFloat(const float value)
Definition: SaveGame.cpp:213
idCommon * common
Definition: Common.cpp:206
virtual float GetMass(int id=-1) const =0
bool GetBool(const char *key, const char *defaultString="0") const
Definition: Dict.h:256
Definition: Dict.h:65
idVec3 firstPersonViewOrigin
Definition: Player.h:370
idEntityPtr< idActor > target
Definition: Misc.h:769
#define NULL
Definition: Lib.h:88
bool objectiveSystemOpen
Definition: Player.h:295
idAnimBlend * CurrentAnim(int channelNum)
void Spawn(void)
Definition: Misc.cpp:291
virtual const idDecl * FindType(declType_t type, const char *name, bool makeDefault=true)=0
float y
Definition: Vector.h:319
bool state
Definition: Misc.h:679
virtual void Think(void)
Definition: Misc.cpp:1965
void Restore(idRestoreGame *savefile)
Definition: Misc.cpp:2018
idVec3 GetVector(const char *key, const char *defaultString=NULL) const
Definition: Dict.h:260
void Restore(idRestoreGame *savefile)
Definition: Misc.cpp:1843
virtual void Evaluate(int time)
virtual void Think(void)
Definition: Misc.cpp:1510
void ServerSendEvent(int eventId, const idBitMsg *msg, bool saveEvent, int excludeClient) const
Definition: Entity.cpp:4897
void Event_Activate(idEntity *activator)
Definition: Misc.cpp:1214
void RadiusPush(const idVec3 &origin, const float radius, const float push, const idEntity *inflictor, const idEntity *ignore, float inflictorScale, const bool quake)
void Event_Activate(idEntity *activator)
Definition: Misc.cpp:2732
virtual void FadeSoundClasses(const int soundClass, const float to, const float over)=0
void CancelEvents(const idEventDef *ev)
Definition: Class.cpp:619
virtual void Teleport(const idVec3 &origin, const idAngles &angles, idEntity *destination)
const idAnim * GetAnim(int index) const
void Save(idSaveGame *savefile) const
Definition: Misc.cpp:965
void Spawn(void)
Definition: Misc.cpp:3048
void CycleAnim(int channelNum, int animnum, int currenttime, int blendtime)
bool stay_on
Definition: Misc.h:116
void Save(idSaveGame *savefile) const
Definition: Misc.cpp:2765
static void ReturnFloat(float value)
void ReadVec4(idVec4 &vec)
Definition: SaveGame.cpp:1020
void Restore(idRestoreGame *savefile)
Definition: Misc.cpp:1695
const idEventDef AI_RandomPath
const char * path
Definition: sws.c:117
void Event_BecomeBroken(idEntity *activator)
Definition: Misc.cpp:589
idEntityPtr< idEntity > activator
Definition: Misc.h:286
void ReadGUIFromSnapshot(const idBitMsgDelta &msg)
Definition: Entity.cpp:4861
virtual const idMat3 & GetAxis(int id=0) const =0
int spawnTime
Definition: Misc.h:335
virtual void Think(void)
Definition: Misc.cpp:3122
bool hidden
Definition: Misc.h:369
virtual idAnimator * GetAnimator(void)
Definition: Entity.cpp:5213
void Event_FindTargets(void)
Definition: Misc.cpp:890
float NormalizeFast(void)
Definition: Vector.h:524
idUserInterface * hud
Definition: Player.h:293
void Spawn(void)
Definition: Misc.cpp:2463
void Event_Activate(idEntity *activator)
Definition: Misc.cpp:2598
virtual void DrawText(const char *text, const idVec3 &origin, float scale, const idVec4 &color, const idMat3 &viewAxis, const int align=1, const int lifetime=0, bool depthTest=false)=0
int Find(const char c, int start=0, int end=-1) const
Definition: Str.h:874
idBounds Rotate(const idMat3 &rotation) const
Definition: Bounds.h:342
idEntity * ent1
Definition: Misc.h:215
idLinkList< idEntity > spawnNode
Definition: Entity.h:114
void Save(idSaveGame *savefile) const
Definition: Misc.cpp:1945
GLenum GLsizei width
Definition: glext.h:2846
int id1
Definition: Misc.h:217
void Restore(idRestoreGame *savefile)
Definition: Misc.cpp:2379
idGameLocal gameLocal
Definition: Game_local.cpp:64
bool RunPhysics(void)
Definition: Entity.cpp:2616
const idEventDef EV_Animated_Start("<start>")
void ForceUpdate(void)
const int SHADERPARM_TIMEOFFSET
Definition: RenderWorld.h:51
void Restore(idRestoreGame *savefile)
Definition: Misc.cpp:278
#define END_CLASS
Definition: Class.h:54
void Restore(idRestoreGame *savefile)
Definition: Misc.cpp:2774
const idEventDef EV_Footstep("footstep")
const idKeyValue * FindKey(const char *key) const
Definition: Dict.cpp:451
void Spawn(void)
Definition: Misc.cpp:1770
const char * Name(void) const
Definition: Anim_Blend.cpp:145
bool state
Definition: Misc.h:654
void SetMonsterOnly(bool set)
Definition: Force_Field.h:75
idLinkList< idEntity > spawnedEntities
Definition: Game_local.h:281
void Implosion(float force)
virtual void Hide(void)
Definition: Entity.cpp:1226
float shake_time
Definition: Misc.h:764
bool inCinematic
Definition: Game_local.h:313
Definition: Misc.h:553
void Event_StartRagdoll(void)
Definition: Misc.cpp:1182
const idEventDef EV_LaunchMissilesUpdate("<launchMissiles>","dddd")
const idEventDef EV_RestoreDamagable("<RestoreDamagable>")
int id2
Definition: Misc.h:218
virtual void DisableClip(void)=0
virtual idClipModel * GetClipModel(int id=0) const =0
GLenum GLsizei GLsizei height
Definition: glext.h:2856
void Restore(idRestoreGame *savefile)
Definition: Misc.cpp:3016
const char * ToString(int precision=2) const
Definition: Vector.cpp:221
void WriteInt(const int value)
Definition: SaveGame.cpp:168
virtual void Present(void)
Definition: Entity.cpp:1471
idDeclManager * declManager
#define SEC2MS(t)
Definition: Math.h:59
void RemoveNullTargets(void)
Definition: Entity.cpp:3633
GLubyte GLubyte b
Definition: glext.h:4662
int nextTriggerTime
Definition: Misc.h:620
void Spawn(void)
Definition: Misc.cpp:1671
idEntity * entities[MAX_GENTITIES]
Definition: Game_local.h:275
bool IsLoaded(void) const
Definition: AF.h:65
virtual bool ClientReceiveEvent(int event, int time, const idBitMsg &msg)
Definition: Entity.cpp:4988
virtual qhandle_t FindPortal(const idBounds &b) const =0
void BeginShaking(void)
Definition: Misc.cpp:2482
int health
Definition: Entity.h:134
idEntity * GetTraceEntity(const trace_t &trace) const
int current_anim_index
Definition: Misc.h:282
int AnimLength(int animnum) const
void ReadStaticObject(idClass &obj)
Definition: SaveGame.cpp:1098
void Save(idSaveGame *savefile) const
Definition: Misc.cpp:1427
void Event_Activate(idEntity *activator)
Definition: Misc.cpp:1877
void BecomeBroken(idEntity *activator)
Definition: Misc.cpp:490
idEntity * ent2
Definition: Misc.h:216
virtual void Show(void)
Definition: Misc.cpp:2262
idForce_Field forceField
Definition: Misc.h:247
idRenderModelManager * renderModelManager
Definition: Matrix.h:333
const int SHADERPARM_RED
Definition: RenderWorld.h:46
int nextTriggerTime
Definition: Misc.h:171
void Restore(idRestoreGame *savefile)
Definition: Misc.cpp:2708
void StartFromCurrentPose(int inheritVelocityTime)
Definition: AF.cpp:999
void SetAASAreaState(const idBounds &bounds, const int areaContents, bool closed)
void Event_Activate(idEntity *activator)
Definition: Misc.cpp:2854
void SetClipMask(int mask, int id=-1)
void Event_LinkSpring(void)
Definition: Misc.cpp:707
void Spawn(void)
Definition: Misc.cpp:1854
float yaw
Definition: Angles.h:54
static bool PredictTrajectory(const idVec3 &firePos, const idVec3 &target, float projectileSpeed, const idVec3 &projGravity, const idClipModel *clip, int clipmask, float max_height, const idEntity *ignore, const idEntity *targetEntity, int drawtime, idVec3 &aimDir)
void UpdateVisuals(void)
Definition: Entity.cpp:1310
void Restore(idRestoreGame *savefile)
Definition: Misc.cpp:1955
bool GetBool(void) const
Definition: CVarSystem.h:142
static void DrawDebugInfo(void)
Definition: Misc.cpp:361
virtual void WriteToSnapshot(idBitMsgDelta &msg) const =0
tuple f
Definition: idal.py:89
Definition: Misc.h:513
#define ENTITYNUM_WORLD
Definition: Game_local.h:85
void ProjectDecal(const idVec3 &origin, const idVec3 &dir, float depth, bool parallel, float size, const char *material, float angle=0)
void Lerp(const idVec4 &v1, const idVec4 &v2, const float l)
Definition: Vector.cpp:318
idAngles viewAngles
Definition: Player.h:258
const idEventDef EV_FootstepRight("rightFoot")
Definition: Actor.h:111
const idEventDef EV_Splat("<Splat>")
void Save(idSaveGame *savefile) const
Definition: Misc.cpp:1832
int Num(void) const
Definition: List.h:265
void Save(idSaveGame *savefile) const
Definition: Misc.cpp:101
idMat3 ToMat3(void) const
Definition: Angles.cpp:199
unsigned char byte
Definition: Lib.h:75
bool IntersectsBounds(const idBounds &a) const
Definition: Bounds.h:361
idStr text
Definition: Misc.h:445
virtual const idBounds & GetAbsBounds(int id=-1) const =0
void Event_TeleportPlayer(idEntity *activator)
Definition: Misc.cpp:221
int modelDefHandle
Definition: Entity.h:372
virtual void SetColor(float red, float green, float blue)
Definition: Entity.cpp:1082
const GLcharARB * name
Definition: glext.h:3629
GLsizeiptr size
Definition: glext.h:3112
void Event_Activate(idEntity *activator)
Definition: Misc.cpp:2794
const char * RandomPrefix(const char *prefix, idRandom &random) const
Definition: Dict.cpp:553
static float AngleNormalize180(float angle)
Definition: Math.h:910
void Save(idSaveGame *savefile) const
Definition: Misc.cpp:1686
#define CLASS_DECLARATION(nameofsuperclass, nameofclass)
Definition: Class.h:110
Definition: Str.h:116
int shakeStopTime
Definition: Misc.h:621
virtual void SetAngularVelocity(const idVec3 &newAngularVelocity, int id=0)=0
void Save(idSaveGame *savefile) const
Definition: Misc.cpp:2698
bool active
Definition: Misc.h:336
GLsizei const GLcharARB const GLint * length
Definition: glext.h:3599
const char * GetName(void) const
Definition: Entity.cpp:875
virtual void SetClipModel(idClipModel *model, float density, int id=0, bool freeOld=true)=0
void UpdateAnimation(void)
Definition: Entity.cpp:5172
void Save(idSaveGame *savefile) const
Definition: Game_local.h:656
void ReadVec3(idVec3 &vec)
Definition: SaveGame.cpp:1011
static void ReturnEntity(idEntity *ent)
class idUserInterface * gui[MAX_RENDERENTITY_GUI]
Definition: RenderWorld.h:130
const char * c_str(void) const
Definition: Str.h:487
void PlayNextAnim(void)
Definition: Misc.cpp:1120
void Clear(int channelNum, int currentTime, int cleartime)
void RestorePhysics(idPhysics *phys)
Definition: Entity.cpp:2596
ID_INLINE int FRAME2MS(int framenum)
Definition: Anim.h:48
virtual void ReadFromSnapshot(const idBitMsgDelta &msg)
Definition: Misc.cpp:1623
void BecomeActive(int flags)
Definition: Entity.cpp:995
idRenderSystemLocal tr
void FindTargets(void)
Definition: Entity.cpp:3614
void Toggle(void)
Definition: Misc.cpp:780
idAngles ToAngles(void) const
Definition: Matrix.cpp:147
virtual int GetPortalState(qhandle_t portal)=0
const idEventDef EV_Remove("<immediateremove>", NULL)
int end_time
Definition: Misc.h:762
function_t * FindFunction(const char *name) const
void SetFrame(int channelNum, int animnum, int frame, int currenttime, int blendtime)
void ReadColorFromSnapshot(const idBitMsgDelta &msg)
Definition: Entity.cpp:4832
virtual void Present(void)
Definition: AFEntity.cpp:1065
float ReadFloat(void) const
Definition: BitMsg.h:625
GLint j
Definition: qgl.h:264
virtual idRenderModel * CheckModel(const char *modelName)=0
void Restore(idRestoreGame *savefile)
Definition: Misc.cpp:980
virtual void DebugBounds(const idVec4 &color, const idBounds &bounds, const idVec3 &org=vec3_origin, const int lifetime=0)=0
void SetPrivateCameraView(idCamera *camView)
const idEventDef EV_ResetRadioHud("<resetradiohud>","e")
void WriteGUIToSnapshot(idBitMsgDelta &msg) const
Definition: Entity.cpp:4847
idRenderWorld * gameRenderWorld
Definition: Game_local.cpp:55
char * va(const char *fmt,...)
Definition: Str.cpp:1568
virtual int PointInArea(const idVec3 &point) const =0
virtual bool GetPhysicsToSoundTransform(idVec3 &origin, idMat3 &axis)
Definition: Misc.cpp:1084
void Fade(const idVec4 &to, float fadeTime)
Definition: Misc.cpp:1546
const idEventDef EV_AnimDone("<AnimDone>","d")
bool StartRagdoll(void)
Definition: Misc.cpp:1095
bool active
Definition: Misc.h:591
void ReadBindFromSnapshot(const idBitMsgDelta &msg)
Definition: Entity.cpp:4780
void WriteBits(int value, int numBits)
Definition: BitMsg.cpp:110
const idEventDef EV_LaunchMissiles("launchMissiles","ssssdf")
#define GENTITYNUM_BITS
Definition: Game_local.h:82
bool PostEventMS(const idEventDef *ev, int time)
Definition: Class.cpp:666
void SetPosition(idPhysics *physics1, int id1, const idVec3 &p1, idPhysics *physics2, int id2, const idVec3 &p2)
int entityNumber
Definition: Entity.h:111
void Event_LaunchMissiles(const char *projectilename, const char *sound, const char *launchjoint, const char *targetjoint, int numshots, int framedelay)
Definition: Misc.cpp:1331
virtual bool LoadAF(void)
Definition: Misc.cpp:1069
int thinkFlags
Definition: Entity.h:125
void Event_Activate(idEntity *activator)
Definition: Misc.cpp:2499
idVec4 fadeFrom
Definition: Misc.h:337
void EnableDamage(bool enable, float duration)
Definition: Moveable.cpp:416
const idEventDef EV_Touch("<touch>","et")
void Event_Activate(idEntity *activator)
Definition: Misc.cpp:2313
idEntityPtr< idBeam > target
Definition: Misc.h:538
bool IsActive(void) const
Definition: AF.h:74
void WriteParticle(const idDeclParticle *particle)
Definition: SaveGame.cpp:406
void Save(idSaveGame *savefile) const
Definition: Misc.cpp:2179
virtual void Think(void)
Definition: Misc.cpp:1893
int num_anims
Definition: Misc.h:281
virtual const idVec3 & GetGravity(void) const =0
virtual void virtual void Warning(const char *fmt,...) id_attribute((format(printf
void Set(const float x, const float y, const float z, const float w)
Definition: Vector.h:873
void Spawn(void)
Definition: Misc.cpp:92
float shaderParms[MAX_ENTITY_SHADER_PARMS]
Definition: RenderWorld.h:127
void ReadString(idStr &string)
Definition: SaveGame.cpp:985
void BecomeInactive(int flags)
Definition: Entity.cpp:1025
void Spawn(void)
Definition: Misc.cpp:2577
virtual void ReadFromSnapshot(const idBitMsgDelta &msg)
Definition: Misc.cpp:1732
int ReadBits(int numBits) const
Definition: BitMsg.cpp:362
const idEventDef EV_StartRagdoll("startRagdoll")
void ReadInt(int &value)
Definition: SaveGame.cpp:922
float CRandomFloat(void)
Definition: Random.h:86
bool playerOriented
Definition: Misc.h:446
void ActivateTargets(idEntity *activator) const
Definition: Entity.cpp:3650
Definition: Entity.h:64
GLuint start
Definition: glext.h:2845
void StopSound(const s_channelType channel, bool broadcast)
Definition: Entity.cpp:1713
idList< idVec3 > lastTargetPos
Definition: Misc.h:771
void InitSpring(float Kstretch, float Kcompress, float damping, float restLength)
Definition: Anim.h:280
#define AREACONTENTS_CLUSTERPORTAL
Definition: AASFile.h:80
idVec4 colorBlue
Definition: Lib.cpp:119
#define MS2SEC(t)
Definition: Math.h:60
void Event_Start(void)
Definition: Misc.cpp:1236
const idEventDef EV_FindTargets("<findTargets>", NULL)
const int SHADERPARM_PARTICLE_STOPTIME
Definition: RenderWorld.h:71
idVec3 p2
Definition: Misc.h:220
virtual void Hide(void)
Definition: Misc.cpp:1559