diff options
author | Michael Levin <risujin@fastmail.fm> | 2009-10-03 11:30:33 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-03 00:15:03 +0000 |
commit | ca3ade0361afe2b5d87c7a46543e6937b04b89bf (patch) | |
tree | 1bd831b9fe1d0ffbc8f57f6b5029aafff79aa386 | |
parent | 4249be79aaab686a2df532ab6e18ead135aff5c6 (diff) |
* Buildable health accuracy increased to 8 bits, flags moved to eFlags (EF_B_*)
* Fixed Tesla Generator not firing over turrets or missing small aliens entirely -- it now shoots from the top of its bounding box to the top of its target's bounding box
* Dying, evolving, or changing teams properly resets the weapon
Flame thrower changes:
* Reverted flame thrower missile radius to 15
* Muzzle is offset for flame thrower to shoot from the hand
-rw-r--r-- | scripts/weapons.particle | 7 | ||||
-rw-r--r-- | src/cgame/cg_buildable.c | 17 | ||||
-rw-r--r-- | src/cgame/cg_tutorial.c | 6 | ||||
-rw-r--r-- | src/game/bg_public.h | 9 | ||||
-rw-r--r-- | src/game/g_buildable.c | 83 | ||||
-rw-r--r-- | src/game/g_client.c | 6 | ||||
-rw-r--r-- | src/game/g_weapon.c | 86 | ||||
-rw-r--r-- | src/game/tremulous.h | 2 |
8 files changed, 98 insertions, 118 deletions
diff --git a/scripts/weapons.particle b/scripts/weapons.particle index 70d3c221..0b0f8fab 100644 --- a/scripts/weapons.particle +++ b/scripts/weapons.particle @@ -313,12 +313,7 @@ models/weapons/flamer/muzzlePS velocityMagnitude 300
velocity 0 0 0 ~0
- accelerationType static
- accelerationDir linear
- accelerationMagnitude 50
- acceleration 0 0 1 ~0 - - physicsRadius 8
+ physicsRadius 15
radius 0 4.0 40.0
alpha 0 1.0 1.0
diff --git a/src/cgame/cg_buildable.c b/src/cgame/cg_buildable.c index 054068f4..3fba12e4 100644 --- a/src/cgame/cg_buildable.c +++ b/src/cgame/cg_buildable.c @@ -548,7 +548,7 @@ static void CG_BuildableAnimation( centity_t *cent, int *old, int *now, float *b cent->buildableAnim = es->torsoAnim; //display the first frame of the construction anim if not yet spawned - if( !( es->generic1 & B_SPAWNED_TOGGLEBIT ) ) + if( !( es->eFlags & EF_B_SPAWNED ) ) { animation_t *anim = &cg_buildables[ es->modelindex ].animations[ BANIM_CONSTRUCT1 ]; @@ -701,7 +701,7 @@ static void CG_BuildableParticleEffects( centity_t *cent ) int health = es->generic1 & B_HEALTH_MASK; float healthFrac = (float)health / B_HEALTH_MASK; - if( !( es->generic1 & B_SPAWNED_TOGGLEBIT ) ) + if( !( es->eFlags & EF_B_SPAWNED ) ) return; if( team == BIT_HUMANS ) @@ -926,7 +926,7 @@ static void CG_BuildableStatusDisplay( centity_t *cent ) // hack for shrunken barricades anim = es->torsoAnim & ~( ANIM_FORCEBIT | ANIM_TOGGLEBIT ); if( es->modelindex == BA_A_BARRICADE && - ( anim == BANIM_DESTROYED || !( es->generic1 & B_SPAWNED_TOGGLEBIT ) ) ) + ( anim == BANIM_DESTROYED || !( es->eFlags & EF_B_SPAWNED ) ) ) maxs[ 2 ] = (int)( maxs[ 2 ] * BARRICADE_SHRINKPROP ); VectorCopy( cent->lerpOrigin, origin ); @@ -972,7 +972,7 @@ static void CG_BuildableStatusDisplay( centity_t *cent ) hit = &cg_entities[ tr.entityNum ].currentState; if( tr.entityNum < MAX_CLIENTS || ( hit->eType == ET_BUILDABLE && - ( !( es->generic1 & B_SPAWNED_TOGGLEBIT ) || + ( !( es->eFlags & EF_B_SPAWNED ) || BG_FindTransparentTestForBuildable( hit->modelindex ) ) ) ) { entNum = tr.entityNum; @@ -1041,8 +1041,8 @@ static void CG_BuildableStatusDisplay( centity_t *cent ) // this is fudged to get the width/height in the cfg to be more realistic scale = ( picH / d ) * 3; - powered = es->generic1 & B_POWERED_TOGGLEBIT; - marked = es->generic1 & B_MARKED_TOGGLEBIT; + powered = es->eFlags & EF_B_POWERED; + marked = es->eFlags & EF_B_MARKED; picH *= scale; picW *= scale; @@ -1297,7 +1297,7 @@ void CG_Buildable( centity_t *cent ) ent.hModel = cg_buildables[ es->modelindex ].models[ 0 ]; - if( !( es->generic1 & B_SPAWNED_TOGGLEBIT ) ) + if( !( es->eFlags & EF_B_SPAWNED ) ) { sfxHandle_t prebuildSound = cgs.media.humanBuildablePrebuild; @@ -1455,7 +1455,8 @@ void CG_Buildable( centity_t *cent ) health = es->generic1 & B_HEALTH_MASK; healthScale = (float)health / B_HEALTH_MASK; - if( healthScale < cent->lastBuildableHealthScale && ( es->generic1 & B_SPAWNED_TOGGLEBIT ) ) + if( healthScale < cent->lastBuildableHealthScale && + ( es->eFlags & EF_B_SPAWNED ) ) { if( cent->lastBuildableDamageSoundTime + BUILDABLE_SOUND_PERIOD < cg.time ) { diff --git a/src/cgame/cg_tutorial.c b/src/cgame/cg_tutorial.c index 9bd258fb..0375b3e0 100644 --- a/src/cgame/cg_tutorial.c +++ b/src/cgame/cg_tutorial.c @@ -201,7 +201,7 @@ static void CG_AlienBuilderText( char *text, playerState_t *ps ) { if( cgs.markDeconstruct ) { - if( es->generic1 & B_MARKED_TOGGLEBIT ) + if( es->eFlags & EF_B_MARKED ) { Q_strcat( text, MAX_TUTORIAL_TEXT, va( "Press %s to unmark this structure\n", @@ -388,7 +388,7 @@ static void CG_HumanCkitText( char *text, playerState_t *ps ) { if( cgs.markDeconstruct ) { - if( es->generic1 & B_MARKED_TOGGLEBIT ) + if( es->eFlags & EF_B_MARKED ) { Q_strcat( text, MAX_TUTORIAL_TEXT, va( "Press %s to unmark this structure\n", @@ -670,7 +670,7 @@ const char *CG_TutorialText( void ) CG_KeyNameForCommand( "+button7" ) ) ); } else if( es && es->modelindex == BA_A_HOVEL && - es->generic1 & B_SPAWNED_TOGGLEBIT && + ( es->eFlags & EF_B_SPAWNED ) && ( ps->stats[ STAT_PCLASS ] == PCL_ALIEN_BUILDER0 || ps->stats[ STAT_PCLASS ] == PCL_ALIEN_BUILDER0_UPG ) ) { diff --git a/src/game/bg_public.h b/src/game/bg_public.h index 30afb07f..67899978 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -285,6 +285,9 @@ typedef enum #define EF_BOUNCE 0x00000008 // for missiles #define EF_BOUNCE_HALF 0x00000010 // for missiles #define EF_NO_BOUNCE_SOUND 0x00000020 // for missiles +#define EF_B_SPAWNED 0x00000008 // buildable has spawned +#define EF_B_POWERED 0x00000010 // buildable is powered +#define EF_B_MARKED 0x00000020 // buildable is marked for deconstruction #define EF_WALLCLIMB 0x00000040 // wall walking #define EF_WALLCLIMBCEILING 0x00000080 // wall walking ceiling hack #define EF_NODRAW 0x00000100 // may have an event, but no model (unspawned items) @@ -441,12 +444,6 @@ typedef enum #define B_HEALTH_BITS 12 #define B_HEALTH_MASK ((1<<B_HEALTH_BITS)-1) -#define B_MARKED_TOGGLEBIT 0x00001000 -#define B_SPAWNED_TOGGLEBIT 0x00002000 -#define B_POWERED_TOGGLEBIT 0x00004000 -#define B_DCCED_TOGGLEBIT 0x00008000 - - // reward sounds (stored in ps->persistant[PERS_PLAYEREVENTS]) #define PLAYEREVENT_DENIEDREWARD 0x0001 #define PLAYEREVENT_GAUNTLETREWARD 0x0002 diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index e44623ee..fc119ad9 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -2182,13 +2182,6 @@ Think function for Tesla Generator */ void HTeslaGen_Think( gentity_t *self ) { - int entityList[ MAX_GENTITIES ]; - vec3_t range; - vec3_t mins, maxs; - vec3_t dir; - int i, num; - gentity_t *enemy; - self->nextthink = level.time + BG_FindNextThinkForBuildable( self->s.modelindex ); //if not powered don't do anything and check again for power next think @@ -2201,31 +2194,28 @@ void HTeslaGen_Think( gentity_t *self ) if( self->spawned && self->count < level.time ) { - //used to mark client side effects + vec3_t range, mins, maxs, dir; + int entityList[ MAX_GENTITIES ], i, num; + + // Communicates firing state to client self->s.eFlags &= ~EF_FIRING; VectorSet( range, TESLAGEN_RANGE, TESLAGEN_RANGE, TESLAGEN_RANGE ); VectorAdd( self->s.origin, range, maxs ); VectorSubtract( self->s.origin, range, mins ); - //find aliens + // Attack nearby Aliens num = trap_EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES ); for( i = 0; i < num; i++ ) { - enemy = &g_entities[ entityList[ i ] ]; - - if( enemy->client && enemy->client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS && - enemy->health > 0 && - Distance( enemy->s.pos.trBase, self->s.pos.trBase ) <= TESLAGEN_RANGE ) - { - VectorSubtract( enemy->s.pos.trBase, self->s.pos.trBase, dir ); - VectorNormalize( dir ); - vectoangles( dir, self->turretAim ); - - //fire at target + self->enemy = &g_entities[ entityList[ i ] ]; + if( self->enemy->client && self->enemy->health > 0 && + self->enemy->client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS && + Distance( self->enemy->s.pos.trBase, + self->s.pos.trBase ) <= TESLAGEN_RANGE ) FireWeapon( self ); - } } + self->enemy = NULL; if( self->s.eFlags & EF_FIRING ) { @@ -2473,28 +2463,8 @@ void G_BuildableThink( gentity_t *ent, int msec ) ent->spawned = qtrue; } - // pack health, power and dcc - ent->dcc = ( ent->biteam != BIT_HUMANS ) ? 0 : G_FindDCC( ent ); - ent->s.generic1 = (int)( ( ent->health + bHealth / B_HEALTH_MASK - 1 ) * - B_HEALTH_MASK / bHealth ); - - if( ent->s.generic1 < 0 ) - ent->s.generic1 = 0; - - if( ent->powered ) - ent->s.generic1 |= B_POWERED_TOGGLEBIT; - - if( ent->dcc ) - ent->s.generic1 |= B_DCCED_TOGGLEBIT; - - if( ent->spawned ) - ent->s.generic1 |= B_SPAWNED_TOGGLEBIT; - - if( ent->deconstruct ) - ent->s.generic1 |= B_MARKED_TOGGLEBIT; - + // Timer actions ent->time1000 += msec; - if( ent->time1000 >= 1000 ) { ent->time1000 -= 1000; @@ -2528,6 +2498,27 @@ void G_BuildableThink( gentity_t *ent, int msec ) if( ent->clientSpawnTime < 0 ) ent->clientSpawnTime = 0; + // Pack health + ent->dcc = ( ent->biteam != BIT_HUMANS ) ? 0 : G_FindDCC( ent ); + if( ent->health > 0 ) + { + ent->s.generic1 = (int)( ( ent->health + bHealth / B_HEALTH_MASK - 1 ) * + B_HEALTH_MASK / bHealth ); + } + else + ent->s.generic1 = 0; + + // Set flags + ent->s.eFlags &= ~( EF_B_POWERED | EF_B_SPAWNED | EF_B_MARKED ); + if( ent->powered ) + ent->s.eFlags |= EF_B_POWERED; + + if( ent->spawned ) + ent->s.eFlags |= EF_B_SPAWNED; + + if( ent->deconstruct ) + ent->s.eFlags |= EF_B_MARKED; + //check if this buildable is touching any triggers G_BuildableTouchTriggers( ent ); @@ -3338,12 +3329,12 @@ static gentity_t *G_Build( gentity_t *builder, buildable_t buildable, vec3_t ori if( BG_FindTeamForBuildable( built->s.modelindex ) == PTE_ALIENS ) { built->powered = qtrue; - built->s.generic1 |= B_POWERED_TOGGLEBIT; + built->s.eFlags |= EF_B_POWERED; } else if( ( built->powered = G_FindPower( built ) ) ) - built->s.generic1 |= B_POWERED_TOGGLEBIT; + built->s.eFlags |= EF_B_POWERED; - built->s.generic1 &= ~B_SPAWNED_TOGGLEBIT; + built->s.eFlags &= ~EF_B_SPAWNED; VectorCopy( normal, built->s.origin2 ); @@ -3461,7 +3452,7 @@ static void G_FinishSpawningBuildable( gentity_t *ent ) built->takedamage = qtrue; built->spawned = qtrue; //map entities are already spawned built->health = BG_FindHealthForBuildable( buildable ); - built->s.generic1 |= B_SPAWNED_TOGGLEBIT; + built->s.eFlags |= EF_B_SPAWNED; // drop towards normal surface VectorScale( built->s.origin2, -4096.0f, dest ); diff --git a/src/game/g_client.c b/src/game/g_client.c index 621a0261..f9742109 100644 --- a/src/game/g_client.c +++ b/src/game/g_client.c @@ -1500,6 +1500,9 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn, vec3_t origin, vec3_t angles client->ps.ammo = maxAmmo; client->ps.clips = maxClips; + // We just spawned, not changing weapons + client->ps.persistant[ PERS_NEWWEAPON ] = 0; + ent->client->ps.stats[ STAT_PCLASS ] = ent->client->pers.classSelection; ent->client->ps.stats[ STAT_PTEAM ] = ent->client->pers.teamSelection; @@ -1571,9 +1574,8 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn, vec3_t origin, vec3_t angles trap_GetUsercmd( client - level.clients, &ent->client->pers.cmd ); G_SetClientViewAngle( ent, spawn_angles ); - if( !( client->sess.sessionTeam == TEAM_SPECTATOR ) ) + if( client->sess.sessionTeam != TEAM_SPECTATOR ) { - /*G_KillBox( ent );*/ //blame this if a newly spawned client gets stuck in another trap_LinkEntity( ent ); // force the base weapon up diff --git a/src/game/g_weapon.c b/src/game/g_weapon.c index 759a1a04..24317bd2 100644 --- a/src/game/g_weapon.c +++ b/src/game/g_weapon.c @@ -593,11 +593,12 @@ HIVE void hiveFire( gentity_t *ent ) { - gentity_t *m; - - m = fire_hive( ent, muzzle, forward ); + vec3_t origin; -// VectorAdd( m->s.pos.trDelta, ent->client->ps.velocity, m->s.pos.trDelta ); // "real" physics + // Fire from the hive tip, not the center + VectorMA( muzzle, ent->r.maxs[ 2 ], ent->s.origin2, origin ); + + fire_hive( ent, origin, forward ); } /* @@ -644,9 +645,15 @@ FLAME THROWER void flamerFire( gentity_t *ent ) { - gentity_t *m; + vec3_t origin; + + // Correct muzzle so that the missile does not start in the ceiling + VectorMA( muzzle, -7.0f, up, origin ); - m = fire_flamer( ent, muzzle, forward ); + // Correct muzzle so that the missile fires from the player's hand + VectorMA( origin, 4.5f, right, origin ); + + fire_flamer( ent, origin, forward ); } /* @@ -792,49 +799,44 @@ TESLA GENERATOR */ -void teslaFire( gentity_t *ent ) +void teslaFire( gentity_t *self ) { - trace_t tr; - vec3_t end; - gentity_t *traceEnt, *tent; - - VectorMA( muzzle, TESLAGEN_RANGE, forward, end ); - - trap_Trace( &tr, muzzle, NULL, NULL, end, ent->s.number, MASK_SHOT ); - - if( tr.entityNum == ENTITYNUM_NONE ) + trace_t tr; + vec3_t origin, target; + gentity_t *tent; + + if( !self->enemy ) return; - traceEnt = &g_entities[ tr.entityNum ]; + // Move the muzzle from the entity origin up a bit to fire over turrets + VectorMA( muzzle, self->r.maxs[ 2 ], self->s.origin2, origin ); - if( !traceEnt->client ) - return; + // Don't aim for the center, aim at the top of the bounding box + VectorCopy( self->enemy->s.origin, target ); + target[ 2 ] += self->enemy->r.maxs[ 2 ]; - if( traceEnt->client && traceEnt->client->ps.stats[ STAT_PTEAM ] != PTE_ALIENS ) + // Trace to the target entity + trap_Trace( &tr, origin, NULL, NULL, target, self->s.number, MASK_SHOT ); + if( tr.entityNum != self->enemy->s.number ) return; - //so the client side knows - ent->s.eFlags |= EF_FIRING; + // Client side firing effect + self->s.eFlags |= EF_FIRING; - if( traceEnt->takedamage ) + // Deal damage + if( self->enemy->takedamage ) { - G_Damage( traceEnt, ent, ent, forward, tr.endpos, - TESLAGEN_DMG, 0, MOD_TESLAGEN ); + vec3_t dir; + + VectorSubtract( target, origin, dir ); + G_Damage( self->enemy, self, self, dir, tr.endpos, + TESLAGEN_DMG, 0, MOD_TESLAGEN ); } - // snap the endpos to integers to save net bandwidth, but nudged towards the line - SnapVectorTowards( tr.endpos, muzzle ); - - // send railgun beam effect + // Send tesla zap trail tent = G_TempEntity( tr.endpos, EV_TESLATRAIL ); - - VectorCopy( muzzle, tent->s.origin2 ); - - tent->s.generic1 = ent->s.number; //src - tent->s.clientNum = traceEnt->s.number; //dest - - // move origin a bit to come closer to the drawn gun muzzle - VectorMA( tent->s.origin2, 28, up, tent->s.origin2 ); + tent->s.generic1 = self->s.number; // src + tent->s.clientNum = self->enemy->s.number; // dest } @@ -1532,20 +1534,12 @@ void FireWeapon( gentity_t *ent ) { // set aiming directions AngleVectors( ent->client->ps.viewangles, forward, right, up ); - CalcMuzzlePoint( ent, forward, right, up, muzzle ); + CalcMuzzlePoint( ent, forward, right, up, muzzle ); } else { AngleVectors( ent->turretAim, forward, right, up ); VectorCopy( ent->s.pos.trBase, muzzle ); - - // Hive muzzle point is on the tip - if( ent->s.eType == ET_BUILDABLE && ent->s.modelindex == BA_A_HIVE ) - VectorMA( muzzle, ent->r.maxs[ 2 ], ent->s.origin2, muzzle ); - - // Tesla generator muzzle point is offset too - if( ent->s.eType == ET_BUILDABLE && ent->s.modelindex == BA_H_TESLAGEN ) - VectorMA( muzzle, 28.0f, ent->s.origin2, muzzle ); } // fire the specific weapon diff --git a/src/game/tremulous.h b/src/game/tremulous.h index ce9136f0..3517a268 100644 --- a/src/game/tremulous.h +++ b/src/game/tremulous.h @@ -448,7 +448,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define FLAMER_K_SCALE 1.0f #define FLAMER_DMG HDM(20) #define FLAMER_RADIUS 50 // splash radius -#define FLAMER_SIZE 8 // missile bounding box +#define FLAMER_SIZE 15 // missile bounding box #define FLAMER_LIFETIME 700.0f #define FLAMER_SPEED 300.0f #define FLAMER_LAG 0.65f // the amount of player velocity that is added to the fireball |