tag shell ejections

This commit is contained in:
Bryce Hutchings 2002-03-11 02:22:45 +00:00
parent 094336f716
commit 9894346d37

View file

@ -5,6 +5,9 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// //
// $Log$ // $Log$
// Revision 1.51 2002/03/11 02:22:45 niceass
// tag shell ejections
//
// Revision 1.50 2002/02/24 20:49:07 slicer // Revision 1.50 2002/02/24 20:49:07 slicer
// Follow Spect Players- Draws the gun // Follow Spect Players- Draws the gun
// //
@ -172,7 +175,7 @@ static qboolean CG_ParseWeaponAnimFile( const char *filename, weaponInfo_t *weap
CG_MachineGunEjectBrass CG_MachineGunEjectBrass
========================== ==========================
*/ */
static void CG_MachineGunEjectBrass( centity_t *cent ) { localEntity_t *CG_MachineGunEjectBrass( centity_t *cent ) {
localEntity_t *le; localEntity_t *le;
refEntity_t *re; refEntity_t *re;
vec3_t velocity, xvelocity; vec3_t velocity, xvelocity;
@ -181,14 +184,14 @@ static void CG_MachineGunEjectBrass( centity_t *cent ) {
vec3_t v[3]; vec3_t v[3];
if ( cg_brassTime.integer <= 0 ) { if ( cg_brassTime.integer <= 0 ) {
return; return NULL;
} }
le = CG_AllocLocalEntity(); le = CG_AllocLocalEntity();
re = &le->refEntity; re = &le->refEntity;
velocity[0] = 0; velocity[0] = 0;
velocity[1] = -50 + 40 * crandom(); velocity[1] = -100 + 50 * crandom();
velocity[2] = 100 + 50 * crandom(); velocity[2] = 100 + 50 * crandom();
le->leType = LE_FRAGMENT; le->leType = LE_FRAGMENT;
@ -223,9 +226,11 @@ static void CG_MachineGunEjectBrass( centity_t *cent ) {
xvelocity[0] = velocity[0] * v[0][0] + velocity[1] * v[1][0] + velocity[2] * v[2][0]; xvelocity[0] = velocity[0] * v[0][0] + velocity[1] * v[1][0] + velocity[2] * v[2][0];
xvelocity[1] = velocity[0] * v[0][1] + velocity[1] * v[1][1] + velocity[2] * v[2][1]; xvelocity[1] = velocity[0] * v[0][1] + velocity[1] * v[1][1] + velocity[2] * v[2][1];
xvelocity[2] = velocity[0] * v[0][2] + velocity[1] * v[1][2] + velocity[2] * v[2][2]; xvelocity[2] = velocity[0] * v[0][2] + velocity[1] * v[1][2] + velocity[2] * v[2][2];
VectorScale( xvelocity, waterScale, le->pos.trDelta ); VectorScale( xvelocity, waterScale, le->pos.trDelta );
AxisCopy( axisDefault, re->axis ); AxisCopy( axisDefault, re->axis );
re->hModel = cgs.media.machinegunBrassModel; re->hModel = cgs.media.machinegunBrassModel;
le->bounceFactor = 0.4 * waterScale; le->bounceFactor = 0.4 * waterScale;
@ -235,13 +240,18 @@ static void CG_MachineGunEjectBrass( centity_t *cent ) {
le->angles.trBase[0] = rand()&31; le->angles.trBase[0] = rand()&31;
le->angles.trBase[1] = rand()&31; le->angles.trBase[1] = rand()&31;
le->angles.trBase[2] = rand()&31; le->angles.trBase[2] = rand()&31;
le->angles.trDelta[0] = 2;
le->angles.trDelta[1] = 1; le->angles.trBase[0] = 5+rand()&10;
le->angles.trDelta[2] = 0; le->angles.trBase[1] = 2+rand()&5;
le->angles.trBase[2] = 0;
// le->angles.trDelta[0] = 2;
// le->angles.trDelta[1] = 1;
// le->angles.trDelta[2] = 0;
le->leFlags = LEF_TUMBLE; le->leFlags = LEF_TUMBLE;
le->leBounceSoundType = LEBS_BRASS; le->leBounceSoundType = LEBS_BRASS;
le->leMarkType = LEMT_NONE; le->leMarkType = LEMT_NONE;
return le;
} }
/* /*
@ -249,20 +259,22 @@ static void CG_MachineGunEjectBrass( centity_t *cent ) {
CG_ShotgunEjectBrass CG_ShotgunEjectBrass
========================== ==========================
*/ */
static void CG_ShotgunEjectBrass( centity_t *cent ) { //static void CG_ShotgunEjectBrass( centity_t *cent, vec3_t origin, vec3_t axis[3] ) {
localEntity_t *CG_ShotgunEjectBrass( centity_t *cent ) {
localEntity_t *le; localEntity_t *le;
refEntity_t *re; refEntity_t *re;
vec3_t velocity, xvelocity; vec3_t velocity, xvelocity;
vec3_t offset, xoffset; vec3_t offset, xoffset;
vec3_t v[3]; vec3_t v[3];
int i, isHC; int i, isHC;
if (cent->currentState.weapon == WP_HANDCANNON) if (cent->currentState.weapon == WP_HANDCANNON)
isHC=1; isHC=1;
else else
isHC=0; isHC=0;
if ( cg_brassTime.integer <= 0 ) { if ( cg_brassTime.integer <= 0 ) {
return; return NULL;
} }
for ( i = 0; i < isHC + 1; i++ ) { for ( i = 0; i < isHC + 1; i++ ) {
@ -301,7 +313,9 @@ static void CG_ShotgunEjectBrass( centity_t *cent ) {
xoffset[1] = offset[0] * v[0][1] + offset[1] * v[1][1] + offset[2] * v[2][1]; xoffset[1] = offset[0] * v[0][1] + offset[1] * v[1][1] + offset[2] * v[2][1];
xoffset[2] = offset[0] * v[0][2] + offset[1] * v[1][2] + offset[2] * v[2][2]; xoffset[2] = offset[0] * v[0][2] + offset[1] * v[1][2] + offset[2] * v[2][2];
VectorAdd( cent->lerpOrigin, xoffset, re->origin ); VectorAdd( cent->lerpOrigin, xoffset, re->origin );
VectorCopy( re->origin, le->pos.trBase ); VectorCopy( re->origin, le->pos.trBase );
if ( CG_PointContents( re->origin, -1 ) & CONTENTS_WATER ) { if ( CG_PointContents( re->origin, -1 ) & CONTENTS_WATER ) {
waterScale = 0.10f; waterScale = 0.10f;
} }
@ -309,6 +323,7 @@ static void CG_ShotgunEjectBrass( centity_t *cent ) {
xvelocity[0] = velocity[0] * v[0][0] + velocity[1] * v[1][0] + velocity[2] * v[2][0]; xvelocity[0] = velocity[0] * v[0][0] + velocity[1] * v[1][0] + velocity[2] * v[2][0];
xvelocity[1] = velocity[0] * v[0][1] + velocity[1] * v[1][1] + velocity[2] * v[2][1]; xvelocity[1] = velocity[0] * v[0][1] + velocity[1] * v[1][1] + velocity[2] * v[2][1];
xvelocity[2] = velocity[0] * v[0][2] + velocity[1] * v[1][2] + velocity[2] * v[2][2]; xvelocity[2] = velocity[0] * v[0][2] + velocity[1] * v[1][2] + velocity[2] * v[2][2];
VectorScale( xvelocity, waterScale, le->pos.trDelta ); VectorScale( xvelocity, waterScale, le->pos.trDelta );
AxisCopy( axisDefault, re->axis ); AxisCopy( axisDefault, re->axis );
@ -329,6 +344,7 @@ static void CG_ShotgunEjectBrass( centity_t *cent ) {
le->leBounceSoundType = LEBS_BRASS; le->leBounceSoundType = LEBS_BRASS;
le->leMarkType = LEMT_NONE; le->leMarkType = LEMT_NONE;
} }
return le;
} }
@ -1396,11 +1412,10 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent
// refEntity_t barrel; // refEntity_t barrel;
refEntity_t flash; refEntity_t flash;
vec3_t angles; vec3_t angles;
// float frac;
weapon_t weaponNum; weapon_t weaponNum;
weaponInfo_t *weapon; weaponInfo_t *weapon;
centity_t *nonPredictedCent; centity_t *nonPredictedCent;
// int col; localEntity_t *shell;
weaponNum = cent->currentState.weapon; weaponNum = cent->currentState.weapon;
@ -1594,13 +1609,26 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent
//CG_LightningBolt( nonPredictedCent, parent->lightingOrigin ); //CG_LightningBolt( nonPredictedCent, parent->lightingOrigin );
// NiceAss: Tag locations used for shell ejection
if ( cent->ejectBrass && weapon->ejectBrassFunc &&
( ps || cg.renderingThirdPerson || cent->currentState.number != cg.predictedPlayerState.clientNum ) ) {
shell = weapon->ejectBrassFunc( cent );
if ( shell && ( weaponNum == WP_PISTOL || weaponNum == WP_MP5 ) ) {
CG_PositionRotatedEntityOnTag( &shell->refEntity, &gun, gun.hModel, "tag_shell");
VectorCopy( shell->refEntity.origin, shell->pos.trBase );
vectoangles( shell->refEntity.axis[0], shell->angles.trBase);
}
cent->ejectBrass = qfalse;
}
//Elder: re-added to fix loss of muzzle flashes! //Elder: re-added to fix loss of muzzle flashes!
// impulse flash // impulse flash
if ( cg.time - cent->muzzleFlashTime > MUZZLE_FLASH_TIME && !cent->pe.railgunFlash ) { if ( cg.time - cent->muzzleFlashTime > MUZZLE_FLASH_TIME && !cent->pe.railgunFlash ) {
return; return;
} }
memset( &flash, 0, sizeof( flash ) ); memset( &flash, 0, sizeof( flash ) );
VectorCopy( parent->lightingOrigin, flash.lightingOrigin ); VectorCopy( parent->lightingOrigin, flash.lightingOrigin );
@ -1633,6 +1661,7 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent
//Elder: Yes flash - try this //Elder: Yes flash - try this
//Elder: add conditional here so the dlight is still drawn when cg_RQ3_flash is 0 //Elder: add conditional here so the dlight is still drawn when cg_RQ3_flash is 0
if ( cg_RQ3_flash.integer ) { if ( cg_RQ3_flash.integer ) {
if (ps) { if (ps) {
// Elder: draw flash based on first-person view // Elder: draw flash based on first-person view
@ -1666,7 +1695,6 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent
else else
CG_PositionRotatedEntityOnTag( &flash, &gun, weapon->weaponModel, "tag_flash"); CG_PositionRotatedEntityOnTag( &flash, &gun, weapon->weaponModel, "tag_flash");
} }
trap_R_AddRefEntityToScene( &flash ); trap_R_AddRefEntityToScene( &flash );
} }
else { else {
@ -2510,7 +2538,7 @@ void CG_FireWeapon( centity_t *cent, int weapModification ) {
return; return;
} }
// KNIFE // KNIFE
// NicEass: This is if the knife slash is not the first (2,3,4,5) // NiceAss: This is if the knife slash is not the first (2,3,4,5)
if (weapModification == RQ3_WPMOD_KNIFENOMARK) { if (weapModification == RQ3_WPMOD_KNIFENOMARK) {
return; return;
} }
@ -2518,6 +2546,9 @@ void CG_FireWeapon( centity_t *cent, int weapModification ) {
return; return;
}*/ }*/
// NiceAss:
cent->ejectBrass = qtrue;
// mark the entity as muzzle flashing, so when it is added it will // mark the entity as muzzle flashing, so when it is added it will
// append the flash to the weapon model // append the flash to the weapon model
if (weapModification != RQ3_WPMOD_SILENCER) if (weapModification != RQ3_WPMOD_SILENCER)
@ -2573,9 +2604,9 @@ void CG_FireWeapon( centity_t *cent, int weapModification ) {
} }
//Elder: TODO: eject sync with animation for M3 and only eject for HC when reloading //Elder: TODO: eject sync with animation for M3 and only eject for HC when reloading
// do brass ejection // do brass ejection
if ( weap->ejectBrassFunc && cg_brassTime.integer > 0 ) { //if ( weap->ejectBrassFunc && cg_brassTime.integer > 0 ) {
weap->ejectBrassFunc( cent ); // weap->ejectBrassFunc( cent );
} //}
/* /*
// MK23 // MK23
@ -4003,7 +4034,7 @@ void CG_ReloadWeapon (centity_t *cent, int reloadStage)
} }
if ( ent->weapon == WP_HANDCANNON ) if ( ent->weapon == WP_HANDCANNON )
CG_ShotgunEjectBrass( cent ); CG_ShotgunEjectBrass( cent, NULL, NULL );
break; break;
case 2: case 2:
if (weap->worldReloadSound[2] && ent->clientNum != cg.snap->ps.clientNum) if (weap->worldReloadSound[2] && ent->clientNum != cg.snap->ps.clientNum)