doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Item.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 #include "../idlib/precompiled.h"
30 #pragma hdrstop
31 
32 #include "Game_local.h"
33 
34 
35 /*
36 ===============================================================================
37 
38  idItem
39 
40 ===============================================================================
41 */
42 
43 const idEventDef EV_DropToFloor( "<dropToFloor>" );
44 const idEventDef EV_RespawnItem( "respawn" );
45 const idEventDef EV_RespawnFx( "<respawnFx>" );
46 const idEventDef EV_GetPlayerPos( "<getplayerpos>" );
47 const idEventDef EV_HideObjective( "<hideobjective>", "e" );
48 const idEventDef EV_CamShot( "<camshot>" );
49 
51  EVENT( EV_DropToFloor, idItem::Event_DropToFloor )
52  EVENT( EV_Touch, idItem::Event_Touch )
53  EVENT( EV_Activate, idItem::Event_Trigger )
54  EVENT( EV_RespawnItem, idItem::Event_Respawn )
55  EVENT( EV_RespawnFx, idItem::Event_RespawnFx )
57 
58 
59 /*
60 ================
61 idItem::idItem
62 ================
63 */
65  spin = false;
66  inView = false;
67  inViewTime = 0;
68  lastCycle = 0;
69  lastRenderViewTime = -1;
70  itemShellHandle = -1;
71  shellMaterial = NULL;
72  orgOrigin.Zero();
73  canPickUp = true;
74  fl.networkSync = true;
75 }
76 
77 /*
78 ================
79 idItem::~idItem
80 ================
81 */
83  // remove the highlight shell
84  if ( itemShellHandle != -1 ) {
86  }
87 }
88 
89 /*
90 ================
91 idItem::Save
92 ================
93 */
94 void idItem::Save( idSaveGame *savefile ) const {
95 
96  savefile->WriteVec3( orgOrigin );
97  savefile->WriteBool( spin );
98  savefile->WriteBool( pulse );
99  savefile->WriteBool( canPickUp );
100 
101  savefile->WriteMaterial( shellMaterial );
102 
103  savefile->WriteBool( inView );
104  savefile->WriteInt( inViewTime );
105  savefile->WriteInt( lastCycle );
106  savefile->WriteInt( lastRenderViewTime );
107 }
108 
109 /*
110 ================
111 idItem::Restore
112 ================
113 */
114 void idItem::Restore( idRestoreGame *savefile ) {
115 
116  savefile->ReadVec3( orgOrigin );
117  savefile->ReadBool( spin );
118  savefile->ReadBool( pulse );
119  savefile->ReadBool( canPickUp );
120 
121  savefile->ReadMaterial( shellMaterial );
122 
123  savefile->ReadBool( inView );
124  savefile->ReadInt( inViewTime );
125  savefile->ReadInt( lastCycle );
126  savefile->ReadInt( lastRenderViewTime );
127 
128  itemShellHandle = -1;
129 }
130 
131 /*
132 ================
133 idItem::UpdateRenderEntity
134 ================
135 */
136 bool idItem::UpdateRenderEntity( renderEntity_s *renderEntity, const renderView_t *renderView ) const {
137 
138  if ( lastRenderViewTime == renderView->time ) {
139  return false;
140  }
141 
142  lastRenderViewTime = renderView->time;
143 
144  // check for glow highlighting if near the center of the view
145  idVec3 dir = renderEntity->origin - renderView->vieworg;
146  dir.Normalize();
147  float d = dir * renderView->viewaxis[0];
148 
149  // two second pulse cycle
150  float cycle = ( renderView->time - inViewTime ) / 2000.0f;
151 
152  if ( d > 0.94f ) {
153  if ( !inView ) {
154  inView = true;
155  if ( cycle > lastCycle ) {
156  // restart at the beginning
157  inViewTime = renderView->time;
158  cycle = 0.0f;
159  }
160  }
161  } else {
162  if ( inView ) {
163  inView = false;
164  lastCycle = ceil( cycle );
165  }
166  }
167 
168  // fade down after the last pulse finishes
169  if ( !inView && cycle > lastCycle ) {
170  renderEntity->shaderParms[4] = 0.0f;
171  } else {
172  // pulse up in 1/4 second
173  cycle -= (int)cycle;
174  if ( cycle < 0.1f ) {
175  renderEntity->shaderParms[4] = cycle * 10.0f;
176  } else if ( cycle < 0.2f ) {
177  renderEntity->shaderParms[4] = 1.0f;
178  } else if ( cycle < 0.3f ) {
179  renderEntity->shaderParms[4] = 1.0f - ( cycle - 0.2f ) * 10.0f;
180  } else {
181  // stay off between pulses
182  renderEntity->shaderParms[4] = 0.0f;
183  }
184  }
185 
186  // update every single time this is in view
187  return true;
188 }
189 
190 /*
191 ================
192 idItem::ModelCallback
193 ================
194 */
195 bool idItem::ModelCallback( renderEntity_t *renderEntity, const renderView_t *renderView ) {
196  const idItem *ent;
197 
198  // this may be triggered by a model trace or other non-view related source
199  if ( !renderView ) {
200  return false;
201  }
202 
203  ent = static_cast<idItem *>(gameLocal.entities[ renderEntity->entityNum ]);
204  if ( !ent ) {
205  gameLocal.Error( "idItem::ModelCallback: callback with NULL game entity" );
206  }
207 
208  return ent->UpdateRenderEntity( renderEntity, renderView );
209 }
210 
211 /*
212 ================
213 idItem::Think
214 ================
215 */
216 void idItem::Think( void ) {
217  if ( thinkFlags & TH_THINK ) {
218  if ( spin ) {
219  idAngles ang;
220  idVec3 org;
221 
222  ang.pitch = ang.roll = 0.0f;
223  ang.yaw = ( gameLocal.time & 4095 ) * 360.0f / -4096.0f;
224  SetAngles( ang );
225 
226  float scale = 0.005f + entityNumber * 0.00001f;
227 
228  org = orgOrigin;
229  org.z += 4.0f + cos( ( gameLocal.time + 2000 ) * scale ) * 4.0f;
230  SetOrigin( org );
231  }
232  }
233 
234  Present();
235 }
236 
237 /*
238 ================
239 idItem::Present
240 ================
241 */
242 void idItem::Present( void ) {
244 
245  if ( !fl.hidden && pulse ) {
246  // also add a highlight shell model
247  renderEntity_t shell;
248 
249  shell = renderEntity;
250 
251  // we will mess with shader parms when the item is in view
252  // to give the "item pulse" effect
254  shell.entityNum = entityNumber;
255  shell.customShader = shellMaterial;
256  if ( itemShellHandle == -1 ) {
258  } else {
260  }
261 
262  }
263 }
264 
265 /*
266 ================
267 idItem::Spawn
268 ================
269 */
270 void idItem::Spawn( void ) {
271  idStr giveTo;
272  idEntity * ent;
273  float tsize;
274 
275  if ( spawnArgs.GetBool( "dropToFloor" ) ) {
277  }
278 
279  if ( spawnArgs.GetFloat( "triggersize", "0", tsize ) ) {
280  GetPhysics()->GetClipModel()->LoadModel( idTraceModel( idBounds( vec3_origin ).Expand( tsize ) ) );
282  }
283 
284  if ( spawnArgs.GetBool( "start_off" ) ) {
285  GetPhysics()->SetContents( 0 );
286  Hide();
287  } else {
289  }
290 
291  giveTo = spawnArgs.GetString( "owner" );
292  if ( giveTo.Length() ) {
293  ent = gameLocal.FindEntity( giveTo );
294  if ( !ent ) {
295  gameLocal.Error( "Item couldn't find owner '%s'", giveTo.c_str() );
296  }
297  PostEventMS( &EV_Touch, 0, ent, 0 );
298  }
299 
300 #ifdef CTF
301  // idItemTeam does not rotate and bob
302  if ( spawnArgs.GetBool( "spin" ) || (gameLocal.isMultiplayer && !this->IsType( idItemTeam::Type ) ) ) {
303  spin = true;
305  }
306 #else
307  if ( spawnArgs.GetBool( "spin" ) || gameLocal.isMultiplayer ) {
308  spin = true;
310  }
311 #endif
312 
313  //pulse = !spawnArgs.GetBool( "nopulse" );
314  //temp hack for tim
315  pulse = false;
317 
318  canPickUp = !( spawnArgs.GetBool( "triggerFirst" ) || spawnArgs.GetBool( "no_touch" ) );
319 
320  inViewTime = -1000;
321  lastCycle = -1;
322  itemShellHandle = -1;
323  shellMaterial = declManager->FindMaterial( "itemHighlightShell" );
324 }
325 
326 /*
327 ================
328 idItem::GetAttributes
329 ================
330 */
331 void idItem::GetAttributes( idDict &attributes ) {
332  int i;
333  const idKeyValue *arg;
334 
335  for( i = 0; i < spawnArgs.GetNumKeyVals(); i++ ) {
336  arg = spawnArgs.GetKeyVal( i );
337  if ( arg->GetKey().Left( 4 ) == "inv_" ) {
338  attributes.Set( arg->GetKey().Right( arg->GetKey().Length() - 4 ), arg->GetValue() );
339  }
340  }
341 }
342 
343 /*
344 ================
345 idItem::GiveToPlayer
346 ================
347 */
349  if ( player == NULL ) {
350  return false;
351  }
352 
353  if ( spawnArgs.GetBool( "inv_carry" ) ) {
354  return player->GiveInventoryItem( &spawnArgs );
355  }
356 
357  return player->GiveItem( this );
358 }
359 
360 /*
361 ================
362 idItem::Pickup
363 ================
364 */
365 bool idItem::Pickup( idPlayer *player ) {
366 
367  if ( !GiveToPlayer( player ) ) {
368  return false;
369  }
370 
371  if ( gameLocal.isServer ) {
372  ServerSendEvent( EVENT_PICKUP, NULL, false, -1 );
373  }
374 
375  // play pickup sound
376  StartSound( "snd_acquire", SND_CHANNEL_ITEM, 0, false, NULL );
377 
378  // trigger our targets
379  ActivateTargets( player );
380 
381  // clear our contents so the object isn't picked up twice
382  GetPhysics()->SetContents( 0 );
383 
384  // hide the model
385  Hide();
386 
387  // add the highlight shell
388  if ( itemShellHandle != -1 ) {
390  itemShellHandle = -1;
391  }
392 
393  float respawn = spawnArgs.GetFloat( "respawn" );
394  bool dropped = spawnArgs.GetBool( "dropped" );
395  bool no_respawn = spawnArgs.GetBool( "no_respawn" );
396 
397  if ( gameLocal.isMultiplayer && respawn == 0.0f ) {
398  respawn = 20.0f;
399  }
400 
401  if ( respawn && !dropped && !no_respawn ) {
402  const char *sfx = spawnArgs.GetString( "fxRespawn" );
403  if ( sfx && *sfx ) {
404  PostEventSec( &EV_RespawnFx, respawn - 0.5f );
405  }
406  PostEventSec( &EV_RespawnItem, respawn );
407  } else if ( !spawnArgs.GetBool( "inv_objective" ) && !no_respawn ) {
408  // give some time for the pickup sound to play
409  // FIXME: Play on the owner
410  if ( !spawnArgs.GetBool( "inv_carry" ) ) {
411  PostEventMS( &EV_Remove, 5000 );
412  }
413  }
414 
416  return true;
417 }
418 
419 /*
420 ================
421 idItem::ClientPredictionThink
422 ================
423 */
425  // only think forward because the state is not synced through snapshots
426  if ( !gameLocal.isNewFrame ) {
427  return;
428  }
429  Think();
430 }
431 
432 /*
433 ================
434 idItem::WriteFromSnapshot
435 ================
436 */
438  msg.WriteBits( IsHidden(), 1 );
439 }
440 
441 /*
442 ================
443 idItem::ReadFromSnapshot
444 ================
445 */
447  if ( msg.ReadBits( 1 ) ) {
448  Hide();
449  } else {
450  Show();
451  }
452 }
453 
454 /*
455 ================
456 idItem::ClientReceiveEvent
457 ================
458 */
459 bool idItem::ClientReceiveEvent( int event, int time, const idBitMsg &msg ) {
460 
461  switch( event ) {
462  case EVENT_PICKUP: {
463 
464  // play pickup sound
465  StartSound( "snd_acquire", SND_CHANNEL_ITEM, 0, false, NULL );
466 
467  // hide the model
468  Hide();
469 
470  // remove the highlight shell
471  if ( itemShellHandle != -1 ) {
473  itemShellHandle = -1;
474  }
475  return true;
476  }
477  case EVENT_RESPAWN: {
478  Event_Respawn();
479  return true;
480  }
481  case EVENT_RESPAWNFX: {
482  Event_RespawnFx();
483  return true;
484  }
485  default: {
486  return idEntity::ClientReceiveEvent( event, time, msg );
487  }
488  }
489  return false;
490 }
491 
492 /*
493 ================
494 idItem::Event_DropToFloor
495 ================
496 */
498  trace_t trace;
499 
500  // don't drop the floor if bound to another entity
501  if ( GetBindMaster() != NULL && GetBindMaster() != this ) {
502  return;
503  }
504 
506  SetOrigin( trace.endpos );
507 }
508 
509 /*
510 ================
511 idItem::Event_Touch
512 ================
513 */
514 void idItem::Event_Touch( idEntity *other, trace_t *trace ) {
515  if ( !other->IsType( idPlayer::Type ) ) {
516  return;
517  }
518 
519  if ( !canPickUp ) {
520  return;
521  }
522 
523  Pickup( static_cast<idPlayer *>(other) );
524 }
525 
526 /*
527 ================
528 idItem::Event_Trigger
529 ================
530 */
531 void idItem::Event_Trigger( idEntity *activator ) {
532 
533  if ( !canPickUp && spawnArgs.GetBool( "triggerFirst" ) ) {
534  canPickUp = true;
535  return;
536  }
537 
538  if ( activator && activator->IsType( idPlayer::Type ) ) {
539  Pickup( static_cast<idPlayer *>( activator ) );
540  }
541 }
542 
543 /*
544 ================
545 idItem::Event_Respawn
546 ================
547 */
548 void idItem::Event_Respawn( void ) {
549  if ( gameLocal.isServer ) {
550  ServerSendEvent( EVENT_RESPAWN, NULL, false, -1 );
551  }
553  Show();
554  inViewTime = -1000;
555  lastCycle = -1;
557  SetOrigin( orgOrigin );
558  StartSound( "snd_respawn", SND_CHANNEL_ITEM, 0, false, NULL );
559  CancelEvents( &EV_RespawnItem ); // don't double respawn
560 }
561 
562 /*
563 ================
564 idItem::Event_RespawnFx
565 ================
566 */
568  if ( gameLocal.isServer ) {
569  ServerSendEvent( EVENT_RESPAWNFX, NULL, false, -1 );
570  }
571  const char *sfx = spawnArgs.GetString( "fxRespawn" );
572  if ( sfx && *sfx ) {
573  idEntityFx::StartFx( sfx, NULL, NULL, this, true );
574  }
575 }
576 
577 /*
578 ===============================================================================
579 
580  idItemPowerup
581 
582 ===============================================================================
583 */
584 
585 /*
586 ===============
587 idItemPowerup
588 ===============
589 */
590 
592 END_CLASS
593 
594 /*
595 ================
596 idItemPowerup::idItemPowerup
597 ================
598 */
600  time = 0;
601  type = 0;
602 }
603 
604 /*
605 ================
606 idItemPowerup::Save
607 ================
608 */
609 void idItemPowerup::Save( idSaveGame *savefile ) const {
610  savefile->WriteInt( time );
611  savefile->WriteInt( type );
612 }
613 
614 /*
615 ================
616 idItemPowerup::Restore
617 ================
618 */
620  savefile->ReadInt( time );
621  savefile->ReadInt( type );
622 }
623 
624 /*
625 ================
626 idItemPowerup::Spawn
627 ================
628 */
629 void idItemPowerup::Spawn( void ) {
630  time = spawnArgs.GetInt( "time", "30" );
631  type = spawnArgs.GetInt( "type", "0" );
632 }
633 
634 /*
635 ================
636 idItemPowerup::GiveToPlayer
637 ================
638 */
640  if ( player->spectating ) {
641  return false;
642  }
643  player->GivePowerUp( type, time * 1000 );
644  return true;
645 }
646 
647 #ifdef CTF
648 
649 
650 /*
651 ===============================================================================
652 
653  idItemTeam
654 
655  Used for flags in Capture the Flag
656 
657 ===============================================================================
658 */
659 
660 // temporarely removed these events
661 
662 const idEventDef EV_FlagReturn( "flagreturn", "e" );
663 const idEventDef EV_TakeFlag( "takeflag", "e" );
664 const idEventDef EV_DropFlag( "dropflag", "d" );
665 const idEventDef EV_FlagCapture( "flagcapture" );
666 
667 CLASS_DECLARATION( idItem, idItemTeam )
668  EVENT( EV_FlagReturn, idItemTeam::Event_FlagReturn )
669  EVENT( EV_TakeFlag, idItemTeam::Event_TakeFlag )
670  EVENT( EV_DropFlag, idItemTeam::Event_DropFlag )
671  EVENT( EV_FlagCapture, idItemTeam::Event_FlagCapture )
672 END_CLASS
673 
674 /*
675 ===============
676 idItemTeam::idItemTeam
677 ===============
678 */
679 idItemTeam::idItemTeam() {
680  team = -1;
681  carried = false;
682  dropped = false;
683  lastDrop = 0;
684 
685  itemGlowHandle = -1;
686 
687  skinDefault = NULL;
688  skinCarried = NULL;
689 
690  scriptTaken = NULL;
691  scriptDropped = NULL;
692  scriptReturned = NULL;
693  scriptCaptured = NULL;
694 
695  lastNuggetDrop = 0;
696  nuggetName = 0;
697 }
698 
699 /*
700 ===============
701 idItemTeam::~idItemTeam
702 ===============
703 */
704 idItemTeam::~idItemTeam() {
705  FreeLightDef();
706 }
707 /*
708 ===============
709 idItemTeam::Spawn
710 ===============
711 */
712 void idItemTeam::Spawn( void ) {
713  team = spawnArgs.GetInt( "team" );
714  returnOrigin = GetPhysics()->GetOrigin() + idVec3( 0, 0, 20 );
715  returnAxis = GetPhysics()->GetAxis();
716 
717  BecomeActive( TH_THINK );
718 
719  const char * skinName;
720  skinName = spawnArgs.GetString( "skin", "" );
721  if ( skinName[0] )
722  skinDefault = declManager->FindSkin( skinName );
723 
724  skinName = spawnArgs.GetString( "skin_carried", "" );
725  if ( skinName[0] )
726  skinCarried = declManager->FindSkin( skinName );
727 
728  nuggetName = spawnArgs.GetString( "nugget_name", "" );
729  if ( !nuggetName[0] ) {
730  nuggetName = NULL;
731  }
732 
733  scriptTaken = LoadScript( "script_taken" );
734  scriptDropped = LoadScript( "script_dropped" );
735  scriptReturned = LoadScript( "script_returned" );
736  scriptCaptured = LoadScript( "script_captured" );
737 
738  /* Spawn attached dlight */
739  /*
740  idDict args;
741  idVec3 lightOffset( 0.0f, 20.0f, 0.0f );
742 
743  // Set up the flag's dynamic light
744  memset( &itemGlow, 0, sizeof( itemGlow ) );
745  itemGlow.axis = mat3_identity;
746  itemGlow.lightRadius.x = 128.0f;
747  itemGlow.lightRadius.y = itemGlow.lightRadius.z = itemGlow.lightRadius.x;
748  itemGlow.noShadows = true;
749  itemGlow.pointLight = true;
750  itemGlow.shaderParms[ SHADERPARM_RED ] = 0.0f;
751  itemGlow.shaderParms[ SHADERPARM_GREEN ] = 0.0f;
752  itemGlow.shaderParms[ SHADERPARM_BLUE ] = 0.0f;
753  itemGlow.shaderParms[ SHADERPARM_ALPHA ] = 0.0f;
754 
755  // Select a shader based on the team
756  if ( team == 0 )
757  itemGlow.shader = declManager->FindMaterial( "lights/redflag" );
758  else
759  itemGlow.shader = declManager->FindMaterial( "lights/blueflag" );
760  */
761 
763 
764  physicsObj.SetContents( 0 );
765  physicsObj.SetClipMask( MASK_SOLID | CONTENTS_MOVEABLECLIP );
766  physicsObj.SetGravity( idVec3( 0, 0, spawnArgs.GetInt("gravity", "-30" ) ) );
767 }
768 
769 
770 /*
771 ===============
772 idItemTeam::LoadScript
773 ===============
774 */
775 function_t * idItemTeam::LoadScript( const char * script ) {
776  function_t * function = NULL;
777  idStr funcname = spawnArgs.GetString( script, "" );
778  if ( funcname.Length() ) {
779  function = gameLocal.program.FindFunction( funcname );
780  if ( function == NULL ) {
781 #ifdef _DEBUG
782  gameLocal.Warning( "idItemTeam '%s' at (%s) calls unknown function '%s'", name.c_str(), GetPhysics()->GetOrigin().ToString(0), funcname.c_str() );
783 #endif
784  }
785  }
786  return function;
787 }
788 
789 
790 /*
791 ===============
792 idItemTeam::Think
793 ===============
794 */
795 void idItemTeam::Think( void ) {
797 
798  TouchTriggers();
799 
800  // TODO : only update on updatevisuals
801  /*idVec3 offset( 0.0f, 0.0f, 20.0f );
802  itemGlow.origin = GetPhysics()->GetOrigin() + offset;
803  if ( itemGlowHandle == -1 ) {
804  itemGlowHandle = gameRenderWorld->AddLightDef( &itemGlow );
805  } else {
806  gameRenderWorld->UpdateLightDef( itemGlowHandle, &itemGlow );
807  }*/
808 
809 #if 1
810  // should only the server do this?
811  if ( gameLocal.isServer && nuggetName && carried && ( !lastNuggetDrop || (gameLocal.time - lastNuggetDrop) > spawnArgs.GetInt("nugget_frequency") ) ) {
812 
813  SpawnNugget( GetPhysics()->GetOrigin() );
814  lastNuggetDrop = gameLocal.time;
815  }
816 #endif
817 
818  // return dropped flag after si_flagDropTimeLimit seconds
819  if ( dropped && !carried && lastDrop != 0 && (gameLocal.time - lastDrop) > ( si_flagDropTimeLimit.GetInteger()*1000 ) ) {
820 
821  Return(); // return flag after 30 seconds on ground
822  return;
823  }
824 }
825 
826 /*
827 ===============
828 idItemTeam::Pickup
829 ===============
830 */
831 bool idItemTeam::Pickup( idPlayer *player ) {
832  if ( !gameLocal.mpGame.IsGametypeFlagBased() ) /* CTF */
833  return false;
834 
837  return false;
838 
839  // wait 2 seconds after drop before beeing picked up again
840  if ( lastDrop != 0 && (gameLocal.time - lastDrop) < spawnArgs.GetInt("pickupDelay", "500") )
841  return false;
842 
843  if ( carried == false && player->team != this->team ) {
844 
845  PostEventMS( &EV_TakeFlag, 0, player );
846 
847  return true;
848  } else if ( carried == false && dropped == true && player->team == this->team ) {
849 
850  gameLocal.mpGame.PlayerScoreCTF( player->entityNumber, 5 );
851 
852  // return flag
853  PostEventMS( &EV_FlagReturn, 0, player );
854 
855  return false;
856  }
857 
858  return false;
859 }
860 
861 /*
862 ===============
863 idItemTeam::ClientReceiveEvent
864 ===============
865 */
866 bool idItemTeam::ClientReceiveEvent( int event, int time, const idBitMsg &msg ) {
867  gameLocal.DPrintf("ClientRecieveEvent: %i\n", event );
868 
869  switch ( event ) {
870  case EVENT_TAKEFLAG: {
871  idPlayer * player = static_cast<idPlayer *>(gameLocal.entities[ msg.ReadBits( GENTITYNUM_BITS ) ]);
872  if ( player == NULL ) {
873  gameLocal.Warning( "NULL player takes flag?\n" );
874  return false;
875  }
876 
877  Event_TakeFlag( player );
878  }
879  return true;
880 
881  case EVENT_DROPFLAG : {
882  bool death = bool( msg.ReadBits( 1 ) == 1 );
883  Event_DropFlag( death );
884  }
885  return true;
886 
887  case EVENT_FLAGRETURN : {
888  Hide();
889 
890  FreeModelDef();
891  FreeLightDef();
892 
893  Event_FlagReturn();
894  }
895  return true;
896 
897  case EVENT_FLAGCAPTURE : {
898  Hide();
899 
900  FreeModelDef();
901  FreeLightDef();
902 
903  Event_FlagCapture();
904  }
905  return true;
906  };
907 
908  return false;
909 }
910 
911 /*
912 ================
913 idItemTeam::Drop
914 ================
915 */
916 void idItemTeam::Drop( bool death )
917 {
918 // PostEventMS( &EV_DropFlag, 0, int(death == true) );
919 // had to remove the delayed drop because of drop flag on disconnect
920  Event_DropFlag( death );
921 }
922 
923 /*
924 ================
925 idItemTeam::Return
926 ================
927 */
928 void idItemTeam::Return( idPlayer * player )
929 {
930  if ( team != 0 && team != 1 )
931  return;
932 
933 // PostEventMS( &EV_FlagReturn, 0 );
934  Event_FlagReturn();
935 }
936 
937 /*
938 ================
939 idItemTeam::Capture
940 ================
941 */
942 void idItemTeam::Capture( void )
943 {
944  if ( team != 0 && team != 1 )
945  return;
946 
947  PostEventMS( &EV_FlagCapture, 0 );
948 }
949 
950 /*
951 ================
952 idItemTeam::PrivateReturn
953 ================
954 */
955 void idItemTeam::PrivateReturn( void )
956 {
957  Unbind();
958 
959  if ( gameLocal.isServer && carried && !dropped ) {
960  int playerIdx = gameLocal.mpGame.GetFlagCarrier( 1-team );
961  if ( playerIdx != -1 ) {
962  idPlayer * player = static_cast<idPlayer*>( gameLocal.entities[ playerIdx ] );
963  player->carryingFlag = false;
964  } else {
965  gameLocal.Warning( "BUG: carried flag has no carrier before return" );
966  }
967  }
968 
969  dropped = false;
970  carried = false;
971 
972  SetOrigin( returnOrigin );
973  SetAxis( returnAxis );
974 
975  trigger->Link( gameLocal.clip, this, 0, GetPhysics()->GetOrigin(), mat3_identity );
976 
977  SetSkin( skinDefault );
978 
979  // Turn off the light
980  /*itemGlow.shaderParms[ SHADERPARM_RED ] = 0.0f;
981  itemGlow.shaderParms[ SHADERPARM_GREEN ] = 0.0f;
982  itemGlow.shaderParms[ SHADERPARM_BLUE ] = 0.0f;
983  itemGlow.shaderParms[ SHADERPARM_ALPHA ] = 0.0f;
984 
985  if ( itemGlowHandle != -1 )
986  gameRenderWorld->UpdateLightDef( itemGlowHandle, &itemGlow );*/
987 
988  GetPhysics()->SetLinearVelocity( idVec3(0, 0, 0) );
989  GetPhysics()->SetAngularVelocity( idVec3(0, 0, 0) );
990 }
991 
992 /*
993 ================
994 idItemTeam::Event_TakeFlag
995 ================
996 */
997 void idItemTeam::Event_TakeFlag( idPlayer * player ) {
998  gameLocal.DPrintf("Event_TakeFlag()!\n");
999 
1000  if ( gameLocal.isServer ) {
1001  idBitMsg msg;
1002  byte msgBuf[MAX_EVENT_PARAM_SIZE];
1003  // Send the event
1004  msg.Init( msgBuf, sizeof( msgBuf ) );
1005  msg.BeginWriting();
1006  msg.WriteBits( player->entityNumber, GENTITYNUM_BITS );
1007  ServerSendEvent( EVENT_TAKEFLAG, &msg, false, -1 );
1008 
1009  gameLocal.mpGame.PlayTeamSound( player->team, SND_FLAG_TAKEN_THEIRS );
1010  gameLocal.mpGame.PlayTeamSound( team, SND_FLAG_TAKEN_YOURS );
1011 
1012  gameLocal.mpGame.PrintMessageEvent( -1, idMultiplayerGame::MSG_FLAGTAKEN, team, player->entityNumber );
1013 
1014  // dont drop a nugget RIGHT away
1015  lastNuggetDrop = gameLocal.time - gameLocal.random.RandomInt( 1000 );
1016 
1017  }
1018 
1019  BindToJoint( player, g_flagAttachJoint.GetString(), true );
1020  idVec3 origin( g_flagAttachOffsetX.GetFloat(), g_flagAttachOffsetY.GetFloat(), g_flagAttachOffsetZ.GetFloat() );
1021  idAngles angle( g_flagAttachAngleX.GetFloat(), g_flagAttachAngleY.GetFloat(), g_flagAttachAngleZ.GetFloat() );
1022  SetAngles( angle );
1023  SetOrigin( origin );
1024 
1025  // Turn the light on
1026  /*itemGlow.shaderParms[ SHADERPARM_RED ] = 1.0f;
1027  itemGlow.shaderParms[ SHADERPARM_GREEN ] = 1.0f;
1028  itemGlow.shaderParms[ SHADERPARM_BLUE ] = 1.0f;
1029  itemGlow.shaderParms[ SHADERPARM_ALPHA ] = 1.0f;
1030 
1031  if ( itemGlowHandle != -1 )
1032  gameRenderWorld->UpdateLightDef( itemGlowHandle, &itemGlow );*/
1033 
1034  if ( scriptTaken ) {
1035  idThread *thread = new idThread();
1036  thread->CallFunction( scriptTaken, false );
1037  thread->DelayedStart( 0 );
1038  }
1039 
1040  dropped = false;
1041  carried = true;
1042  player->carryingFlag = true;
1043 
1044  SetSkin( skinCarried );
1045 
1046  UpdateVisuals();
1047  UpdateGuis();
1048 
1049  if ( gameLocal.isServer ) {
1050  if ( team == 0 )
1051  gameLocal.mpGame.player_red_flag = player->entityNumber;
1052  else
1053  gameLocal.mpGame.player_blue_flag = player->entityNumber;
1054  }
1055 }
1056 
1057 /*
1058 ================
1059 idItemTeam::Event_DropFlag
1060 ================
1061 */
1062 void idItemTeam::Event_DropFlag( bool death ) {
1063  gameLocal.DPrintf("Event_DropFlag()!\n");
1064 
1065  if ( gameLocal.isServer ) {
1066  idBitMsg msg;
1067  byte msgBuf[MAX_EVENT_PARAM_SIZE];
1068  // Send the event
1069  msg.Init( msgBuf, sizeof( msgBuf ) );
1070  msg.BeginWriting();
1071  msg.WriteBits( death, 1 );
1072  ServerSendEvent( EVENT_DROPFLAG, &msg, false, -1 );
1073 
1074  if ( gameLocal.mpGame.IsFlagMsgOn() ) {
1075  gameLocal.mpGame.PlayTeamSound( 1-team, SND_FLAG_DROPPED_THEIRS );
1076  gameLocal.mpGame.PlayTeamSound( team, SND_FLAG_DROPPED_YOURS );
1077 
1078  gameLocal.mpGame.PrintMessageEvent( -1, idMultiplayerGame::MSG_FLAGDROP, team );
1079  }
1080  }
1081 
1082  lastDrop = gameLocal.time;
1083 
1084  BecomeActive( TH_THINK );
1085  Show();
1086 
1087  if ( death )
1088  GetPhysics()->SetLinearVelocity( idVec3(0, 0, 0) );
1089  else
1090  GetPhysics()->SetLinearVelocity( idVec3(0, 0, 20) );
1091 
1092  GetPhysics()->SetAngularVelocity( idVec3(0, 0, 0) );
1093 
1094 // GetPhysics()->SetLinearVelocity( ( GetPhysics()->GetLinearVelocity() * GetBindMaster()->GetPhysics()->GetAxis() ) + GetBindMaster()->GetPhysics()->GetLinearVelocity() );
1095 
1096  if ( GetBindMaster() ) {
1097  const idBounds bounds = GetPhysics()->GetBounds();
1098  idVec3 origin = GetBindMaster()->GetPhysics()->GetOrigin() + idVec3(0, 0, ( bounds[1].z-bounds[0].z )*0.6f );
1099 
1100  Unbind();
1101 
1102  SetOrigin( origin );
1103  }
1104 
1105  idAngles angle = GetPhysics()->GetAxis().ToAngles();
1106  angle.roll = 0;
1107  angle.pitch = 0;
1108  SetAxis( angle.ToMat3() );
1109 
1110  dropped = true;
1111  carried = false;
1112 
1113  if ( scriptDropped ) {
1114  idThread *thread = new idThread();
1115  thread->CallFunction( scriptDropped, false );
1116  thread->DelayedStart( 0 );
1117  }
1118 
1119  SetSkin( skinDefault );
1120  UpdateVisuals();
1121  UpdateGuis();
1122 
1123 
1124  if ( gameLocal.isServer ) {
1125  if ( team == 0 )
1126  gameLocal.mpGame.player_red_flag = -1;
1127  else
1128  gameLocal.mpGame.player_blue_flag = -1;
1129 
1130  }
1131 }
1132 
1133 /*
1134 ================
1135 idItemTeam::Event_FlagReturn
1136 ================
1137 */
1138 void idItemTeam::Event_FlagReturn( idPlayer * player ) {
1139  gameLocal.DPrintf("Event_FlagReturn()!\n");
1140 
1141  if ( gameLocal.isServer ) {
1142  ServerSendEvent( EVENT_FLAGRETURN, NULL, false, -1 );
1143 
1144  if ( gameLocal.mpGame.IsFlagMsgOn() ) {
1145  gameLocal.mpGame.PlayTeamSound( 1-team, SND_FLAG_RETURN );
1146  gameLocal.mpGame.PlayTeamSound( team, SND_FLAG_RETURN );
1147 
1148  int entitynum = 255;
1149  if ( player ) {
1150  entitynum = player->entityNumber;
1151  }
1152 
1153  gameLocal.mpGame.PrintMessageEvent( -1, idMultiplayerGame::MSG_FLAGRETURN, team, entitynum );
1154  }
1155  }
1156 
1157  BecomeActive( TH_THINK );
1158  Show();
1159 
1160  PrivateReturn();
1161 
1162  if ( scriptReturned ) {
1163  idThread *thread = new idThread();
1164  thread->CallFunction( scriptReturned, false );
1165  thread->DelayedStart( 0 );
1166  }
1167 
1168  UpdateVisuals();
1169  UpdateGuis();
1170 // Present();
1171 
1172  if ( gameLocal.isServer ) {
1173  if ( team == 0 )
1174  gameLocal.mpGame.player_red_flag = -1;
1175  else
1176  gameLocal.mpGame.player_blue_flag = -1;
1177  }
1178 }
1179 
1180 /*
1181 ================
1182 idItemTeam::Event_FlagCapture
1183 ================
1184 */
1185 void idItemTeam::Event_FlagCapture( void ) {
1186  gameLocal.DPrintf("Event_FlagCapture()!\n");
1187 
1188  if ( gameLocal.isServer ) {
1189  ServerSendEvent( EVENT_FLAGCAPTURE, NULL, false, -1 );
1190 
1191  gameLocal.mpGame.PlayTeamSound( 1-team, SND_FLAG_CAPTURED_THEIRS );
1192  gameLocal.mpGame.PlayTeamSound( team, SND_FLAG_CAPTURED_YOURS );
1193 
1194  gameLocal.mpGame.TeamScoreCTF( 1-team, 1 );
1195 
1196  int playerIdx = gameLocal.mpGame.GetFlagCarrier( 1-team );
1197  if ( playerIdx != -1 ) {
1198  gameLocal.mpGame.PlayerScoreCTF( playerIdx, 10 );
1199  } else {
1200  playerIdx = 255;
1201  }
1202 
1203  gameLocal.mpGame.PrintMessageEvent( -1, idMultiplayerGame::MSG_FLAGCAPTURE, team, playerIdx );
1204  }
1205 
1206  BecomeActive( TH_THINK );
1207  Show();
1208 
1209  PrivateReturn();
1210 
1211  if ( scriptCaptured ) {
1212  idThread *thread = new idThread();
1213  thread->CallFunction( scriptCaptured, false );
1214  thread->DelayedStart( 0 );
1215  }
1216 
1217  UpdateVisuals();
1218  UpdateGuis();
1219 
1220 
1221  if ( gameLocal.isServer ) {
1222  if ( team == 0 )
1223  gameLocal.mpGame.player_red_flag = -1;
1224  else
1225  gameLocal.mpGame.player_blue_flag = -1;
1226  }
1227 
1228 }
1229 
1230 /*
1231 ================
1232 idItemTeam::FreeLightDef
1233 ================
1234 */
1235 void idItemTeam::FreeLightDef( void ) {
1236  if ( itemGlowHandle != -1 ) {
1237  gameRenderWorld->FreeLightDef( itemGlowHandle );
1238  itemGlowHandle = -1;
1239  }
1240 }
1241 
1242 /*
1243 ================
1244 idItemTeam::SpawnNugget
1245 ================
1246 */
1247 void idItemTeam::SpawnNugget( idVec3 pos ) {
1248 
1249  idAngles angle( gameLocal.random.RandomInt(spawnArgs.GetInt("nugget_pitch", "30")), gameLocal.random.RandomInt(spawnArgs.GetInt("nugget_yaw", "360" )), 0 );
1250  float velocity = float(gameLocal.random.RandomInt( 40 )+15);
1251 
1252  velocity *= spawnArgs.GetFloat("nugget_velocity", "1" );
1253 
1254  idEntity * ent = idMoveableItem::DropItem( nuggetName, pos, GetPhysics()->GetAxis(), angle.ToMat3()*idVec3(velocity, velocity, velocity), 0, spawnArgs.GetInt("nugget_removedelay") );
1255  idPhysics_RigidBody * physics = static_cast<idPhysics_RigidBody *>( ent->GetPhysics() );
1256 
1257  if ( physics && physics->IsType( idPhysics_RigidBody::Type ) ) {
1258  physics->DisableImpact();
1259  }
1260 }
1261 
1262 
1263 
1264 /*
1265 ================
1266 idItemTeam::Event_FlagCapture
1267 ================
1268 */
1269 void idItemTeam::WriteToSnapshot( idBitMsgDelta &msg ) const {
1270  msg.WriteBits( carried, 1 );
1271  msg.WriteBits( dropped, 1 );
1272 
1273  WriteBindToSnapshot( msg );
1274 
1276 }
1277 
1278 
1279 /*
1280 ================
1281 idItemTeam::ReadFromSnapshot
1282 ================
1283 */
1284 void idItemTeam::ReadFromSnapshot( const idBitMsgDelta &msg ) {
1285  carried = msg.ReadBits( 1 ) == 1;
1286  dropped = msg.ReadBits( 1 ) == 1;
1287 
1288  ReadBindFromSnapshot( msg );
1289 
1290  if ( msg.HasChanged() )
1291  {
1292  UpdateGuis();
1293 
1294  if ( carried == true )
1295  SetSkin( skinCarried );
1296  else
1297  SetSkin( skinDefault );
1298  }
1299 
1301 }
1302 
1303 /*
1304 ================
1305 idItemTeam::UpdateGuis
1306 
1307 Update all client's huds wrt the flag status.
1308 ================
1309 */
1310 void idItemTeam::UpdateGuis( void ) {
1311  idPlayer *player;
1312 
1313  for ( int i = 0; i < gameLocal.numClients; i++ ) {
1314  player = static_cast<idPlayer *>( gameLocal.entities[ i ] );
1315 
1316  if ( player == NULL || player->hud == NULL )
1317  continue;
1318 
1319  player->hud->SetStateInt( "red_flagstatus", gameLocal.mpGame.GetFlagStatus( 0 ) );
1320  player->hud->SetStateInt( "blue_flagstatus", gameLocal.mpGame.GetFlagStatus( 1 ) );
1321 
1322  player->hud->SetStateInt( "red_team_score", gameLocal.mpGame.GetFlagPoints( 0 ) );
1323  player->hud->SetStateInt( "blue_team_score", gameLocal.mpGame.GetFlagPoints( 1 ) );
1324 
1325  }
1326 
1327 }
1328 
1329 /*
1330 ================
1331 idItemTeam::Present
1332 ================
1333 */
1334 void idItemTeam::Present( void ) {
1335  // hide the flag for localplayer if in first person
1336  if ( carried && GetBindMaster() ) {
1337  idPlayer * player = static_cast<idPlayer *>( GetBindMaster() );
1338  if ( player == gameLocal.GetLocalPlayer() && !pm_thirdPerson.GetBool() ) {
1339  FreeModelDef();
1340  BecomeActive( TH_UPDATEVISUALS );
1341  return;
1342  }
1343  }
1344 
1346 }
1347 
1348 #endif
1349 
1350 /*
1351 ===============================================================================
1352 
1353  idObjective
1354 
1355 ===============================================================================
1356 */
1357 
1359  EVENT( EV_Activate, idObjective::Event_Trigger )
1360  EVENT( EV_HideObjective, idObjective::Event_HideObjective )
1361  EVENT( EV_GetPlayerPos, idObjective::Event_GetPlayerPos )
1362  EVENT( EV_CamShot, idObjective::Event_CamShot )
1363 END_CLASS
1364 
1365 /*
1366 ================
1367 idObjective::idObjective
1368 ================
1369 */
1371  playerPos.Zero();
1372 }
1373 
1374 /*
1375 ================
1376 idObjective::Save
1377 ================
1378 */
1379 void idObjective::Save( idSaveGame *savefile ) const {
1380  savefile->WriteVec3( playerPos );
1381 }
1382 
1383 /*
1384 ================
1385 idObjective::Restore
1386 ================
1387 */
1389  savefile->ReadVec3( playerPos );
1390 }
1391 
1392 /*
1393 ================
1394 idObjective::Spawn
1395 ================
1396 */
1397 void idObjective::Spawn( void ) {
1398  Hide();
1399  if ( cvarSystem->GetCVarBool( "com_makingBuild") ) {
1400  PostEventMS( &EV_CamShot, 250 );
1401  }
1402 }
1403 
1404 /*
1405 ================
1406 idObjective::Event_Screenshot
1407 ================
1408 */
1410  const char *camName;
1411  idStr shotName = gameLocal.GetMapName();
1412  shotName.StripFileExtension();
1413  shotName += "/";
1414  shotName += spawnArgs.GetString( "screenshot" );
1415  shotName.SetFileExtension( ".tga" );
1416  if ( spawnArgs.GetString( "camShot", "", &camName ) ) {
1417  idEntity *ent = gameLocal.FindEntity( camName );
1418  if ( ent && ent->cameraTarget ) {
1419  const renderView_t *view = ent->cameraTarget->GetRenderView();
1420  renderView_t fullView = *view;
1421  fullView.width = SCREEN_WIDTH;
1422  fullView.height = SCREEN_HEIGHT;
1423 
1424 #ifdef _D3XP
1425  // HACK : always draw sky-portal view if there is one in the map, this isn't real-time
1426  if ( gameLocal.portalSkyEnt.GetEntity() && g_enablePortalSky.GetBool() ) {
1427  renderView_t portalView = fullView;
1428  portalView.vieworg = gameLocal.portalSkyEnt.GetEntity()->GetPhysics()->GetOrigin();
1429 
1430  // setup global fixup projection vars
1431  if ( 1 ) {
1432  int vidWidth, vidHeight;
1433  idVec2 shiftScale;
1434 
1435  renderSystem->GetGLSettings( vidWidth, vidHeight );
1436 
1437  float pot;
1438  int temp;
1439 
1440  int w = vidWidth;
1441  for (temp = 1 ; temp < w ; temp<<=1) {
1442  }
1443  pot = (float)temp;
1444  shiftScale.x = (float)w / pot;
1445 
1446  int h = vidHeight;
1447  for (temp = 1 ; temp < h ; temp<<=1) {
1448  }
1449  pot = (float)temp;
1450  shiftScale.y = (float)h / pot;
1451 
1452  fullView.shaderParms[4] = shiftScale.x;
1453  fullView.shaderParms[5] = shiftScale.y;
1454  }
1455 
1456  gameRenderWorld->RenderScene( &portalView );
1457  renderSystem->CaptureRenderToImage( "_currentRender" );
1458  }
1459 #endif
1460 
1461  // draw a view to a texture
1462  renderSystem->CropRenderSize( 256, 256, true );
1463  gameRenderWorld->RenderScene( &fullView );
1464  renderSystem->CaptureRenderToFile( shotName );
1465  renderSystem->UnCrop();
1466  }
1467  }
1468 }
1469 
1470 /*
1471 ================
1472 idObjective::Event_Trigger
1473 ================
1474 */
1476  idPlayer *player = gameLocal.GetLocalPlayer();
1477  if ( player ) {
1478 
1479  //Pickup( player );
1480 
1481  if ( spawnArgs.GetString( "inv_objective", NULL ) ) {
1482  if ( player && player->hud ) {
1483  idStr shotName = gameLocal.GetMapName();
1484  shotName.StripFileExtension();
1485  shotName += "/";
1486  shotName += spawnArgs.GetString( "screenshot" );
1487  shotName.SetFileExtension( ".tga" );
1488  player->hud->SetStateString( "screenshot", shotName );
1489  player->hud->SetStateString( "objective", "1" );
1490  player->hud->SetStateString( "objectivetext", spawnArgs.GetString( "objectivetext" ) );
1491  player->hud->SetStateString( "objectivetitle", spawnArgs.GetString( "objectivetitle" ) );
1492  player->GiveObjective( spawnArgs.GetString( "objectivetitle" ), spawnArgs.GetString( "objectivetext" ), shotName );
1493 
1494  // a tad slow but keeps from having to update all objectives in all maps with a name ptr
1495  for( int i = 0; i < gameLocal.num_entities; i++ ) {
1496  if ( gameLocal.entities[ i ] && gameLocal.entities[ i ]->IsType( idObjectiveComplete::Type ) ) {
1497  if ( idStr::Icmp( spawnArgs.GetString( "objectivetitle" ), gameLocal.entities[ i ]->spawnArgs.GetString( "objectivetitle" ) ) == 0 ){
1498  gameLocal.entities[ i ]->spawnArgs.SetBool( "objEnabled", true );
1499  break;
1500  }
1501  }
1502  }
1503 
1504  PostEventMS( &EV_GetPlayerPos, 2000 );
1505  }
1506  }
1507  }
1508 }
1509 
1510 /*
1511 ================
1512 idObjective::Event_GetPlayerPos
1513 ================
1514 */
1516  idPlayer *player = gameLocal.GetLocalPlayer();
1517  if ( player ) {
1518  playerPos = player->GetPhysics()->GetOrigin();
1519  PostEventMS( &EV_HideObjective, 100, player );
1520  }
1521 }
1522 
1523 /*
1524 ================
1525 idObjective::Event_HideObjective
1526 ================
1527 */
1529  idPlayer *player = gameLocal.GetLocalPlayer();
1530  if ( player ) {
1531  idVec3 v = player->GetPhysics()->GetOrigin() - playerPos;
1532  if ( v.Length() > 64.0f ) {
1533  player->HideObjective();
1534  PostEventMS( &EV_Remove, 0 );
1535  } else {
1536  PostEventMS( &EV_HideObjective, 100, player );
1537  }
1538  }
1539 }
1540 
1541 /*
1542 ===============================================================================
1543 
1544  idVideoCDItem
1545 
1546 ===============================================================================
1547 */
1548 
1550 END_CLASS
1551 
1552 /*
1553 ================
1554 idVideoCDItem::Spawn
1555 ================
1556 */
1557 void idVideoCDItem::Spawn( void ) {
1558 }
1559 
1560 /*
1561 ================
1562 idVideoCDItem::GiveToPlayer
1563 ================
1564 */
1566  idStr str = spawnArgs.GetString( "video" );
1567  if ( player && str.Length() ) {
1568  player->GiveVideo( str, &spawnArgs );
1569  }
1570  return true;
1571 }
1572 
1573 /*
1574 ===============================================================================
1575 
1576  idPDAItem
1577 
1578 ===============================================================================
1579 */
1580 
1582 END_CLASS
1583 
1584 /*
1585 ================
1586 idPDAItem::GiveToPlayer
1587 ================
1588 */
1589 bool idPDAItem::GiveToPlayer(idPlayer *player) {
1590  const char *str = spawnArgs.GetString( "pda_name" );
1591  if ( player ) {
1592  player->GivePDA( str, &spawnArgs );
1593  }
1594  return true;
1595 }
1596 
1597 /*
1598 ===============================================================================
1599 
1600  idMoveableItem
1601 
1602 ===============================================================================
1603 */
1604 
1606  EVENT( EV_DropToFloor, idMoveableItem::Event_DropToFloor )
1607  EVENT( EV_Gib, idMoveableItem::Event_Gib )
1608 END_CLASS
1609 
1610 /*
1611 ================
1612 idMoveableItem::idMoveableItem
1613 ================
1614 */
1616  trigger = NULL;
1617  smoke = NULL;
1618  smokeTime = 0;
1619 #ifdef _D3XP
1620  nextSoundTime = 0;
1621 #endif
1622 #ifdef CTF
1623  repeatSmoke = false;
1624 #endif
1625 }
1626 
1627 /*
1628 ================
1629 idMoveableItem::~idMoveableItem
1630 ================
1631 */
1633  if ( trigger ) {
1634  delete trigger;
1635  }
1636 }
1637 
1638 /*
1639 ================
1640 idMoveableItem::Save
1641 ================
1642 */
1643 void idMoveableItem::Save( idSaveGame *savefile ) const {
1644  savefile->WriteStaticObject( physicsObj );
1645 
1646  savefile->WriteClipModel( trigger );
1647 
1648  savefile->WriteParticle( smoke );
1649  savefile->WriteInt( smokeTime );
1650 #ifdef _D3XP
1651  savefile->WriteInt( nextSoundTime );
1652 #endif
1653 }
1654 
1655 /*
1656 ================
1657 idMoveableItem::Restore
1658 ================
1659 */
1661  savefile->ReadStaticObject( physicsObj );
1663 
1664  savefile->ReadClipModel( trigger );
1665 
1666  savefile->ReadParticle( smoke );
1667  savefile->ReadInt( smokeTime );
1668 #ifdef _D3XP
1669  savefile->ReadInt( nextSoundTime );
1670 #endif
1671 }
1672 
1673 /*
1674 ================
1675 idMoveableItem::Spawn
1676 ================
1677 */
1679  idTraceModel trm;
1680  float density, friction, bouncyness, tsize;
1681  idStr clipModelName;
1682  idBounds bounds;
1683 #ifdef _D3XP
1684  SetTimeState ts( timeGroup );
1685 #endif
1686 
1687  // create a trigger for item pickup
1688  spawnArgs.GetFloat( "triggersize", "16.0", tsize );
1689  trigger = new idClipModel( idTraceModel( idBounds( vec3_origin ).Expand( tsize ) ) );
1690  trigger->Link( gameLocal.clip, this, 0, GetPhysics()->GetOrigin(), GetPhysics()->GetAxis() );
1692 
1693  // check if a clip model is set
1694  spawnArgs.GetString( "clipmodel", "", clipModelName );
1695  if ( !clipModelName[0] ) {
1696  clipModelName = spawnArgs.GetString( "model" ); // use the visual model
1697  }
1698 
1699  // load the trace model
1700  if ( !collisionModelManager->TrmFromModel( clipModelName, trm ) ) {
1701  gameLocal.Error( "idMoveableItem '%s': cannot load collision model %s", name.c_str(), clipModelName.c_str() );
1702  return;
1703  }
1704 
1705  // if the model should be shrinked
1706  if ( spawnArgs.GetBool( "clipshrink" ) ) {
1707  trm.Shrink( CM_CLIP_EPSILON );
1708  }
1709 
1710  // get rigid body properties
1711  spawnArgs.GetFloat( "density", "0.5", density );
1712  density = idMath::ClampFloat( 0.001f, 1000.0f, density );
1713  spawnArgs.GetFloat( "friction", "0.05", friction );
1714  friction = idMath::ClampFloat( 0.0f, 1.0f, friction );
1715  spawnArgs.GetFloat( "bouncyness", "0.6", bouncyness );
1716  bouncyness = idMath::ClampFloat( 0.0f, 1.0f, bouncyness );
1717 
1718  // setup the physics
1719  physicsObj.SetSelf( this );
1720  physicsObj.SetClipModel( new idClipModel( trm ), density );
1721  physicsObj.SetOrigin( GetPhysics()->GetOrigin() );
1722  physicsObj.SetAxis( GetPhysics()->GetAxis() );
1723  physicsObj.SetBouncyness( bouncyness );
1724  physicsObj.SetFriction( 0.6f, 0.6f, friction );
1728  SetPhysics( &physicsObj );
1729 
1730  smoke = NULL;
1731  smokeTime = 0;
1732 #ifdef _D3XP
1733  nextSoundTime = 0;
1734 #endif
1735  const char *smokeName = spawnArgs.GetString( "smoke_trail" );
1736  if ( *smokeName != '\0' ) {
1737  smoke = static_cast<const idDeclParticle *>( declManager->FindType( DECL_PARTICLE, smokeName ) );
1740  }
1741 
1742 #ifdef CTF
1743  repeatSmoke = spawnArgs.GetBool( "repeatSmoke", "0" );
1744 #endif
1745 }
1746 
1747 /*
1748 ================
1749 idMoveableItem::Think
1750 ================
1751 */
1753 
1754  RunPhysics();
1755 
1756  if ( thinkFlags & TH_PHYSICS ) {
1757  // update trigger position
1758  trigger->Link( gameLocal.clip, this, 0, GetPhysics()->GetOrigin(), mat3_identity );
1759  }
1760 
1761  if ( thinkFlags & TH_UPDATEPARTICLES ) {
1763 #ifdef CTF
1764  if ( !repeatSmoke ) {
1765  smokeTime = 0;
1766  BecomeInactive( TH_UPDATEPARTICLES );
1767  } else {
1769  }
1770 #else
1771  smokeTime = 0;
1772  BecomeInactive( TH_UPDATEPARTICLES );
1773 #endif
1774  }
1775  }
1776 
1777  Present();
1778 }
1779 
1780 #ifdef _D3XP
1781 /*
1782 =================
1783 idMoveableItem::Collide
1784 =================
1785 */
1786 bool idMoveableItem::Collide( const trace_t &collision, const idVec3 &velocity ) {
1787  float v, f;
1788 
1789  v = -( velocity * collision.c.normal );
1790  if ( v > 80 && gameLocal.time > nextSoundTime ) {
1791  f = v > 200 ? 1.0f : idMath::Sqrt( v - 80 ) * 0.091f;
1792  if ( StartSound( "snd_bounce", SND_CHANNEL_ANY, 0, false, NULL ) ) {
1793  // don't set the volume unless there is a bounce sound as it overrides the entire channel
1794  // which causes footsteps on ai's to not honor their shader parms
1795  SetSoundVolume( f );
1796  }
1797  nextSoundTime = gameLocal.time + 500;
1798  }
1799 
1800  return false;
1801 }
1802 #endif
1803 
1804 /*
1805 ================
1806 idMoveableItem::Pickup
1807 ================
1808 */
1810  bool ret = idItem::Pickup( player );
1811  if ( ret ) {
1812  trigger->SetContents( 0 );
1813  }
1814  return ret;
1815 }
1816 
1817 /*
1818 ================
1819 idMoveableItem::DropItem
1820 ================
1821 */
1822 idEntity *idMoveableItem::DropItem( const char *classname, const idVec3 &origin, const idMat3 &axis, const idVec3 &velocity, int activateDelay, int removeDelay ) {
1823  idDict args;
1824  idEntity *item;
1825 
1826  args.Set( "classname", classname );
1827  args.Set( "dropped", "1" );
1828 
1829  // we sometimes drop idMoveables here, so set 'nodrop' to 1 so that it doesn't get put on the floor
1830  args.Set( "nodrop", "1" );
1831 
1832  if ( activateDelay ) {
1833  args.SetBool( "triggerFirst", true );
1834  }
1835 
1836  gameLocal.SpawnEntityDef( args, &item );
1837  if ( item ) {
1838  // set item position
1839  item->GetPhysics()->SetOrigin( origin );
1840  item->GetPhysics()->SetAxis( axis );
1841  item->GetPhysics()->SetLinearVelocity( velocity );
1842  item->UpdateVisuals();
1843  if ( activateDelay ) {
1844  item->PostEventMS( &EV_Activate, activateDelay, item );
1845  }
1846  if ( !removeDelay ) {
1847  removeDelay = 5 * 60 * 1000;
1848  }
1849  // always remove a dropped item after 5 minutes in case it dropped to an unreachable location
1850  item->PostEventMS( &EV_Remove, removeDelay );
1851  }
1852  return item;
1853 }
1854 
1855 /*
1856 ================
1857 idMoveableItem::DropItems
1858 
1859  The entity should have the following key/value pairs set:
1860  "def_drop<type>Item" "item def"
1861  "drop<type>ItemJoint" "joint name"
1862  "drop<type>ItemRotation" "pitch yaw roll"
1863  "drop<type>ItemOffset" "x y z"
1864  "skin_drop<type>" "skin name"
1865  To drop multiple items the following key/value pairs can be used:
1866  "def_drop<type>Item<X>" "item def"
1867  "drop<type>Item<X>Joint" "joint name"
1868  "drop<type>Item<X>Rotation" "pitch yaw roll"
1869  "drop<type>Item<X>Offset" "x y z"
1870  where <X> is an aribtrary string.
1871 ================
1872 */
1874  const idKeyValue *kv;
1875  const char *skinName, *c, *jointName;
1876  idStr key, key2;
1877  idVec3 origin;
1878  idMat3 axis;
1879  idAngles angles;
1880  const idDeclSkin *skin;
1881  jointHandle_t joint;
1882  idEntity *item;
1883 
1884  // drop all items
1885  kv = ent->spawnArgs.MatchPrefix( va( "def_drop%sItem", type ), NULL );
1886  while ( kv ) {
1887 
1888  c = kv->GetKey().c_str() + kv->GetKey().Length();
1889  if ( idStr::Icmp( c - 5, "Joint" ) != 0 && idStr::Icmp( c - 8, "Rotation" ) != 0 ) {
1890 
1891  key = kv->GetKey().c_str() + 4;
1892  key2 = key;
1893  key += "Joint";
1894  key2 += "Offset";
1895  jointName = ent->spawnArgs.GetString( key );
1896  joint = ent->GetAnimator()->GetJointHandle( jointName );
1897  if ( !ent->GetJointWorldTransform( joint, gameLocal.time, origin, axis ) ) {
1898  gameLocal.Warning( "%s refers to invalid joint '%s' on entity '%s'\n", key.c_str(), jointName, ent->name.c_str() );
1899  origin = ent->GetPhysics()->GetOrigin();
1900  axis = ent->GetPhysics()->GetAxis();
1901  }
1902  if ( g_dropItemRotation.GetString()[0] ) {
1903  angles.Zero();
1904  sscanf( g_dropItemRotation.GetString(), "%f %f %f", &angles.pitch, &angles.yaw, &angles.roll );
1905  } else {
1906  key = kv->GetKey().c_str() + 4;
1907  key += "Rotation";
1908  ent->spawnArgs.GetAngles( key, "0 0 0", angles );
1909  }
1910  axis = angles.ToMat3() * axis;
1911 
1912  origin += ent->spawnArgs.GetVector( key2, "0 0 0" );
1913 
1914  item = DropItem( kv->GetValue(), origin, axis, vec3_origin, 0, 0 );
1915  if ( list && item ) {
1916  list->Append( item );
1917  }
1918  }
1919 
1920  kv = ent->spawnArgs.MatchPrefix( va( "def_drop%sItem", type ), kv );
1921  }
1922 
1923  // change the skin to hide all items
1924  skinName = ent->spawnArgs.GetString( va( "skin_drop%s", type ) );
1925  if ( skinName[0] ) {
1926  skin = declManager->FindSkin( skinName );
1927  ent->SetSkin( skin );
1928  }
1929 }
1930 
1931 /*
1932 ======================
1933 idMoveableItem::WriteToSnapshot
1934 ======================
1935 */
1937  physicsObj.WriteToSnapshot( msg );
1938 }
1939 
1940 /*
1941 ======================
1942 idMoveableItem::ReadFromSnapshot
1943 ======================
1944 */
1947  if ( msg.HasChanged() ) {
1948  UpdateVisuals();
1949  }
1950 }
1951 
1952 /*
1953 ============
1954 idMoveableItem::Gib
1955 ============
1956 */
1957 void idMoveableItem::Gib( const idVec3 &dir, const char *damageDefName ) {
1958  // spawn smoke puff
1959  const char *smokeName = spawnArgs.GetString( "smoke_gib" );
1960  if ( *smokeName != '\0' ) {
1961  const idDeclParticle *smoke = static_cast<const idDeclParticle *>( declManager->FindType( DECL_PARTICLE, smokeName ) );
1963  }
1964  // remove the entity
1965  PostEventMS( &EV_Remove, 0 );
1966 }
1967 
1968 /*
1969 ================
1970 idMoveableItem::Event_DropToFloor
1971 ================
1972 */
1974  // the physics will drop the moveable to the floor
1975 }
1976 
1977 /*
1978 ============
1979 idMoveableItem::Event_Gib
1980 ============
1981 */
1982 void idMoveableItem::Event_Gib( const char *damageDefName ) {
1983  Gib( idVec3( 0, 0, 1 ), damageDefName );
1984 }
1985 
1986 /*
1987 ===============================================================================
1988 
1989  idMoveablePDAItem
1990 
1991 ===============================================================================
1992 */
1993 
1995 END_CLASS
1996 
1997 /*
1998 ================
1999 idMoveablePDAItem::GiveToPlayer
2000 ================
2001 */
2002 bool idMoveablePDAItem::GiveToPlayer(idPlayer *player) {
2003  const char *str = spawnArgs.GetString( "pda_name" );
2004  if ( player ) {
2005  player->GivePDA( str, &spawnArgs );
2006  }
2007  return true;
2008 }
2009 
2010 /*
2011 ===============================================================================
2012 
2013  idItemRemover
2014 
2015 ===============================================================================
2016 */
2017 
2019  EVENT( EV_Activate, idItemRemover::Event_Trigger )
2020 END_CLASS
2021 
2022 /*
2023 ================
2024 idItemRemover::Spawn
2025 ================
2026 */
2027 void idItemRemover::Spawn( void ) {
2028 }
2029 
2030 /*
2031 ================
2032 idItemRemover::RemoveItem
2033 ================
2034 */
2036  const char *remove;
2037 
2038  remove = spawnArgs.GetString( "remove" );
2039  player->RemoveInventoryItem( remove );
2040 }
2041 
2042 /*
2043 ================
2044 idItemRemover::Event_Trigger
2045 ================
2046 */
2048  if ( activator->IsType( idPlayer::Type ) ) {
2049  RemoveItem( static_cast<idPlayer *>(activator) );
2050  }
2051 }
2052 
2053 /*
2054 ===============================================================================
2055 
2056  idObjectiveComplete
2057 
2058 ===============================================================================
2059 */
2060 
2062  EVENT( EV_Activate, idObjectiveComplete::Event_Trigger )
2063  EVENT( EV_HideObjective, idObjectiveComplete::Event_HideObjective )
2064  EVENT( EV_GetPlayerPos, idObjectiveComplete::Event_GetPlayerPos )
2065 END_CLASS
2066 
2067 /*
2068 ================
2069 idObjectiveComplete::idObjectiveComplete
2070 ================
2071 */
2073  playerPos.Zero();
2074 }
2075 
2076 /*
2077 ================
2078 idObjectiveComplete::Save
2079 ================
2080 */
2081 void idObjectiveComplete::Save( idSaveGame *savefile ) const {
2082  savefile->WriteVec3( playerPos );
2083 }
2084 
2085 /*
2086 ================
2087 idObjectiveComplete::Restore
2088 ================
2089 */
2091  savefile->ReadVec3( playerPos );
2092 }
2093 
2094 /*
2095 ================
2096 idObjectiveComplete::Spawn
2097 ================
2098 */
2100  spawnArgs.SetBool( "objEnabled", false );
2101  Hide();
2102 }
2103 
2104 /*
2105 ================
2106 idObjectiveComplete::Event_Trigger
2107 ================
2108 */
2110  if ( !spawnArgs.GetBool( "objEnabled" ) ) {
2111  return;
2112  }
2113  idPlayer *player = gameLocal.GetLocalPlayer();
2114  if ( player ) {
2115  RemoveItem( player );
2116 
2117  if ( spawnArgs.GetString( "inv_objective", NULL ) ) {
2118  if ( player->hud ) {
2119  player->hud->SetStateString( "objective", "2");
2120 
2121  player->hud->SetStateString( "objectivetext", spawnArgs.GetString( "objectivetext" ) );
2122 #ifdef _D3XP
2123  player->hud->SetStateString( "objectivecompletetitle", spawnArgs.GetString( "objectivetitle" ) );
2124 #else
2125  player->hud->SetStateString( "objectivetitle", spawnArgs.GetString( "objectivetitle" ) );
2126 #endif
2127  player->CompleteObjective( spawnArgs.GetString( "objectivetitle" ) );
2128  PostEventMS( &EV_GetPlayerPos, 2000 );
2129  }
2130  }
2131  }
2132 }
2133 
2134 /*
2135 ================
2136 idObjectiveComplete::Event_GetPlayerPos
2137 ================
2138 */
2140  idPlayer *player = gameLocal.GetLocalPlayer();
2141  if ( player ) {
2142  playerPos = player->GetPhysics()->GetOrigin();
2143  PostEventMS( &EV_HideObjective, 100, player );
2144  }
2145 }
2146 
2147 /*
2148 ================
2149 idObjectiveComplete::Event_HideObjective
2150 ================
2151 */
2153  idPlayer *player = gameLocal.GetLocalPlayer();
2154  if ( player ) {
2155  idVec3 v = player->GetPhysics()->GetOrigin();
2156  v -= playerPos;
2157  if ( v.Length() > 64.0f ) {
2158  player->hud->HandleNamedEvent( "closeObjective" );
2159  PostEventMS( &EV_Remove, 0 );
2160  } else {
2161  PostEventMS( &EV_HideObjective, 100, player );
2162  }
2163  }
2164 }
virtual const idVec3 & GetOrigin(int id=0) const =0
jointHandle_t
Definition: Model.h:156
idPlayer * GetLocalPlayer() const
void SetClipModel(idClipModel *model, float density, int id=0, bool freeOld=true)
virtual void UnCrop()=0
renderEntity_t renderEntity
Definition: Entity.h:371
void BeginWriting(void)
Definition: BitMsg.h:265
void Save(idSaveGame *savefile) const
Definition: Item.cpp:94
float GetFloat(const char *key, const char *defaultString="0") const
Definition: Dict.h:248
virtual bool TrmFromModel(const char *modelName, idTraceModel &trm)=0
virtual void Present()
Definition: Item.cpp:242
int num_entities
Definition: Game_local.h:278
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)
int GetInt(const char *key, const char *defaultString="0") const
Definition: Dict.h:252
idStr & SetFileExtension(const char *extension)
Definition: Str.cpp:743
bool PostEventSec(const idEventDef *ev, float time)
Definition: Class.cpp:747
void ReadParticle(const idDeclParticle *&particle)
Definition: SaveGame.cpp:1164
void Link(idClip &clp)
Definition: Clip.cpp:545
idCVarSystem * cvarSystem
Definition: CVarSystem.cpp:487
virtual void FreeLightDef(qhandle_t lightHandle)=0
idMat3 mat3_identity(idVec3(1, 0, 0), idVec3(0, 1, 0), idVec3(0, 0, 1))
void RemoveItem(idPlayer *player)
Definition: Item.cpp:2035
virtual void SetContents(int contents, int id=-1)=0
void ReadMaterial(const idMaterial *&material)
Definition: SaveGame.cpp:1132
void CallFunction(const function_t *func, bool clearStack)
idClip clip
Definition: Game_local.h:296
virtual void SetStateString(const char *varName, const char *value)=0
void SetContents(int newContents)
Definition: Clip.h:166
struct idEntity::entityFlags_s fl
float y
Definition: Vector.h:55
void DelayedStart(int delay)
const int MAX_EVENT_PARAM_SIZE
Definition: Game_local.h:132
idSmokeParticles * smokeParticles
Definition: Game_local.h:307
const GLdouble * v
Definition: glext.h:2936
bool GiveItem(idItem *item)
const idStr & GetKey(void) const
Definition: Dict.h:52
const idEventDef EV_Activate("activate","e")
bool isNewFrame
Definition: Game_local.h:333
const idEventDef EV_DropToFloor("<dropToFloor>")
idEntity * GetBindMaster(void) const
Definition: Entity.cpp:2153
virtual qhandle_t AddEntityDef(const renderEntity_t *re)=0
const idEventDef EV_RespawnFx("<respawnFx>")
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:4804
idRandom random
Definition: Game_local.h:291
int lastCycle
Definition: Item.h:91
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
bool isMultiplayer
Definition: Game_local.h:325
idAngles GetAngles(const char *key, const char *defaultString=NULL) const
Definition: Dict.h:278
bool IsType(const idTypeInfo &c) const
Definition: Class.h:337
void SetAngles(const idAngles &ang)
Definition: Entity.cpp:2812
idEntity * FindEntity(const char *name) const
const int SCREEN_HEIGHT
Definition: RenderSystem.h:154
idRenderSystem * renderSystem
float z
Definition: Vector.h:320
#define MASK_SOLID
Definition: Game_local.h:735
const idKeyValue * MatchPrefix(const char *prefix, const idKeyValue *lastMatch=NULL) const
Definition: Dict.cpp:523
case const int
Definition: Callbacks.cpp:52
static void DropItems(idAnimatedEntity *ent, const char *type, idList< idEntity * > *list)
Definition: Item.cpp:1873
const idEventDef EV_Gib("gib","s")
const idDeclParticle * smoke
Definition: Item.h:186
void WriteBits(int value, int numBits)
Definition: BitMsg.cpp:648
void PrintMessageEvent(int to, msg_evt_t evt, int parm1=-1, int parm2=-1)
idPhysics_RigidBody physicsObj
Definition: Item.h:184
void Spawn(void)
Definition: Item.cpp:1678
static float ClampFloat(float min, float max, float value)
Definition: Math.h:893
jointHandle_t GetJointHandle(const char *name) const
void Event_Trigger(idEntity *activator)
Definition: Item.cpp:1475
Definition: Vector.h:316
case const float
Definition: Callbacks.cpp:62
void ReadBool(bool &value)
Definition: SaveGame.cpp:976
virtual void Think(void)
Definition: Item.cpp:1752
bool isServer
Definition: Game_local.h:326
void WriteStaticObject(const idClass &obj)
Definition: SaveGame.cpp:348
static float Sqrt(float x)
Definition: Math.h:302
virtual void GetGLSettings(int &width, int &height)=0
void Spawn()
Definition: Item.cpp:629
virtual void HandleNamedEvent(const char *eventName)=0
idVec3 orgOrigin
Definition: Item.h:79
const char * Left(int len, idStr &result) const
Definition: Str.h:892
int team
Definition: Actor.h:115
virtual ~idItem()
Definition: Item.cpp:82
void Spawn()
Definition: Item.cpp:1397
virtual void SetLinearVelocity(const idVec3 &newLinearVelocity, int id=0)=0
idVec3 playerPos
Definition: Item.h:133
virtual void Think(void)
Definition: Item.cpp:216
GLuint GLuint GLsizei GLenum type
Definition: glext.h:2845
void Event_RespawnFx(void)
Definition: Item.cpp:567
virtual void SetStateInt(const char *varName, const int value)=0
virtual const idMaterial * FindMaterial(const char *name, bool makeDefault=true)=0
void ReadFromSnapshot(const idBitMsgDelta &msg)
void SetSoundVolume(float volume)
Definition: Entity.cpp:1740
void Set(const char *key, const char *value)
Definition: Dict.cpp:275
int ReadBits(int numBits) const
Definition: BitMsg.cpp:709
idDict spawnArgs
Definition: Entity.h:122
void WriteClipModel(const class idClipModel *clipModel)
Definition: SaveGame.cpp:744
void Event_HideObjective(idEntity *e)
Definition: Item.cpp:2152
int i
Definition: process.py:33
contactInfo_t c
idClipModel * trigger
Definition: Item.h:185
deferredEntityCallback_t callback
Definition: RenderWorld.h:96
void WriteVec3(const idVec3 &vec)
Definition: SaveGame.cpp:253
bool HasChanged(void) const
Definition: BitMsg.h:534
idAngles & Zero(void)
Definition: Angles.h:126
idMultiplayerGame::gameState_t GetGameState(void) const
const idMaterial * customShader
Definition: RenderWorld.h:123
void Event_DropToFloor(void)
Definition: Item.cpp:1973
int Icmp(const char *text) const
Definition: Str.h:667
void WriteMaterial(const idMaterial *material)
Definition: SaveGame.cpp:380
#define EVENT(event, function)
Definition: Class.h:53
void RemoveInventoryItem(idDict *item)
void Init(byte *data, int length)
Definition: BitMsg.h:155
const char * GetMapName(void) const
idVec3 endpos
idProgram program
Definition: Game_local.h:293
virtual bool Pickup(idPlayer *player)
Definition: Item.cpp:365
void WriteBool(const bool value)
Definition: SaveGame.cpp:222
idVec3 playerPos
Definition: Item.h:307
virtual renderView_t * GetRenderView()
Definition: Entity.cpp:1577
bool canPickUp
Definition: Item.h:82
bool IsHidden(void) const
Definition: Entity.cpp:1217
const idEventDef EV_HideObjective("<hideobjective>","e")
void void void Warning(const char *fmt,...) const id_attribute((format(printf
Definition: Game_local.cpp:735
virtual bool GiveToPlayer(idPlayer *player)
Definition: Item.cpp:1565
void Save(idSaveGame *savefile) const
Definition: Item.cpp:1643
int RandomInt(void)
Definition: Random.h:70
virtual void Show(void)
Definition: Entity.cpp:1239
bool GivePowerUp(int powerup, int time)
void SetSelf(idEntity *e)
void Event_Trigger(idEntity *activator)
Definition: Item.cpp:2109
virtual void FreeEntityDef(qhandle_t entityHandle)=0
idCVar g_dropItemRotation("g_dropItemRotation","", CVAR_GAME,"")
virtual bool GiveToPlayer(idPlayer *player)
Definition: Item.cpp:348
void Event_Respawn(void)
Definition: Item.cpp:548
void Spawn(void)
Definition: Item.cpp:270
Definition: Vector.h:52
virtual void CaptureRenderToFile(const char *fileName, bool fixAlpha=false)=0
idPhysics * GetPhysics(void) const
Definition: Entity.cpp:2607
bool pulse
Definition: Item.h:81
void SetSkin(const idDeclSkin *skin)
Definition: Entity.cpp:1178
int inViewTime
Definition: Item.h:90
const GLubyte * c
Definition: glext.h:4677
const char * GetString(const char *key, const char *defaultString="") const
Definition: Dict.h:240
virtual void CaptureRenderToImage(const char *imageName)=0
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:3454
bool SpawnEntityDef(const idDict &args, idEntity **ent=NULL, bool setDefaults=true)
float Length(void) const
Definition: Vector.h:631
virtual bool Collide(const trace_t &collision, const idVec3 &velocity)
Definition: Entity.cpp:2868
idStr & StripFileExtension(void)
Definition: Str.cpp:757
idEntity * cameraTarget
Definition: Entity.h:130
bool StartSound(const char *soundName, const s_channelType channel, int soundShaderFlags, bool broadcast, int *length)
Definition: Entity.cpp:1622
void GiveVideo(const char *videoName, idDict *item)
idVec3 vec3_origin(0.0f, 0.0f, 0.0f)
void SetPhysics(idPhysics *phys)
Definition: Entity.cpp:2574
void WriteToSnapshot(idBitMsgDelta &msg) const
void Gib(const idVec3 &dir, const char *damageDefName)
Definition: Item.cpp:1957
bool GetBool(const char *key, const char *defaultString="0") const
Definition: Dict.h:256
Definition: Dict.h:65
#define NULL
Definition: Lib.h:88
void Restore(idRestoreGame *savefile)
Definition: Item.cpp:114
bool UpdateRenderEntity(renderEntity_s *renderEntity, const renderView_t *renderView) const
Definition: Item.cpp:136
void Event_Trigger(idEntity *activator)
Definition: Item.cpp:531
void void DPrintf(const char *fmt,...) const id_attribute((format(printf
Definition: Game_local.cpp:715
virtual const idDecl * FindType(declType_t type, const char *name, bool makeDefault=true)=0
void Event_GetPlayerPos()
Definition: Item.cpp:2139
idVec3 GetVector(const char *key, const char *defaultString=NULL) const
Definition: Dict.h:260
void Event_DropToFloor(void)
Definition: Item.cpp:497
void ServerSendEvent(int eventId, const idBitMsg *msg, bool saveEvent, int excludeClient) const
Definition: Entity.cpp:4897
static bool ModelCallback(renderEntity_s *renderEntity, const renderView_t *renderView)
Definition: Item.cpp:195
virtual void SetOrigin(const idVec3 &newOrigin, int id=-1)=0
void CancelEvents(const idEventDef *ev)
Definition: Class.cpp:619
const idVec3 & GetGravity(void) const
#define CM_CLIP_EPSILON
int time
Definition: Item.h:117
Definition: Item.h:41
float x
Definition: Vector.h:54
float roll
Definition: Angles.h:55
const idStr & GetValue(void) const
Definition: Dict.h:53
void Save(idSaveGame *savefile) const
Definition: Item.cpp:2081
float shaderParms[MAX_GLOBAL_SHADER_PARMS]
Definition: RenderWorld.h:223
virtual const idMat3 & GetAxis(int id=0) const =0
void Event_Trigger(idEntity *activator)
Definition: Item.cpp:2047
virtual idAnimator * GetAnimator(void)
Definition: Entity.cpp:5213
virtual void UpdateEntityDef(qhandle_t entityHandle, const renderEntity_t *re)=0
void SetFriction(const float linear, const float angular, const float contact)
idUserInterface * hud
Definition: Player.h:293
const char * Right(int len, idStr &result) const
Definition: Str.h:896
void Save(idSaveGame *savefile) const
Definition: Item.cpp:609
virtual bool Pickup(idPlayer *player)
Definition: Item.cpp:1809
float pitch
Definition: Angles.h:53
idGameLocal gameLocal
Definition: Game_local.cpp:64
void SetBool(const char *key, bool val)
Definition: Dict.h:196
bool RunPhysics(void)
Definition: Entity.cpp:2616
#define END_CLASS
Definition: Class.h:54
virtual void ReadFromSnapshot(const idBitMsgDelta &msg)
Definition: Item.cpp:1945
bool GiveInventoryItem(idDict *item)
virtual void Hide(void)
Definition: Entity.cpp:1226
void SetAxis(const idMat3 &newAxis, int id=-1)
virtual idClipModel * GetClipModel(int id=0) const =0
void WriteInt(const int value)
Definition: SaveGame.cpp:168
int numClients
Definition: Game_local.h:271
virtual void Present(void)
Definition: Entity.cpp:1471
int lastRenderViewTime
Definition: Item.h:92
static idEntity * DropItem(const char *classname, const idVec3 &origin, const idMat3 &axis, const idVec3 &velocity, int activateDelay, int removeDelay)
Definition: Item.cpp:1822
void Restore(idRestoreGame *savefile)
Definition: Item.cpp:2090
idDeclManager * declManager
idEntity * entities[MAX_GENTITIES]
Definition: Game_local.h:275
void Shrink(const float m)
virtual bool ClientReceiveEvent(int event, int time, const idBitMsg &msg)
Definition: Entity.cpp:4988
const char * GetString(void) const
Definition: CVarSystem.h:141
idVec3 vieworg
Definition: RenderWorld.h:215
void SetContents(int contents, int id=-1)
void ReadStaticObject(idClass &obj)
Definition: SaveGame.cpp:1098
virtual void WriteToSnapshot(idBitMsgDelta &msg) const
Definition: Item.cpp:1936
void ReadClipModel(idClipModel *&clipModel)
Definition: SaveGame.cpp:1519
int Append(const type &obj)
Definition: List.h:646
virtual ~idMoveableItem()
Definition: Item.cpp:1632
bool TraceBounds(trace_t &results, const idVec3 &start, const idVec3 &end, const idBounds &bounds, int contentMask, const idEntity *passEntity)
Definition: Clip.h:338
Definition: Matrix.h:333
virtual void ClientPredictionThink(void)
Definition: Item.cpp:424
const idEventDef EV_CamShot("<camshot>")
const int SCREEN_WIDTH
Definition: RenderSystem.h:153
void SetClipMask(int mask, int id=-1)
float yaw
Definition: Angles.h:54
void UpdateVisuals(void)
Definition: Entity.cpp:1310
bool GetBool(void) const
Definition: CVarSystem.h:142
tuple f
Definition: idal.py:89
bool LoadModel(const char *name)
Definition: Clip.cpp:215
bool IsGametypeFlagBased(void)
void GetAttributes(idDict &attributes)
Definition: Item.cpp:331
idMat3 ToMat3(void) const
Definition: Angles.cpp:199
unsigned char byte
Definition: Lib.h:75
const GLcharARB * name
Definition: glext.h:3629
idCVar pm_thirdPerson("pm_thirdPerson","0", CVAR_GAME|CVAR_NETWORKSYNC|CVAR_BOOL,"enables third person view")
bool GetJointWorldTransform(jointHandle_t jointHandle, int currentTime, idVec3 &offset, idMat3 &axis)
Definition: Entity.cpp:5248
void Save(idSaveGame *savefile) const
Definition: Item.cpp:1379
#define CLASS_DECLARATION(nameofsuperclass, nameofclass)
Definition: Class.h:110
Definition: Str.h:116
idBounds bounds
Definition: RenderWorld.h:95
void Restore(idRestoreGame *savefile)
Definition: Item.cpp:1660
void Event_Gib(const char *damageDefName)
Definition: Item.cpp:1982
void ReadVec3(idVec3 &vec)
Definition: SaveGame.cpp:1011
const char * c_str(void) const
Definition: Str.h:487
virtual void WriteToSnapshot(idBitMsgDelta &msg) const
Definition: Item.cpp:437
virtual void RenderScene(const renderView_t *renderView)=0
void RestorePhysics(idPhysics *phys)
Definition: Entity.cpp:2596
void BecomeActive(int flags)
Definition: Entity.cpp:995
void Event_HideObjective(idEntity *e)
Definition: Item.cpp:1528
virtual bool GetCVarBool(const char *name) const =0
const idKeyValue * GetKeyVal(int index) const
Definition: Dict.h:294
const idEventDef EV_Remove("<immediateremove>", NULL)
virtual void ReadFromSnapshot(const idBitMsgDelta &msg)
Definition: Item.cpp:446
void Restore(idRestoreGame *savefile)
Definition: Item.cpp:619
bool inView
Definition: Item.h:89
function_t * FindFunction(const char *name) const
void HideObjective(void)
unsigned char bool
Definition: setup.h:74
const idEventDef EV_GetPlayerPos("<getplayerpos>")
virtual const idDeclSkin * FindSkin(const char *name, bool makeDefault=true)=0
virtual void CropRenderSize(int width, int height, bool makePowerOfTwo=false, bool forceDimensions=false)=0
void SetGravity(const idVec3 &newGravity)
void Restore(idRestoreGame *savefile)
Definition: Item.cpp:1388
void Event_GetPlayerPos()
Definition: Item.cpp:1515
idRenderWorld * gameRenderWorld
Definition: Game_local.cpp:55
virtual bool GiveToPlayer(idPlayer *player)
Definition: Item.cpp:639
char * va(const char *fmt,...)
Definition: Str.cpp:1568
void Event_Touch(idEntity *other, trace_t *trace)
Definition: Item.cpp:514
static idEntityFx * StartFx(const char *fx, const idVec3 *useOrigin, const idMat3 *useAxis, idEntity *ent, bool bind)
Definition: Fx.cpp:716
void WriteBits(int value, int numBits)
Definition: BitMsg.cpp:110
#define GENTITYNUM_BITS
Definition: Game_local.h:82
bool PostEventMS(const idEventDef *ev, int time)
Definition: Class.cpp:666
void SetOrigin(const idVec3 &org)
Definition: Entity.cpp:2784
idMultiplayerGame mpGame
Definition: Game_local.h:305
bool spin
Definition: Item.h:80
int entityNumber
Definition: Entity.h:111
int itemShellHandle
Definition: Item.h:85
void CompleteObjective(const char *title)
idMat3 viewaxis
Definition: RenderWorld.h:216
idStr name
Definition: Entity.h:121
int thinkFlags
Definition: Entity.h:125
const idEventDef EV_Touch("<touch>","et")
void WriteParticle(const idDeclParticle *particle)
Definition: SaveGame.cpp:406
GLdouble GLdouble z
Definition: glext.h:3067
void SetBouncyness(const float b)
int GetNumKeyVals(void) const
Definition: Dict.h:290
float shaderParms[MAX_ENTITY_SHADER_PARMS]
Definition: RenderWorld.h:127
void GiveObjective(const char *title, const char *text, const char *screenshot)
void BecomeInactive(int flags)
Definition: Entity.cpp:1025
bool spectating
Definition: Player.h:340
int smokeTime
Definition: Item.h:187
int ReadBits(int numBits) const
Definition: BitMsg.cpp:362
const idEventDef EV_RespawnItem("respawn")
void ReadInt(int &value)
Definition: SaveGame.cpp:922
float CRandomFloat(void)
Definition: Random.h:86
void Event_CamShot()
Definition: Item.cpp:1409
idCollisionModelManager * collisionModelManager
void ActivateTargets(idEntity *activator) const
Definition: Entity.cpp:3650
const idMaterial * shellMaterial
Definition: Item.h:86
void SetOrigin(const idVec3 &newOrigin, int id=-1)
virtual bool ClientReceiveEvent(int event, int time, const idBitMsg &msg)
Definition: Item.cpp:459
virtual void SetAxis(const idMat3 &newAxis, int id=-1)=0