/** * @brief G_AttachBodyParts * @param[in] ent */ static void G_AttachBodyParts(gentity_t *ent) { int i; gentity_t *list; for (i = 0; i < level.numConnectedClients; i++, list++) { list = g_entities + level.sortedClients[i]; // ok lets test everything under the sun if (list->inuse && (list->client->sess.sessionTeam == TEAM_AXIS || list->client->sess.sessionTeam == TEAM_ALLIES) && (list != ent) && list->r.linked && !(list->client->ps.pm_flags & PMF_LIMBO) && (list->client->ps.pm_type == PM_NORMAL || list->client->ps.pm_type == PM_DEAD) ) { list->client->tempHead = G_BuildHead(list, &refent, qtrue); list->client->tempLeg = G_BuildLeg(list, &refent, qfalse); } else { list->client->tempHead = NULL; list->client->tempLeg = NULL; } } }
qboolean IsLegShot( gentity_t *targ, vec3_t dir, vec3_t point, int mod ) { float height; float theight; gentity_t *leg; if (!(targ->client)) return qfalse; if (targ->health <= 0) return qfalse; if(!point) { return qfalse; } if(!IsHeadShotWeapon(mod)) { return qfalse; } leg = G_BuildLeg( targ ); if( leg ) { gentity_t *traceEnt; vec3_t start, end; trace_t tr; // trace another shot see if we hit the legs VectorCopy( point, start ); VectorMA( start, 64, dir, end ); trap_Trace( &tr, start, NULL, NULL, end, targ->s.number, MASK_SHOT ); traceEnt = &g_entities[ tr.entityNum ]; if( g_debugBullets.integer >= 3 ) { // show hit player head bb gentity_t *tent; vec3_t b1, b2; VectorCopy( leg->r.currentOrigin, b1 ); VectorCopy( leg->r.currentOrigin, b2 ); VectorAdd( b1, leg->r.mins, b1 ); VectorAdd( b2, leg->r.maxs, b2 ); tent = G_TempEntity( b1, EV_RAILTRAIL ); VectorCopy( b2, tent->s.origin2 ); tent->s.dmgFlags = 1; // show headshot trace // end the headshot trace at the head box if it hits if( tr.fraction != 1 ) { VectorMA( start, (tr.fraction * 64), dir, end ); } tent = G_TempEntity( start, EV_RAILTRAIL ); VectorCopy( end, tent->s.origin2 ); tent->s.dmgFlags = 0; } G_FreeEntity( leg ); if( traceEnt == leg ) { return qtrue; } } else { height = point[2] - targ->r.absmin[2]; theight = targ->r.absmax[2] - targ->r.absmin[2]; if(height < (theight * 0.4f)) { return qtrue; } } return qfalse; }