Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =============
- SpawnCorpse
- A player is respawning, so make an entity that looks
- just like the existing corpse to leave behind.
- =============
- */
- void SpawnCorpse( gentity_t *ent )
- {
- gentity_t *body;
- int contents;
- vec3_t origin, dest;
- trace_t tr;
- float vDiff;
- // prevent crashing everyone with bad corpsenum bug
- if( ent->client->pers.connected != CON_CONNECTED )
- return;
- VectorCopy( ent->r.currentOrigin, origin );
- trap_UnlinkEntity( ent );
- // if client is in a nodrop area, don't leave the body
- contents = trap_PointContents( origin, -1 );
- if( contents & CONTENTS_NODROP )
- return;
- body = G_Spawn( );
- VectorCopy( ent->s.apos.trBase, body->s.angles );
- body->s.eFlags = EF_DEAD;
- body->s.eType = ET_CORPSE;
- body->s.number = body - g_entities;
- body->timestamp = level.time;
- body->s.event = 0;
- body->r.contents = CONTENTS_CORPSE;
- body->s.clientNum = ent->client->ps.stats[ STAT_PCLASS ];
- body->nonSegModel = ent->client->ps.persistant[ PERS_STATE ] & PS_NONSEGMODEL;
- if( ent->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS )
- body->classname = "humanCorpse";
- else
- body->classname = "alienCorpse";
- body->s.powerups = MAX_CLIENTS;
- body->think = BodySink;
- body->nextthink = level.time + 20000;
- body->s.legsAnim = ent->s.legsAnim;
- if( !body->nonSegModel )
- {
- switch( body->s.legsAnim & ~ANIM_TOGGLEBIT )
- {
- case BOTH_DEATH1:
- case BOTH_DEAD1:
- body->s.torsoAnim = body->s.legsAnim = BOTH_DEAD1;
- break;
- case BOTH_DEATH2:
- case BOTH_DEAD2:
- body->s.torsoAnim = body->s.legsAnim = BOTH_DEAD2;
- break;
- case BOTH_DEATH3:
- case BOTH_DEAD3:
- default:
- body->s.torsoAnim = body->s.legsAnim = BOTH_DEAD3;
- break;
- }
- }
- else
- {
- switch( body->s.legsAnim & ~ANIM_TOGGLEBIT )
- {
- case NSPA_DEATH1:
- case NSPA_DEAD1:
- body->s.legsAnim = NSPA_DEAD1;
- break;
- case NSPA_DEATH2:
- case NSPA_DEAD2:
- body->s.legsAnim = NSPA_DEAD2;
- break;
- case NSPA_DEATH3:
- case NSPA_DEAD3:
- default:
- body->s.legsAnim = NSPA_DEAD3;
- break;
- }
- }
- body->takedamage = qfalse;
- body->health = ent->health = ent->client->ps.stats[ STAT_HEALTH ];
- ent->health = 0;
- //change body dimensions
- BG_FindBBoxForClass( ent->client->ps.stats[ STAT_PCLASS ], NULL, NULL, NULL, body->r.mins, body->r.maxs );
- vDiff = body->r.mins[ 2 ] - ent->r.mins[ 2 ];
- //drop down to match the *model* origins of ent and body
- VectorSet( dest, origin[ 0 ], origin[ 1 ], origin[ 2 ] - vDiff );
- trap_Trace( &tr, origin, body->r.mins, body->r.maxs, dest, body->s.number, body->clipmask );
- VectorCopy( tr.endpos, origin );
- G_SetOrigin( body, origin );
- VectorCopy( origin, body->s.origin );
- body->s.pos.trType = TR_GRAVITY;
- body->s.pos.trTime = level.time;
- VectorCopy( ent->client->ps.velocity, body->s.pos.trDelta );
- VectorCopy ( body->s.pos.trBase, body->r.currentOrigin );
- trap_LinkEntity( body );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement