fixed weapon animations

This commit is contained in:
Scott Brooks 2001-07-28 12:32:54 +00:00
parent 01f7221980
commit 81f8573e99

View file

@ -1,4 +1,4 @@
// Copyright (C) 1999-2000 Id Software, Inc. // Copyright (C) 1999-2000 Id Software, Inc.
// //
// cg_weapons.c -- events and effects dealing with weapons // cg_weapons.c -- events and effects dealing with weapons
#include "cg_local.h" #include "cg_local.h"
@ -8,59 +8,59 @@ CG_ParseWeaponAnimFile
========================== ==========================
*/ */
static qboolean CG_ParseWeaponAnimFile( const char *filename, weaponInfo_t *weapon ) { static qboolean CG_ParseWeaponAnimFile( const char *filename, weaponInfo_t *weapon ) {
char *text_p; char *text_p;
int len; int len;
int i; int i;
char *token; char *token;
float fps; float fps;
int skip; int skip;
char text[20000]; char text[20000];
fileHandle_t f; fileHandle_t f;
animation_t *animations; animation_t *animations;
animations = weapon->animations; animations = weapon->animations;
// load the file // load the file
len = trap_FS_FOpenFile( filename, &f, FS_READ ); len = trap_FS_FOpenFile( filename, &f, FS_READ );
if ( len <= 0 ) { if ( len <= 0 ) {
return qfalse; return qfalse;
} }
if ( len >= sizeof( text ) - 1 ) { if ( len >= sizeof( text ) - 1 ) {
CG_Printf( "File %s too long\n", filename ); CG_Printf( "File %s too long\n", filename );
return qfalse; return qfalse;
} }
trap_FS_Read( text, len, f ); trap_FS_Read( text, len, f );
text[len] = 0; text[len] = 0;
trap_FS_FCloseFile( f ); trap_FS_FCloseFile( f );
// parse the text
text_p = text;
skip = 0; // quite the compiler warning
// read information for each frame
for ( i = 0 ; i < MAX_WEAPON_ANIMATIONS ; i++ ) {
token = COM_Parse( &text_p );
if ( !token ) break;
animations[i].firstFrame = atoi( token );
token = COM_Parse( &text_p );
if ( !token ) break;
animations[i].numFrames = atoi( token );
token = COM_Parse( &text_p );
if ( !token ) break;
animations[i].loopFrames = atoi( token );
token = COM_Parse( &text_p );
if ( !token ) break;
fps = atof( token );
if ( fps == 0 ) fps = 1;
animations[i].frameLerp = 1000 / fps;
animations[i].initialLerp = 1000 / fps;
}
if ( i != MAX_WEAPON_ANIMATIONS ) {
CG_Printf( "Error parsing weapon animation file: %s", filename );
return qfalse;
}
// parse the text return qtrue;
text_p = text;
skip = 0; // quite the compiler warning
// read information for each frame
for ( i = 0 ; i < MAX_WEAPON_ANIMATIONS ; i++ ) {
token = COM_Parse( &text_p );
if ( !token ) break;
animations[i].firstFrame = atoi( token );
token = COM_Parse( &text_p );
if ( !token ) break;
animations[i].numFrames = atoi( token );
token = COM_Parse( &text_p );
if ( !token ) break;
animations[i].loopFrames = atoi( token );
token = COM_Parse( &text_p );
if ( !token ) break;
fps = atof( token );
if ( fps == 0 ) fps = 1;
animations[i].frameLerp = 1000 / fps;
animations[i].initialLerp = 1000 / fps;
}
if ( i != MAX_WEAPON_ANIMATIONS ) {
CG_Printf( "Error parsing weapon animation file: %s", filename );
return qfalse;
}
return qtrue;
} }
// END // END
@ -599,7 +599,7 @@ void CG_RegisterWeapon( int weaponNum ) {
if ( !weaponInfo->handsModel ) { if ( !weaponInfo->handsModel ) {
//Elder: WTF!? //Elder: WTF!?
weaponInfo->handsModel = trap_R_RegisterModel( "models/weapons2/m3/m3_hand.md3" ); weaponInfo->handsModel = trap_R_RegisterModel( "models/weapons2/mk23/mk23_hand.md3" );
} }
//Elder: if no _1st model, point to the weaponModel... this may get funky :) //Elder: if no _1st model, point to the weaponModel... this may get funky :)
@ -1250,8 +1250,7 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent
return; return;
} }
if ( ps || cg.renderingThirdPerson || if ( ps || cg.renderingThirdPerson || cent->currentState.number != cg.predictedPlayerState.clientNum ) {
cent->currentState.number != cg.predictedPlayerState.clientNum ) {
// add lightning bolt // add lightning bolt
//Blaze: No need for this //Blaze: No need for this
//CG_LightningBolt( nonPredictedCent, flash.origin ); //CG_LightningBolt( nonPredictedCent, flash.origin );
@ -1281,10 +1280,10 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent
weapon->flashDlightColor[1], weapon->flashDlightColor[2] ); weapon->flashDlightColor[1], weapon->flashDlightColor[2] );
} }
} }
if (ps) //if (ps)
CG_PositionRotatedEntityOnTag( &flash, &gun, weapon->firstModel, "tag_flash"); // CG_PositionRotatedEntityOnTag( &flash, &gun, weapon->firstModel, "tag_flash");
else //else
CG_PositionRotatedEntityOnTag( &flash, &gun, weapon->weaponModel, "tag_flash"); // CG_PositionRotatedEntityOnTag( &flash, &gun, weapon->weaponModel, "tag_flash");
} }
@ -1411,7 +1410,7 @@ void CG_AddViewWeapon( playerState_t *ps ) {
hand.backlerp = cent->pe.torso.backlerp; hand.backlerp = cent->pe.torso.backlerp;
} }
hand.hModel = weapon->firstModel; hand.hModel = weapon->handsModel;
hand.renderfx = RF_DEPTHHACK | RF_FIRST_PERSON | RF_MINLIGHT; hand.renderfx = RF_DEPTHHACK | RF_FIRST_PERSON | RF_MINLIGHT;
// add everything onto the hand // add everything onto the hand