Advertisement
Guest User

Untitled

a guest
Jan 28th, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 KB | None | 0 0
  1. =============
  2. SpawnCorpse
  3. A player is respawning, so make an entity that looks
  4. just like the existing corpse to leave behind.
  5. =============
  6. */
  7. void SpawnCorpse( gentity_t *ent )
  8. {
  9. gentity_t *body;
  10. int contents;
  11. vec3_t origin, dest;
  12. trace_t tr;
  13. float vDiff;
  14.  
  15. // prevent crashing everyone with bad corpsenum bug
  16. if( ent->client->pers.connected != CON_CONNECTED )
  17. return;
  18.  
  19. VectorCopy( ent->r.currentOrigin, origin );
  20.  
  21. trap_UnlinkEntity( ent );
  22.  
  23. // if client is in a nodrop area, don't leave the body
  24. contents = trap_PointContents( origin, -1 );
  25. if( contents & CONTENTS_NODROP )
  26. return;
  27.  
  28. body = G_Spawn( );
  29.  
  30. VectorCopy( ent->s.apos.trBase, body->s.angles );
  31. body->s.eFlags = EF_DEAD;
  32. body->s.eType = ET_CORPSE;
  33. body->s.number = body - g_entities;
  34. body->timestamp = level.time;
  35. body->s.event = 0;
  36. body->r.contents = CONTENTS_CORPSE;
  37. body->s.clientNum = ent->client->ps.stats[ STAT_PCLASS ];
  38. body->nonSegModel = ent->client->ps.persistant[ PERS_STATE ] & PS_NONSEGMODEL;
  39.  
  40. if( ent->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS )
  41. body->classname = "humanCorpse";
  42. else
  43. body->classname = "alienCorpse";
  44.  
  45. body->s.powerups = MAX_CLIENTS;
  46.  
  47. body->think = BodySink;
  48. body->nextthink = level.time + 20000;
  49.  
  50. body->s.legsAnim = ent->s.legsAnim;
  51.  
  52. if( !body->nonSegModel )
  53. {
  54. switch( body->s.legsAnim & ~ANIM_TOGGLEBIT )
  55. {
  56. case BOTH_DEATH1:
  57. case BOTH_DEAD1:
  58. body->s.torsoAnim = body->s.legsAnim = BOTH_DEAD1;
  59. break;
  60. case BOTH_DEATH2:
  61. case BOTH_DEAD2:
  62. body->s.torsoAnim = body->s.legsAnim = BOTH_DEAD2;
  63. break;
  64. case BOTH_DEATH3:
  65. case BOTH_DEAD3:
  66. default:
  67. body->s.torsoAnim = body->s.legsAnim = BOTH_DEAD3;
  68. break;
  69. }
  70. }
  71. else
  72. {
  73. switch( body->s.legsAnim & ~ANIM_TOGGLEBIT )
  74. {
  75. case NSPA_DEATH1:
  76. case NSPA_DEAD1:
  77. body->s.legsAnim = NSPA_DEAD1;
  78. break;
  79. case NSPA_DEATH2:
  80. case NSPA_DEAD2:
  81. body->s.legsAnim = NSPA_DEAD2;
  82. break;
  83. case NSPA_DEATH3:
  84. case NSPA_DEAD3:
  85. default:
  86. body->s.legsAnim = NSPA_DEAD3;
  87. break;
  88. }
  89. }
  90.  
  91. body->takedamage = qfalse;
  92.  
  93. body->health = ent->health = ent->client->ps.stats[ STAT_HEALTH ];
  94. ent->health = 0;
  95.  
  96. //change body dimensions
  97. BG_FindBBoxForClass( ent->client->ps.stats[ STAT_PCLASS ], NULL, NULL, NULL, body->r.mins, body->r.maxs );
  98. vDiff = body->r.mins[ 2 ] - ent->r.mins[ 2 ];
  99.  
  100. //drop down to match the *model* origins of ent and body
  101. VectorSet( dest, origin[ 0 ], origin[ 1 ], origin[ 2 ] - vDiff );
  102. trap_Trace( &tr, origin, body->r.mins, body->r.maxs, dest, body->s.number, body->clipmask );
  103. VectorCopy( tr.endpos, origin );
  104.  
  105. G_SetOrigin( body, origin );
  106. VectorCopy( origin, body->s.origin );
  107. body->s.pos.trType = TR_GRAVITY;
  108. body->s.pos.trTime = level.time;
  109. VectorCopy( ent->client->ps.velocity, body->s.pos.trDelta );
  110.  
  111. VectorCopy ( body->s.pos.trBase, body->r.currentOrigin );
  112. trap_LinkEntity( body );
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement