diff options
author | Michael Levin <risujin@fastmail.fm> | 2009-10-03 11:32:18 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-03 00:15:06 +0000 |
commit | 588af5daec6d9508b6cf46335bfc6de72c82331f (patch) | |
tree | 9e5d007cf9d99e7cd9c0f9bc329f1315967cb2bf /src | |
parent | 03d3044a87e83a85a7365e77affc68986f093f22 (diff) |
* Options menu video modes glitch fixed (a backport)
* Scores will not be reset to 0 for players whose classes change while the scoreboard is showing
* Hive offset fixed so that less of the hive is sunk under the floor
* Buildable positioning cap-traces are cached, saving CPU
* Buildable cap-traces will not interact with bodies (players and buildables)
* For Aliens holding dodge while jumping will result in a weaker jump
Marauder walljump changes:
* Finds a wall regardless of where player is aiming
* No longer uses direction keys to direct walljump (player is using these to hug the wall!)
* Will direct jump in player's view direction
Diffstat (limited to 'src')
-rw-r--r-- | src/cgame/cg_buildable.c | 31 | ||||
-rw-r--r-- | src/cgame/cg_local.h | 11 | ||||
-rw-r--r-- | src/cgame/cg_main.c | 2 | ||||
-rw-r--r-- | src/game/bg_pmove.c | 140 | ||||
-rw-r--r-- | src/game/tremulous.h | 5 |
5 files changed, 114 insertions, 75 deletions
diff --git a/src/cgame/cg_buildable.c b/src/cgame/cg_buildable.c index 3fba12e4..8f4c2e5c 100644 --- a/src/cgame/cg_buildable.c +++ b/src/cgame/cg_buildable.c @@ -622,12 +622,14 @@ static void CG_PositionAndOrientateBuildable( const vec3_t angles, const vec3_t VectorMA( inOrigin, -TRACE_DEPTH, normal, end ); VectorMA( inOrigin, 1.0f, normal, start ); - CG_CapTrace( &tr, start, mins, maxs, end, skipNumber, MASK_PLAYERSOLID ); + CG_CapTrace( &tr, start, mins, maxs, end, skipNumber, + CONTENTS_SOLID | CONTENTS_PLAYERCLIP ); if( tr.fraction == 1.0f ) { //erm we missed completely - try again with a box trace - CG_Trace( &tr, start, mins, maxs, end, skipNumber, MASK_PLAYERSOLID ); + CG_Trace( &tr, start, mins, maxs, end, skipNumber, + CONTENTS_SOLID | CONTENTS_PLAYERCLIP ); } VectorMA( inOrigin, tr.fraction * -TRACE_DEPTH, normal, outOrigin ); @@ -1286,8 +1288,29 @@ void CG_Buildable( centity_t *cent ) BG_FindBBoxForBuildable( es->modelindex, mins, maxs ); if( es->pos.trType == TR_STATIONARY ) - CG_PositionAndOrientateBuildable( angles, ent.origin, surfNormal, es->number, - mins, maxs, ent.axis, ent.origin ); + { + // Positioning a buildable involves potentially up to two traces, and + // seeing as buildables rarely move, we cache the results and recalculate + // only if the buildable moves or changes orientation + if( VectorCompare( cent->buildableCache.cachedOrigin, cent->lerpOrigin ) && + VectorCompare( cent->buildableCache.cachedNormal, surfNormal ) ) + { + VectorCopy( cent->buildableCache.axis[ 0 ], ent.axis[ 0 ] ); + VectorCopy( cent->buildableCache.axis[ 1 ], ent.axis[ 1 ] ); + VectorCopy( cent->buildableCache.axis[ 2 ], ent.axis[ 2 ] ); + } + else + { + CG_PositionAndOrientateBuildable( angles, ent.origin, surfNormal, + es->number, mins, maxs, ent.axis, + ent.origin ); + VectorCopy( ent.axis[ 0 ], cent->buildableCache.axis[ 0 ] ); + VectorCopy( ent.axis[ 1 ], cent->buildableCache.axis[ 1 ] ); + VectorCopy( ent.axis[ 2 ], cent->buildableCache.axis[ 2 ] ); + VectorCopy( cent->lerpOrigin, cent->buildableCache.cachedOrigin ); + VectorCopy( surfNormal, cent->buildableCache.cachedNormal ); + } + } //offset on the Z axis if required VectorMA( ent.origin, BG_FindZOffsetForBuildable( es->modelindex ), surfNormal, ent.origin ); diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index 891edbd4..d969dca1 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -599,6 +599,14 @@ typedef struct buildableStatus_s qboolean visible; // Status is visble? } buildableStatus_t; +typedef struct buildableCache_s +{ + vec3_t cachedOrigin; // If either the cached entity origin or the + vec3_t cachedNormal; // cached surfNormal change the cache is invalid + vec3_t axis[ 3 ]; + vec3_t origin; +} buildableCache_t; + //================================================= // centity_t have a direct corespondence with gentity_t in the game, but @@ -643,6 +651,7 @@ typedef struct centity_s buildableAnimNumber_t oldBuildableAnim; //to detect when new anims are set particleSystem_t *buildablePS; buildableStatus_t buildableStatus; + buildableCache_t buildableCache; // so we don't recalculate things float lastBuildableHealthScale; int lastBuildableDamageSoundTime; @@ -672,7 +681,7 @@ typedef struct centity_s int muzzleTSDeathTime; qboolean valid; - qboolean oldValid; + qboolean oldValid; } centity_t; diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c index c094ffee..c4c47baa 100644 --- a/src/cgame/cg_main.c +++ b/src/cgame/cg_main.c @@ -1589,7 +1589,7 @@ static const char *CG_FeederItemText( float feederID, int index, int column, qha break; case 4: - return va( "%d", info->score ); + return va( "%d", sp->score ); break; case 5: diff --git a/src/game/bg_pmove.c b/src/game/bg_pmove.c index 46d55cc2..8055f115 100644 --- a/src/game/bg_pmove.c +++ b/src/game/bg_pmove.c @@ -595,60 +595,92 @@ PM_CheckWallJump */ static qboolean PM_CheckWallJump( void ) { - vec3_t dir, forward, right; - vec3_t refNormal = { 0.0f, 0.0f, 1.0f }; - float normalFraction = 1.5f; - float cmdFraction = 1.0f; - float upFraction = 1.5f; + trace_t trace; + vec3_t point, dir, forward, right; + float magnitude; + int i; + // don't allow jump until all buttons are up if( pm->ps->pm_flags & PMF_RESPAWNED ) - return qfalse; // don't allow jump until all buttons are up + return qfalse; + // not holding jump if( pm->cmd.upmove < 10 ) - // not holding jump return qfalse; + // walljump timeout if( pm->ps->pm_flags & PMF_TIME_WALLJUMP ) return qfalse; // must wait for jump to be released - if( pm->ps->pm_flags & PMF_JUMP_HELD && - pm->ps->grapplePoint[ 2 ] == 1.0f ) + if( pm->ps->pm_flags & PMF_JUMP_HELD ) { // clear upmove so cmdscale doesn't lower running speed pm->cmd.upmove = 0; return qfalse; } - pm->ps->pm_flags |= PMF_TIME_WALLJUMP; - pm->ps->pm_time = 200; + ProjectPointOnPlane( forward, pml.forward, pm->ps->grapplePoint ); + ProjectPointOnPlane( right, pml.right, pm->ps->grapplePoint ); - pml.groundPlane = qfalse; // jumping away - pml.walking = qfalse; - pm->ps->pm_flags |= PMF_JUMP_HELD; + // Trace to find a suitable wall + for( i = 0; ; i++) + { + switch( i ) + { + // Forward + case 0: + VectorMA( pm->ps->origin, 0.25f, forward, point ); + break; - pm->ps->groundEntityNum = ENTITYNUM_NONE; + // Right + case 1: + VectorMA( pm->ps->origin, 0.25f, right, point ); + break; - ProjectPointOnPlane( forward, pml.forward, pm->ps->grapplePoint ); - ProjectPointOnPlane( right, pml.right, pm->ps->grapplePoint ); + // Left + case 2: + VectorMA( pm->ps->origin, -0.25f, right, point ); + break; - VectorScale( pm->ps->grapplePoint, normalFraction, dir ); + // Back + case 3: + VectorMA( pm->ps->origin, -0.25f, forward, point ); + break; - if( pm->cmd.forwardmove > 0 ) - VectorMA( dir, cmdFraction, forward, dir ); - else if( pm->cmd.forwardmove < 0 ) - VectorMA( dir, -cmdFraction, forward, dir ); + // Give up + default: + return qfalse; + } + pm->trace( &trace, pm->ps->origin, pm->mins, pm->maxs, point, + pm->ps->clientNum, pm->tracemask ); + if( trace.fraction < 1.0f && + !( trace.surfaceFlags & ( SURF_SKY | SURF_SLICK ) ) ) + break; + } - if( pm->cmd.rightmove > 0 ) - VectorMA( dir, cmdFraction, right, dir ); - else if( pm->cmd.rightmove < 0 ) - VectorMA( dir, -cmdFraction, right, dir ); + VectorCopy( trace.plane.normal, pm->ps->grapplePoint ); - VectorMA( dir, upFraction, refNormal, dir ); - VectorNormalize( dir ); + pml.groundPlane = qfalse; + pml.walking = qfalse; + + pm->ps->pm_flags |= PMF_TIME_WALLJUMP | PMF_JUMP_HELD; + pm->ps->pm_time = 200; + pm->ps->groundEntityNum = ENTITYNUM_NONE; + + ProjectPointOnPlane( forward, pml.forward, pm->ps->grapplePoint ); - VectorMA( pm->ps->velocity, BG_FindJumpMagnitudeForClass( pm->ps->stats[ STAT_PCLASS ] ), - dir, pm->ps->velocity ); + // Add all the jump components + VectorScale( pm->ps->grapplePoint, LEVEL2_WALLJUMP_NORMAL, dir ); + VectorMA( dir, LEVEL2_WALLJUMP_FORWARD, forward, dir ); + dir[ 2 ] += LEVEL2_WALLJUMP_UP; + + // Give the player some velocity + magnitude = BG_FindJumpMagnitudeForClass( pm->ps->stats[ STAT_PCLASS ] ); + if( ( pm->cmd.buttons & BUTTON_DODGE ) && + pm->ps->stats[ STAT_PTEAM ] == PTE_ALIENS ) + magnitude *= ALIEN_MINI_JUMP_SCALE; + VectorMA( pm->ps->velocity, magnitude, dir, pm->ps->velocity ); //for a long run of wall jumps the velocity can get pretty large, this caps it if( VectorLength( pm->ps->velocity ) > LEVEL2_WALLJUMP_MAXSPEED ) @@ -689,17 +721,16 @@ PM_CheckJump static qboolean PM_CheckJump( void ) { vec3_t normal; + float magnitude; // don't rejump after a dodge or jump if( pm->ps->pm_flags & PMF_TIME_LAND ) return qfalse; - if( BG_FindJumpMagnitudeForClass( pm->ps->stats[ STAT_PCLASS ] ) == 0.0f ) + magnitude = BG_FindJumpMagnitudeForClass( pm->ps->stats[ STAT_PCLASS ] ); + if( magnitude == 0.0f ) return qfalse; - if( BG_ClassHasAbility( pm->ps->stats[ STAT_PCLASS ], SCA_WALLJUMPER ) ) - return PM_CheckWallJump( ); - //can't jump and pounce at the same time if( ( pm->ps->weapon == WP_ALEVEL3 || pm->ps->weapon == WP_ALEVEL3_UPG ) && @@ -737,7 +768,7 @@ static qboolean PM_CheckJump( void ) return qfalse; } - pml.groundPlane = qfalse; // jumping away + pml.groundPlane = qfalse; pml.walking = qfalse; pm->ps->pm_flags |= PMF_JUMP_HELD; @@ -750,8 +781,10 @@ static qboolean PM_CheckJump( void ) // jump away from wall BG_GetClientNormal( pm->ps, normal ); - VectorMA( pm->ps->velocity, BG_FindJumpMagnitudeForClass( pm->ps->stats[ STAT_PCLASS ] ), - normal, pm->ps->velocity ); + if( ( pm->cmd.buttons & BUTTON_DODGE ) && + pm->ps->stats[ STAT_PTEAM ] == PTE_ALIENS ) + magnitude *= ALIEN_MINI_JUMP_SCALE; + VectorMA( pm->ps->velocity, magnitude, normal, pm->ps->velocity ); PM_AddEvent( EV_JUMP ); @@ -2118,7 +2151,6 @@ PM_GroundTrace static void PM_GroundTrace( void ) { vec3_t point; - vec3_t movedir; vec3_t refNormal = { 0.0f, 0.0f, 1.0f }; trace_t trace; @@ -2220,37 +2252,7 @@ static void PM_GroundTrace( void ) pml.groundPlane = qfalse; pml.walking = qfalse; - if( BG_ClassHasAbility( pm->ps->stats[ STAT_PCLASS ], SCA_WALLJUMPER ) ) - { - ProjectPointOnPlane( movedir, pml.forward, refNormal ); - VectorNormalize( movedir ); - - if( pm->cmd.forwardmove < 0 ) - VectorNegate( movedir, movedir ); - - //allow strafe transitions - if( pm->cmd.rightmove ) - { - VectorCopy( pml.right, movedir ); - - if( pm->cmd.rightmove < 0 ) - VectorNegate( movedir, movedir ); - } - - //trace into direction we are moving - VectorMA( pm->ps->origin, 0.25f, movedir, point ); - pm->trace( &trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask ); - - if( trace.fraction < 1.0f && !( trace.surfaceFlags & ( SURF_SKY | SURF_SLICK ) ) ) - { - if( !VectorCompare( trace.plane.normal, pm->ps->grapplePoint ) ) - { - VectorCopy( trace.plane.normal, pm->ps->grapplePoint ); - PM_CheckWallJump( ); - } - } - } - + PM_CheckWallJump( ); return; } } diff --git a/src/game/tremulous.h b/src/game/tremulous.h index 3517a268..9dfa78d2 100644 --- a/src/game/tremulous.h +++ b/src/game/tremulous.h @@ -83,6 +83,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define LEVEL2_AREAZAP_REPEAT 500 #define LEVEL2_AREAZAP_MAX_TARGETS 3 #define LEVEL2_WALLJUMP_MAXSPEED 1000.0f +#define LEVEL2_WALLJUMP_NORMAL 0.375f // magnitude scale from surface +#define LEVEL2_WALLJUMP_FORWARD 0.250f // magnitude scale in view direction +#define LEVEL2_WALLJUMP_UP 0.375f // magnitude scale up #define LEVEL3_CLAW_DMG ADM(80) #define LEVEL3_CLAW_UPG_RANGE 96.0f @@ -352,6 +355,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define ALIEN_CREDITS_PER_FRAG 400 #define ALIEN_TK_SUICIDE_PENALTY 350 +#define ALIEN_MINI_JUMP_SCALE 0.667f // scales jump magnitude for a mini-jump + // Uncomment to allow Aliens to wallwalk on any entity (buildables, players, etc) //#define ALIEN_WALLWALK_ENTITIES |