mirror of
https://github.com/ReactionQuake3/reaction.git
synced 2025-01-19 08:01:55 +00:00
fixed weapon animations
This commit is contained in:
parent
9ffeb01ba1
commit
01f7221980
1 changed files with 87 additions and 143 deletions
|
@ -2,6 +2,67 @@
|
|||
//
|
||||
// cg_weapons.c -- events and effects dealing with weapons
|
||||
#include "cg_local.h"
|
||||
/* [QUARANTINE] - Weapon Animations - CG_ParseWeaponAnimFile
|
||||
==========================
|
||||
CG_ParseWeaponAnimFile
|
||||
==========================
|
||||
*/
|
||||
static qboolean CG_ParseWeaponAnimFile( const char *filename, weaponInfo_t *weapon ) {
|
||||
char *text_p;
|
||||
int len;
|
||||
int i;
|
||||
char *token;
|
||||
float fps;
|
||||
int skip;
|
||||
char text[20000];
|
||||
fileHandle_t f;
|
||||
animation_t *animations;
|
||||
|
||||
animations = weapon->animations;
|
||||
|
||||
// load the file
|
||||
len = trap_FS_FOpenFile( filename, &f, FS_READ );
|
||||
if ( len <= 0 ) {
|
||||
return qfalse;
|
||||
}
|
||||
if ( len >= sizeof( text ) - 1 ) {
|
||||
CG_Printf( "File %s too long\n", filename );
|
||||
return qfalse;
|
||||
}
|
||||
trap_FS_Read( text, len, f );
|
||||
text[len] = 0;
|
||||
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;
|
||||
}
|
||||
|
||||
return qtrue;
|
||||
}
|
||||
// END
|
||||
|
||||
/*
|
||||
==========================
|
||||
|
@ -450,6 +511,10 @@ void CG_RegisterWeapon( int weaponNum ) {
|
|||
gitem_t *item, *ammo;
|
||||
char path[MAX_QPATH];
|
||||
vec3_t mins, maxs;
|
||||
// QUARANTINE - Weapon Animations - Added Variable
|
||||
char filename[MAX_QPATH]; //Used to open animation.cfg files
|
||||
// END
|
||||
|
||||
int i;
|
||||
|
||||
weaponInfo = &cg_weapons[weaponNum];
|
||||
|
@ -544,150 +609,18 @@ void CG_RegisterWeapon( int weaponNum ) {
|
|||
|
||||
weaponInfo->loopFireSound = qfalse;
|
||||
switch ( weaponNum ) {
|
||||
/*Blaze: Dont need this
|
||||
case WP_GAUNTLET:
|
||||
MAKERGB( weaponInfo->flashDlightColor, 0.6f, 0.6f, 1.0f );
|
||||
weaponInfo->firingSound = trap_S_RegisterSound( "sound/weapons/melee/fstrun.wav", qfalse );
|
||||
weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/melee/fstatck.wav", qfalse );
|
||||
break;
|
||||
|
||||
case WP_LIGHTNING:
|
||||
MAKERGB( weaponInfo->flashDlightColor, 0.6f, 0.6f, 1.0f );
|
||||
weaponInfo->readySound = trap_S_RegisterSound( "sound/weapons/melee/fsthum.wav", qfalse );
|
||||
weaponInfo->firingSound = trap_S_RegisterSound( "sound/weapons/lightning/lg_hum.wav", qfalse );
|
||||
|
||||
weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/lightning/lg_fire.wav", qfalse );
|
||||
cgs.media.lightningShader = trap_R_RegisterShader( "lightningBolt");
|
||||
cgs.media.lightningExplosionModel = trap_R_RegisterModel( "models/weaphits/crackle.md3" );
|
||||
cgs.media.sfx_lghit1 = trap_S_RegisterSound( "sound/weapons/lightning/lg_hit.wav", qfalse );
|
||||
cgs.media.sfx_lghit2 = trap_S_RegisterSound( "sound/weapons/lightning/lg_hit2.wav", qfalse );
|
||||
cgs.media.sfx_lghit3 = trap_S_RegisterSound( "sound/weapons/lightning/lg_hit3.wav", qfalse );
|
||||
|
||||
break;
|
||||
|
||||
case WP_GRAPPLING_HOOK:
|
||||
MAKERGB( weaponInfo->flashDlightColor, 0.6f, 0.6f, 1.0f );
|
||||
weaponInfo->missileModel = trap_R_RegisterModel( "models/ammo/rocket/rocket.md3" );
|
||||
weaponInfo->missileTrailFunc = CG_GrappleTrail;
|
||||
weaponInfo->missileDlight = 200;
|
||||
weaponInfo->wiTrailTime = 2000;
|
||||
weaponInfo->trailRadius = 64;
|
||||
MAKERGB( weaponInfo->missileDlightColor, 1, 0.75f, 0 );
|
||||
weaponInfo->readySound = trap_S_RegisterSound( "sound/weapons/melee/fsthum.wav", qfalse );
|
||||
weaponInfo->firingSound = trap_S_RegisterSound( "sound/weapons/melee/fstrun.wav", qfalse );
|
||||
break;
|
||||
|
||||
#ifdef MISSIONPACK
|
||||
case WP_CHAINGUN:
|
||||
weaponInfo->firingSound = trap_S_RegisterSound( "sound/weapons/vulcan/wvulfire.wav", qfalse );
|
||||
weaponInfo->loopFireSound = qtrue;
|
||||
MAKERGB( weaponInfo->flashDlightColor, 1, 1, 0 );
|
||||
weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/vulcan/vulcanf1b.wav", qfalse );
|
||||
weaponInfo->flashSound[1] = trap_S_RegisterSound( "sound/weapons/vulcan/vulcanf2b.wav", qfalse );
|
||||
weaponInfo->flashSound[2] = trap_S_RegisterSound( "sound/weapons/vulcan/vulcanf3b.wav", qfalse );
|
||||
weaponInfo->flashSound[3] = trap_S_RegisterSound( "sound/weapons/vulcan/vulcanf4b.wav", qfalse );
|
||||
weaponInfo->ejectBrassFunc = CG_MachineGunEjectBrass;
|
||||
cgs.media.bulletExplosionShader = trap_R_RegisterShader( "bulletExplosion" );
|
||||
break;
|
||||
#endif
|
||||
|
||||
case WP_MACHINEGUN:
|
||||
MAKERGB( weaponInfo->flashDlightColor, 1, 1, 0 );
|
||||
weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/machinegun/machgf1b.wav", qfalse );
|
||||
weaponInfo->flashSound[1] = trap_S_RegisterSound( "sound/weapons/machinegun/machgf2b.wav", qfalse );
|
||||
weaponInfo->flashSound[2] = trap_S_RegisterSound( "sound/weapons/machinegun/machgf3b.wav", qfalse );
|
||||
weaponInfo->flashSound[3] = trap_S_RegisterSound( "sound/weapons/machinegun/machgf4b.wav", qfalse );
|
||||
weaponInfo->ejectBrassFunc = CG_MachineGunEjectBrass;
|
||||
cgs.media.bulletExplosionShader = trap_R_RegisterShader( "bulletExplosion" );
|
||||
break;
|
||||
|
||||
case WP_SHOTGUN:
|
||||
MAKERGB( weaponInfo->flashDlightColor, 1, 1, 0 );
|
||||
weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/shotgun/sshotf1b.wav", qfalse );
|
||||
weaponInfo->ejectBrassFunc = CG_ShotgunEjectBrass;
|
||||
break;
|
||||
|
||||
case WP_ROCKET_LAUNCHER:
|
||||
weaponInfo->missileModel = trap_R_RegisterModel( "models/ammo/rocket/rocket.md3" );
|
||||
weaponInfo->missileSound = trap_S_RegisterSound( "sound/weapons/rocket/rockfly.wav", qfalse );
|
||||
weaponInfo->missileTrailFunc = CG_RocketTrail;
|
||||
weaponInfo->missileDlight = 200;
|
||||
weaponInfo->wiTrailTime = 2000;
|
||||
weaponInfo->trailRadius = 64;
|
||||
|
||||
MAKERGB( weaponInfo->missileDlightColor, 1, 0.75f, 0 );
|
||||
MAKERGB( weaponInfo->flashDlightColor, 1, 0.75f, 0 );
|
||||
|
||||
weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/rocket/rocklf1a.wav", qfalse );
|
||||
cgs.media.rocketExplosionShader = trap_R_RegisterShader( "rocketExplosion" );
|
||||
break;
|
||||
|
||||
#ifdef MISSIONPACK
|
||||
case WP_PROX_LAUNCHER:
|
||||
weaponInfo->missileModel = trap_R_RegisterModel( "models/weaphits/proxmine.md3" );
|
||||
weaponInfo->missileTrailFunc = CG_GrenadeTrail;
|
||||
weaponInfo->wiTrailTime = 700;
|
||||
weaponInfo->trailRadius = 32;
|
||||
MAKERGB( weaponInfo->flashDlightColor, 1, 0.70f, 0 );
|
||||
weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/proxmine/wstbfire.wav", qfalse );
|
||||
cgs.media.grenadeExplosionShader = trap_R_RegisterShader( "grenadeExplosion" );
|
||||
break;
|
||||
#endif
|
||||
|
||||
case WP_GRENADE_LAUNCHER:
|
||||
weaponInfo->missileModel = trap_R_RegisterModel( "models/ammo/grenade1.md3" );
|
||||
weaponInfo->missileTrailFunc = CG_GrenadeTrail;
|
||||
weaponInfo->wiTrailTime = 700;
|
||||
weaponInfo->trailRadius = 32;
|
||||
MAKERGB( weaponInfo->flashDlightColor, 1, 0.70f, 0 );
|
||||
weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/grenade/grenlf1a.wav", qfalse );
|
||||
cgs.media.grenadeExplosionShader = trap_R_RegisterShader( "grenadeExplosion" );
|
||||
break;
|
||||
|
||||
#ifdef MISSIONPACK
|
||||
case WP_NAILGUN:
|
||||
weaponInfo->ejectBrassFunc = CG_NailgunEjectBrass;
|
||||
weaponInfo->missileTrailFunc = CG_NailTrail;
|
||||
weaponInfo->missileSound = trap_S_RegisterSound( "sound/weapons/nailgun/wnalflit.wav", qfalse );
|
||||
weaponInfo->trailRadius = 16;
|
||||
weaponInfo->wiTrailTime = 250;
|
||||
weaponInfo->missileModel = trap_R_RegisterModel( "models/weaphits/nail.md3" );
|
||||
MAKERGB( weaponInfo->flashDlightColor, 1, 0.75f, 0 );
|
||||
weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/nailgun/wnalfire.wav", qfalse );
|
||||
break;
|
||||
#endif
|
||||
|
||||
case WP_PLASMAGUN:
|
||||
weaponInfo->missileSound = trap_S_RegisterSound( "sound/weapons/plasma/lasfly.wav", qfalse );
|
||||
MAKERGB( weaponInfo->flashDlightColor, 0.6f, 0.6f, 1.0f );
|
||||
weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/plasma/hyprbf1a.wav", qfalse );
|
||||
cgs.media.plasmaExplosionShader = trap_R_RegisterShader( "plasmaExplosion" );
|
||||
break;
|
||||
|
||||
case WP_RAILGUN:
|
||||
weaponInfo->readySound = trap_S_RegisterSound( "sound/weapons/railgun/rg_hum.wav", qfalse );
|
||||
MAKERGB( weaponInfo->flashDlightColor, 1, 0.5f, 0 );
|
||||
weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/railgun/railgf1a.wav", qfalse );
|
||||
cgs.media.railExplosionShader = trap_R_RegisterShader( "railExplosion" );
|
||||
cgs.media.railRingsShader = trap_R_RegisterShader( "railDisc" );
|
||||
cgs.media.railCoreShader = trap_R_RegisterShader( "railCore" );
|
||||
break;
|
||||
|
||||
case WP_BFG:
|
||||
weaponInfo->readySound = trap_S_RegisterSound( "sound/weapons/bfg/bfg_hum.wav", qfalse );
|
||||
MAKERGB( weaponInfo->flashDlightColor, 1, 0.7f, 1 );
|
||||
weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/bfg/bfg_fire.wav", qfalse );
|
||||
cgs.media.bfgExplosionShader = trap_R_RegisterShader( "bfgExplosion" );
|
||||
weaponInfo->missileModel = trap_R_RegisterModel( "models/weaphits/bfg.md3" );
|
||||
weaponInfo->missileSound = trap_S_RegisterSound( "sound/weapons/rocket/rockfly.wav", qfalse );
|
||||
break;
|
||||
*/
|
||||
//Blaze: Reaction Pistol
|
||||
case WP_PISTOL:
|
||||
MAKERGB( weaponInfo->flashDlightColor, 1, 1, 0 );
|
||||
weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/mk23/mk23fire.wav", qfalse );
|
||||
weaponInfo->ejectBrassFunc = CG_MachineGunEjectBrass;
|
||||
cgs.media.bulletExplosionShader = trap_R_RegisterShader( "bulletExplosion" );
|
||||
Com_sprintf( filename, sizeof(filename), "models/weapons2/mk23/animation.cfg" );
|
||||
if ( !CG_ParseWeaponAnimFile(filename, weaponInfo) ) {
|
||||
Com_Printf("Failed to load weapon animation file %s\n", filename);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case WP_KNIFE:
|
||||
|
@ -1174,8 +1107,8 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent
|
|||
trap_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin, weapon->readySound );
|
||||
}
|
||||
}
|
||||
if (ps == NULL)
|
||||
{
|
||||
//if (ps == NULL)
|
||||
//{
|
||||
/* resizing code
|
||||
msec = cg.time - cent->miscTime;
|
||||
if ( msec >= 0 && msec < ITEM_SCALEUP_TIME ) {
|
||||
|
@ -1199,8 +1132,14 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent
|
|||
}
|
||||
*/
|
||||
|
||||
}
|
||||
//}
|
||||
if ( !ps ) {
|
||||
CG_PositionEntityOnTag( &gun, parent, parent->hModel, "tag_weapon");
|
||||
}
|
||||
else {
|
||||
CG_WeaponAnimation( cent, &gun.oldframe, &gun.frame, &gun.backlerp );
|
||||
CG_PositionWeaponOnTag( &gun, parent, parent->hModel, "tag_weapon");
|
||||
}
|
||||
|
||||
CG_AddWeaponWithPowerups( &gun, cent->currentState.powerups );
|
||||
|
||||
|
@ -1342,6 +1281,11 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent
|
|||
weapon->flashDlightColor[1], weapon->flashDlightColor[2] );
|
||||
}
|
||||
}
|
||||
if (ps)
|
||||
CG_PositionRotatedEntityOnTag( &flash, &gun, weapon->firstModel, "tag_flash");
|
||||
else
|
||||
CG_PositionRotatedEntityOnTag( &flash, &gun, weapon->weaponModel, "tag_flash");
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1407,7 +1351,7 @@ void CG_AddViewWeapon( playerState_t *ps ) {
|
|||
switch(ps->weapon)
|
||||
{
|
||||
case WP_PISTOL:
|
||||
rxn_gunx -= 4;
|
||||
rxn_gunx += 10;
|
||||
break;
|
||||
case WP_M4:
|
||||
rxn_gunx += 10;
|
||||
|
@ -1467,7 +1411,7 @@ void CG_AddViewWeapon( playerState_t *ps ) {
|
|||
hand.backlerp = cent->pe.torso.backlerp;
|
||||
}
|
||||
|
||||
hand.hModel = weapon->handsModel;
|
||||
hand.hModel = weapon->firstModel;
|
||||
hand.renderfx = RF_DEPTHHACK | RF_FIRST_PERSON | RF_MINLIGHT;
|
||||
|
||||
// add everything onto the hand
|
||||
|
|
Loading…
Reference in a new issue