summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2003-10-03 12:05:04 +0000
committerTim Angus <tim@ngus.net>2003-10-03 12:05:04 +0000
commit4ee9c29e78a84f6f3e80813b124aa045617633e6 (patch)
tree115861e6b0276807726633bf610748fca766eafa /src
parent15916bb611ac8be90f1719ca84144149bbc97ca1 (diff)
* Added disableIn3rdPerson to weapon.cfg to handle alien weapons more elegantly
* Muzzle effects are attached to tag_weapon where tag_flash is not available * Handle particle effects properly with cg_drawGun 1 * Fixed some serious bugs in particle system that culled particle systems early
Diffstat (limited to 'src')
-rw-r--r--src/cgame/cg_event.c10
-rw-r--r--src/cgame/cg_local.h4
-rw-r--r--src/cgame/cg_main.c2
-rw-r--r--src/cgame/cg_particles.c26
-rw-r--r--src/cgame/cg_players.c3
-rw-r--r--src/cgame/cg_weapons.c106
-rw-r--r--src/game/bg_pmove.c12
-rw-r--r--src/game/bg_public.h2
-rw-r--r--src/game/g_combat.c11
-rw-r--r--src/game/tremulous.h1
10 files changed, 123 insertions, 54 deletions
diff --git a/src/cgame/cg_event.c b/src/cgame/cg_event.c
index bf77d489..abf9e821 100644
--- a/src/cgame/cg_event.c
+++ b/src/cgame/cg_event.c
@@ -673,6 +673,16 @@ void CG_EntityEvent( centity_t *cent, vec3_t position )
CG_AlienBuildableExplosion( position, dir );
break;
+ case EV_HUMAN_BUILDABLE_DAMAGE:
+ DEBUGNAME( "EV_HUMAN_BUILDABLE_DAMAGE" );
+ trap_S_StartSound( NULL, es->number, CHAN_BODY, cgs.media.humanBuildableDamage );
+ break;
+
+ case EV_ALIEN_BUILDABLE_DAMAGE:
+ DEBUGNAME( "EV_ALIEN_BUILDABLE_DAMAGE" );
+ trap_S_StartSound( NULL, es->number, CHAN_BODY, cgs.media.alienBuildableDamage );
+ break;
+
case EV_TESLATRAIL:
DEBUGNAME( "EV_TESLATRAIL" );
cent->currentState.weapon = WP_TESLAGEN;
diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h
index 92d94321..39d13c03 100644
--- a/src/cgame/cg_local.h
+++ b/src/cgame/cg_local.h
@@ -708,6 +708,8 @@ typedef struct weaponInfo_s
void (*ejectBrassFunc)( centity_t * );
sfxHandle_t readySound;
+
+ qboolean disableIn3rdPerson;
weaponInfoMode_t wim[ WPM_NUM_WEAPONMODES ];
} weaponInfo_t;
@@ -1165,6 +1167,8 @@ typedef struct
sfxHandle_t alienBuildableExplosion;
sfxHandle_t humanBuildableExplosion;
+ sfxHandle_t alienBuildableDamage;
+ sfxHandle_t humanBuildableDamage;
qhandle_t cursor;
qhandle_t selectCursor;
diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c
index 8dffa7dd..5163e16e 100644
--- a/src/cgame/cg_main.c
+++ b/src/cgame/cg_main.c
@@ -641,6 +641,8 @@ static void CG_RegisterSounds( void )
cgs.media.alienBuildableExplosion = trap_S_RegisterSound( "sound/buildables/alien/explosion.wav", qfalse );
cgs.media.humanBuildableExplosion = trap_S_RegisterSound( "sound/buildables/human/explosion.wav", qfalse );
+ cgs.media.alienBuildableDamage = trap_S_RegisterSound( "sound/buildables/alien/damage.wav", qfalse );
+ cgs.media.humanBuildableDamage = trap_S_RegisterSound( "sound/buildables/human/damage.wav", qfalse );
cgs.media.hgrenb1aSound = trap_S_RegisterSound( "sound/weapons/grenade/hgrenb1a.wav", qfalse );
cgs.media.hgrenb2aSound = trap_S_RegisterSound( "sound/weapons/grenade/hgrenb2a.wav", qfalse );
diff --git a/src/cgame/cg_particles.c b/src/cgame/cg_particles.c
index 40512ecd..44a309ea 100644
--- a/src/cgame/cg_particles.c
+++ b/src/cgame/cg_particles.c
@@ -238,10 +238,12 @@ introducing new particles
static void CG_SpawnNewParticles( void )
{
int i, j;
+ particle_t *p;
particleSystem_t *ps;
particleEjector_t *pe;
baseParticleEjector_t *bpe;
float lerpFrac;
+ int count;
for( i = 0; i < MAX_PARTICLE_EJECTORS; i++ )
{
@@ -278,7 +280,21 @@ static void CG_SpawnNewParticles( void )
pe->valid = qfalse;
if( pe->count == 0 )
- pe->valid = qfalse;
+ {
+ count = 0;
+
+ //wait for child particles to die before declaring this pe invalid
+ for( j = 0; j < MAX_PARTICLES; j++ )
+ {
+ p = &particles[ j ];
+
+ if( p->valid && p->parent == pe )
+ count++;
+ }
+
+ if( !count )
+ pe->valid = qfalse;
+ }
}
}
}
@@ -1432,6 +1448,10 @@ void CG_SetParticleSystemNormal( particleSystem_t *ps, vec3_t normal )
CG_DestroyParticleSystem
Destroy a particle system
+
+This doesn't actually invalidate anything, it just stops
+particle ejectors from producing new particles so the
+garbage collector will eventually remove this system
===============
*/
void CG_DestroyParticleSystem( particleSystem_t *ps )
@@ -1448,14 +1468,12 @@ void CG_DestroyParticleSystem( particleSystem_t *ps )
if( cg_debugParticles.integer >= 1 )
CG_Printf( "PS destroyed\n" );
- ps->valid = qfalse;
-
for( i = 0; i < MAX_PARTICLE_EJECTORS; i++ )
{
pe = &particleEjectors[ i ];
if( pe->valid && pe->parent == ps )
- pe->valid = qfalse;
+ pe->totalParticles = pe->count = 0;
}
}
diff --git a/src/cgame/cg_players.c b/src/cgame/cg_players.c
index a08279bf..a48f8ce6 100644
--- a/src/cgame/cg_players.c
+++ b/src/cgame/cg_players.c
@@ -2036,8 +2036,7 @@ void CG_Player( centity_t *cent )
//
// add the gun / barrel / flash
//
- if( team == PTE_HUMANS )
- CG_AddPlayerWeapon( &torso, NULL, cent );
+ CG_AddPlayerWeapon( &torso, NULL, cent );
CG_PlayerUpgrades( cent, &torso );
}
diff --git a/src/cgame/cg_weapons.c b/src/cgame/cg_weapons.c
index ca8a2fb3..2b1edc06 100644
--- a/src/cgame/cg_weapons.c
+++ b/src/cgame/cg_weapons.c
@@ -692,6 +692,12 @@ static qboolean CG_ParseWeaponFile( const char *filename, weaponInfo_t *wi )
continue;
}
+ else if( !Q_stricmp( token, "disableIn3rdPerson" ) )
+ {
+ wi->disableIn3rdPerson = qtrue;
+
+ continue;
+ }
Com_Printf( S_COLOR_RED "ERROR: unknown token '%s'\n", token );
return qfalse;
@@ -900,17 +906,6 @@ static float CG_MachinegunSpinAngle( centity_t *cent )
/*
-========================
-CG_AddWeaponWithPowerups
-========================
-*/
-static void CG_AddWeaponWithPowerups( refEntity_t *gun, int powerups )
-{
- trap_R_AddRefEntityToScene( gun );
-}
-
-
-/*
=============
CG_AddPlayerWeapon
@@ -929,6 +924,8 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent
weaponMode_t weaponMode;
weaponInfo_t *weapon;
centity_t *nonPredictedCent;
+ pTeam_t team = cent->currentState.powerups & 0xFF;
+ qboolean noGunModel;
weaponNum = cent->currentState.weapon;
weaponMode = cent->currentState.generic1;
@@ -971,9 +968,9 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent
}
gun.hModel = weapon->weaponModel;
- if( !gun.hModel )
- return;
+ noGunModel = ( ( !ps || cg.renderingThirdPerson ) && weapon->disableIn3rdPerson ) || !gun.hModel;
+
if( !ps )
{
// add weapon ready sound
@@ -987,27 +984,30 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent
trap_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin, weapon->readySound );
}
- CG_PositionEntityOnTag( &gun, parent, parent->hModel, "tag_weapon" );
+ if( !noGunModel )
+ {
+ CG_PositionEntityOnTag( &gun, parent, parent->hModel, "tag_weapon" );
- CG_AddWeaponWithPowerups( &gun, cent->currentState.powerups );
+ trap_R_AddRefEntityToScene( &gun );
- // add the spinning barrel
- if( weapon->barrelModel )
- {
- memset( &barrel, 0, sizeof( barrel ) );
- VectorCopy( parent->lightingOrigin, barrel.lightingOrigin );
- barrel.shadowPlane = parent->shadowPlane;
- barrel.renderfx = parent->renderfx;
+ // add the spinning barrel
+ if( weapon->barrelModel )
+ {
+ memset( &barrel, 0, sizeof( barrel ) );
+ VectorCopy( parent->lightingOrigin, barrel.lightingOrigin );
+ barrel.shadowPlane = parent->shadowPlane;
+ barrel.renderfx = parent->renderfx;
- barrel.hModel = weapon->barrelModel;
- angles[ YAW ] = 0;
- angles[ PITCH ] = 0;
- angles[ ROLL ] = CG_MachinegunSpinAngle( cent );
- AnglesToAxis( angles, barrel.axis );
+ barrel.hModel = weapon->barrelModel;
+ angles[ YAW ] = 0;
+ angles[ PITCH ] = 0;
+ angles[ ROLL ] = CG_MachinegunSpinAngle( cent );
+ AnglesToAxis( angles, barrel.axis );
- CG_PositionRotatedEntityOnTag( &barrel, &gun, weapon->weaponModel, "tag_barrel" );
+ CG_PositionRotatedEntityOnTag( &barrel, &gun, weapon->weaponModel, "tag_barrel" );
- CG_AddWeaponWithPowerups( &barrel, cent->currentState.powerups );
+ trap_R_AddRefEntityToScene( &barrel );
+ }
}
// make sure we aren't looking at cg.predictedPlayerEntity for LG
@@ -1023,7 +1023,12 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent
{
if( ps || cg.renderingThirdPerson ||
cent->currentState.number != cg.predictedPlayerState.clientNum )
- CG_SetParticleSystemTag( cent->muzzlePS, gun, weapon->weaponModel, "tag_flash" );
+ {
+ if( noGunModel )
+ CG_SetParticleSystemTag( cent->muzzlePS, *parent, parent->hModel, "tag_weapon" );
+ else
+ CG_SetParticleSystemTag( cent->muzzlePS, gun, weapon->weaponModel, "tag_flash" );
+ }
//FIXME: this leaves open the possibility for keep a persistent muzzle system going
// by hopping between firing buttons -- currently nothing with a persistent
@@ -1062,7 +1067,11 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent
angles[ ROLL ] = crandom( ) * 10;
AnglesToAxis( angles, flash.axis );
- CG_PositionRotatedEntityOnTag( &flash, &gun, weapon->weaponModel, "tag_flash" );
+ if( noGunModel )
+ CG_PositionRotatedEntityOnTag( &flash, parent, parent->hModel, "tag_weapon" );
+ else
+ CG_PositionRotatedEntityOnTag( &flash, &gun, weapon->weaponModel, "tag_flash" );
+
trap_R_AddRefEntityToScene( &flash );
if( ps || cg.renderingThirdPerson ||
@@ -1071,7 +1080,12 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent
if( weapon->wim[ weaponMode ].muzzleParticleSystem && cent->muzzlePsTrigger )
{
cent->muzzlePS = CG_SpawnNewParticleSystem( weapon->wim[ weaponMode ].muzzleParticleSystem );
- CG_SetParticleSystemTag( cent->muzzlePS, gun, weapon->weaponModel, "tag_flash" );
+
+ if( noGunModel )
+ CG_SetParticleSystemTag( cent->muzzlePS, *parent, parent->hModel, "tag_weapon" );
+ else
+ CG_SetParticleSystemTag( cent->muzzlePS, gun, weapon->weaponModel, "tag_flash" );
+
CG_SetParticleSystemCent( cent->muzzlePS, cent );
CG_AttachParticleSystemToTag( cent->muzzlePS );
cent->muzzlePsTrigger = qfalse;
@@ -1106,6 +1120,11 @@ void CG_AddViewWeapon( playerState_t *ps )
vec3_t angles;
weaponInfo_t *wi;
weapon_t weapon = ps->weapon;
+ weaponMode_t weaponMode = ps->generic1;
+
+ CG_RegisterWeapon( weapon );
+ wi = &cg_weapons[ weapon ];
+ cent = &cg.predictedPlayerEntity; // &cg_entities[cg.snap->ps.clientNum];
if( ( ps->persistant[PERS_TEAM] == TEAM_SPECTATOR ) ||
( ps->stats[ STAT_STATE ] & SS_INFESTING ) ||
@@ -1132,13 +1151,20 @@ void CG_AddViewWeapon( playerState_t *ps )
{
vec3_t origin;
- //FIXME: deal with new particle system
- if( cg.predictedPlayerState.eFlags & EF_FIRING )
+ VectorCopy( cg.refdef.vieworg, origin );
+ VectorMA( origin, -8, cg.refdef.viewaxis[ 2 ], origin );
+
+ if( cent->muzzlePS )
+ CG_SetParticleSystemOrigin( cent->muzzlePS, origin );
+
+ //check for particle systems
+ if( wi->wim[ weaponMode ].muzzleParticleSystem && cent->muzzlePsTrigger )
{
- // special hack for lightning gun...
- // TA: and flamer
- VectorCopy( cg.refdef.vieworg, origin );
- VectorMA( origin, -8, cg.refdef.viewaxis[ 2 ], origin );
+ cent->muzzlePS = CG_SpawnNewParticleSystem( wi->wim[ weaponMode ].muzzleParticleSystem );
+ CG_SetParticleSystemOrigin( cent->muzzlePS, origin );
+ CG_SetParticleSystemCent( cent->muzzlePS, cent );
+ CG_AttachParticleSystemToOrigin( cent->muzzlePS );
+ cent->muzzlePsTrigger = qfalse;
}
return;
@@ -1156,10 +1182,6 @@ void CG_AddViewWeapon( playerState_t *ps )
else
fovOffset = 0;
- cent = &cg.predictedPlayerEntity; // &cg_entities[cg.snap->ps.clientNum];
- CG_RegisterWeapon( weapon );
- wi = &cg_weapons[ weapon ];
-
memset( &hand, 0, sizeof( hand ) );
// set up gun position
diff --git a/src/game/bg_pmove.c b/src/game/bg_pmove.c
index 53593573..8bac27f5 100644
--- a/src/game/bg_pmove.c
+++ b/src/game/bg_pmove.c
@@ -348,11 +348,10 @@ static float PM_CmdScale( usercmd_t *cmd )
if( pm->ps->stats[ STAT_PTEAM ] == PTE_HUMANS && pm->ps->pm_type == PM_NORMAL )
{
- if( !( pm->ps->stats[ STAT_STATE ] & SS_SPEEDBOOST ) )
- {
- //if not sprinting
+ if( pm->ps->stats[ STAT_STATE ] & SS_SPEEDBOOST )
+ modifier *= HUMAN_SPRINT_MODIFIER;
+ else
modifier *= HUMAN_JOG_MODIFIER;
- }
if( cmd->forwardmove < 0 )
{
@@ -1771,7 +1770,7 @@ static void PM_GroundClimbTrace( void )
rTtANGrTsTt -= 32768;
//set the correction angle
- if( traceCROSSsurf[ 2 ] < 0 )
+ if( traceCROSSsurf[ 2 ] <= 0.0f )
rTtANGrTsTt = -rTtANGrTsTt;
//phew! - correct the angle
@@ -2343,6 +2342,9 @@ static void PM_Footsteps( void )
}
bobmove *= BG_FindBobCycleForClass( pm->ps->stats[ STAT_PCLASS ] );
+
+ if( pm->ps->stats[ STAT_STATE ] & SS_SPEEDBOOST )
+ bobmove *= HUMAN_SPRINT_MODIFIER;
// check for footstep / splash sounds
old = pm->ps->bobCycle;
diff --git a/src/game/bg_public.h b/src/game/bg_public.h
index 550c7f2f..876a2f7e 100644
--- a/src/game/bg_public.h
+++ b/src/game/bg_public.h
@@ -541,6 +541,8 @@ typedef enum
EV_HUMAN_BUILDABLE_EXPLOSION,
EV_ALIEN_BUILDABLE_EXPLOSION,
EV_ALIEN_ACIDTUBE,
+ EV_HUMAN_BUILDABLE_DAMAGE,
+ EV_ALIEN_BUILDABLE_DAMAGE,
EV_ALIEN_EVOLVE,
diff --git a/src/game/g_combat.c b/src/game/g_combat.c
index 3d57b5b0..f820b2b0 100644
--- a/src/game/g_combat.c
+++ b/src/game/g_combat.c
@@ -990,8 +990,17 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker,
if( take )
{
targ->health = targ->health - take;
+
+ if( targ->s.eType == ET_BUILDABLE )
+ {
+ if( targ->biteam == BIT_ALIENS )
+ G_AddEvent( targ, EV_ALIEN_BUILDABLE_DAMAGE, 0 );
+ else if( targ->biteam == BIT_HUMANS )
+ G_AddEvent( targ, EV_HUMAN_BUILDABLE_DAMAGE, 0 );
+ }
+
if( targ->client )
- targ->client->ps.stats[STAT_HEALTH] = targ->health;
+ targ->client->ps.stats[ STAT_HEALTH ] = targ->health;
//TA: add to the attackers "account" on the target
if( targ->client && attacker->client &&
diff --git a/src/game/tremulous.h b/src/game/tremulous.h
index b030e6d5..692da42b 100644
--- a/src/game/tremulous.h
+++ b/src/game/tremulous.h
@@ -475,6 +475,7 @@
* HUMAN misc
*/
+#define HUMAN_SPRINT_MODIFIER 1.2f
#define HUMAN_JOG_MODIFIER 0.9f
#define HUMAN_BACK_MODIFIER 0.7f
#define HUMAN_SIDE_MODIFIER 0.8f