static void CG_BodyQueueCopy(centity_t *cent, int clientNum, int knownWeapon) { centity_t *source; animation_t *anim; float animSpeed; int flags=BONE_ANIM_OVERRIDE_FREEZE; clientInfo_t *ci; if (cent->ghoul2) { trap_G2API_CleanGhoul2Models(¢->ghoul2); } if (clientNum < 0 || clientNum >= MAX_CLIENTS) { return; } source = &cg_entities[ clientNum ]; ci = &cgs.clientinfo[ clientNum ]; if (!source) { return; } if (!source->ghoul2) { return; } cent->isRagging = qfalse; //reset in case it's still set from another body that was in this cent slot. cent->ownerRagging = source->isRagging; //if the owner was in ragdoll state, then we want to go into it too right away. #if 0 VectorCopy(source->lerpOriginOffset, cent->lerpOriginOffset); #endif cent->bodyFadeTime = 0; cent->bodyHeight = 0; cent->dustTrailTime = source->dustTrailTime; trap_G2API_DuplicateGhoul2Instance(source->ghoul2, ¢->ghoul2); if (source->isRagging) { //just reset it now. source->isRagging = qfalse; trap_G2API_SetRagDoll(source->ghoul2, NULL); //calling with null parms resets to no ragdoll. } //either force the weapon from when we died or remove it if it was a dropped weapon if (knownWeapon > WP_BRYAR_PISTOL && trap_G2API_HasGhoul2ModelOnIndex(&(cent->ghoul2), 1)) { trap_G2API_RemoveGhoul2Model(&(cent->ghoul2), 1); } else if (trap_G2API_HasGhoul2ModelOnIndex(&(cent->ghoul2), 1)) { trap_G2API_CopySpecificGhoul2Model(CG_G2WeaponInstance(cent, knownWeapon), 0, cent->ghoul2, 1); } if (!cent->ownerRagging) { int aNum; int eFrame; qboolean fallBack = qfalse; //anim = &bgAllAnims[cent->localAnimIndex].anims[ cent->currentState.torsoAnim ]; if (!BG_InDeathAnim(source->currentState.torsoAnim)) { //then just snap the corpse into a default anim = &bgAllAnims[source->localAnimIndex].anims[ BOTH_DEAD1 ]; fallBack = qtrue; } else { anim = &bgAllAnims[source->localAnimIndex].anims[ source->currentState.torsoAnim ]; } animSpeed = 50.0f / anim->frameLerp; if (!fallBack) { //this will just set us to the last frame of the animation, in theory aNum = cgs.clientinfo[source->currentState.number].frame+1; while (aNum >= anim->firstFrame+anim->numFrames) { aNum--; } if (aNum < anim->firstFrame-1) { //wrong animation...? aNum = (anim->firstFrame+anim->numFrames)-1; } } else { aNum = anim->firstFrame; } eFrame = anim->firstFrame + anim->numFrames; //if (!cgs.clientinfo[source->currentState.number].frame || (cent->currentState.torsoAnim) != (source->currentState.torsoAnim) ) //{ // aNum = (anim->firstFrame+anim->numFrames)-1; //} trap_G2API_SetBoneAnim(cent->ghoul2, 0, "upper_lumbar", aNum, eFrame, flags, animSpeed, cg.time, -1, 150); trap_G2API_SetBoneAnim(cent->ghoul2, 0, "model_root", aNum, eFrame, flags, animSpeed, cg.time, -1, 150); trap_G2API_SetBoneAnim(cent->ghoul2, 0, "Motion", aNum, eFrame, flags, animSpeed, cg.time, -1, 150); } //After we create the bodyqueue, regenerate any limbs on the real instance if (source->torsoBolt) { CG_ReattachLimb(source); } }
void SetupGameGhoul2Model(gclient_t *client, char *modelname) { int handle; char afilename[MAX_QPATH]; char /**GLAName,*/ *slash; char GLAName[MAX_QPATH]; vec3_t tempVec = {0,0,0}; // First things first. If this is a ghoul2 model, then let's make sure we demolish this first. if (client->ghoul2 && trap_G2_HaveWeGhoul2Models(client->ghoul2)) { trap_G2API_CleanGhoul2Models(&(client->ghoul2)); } /* Com_sprintf( afilename, sizeof( afilename ), "models/players/%s/model.glm", modelname ); handle = trap_G2API_InitGhoul2Model(&client->ghoul2, afilename, 0, 0, -20, 0, 0); if (handle<0) { Com_sprintf( afilename, sizeof( afilename ), "models/players/kyle/model.glm" ); handle = trap_G2API_InitGhoul2Model(&client->ghoul2, afilename, 0, 0, -20, 0, 0); if (handle<0) { return; } } */ //rww - just load the "standard" model for the server" if (!precachedKyle) { Com_sprintf( afilename, sizeof( afilename ), "models/players/kyle/model.glm" ); handle = trap_G2API_InitGhoul2Model(&precachedKyle, afilename, 0, 0, -20, 0, 0); if (handle<0) { return; } } if (precachedKyle && trap_G2_HaveWeGhoul2Models(precachedKyle)) { trap_G2API_DuplicateGhoul2Instance(precachedKyle, &client->ghoul2); } else { return; } // The model is now loaded. GLAName[0] = 0; if (!BGPAFtextLoaded) { //get the location of the animation.cfg //GLAName = trap_G2API_GetGLAName( client->ghoul2, 0); trap_G2API_GetGLAName( client->ghoul2, 0, GLAName); if (!GLAName[0]) { if (!BG_ParseAnimationFile("models/players/_humanoid/animation.cfg")) { Com_Printf( "Failed to load animation file %s\n", afilename ); return; } return; } Q_strncpyz( afilename, GLAName, sizeof( afilename )); slash = Q_strrchr( afilename, '/' ); if ( slash ) { strcpy(slash, "/animation.cfg"); } // Now afilename holds just the path to the animation.cfg else { // Didn't find any slashes, this is a raw filename right in base (whish isn't a good thing) return; } // Try to load the animation.cfg for this model then. if ( !BG_ParseAnimationFile( afilename ) ) { // The GLA's animations failed if (!BG_ParseAnimationFile("models/players/_humanoid/animation.cfg")) { Com_Printf( "Failed to load animation file %s\n", afilename ); return; } } } trap_G2API_AddBolt(client->ghoul2, 0, "*r_hand"); trap_G2API_AddBolt(client->ghoul2, 0, "*l_hand"); // NOTE - ensure this sequence of bolt and bone accessing are always the same because the client expects them in a certain order trap_G2API_SetBoneAnim(client->ghoul2, 0, "model_root", 0, 12, BONE_ANIM_OVERRIDE_LOOP, 1.0f, level.time, -1, -1); trap_G2API_SetBoneAngles(client->ghoul2, 0, "upper_lumbar", tempVec, BONE_ANGLES_POSTMULT, POSITIVE_X, NEGATIVE_Y, NEGATIVE_Z, NULL, 0, level.time); trap_G2API_SetBoneAngles(client->ghoul2, 0, "cranium", tempVec, BONE_ANGLES_POSTMULT, POSITIVE_Z, NEGATIVE_Y, POSITIVE_X, NULL, 0, level.time); if (!g2SaberInstance) { trap_G2API_InitGhoul2Model(&g2SaberInstance, "models/weapons2/saber/saber_w.glm", 0, 0, -20, 0, 0); if (g2SaberInstance) { // indicate we will be bolted to model 0 (ie the player) on bolt 0 (always the right hand) when we get copied trap_G2API_SetBoltInfo(g2SaberInstance, 0, 0); // now set up the gun bolt on it trap_G2API_AddBolt(g2SaberInstance, 0, "*flash"); } } if (g2SaberInstance) { trap_G2API_CopySpecificGhoul2Model(g2SaberInstance, 0, client->ghoul2, 1); } }