diff options
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/bg_pmove.c | 225 | ||||
-rw-r--r-- | src/game/g_weapon.c | 129 | ||||
-rw-r--r-- | src/game/tremulous.h | 10 |
3 files changed, 126 insertions, 238 deletions
diff --git a/src/game/bg_pmove.c b/src/game/bg_pmove.c index 81563829..ee800910 100644 --- a/src/game/bg_pmove.c +++ b/src/game/bg_pmove.c @@ -595,114 +595,62 @@ PM_CheckWallJump */ static qboolean PM_CheckWallJump( void ) { - trace_t trace; - vec3_t mins, point, dir; - float magnitude, towardSurf; - int i; - qboolean minijump; - - // Has to be able to walljump - if( !BG_ClassHasAbility( pm->ps->stats[ STAT_PCLASS ], SCA_WALLJUMPER ) ) - return qfalse; + 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; - // Don't allow jump until all buttons are up if( pm->ps->pm_flags & PMF_RESPAWNED ) - return qfalse; + return qfalse; // don't allow jump until all buttons are up - // Not holding jump or minijump - minijump = pm->ps->stats[ STAT_PTEAM ] == PTE_ALIENS && - ( pm->cmd.buttons & BUTTON_DODGE ); - if( pm->cmd.upmove < 10 && !minijump ) + 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 ) + if( pm->ps->pm_flags & PMF_JUMP_HELD && + pm->ps->grapplePoint[ 2 ] == 1.0f ) { // clear upmove so cmdscale doesn't lower running speed pm->cmd.upmove = 0; return qfalse; } - // We don't want to hit the floor so adjust the mins - VectorCopy( pm->mins, mins ); - mins[ 2 ] += STEPSIZE; + pm->ps->pm_flags |= PMF_TIME_WALLJUMP; + pm->ps->pm_time = 200; - // Trace to find a suitable wall - for( i = 0; ; i++) - { - VectorCopy( pm->ps->origin, point ); + pml.groundPlane = qfalse; // jumping away + pml.walking = qfalse; + pm->ps->pm_flags |= PMF_JUMP_HELD; - switch( i ) - { - case 0: - point[ 0 ] += LEVEL2_WALLJUMP_RANGE; // +x - break; - case 1: - point[ 0 ] -= LEVEL2_WALLJUMP_RANGE; // -x - break; - case 2: - point[ 1 ] += LEVEL2_WALLJUMP_RANGE; // +y - break; - case 3: - point[ 1 ] -= LEVEL2_WALLJUMP_RANGE; // -y - break; + pm->ps->groundEntityNum = ENTITYNUM_NONE; - // Give up - default: - return qfalse; - } - pm->trace( &trace, pm->ps->origin, mins, pm->maxs, point, - pm->ps->clientNum, pm->tracemask ); - if( trace.fraction < 1.0f && - !( trace.surfaceFlags & ( SURF_SKY | SURF_SLICK ) ) ) - break; - } + ProjectPointOnPlane( forward, pml.forward, pm->ps->grapplePoint ); + ProjectPointOnPlane( right, pml.right, pm->ps->grapplePoint ); - VectorCopy( trace.plane.normal, pm->ps->grapplePoint ); + VectorScale( pm->ps->grapplePoint, normalFraction, dir ); - pml.groundPlane = qfalse; - pml.walking = qfalse; - - pm->ps->pm_flags |= PMF_TIME_WALLJUMP | PMF_JUMP_HELD; - pm->ps->pm_time = LEVEL2_WALLJUMP_REPEAT; - pm->ps->groundEntityNum = ENTITYNUM_NONE; + if( pm->cmd.forwardmove > 0 ) + VectorMA( dir, cmdFraction, forward, dir ); + else if( pm->cmd.forwardmove < 0 ) + VectorMA( dir, -cmdFraction, forward, dir ); - // Jump magnitude is modulated for minijumps - magnitude = BG_FindJumpMagnitudeForClass( pm->ps->stats[ STAT_PCLASS ] ); - if( minijump ) - magnitude *= ALIEN_MINI_JUMP_SCALE; - - // Remove the velocity component toward the surface - towardSurf = -DotProduct( pm->ps->velocity, pm->ps->grapplePoint ); - if( towardSurf <= 0 ) - towardSurf = 0; - VectorMA( pm->ps->velocity, towardSurf, pm->ps->grapplePoint, - pm->ps->velocity ); - - // Compute horizontal view component, subtracting normal - VectorScale( pml.forward, LEVEL2_WALLJUMP_FORWARD, dir ); - dir[ 2 ] += LEVEL2_WALLJUMP_UP; - towardSurf = -DotProduct( dir, pm->ps->grapplePoint ); - if( towardSurf > 0 ) - VectorMA( dir, towardSurf, pm->ps->grapplePoint, dir ); - - // Add normal component and normalize - VectorMA( dir, LEVEL2_WALLJUMP_NORMAL, pm->ps->grapplePoint, dir ); + if( pm->cmd.rightmove > 0 ) + VectorMA( dir, cmdFraction, right, dir ); + else if( pm->cmd.rightmove < 0 ) + VectorMA( dir, -cmdFraction, right, dir ); + + VectorMA( dir, upFraction, refNormal, dir ); VectorNormalize( dir ); - - // Apply jump impulse to velocity - VectorMA( pm->ps->velocity, magnitude, dir, pm->ps->velocity ); - - if( pm->debugLevel ) - Com_Printf( "%i: walljump velocity { %f, %f, %f }\n", c_pmove, - pm->ps->velocity[ 0 ], pm->ps->velocity[ 1 ], - pm->ps->velocity[ 2 ] ); - - // Cap velocity + + VectorMA( pm->ps->velocity, BG_FindJumpMagnitudeForClass( pm->ps->stats[ STAT_PCLASS ] ), + 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 ) { VectorNormalize( pm->ps->velocity ); @@ -711,7 +659,6 @@ static qboolean PM_CheckWallJump( void ) PM_AddEvent( EV_JUMP ); - // Set jumping animation if( pm->cmd.forwardmove >= 0 ) { if( !( pm->ps->persistant[ PERS_STATE ] & PS_NONSEGMODEL ) ) @@ -734,87 +681,72 @@ static qboolean PM_CheckWallJump( void ) return qtrue; } -/* -============= -PM_CheckJump -============= -*/ static qboolean PM_CheckJump( void ) { vec3_t normal; - float magnitude; - qboolean minijump; - - // Can't jump in the air - if( pm->ps->groundEntityNum == ENTITYNUM_NONE ) - return qfalse; - // Don't rejump after a dodge or jump - if( pm->ps->pm_flags & PMF_TIME_LAND ) + if( BG_FindJumpMagnitudeForClass( pm->ps->stats[ STAT_PCLASS ] ) == 0.0f ) return qfalse; - // Can't jump and pounce at the same time + 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 ) && pm->ps->stats[ STAT_MISC ] > 0 ) return qfalse; - // Can't jump and charge at the same time + //can't jump and charge at the same time if( ( pm->ps->weapon == WP_ALEVEL4 ) && pm->ps->stats[ STAT_MISC ] > 0 ) return qfalse; - // Can't jump without stamina if( ( pm->ps->stats[ STAT_PTEAM ] == PTE_HUMANS ) && ( pm->ps->stats[ STAT_STAMINA ] < 0 ) ) return qfalse; - // Don't allow jump until all buttons are up if( pm->ps->pm_flags & PMF_RESPAWNED ) - return qfalse; + return qfalse; // don't allow jump until all buttons are up - // Not holding jump or dodge - minijump = pm->ps->stats[ STAT_PTEAM ] == PTE_ALIENS && - ( pm->cmd.buttons & BUTTON_DODGE ); - if( pm->cmd.upmove < 10 && !minijump ) + if( pm->cmd.upmove < 10 ) // not holding jump return qfalse; - // Can't jump while grabbed or without releasing jump - if( pm->ps->pm_type == PM_GRABBED || - ( pm->ps->pm_flags & PMF_JUMP_HELD ) ) + //can't jump whilst grabbed + if( pm->ps->pm_type == PM_GRABBED ) { - // Clear upmove so cmdscale doesn't lower running speed pm->cmd.upmove = 0; + // not holding jump return qfalse; } - // Have to be able to jump - magnitude = BG_FindJumpMagnitudeForClass( pm->ps->stats[ STAT_PCLASS ] ); - if( magnitude == 0.0f ) + // must wait for jump to be released + if( pm->ps->pm_flags & PMF_JUMP_HELD ) + { + // clear upmove so cmdscale doesn't lower running speed + pm->cmd.upmove = 0; return qfalse; + } - pml.groundPlane = qfalse; + pml.groundPlane = qfalse; // jumping away pml.walking = qfalse; pm->ps->pm_flags |= PMF_JUMP_HELD; - // Take some stamina off + // take some stamina off if( pm->ps->stats[ STAT_PTEAM ] == PTE_HUMANS ) pm->ps->stats[ STAT_STAMINA ] -= STAMINA_JUMP_TAKE; pm->ps->groundEntityNum = ENTITYNUM_NONE; - // Jump away from walls + // jump away from wall BG_GetClientNormal( pm->ps, normal ); - // Give player some velocity - if( minijump ) - magnitude *= ALIEN_MINI_JUMP_SCALE; - VectorMA( pm->ps->velocity, magnitude, normal, pm->ps->velocity ); + VectorMA( pm->ps->velocity, BG_FindJumpMagnitudeForClass( pm->ps->stats[ STAT_PCLASS ] ), + normal, pm->ps->velocity ); PM_AddEvent( EV_JUMP ); - // Set jumping animation if( pm->cmd.forwardmove >= 0 ) { if( !( pm->ps->persistant[ PERS_STATE ] & PS_NONSEGMODEL ) ) @@ -1195,7 +1127,6 @@ static void PM_AirMove( void ) float scale; usercmd_t cmd; - PM_CheckWallJump( ); PM_Friction( ); fmove = pm->cmd.forwardmove; @@ -1974,11 +1905,7 @@ static void PM_GroundClimbTrace( void ) //if we hit something if( trace.fraction < 1.0f && !( trace.surfaceFlags & ( SURF_SKY | SURF_SLICK ) ) -#ifdef ALIEN_WALLWALK_ENTITIES - ) -#else - && !( trace.entityNum != ENTITYNUM_WORLD && i != 4 ) ) -#endif + && !( trace.entityNum != ENTITYNUM_WORLD && i != 4 ) ) { if( i == 2 || i == 3 ) { @@ -2179,6 +2106,7 @@ 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; @@ -2279,6 +2207,39 @@ static void PM_GroundTrace( void ) PM_GroundTraceMissed( ); 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 ) ) && + ( trace.entityNum == ENTITYNUM_WORLD ) ) + { + if( !VectorCompare( trace.plane.normal, pm->ps->grapplePoint ) ) + { + VectorCopy( trace.plane.normal, pm->ps->grapplePoint ); + PM_CheckWallJump( ); + } + } + } + return; } } @@ -3594,9 +3555,7 @@ void PmoveSingle( pmove_t *pmove ) AngleVectors( pm->ps->viewangles, pml.forward, pml.right, pml.up ); - if( pm->cmd.upmove < 10 && - ( !( pm->cmd.buttons & BUTTON_DODGE ) || - pm->ps->stats[ STAT_PTEAM ] != PTE_ALIENS ) ) + if( pm->cmd.upmove < 10 ) { // not holding jump or minijump pm->ps->pm_flags &= ~PMF_JUMP_HELD; diff --git a/src/game/g_weapon.c b/src/game/g_weapon.c index 24317bd2..045aa648 100644 --- a/src/game/g_weapon.c +++ b/src/game/g_weapon.c @@ -462,108 +462,47 @@ MASS DRIVER void massDriverFire( gentity_t *ent ) { - trace_t tr; - vec3_t hitPoints[ MDRIVER_MAX_HITS ], hitNormals[ MDRIVER_MAX_HITS ], - origin, originToEnd, muzzleToEnd, muzzleToOrigin, end; - gentity_t *traceEnts[ MDRIVER_MAX_HITS ], *traceEnt, *tent; - float length_offset; - int i, hits = 0, skipent; + trace_t tr; + vec3_t end; + gentity_t *tent; + gentity_t *traceEnt; - // loop through all entities hit by a line trace - G_UnlaggedOn( muzzle, 8192 * 16 ); VectorMA( muzzle, 8192 * 16, forward, end ); - VectorCopy( muzzle, tr.endpos ); - skipent = ent->s.number; - for( i = 0; i < MDRIVER_MAX_HITS && skipent != ENTITYNUM_NONE; i++ ) - { - trap_Trace( &tr, tr.endpos, NULL, NULL, end, skipent, MASK_SHOT ); - if( tr.surfaceFlags & SURF_NOIMPACT ) - break; - traceEnt = &g_entities[ tr.entityNum ]; - skipent = tr.entityNum; - if( traceEnt->s.eType == ET_PLAYER ) - { - // don't travel through teammates with FF off - if( OnSameTeam( ent, traceEnt ) && - ( !g_friendlyFire.integer || !g_friendlyFireHumans.integer ) ) - skipent = ENTITYNUM_NONE; - } - else if( traceEnt->s.eType == ET_BUILDABLE ) - { - // don't travel through team buildables with FF off - if( traceEnt->biteam == ent->client->pers.teamSelection && - !g_friendlyBuildableFire.integer ) - skipent = ENTITYNUM_NONE; - } - else - skipent = ENTITYNUM_NONE; - // save the hit entity, position, and normal - VectorCopy( tr.endpos, hitPoints[ hits ] ); - VectorCopy( tr.plane.normal, hitNormals[ hits ] ); - SnapVectorNormal( hitPoints[ hits ], tr.plane.normal ); - traceEnts[ hits++ ] = traceEnt; - } + G_UnlaggedOn( muzzle, 8192 * 16 ); + trap_Trace( &tr, muzzle, NULL, NULL, end, ent->s.number, MASK_SHOT ); + G_UnlaggedOff( ); - // originate trail line from the gun tip, not the head! - VectorCopy( muzzle, origin ); - VectorMA( origin, -6, up, origin ); - VectorMA( origin, 4, right, origin ); - VectorMA( origin, 24, forward, origin ); - - // save the final position - VectorCopy( tr.endpos, end ); - VectorSubtract( end, origin, originToEnd ); - VectorNormalize( originToEnd ); - - // origin is further in front than muzzle, need to adjust length - VectorSubtract( origin, muzzle, muzzleToOrigin ); - VectorSubtract( end, muzzle, muzzleToEnd ); - VectorNormalize( muzzleToEnd ); - length_offset = DotProduct( muzzleToEnd, muzzleToOrigin ); - - // now that the trace is finished, we know where we stopped and can generate - // visually correct impact locations - for( i = 0; i < hits; i++ ) - { - vec3_t muzzleToPos; - float length; - - // restore saved values - VectorCopy( hitPoints[ i ], tr.endpos ); - VectorCopy( hitNormals[ i ], tr.plane.normal ); - traceEnt = traceEnts[ i ]; - - // compute the visually correct impact point - VectorSubtract( tr.endpos, muzzle, muzzleToPos ); - length = VectorLength( muzzleToPos ) - length_offset; - VectorMA( origin, length, originToEnd, tr.endpos ); + if( tr.surfaceFlags & SURF_NOIMPACT ) + return; - // send impact - if( traceEnt->takedamage && traceEnt->client ) - BloodSpurt( ent, traceEnt, &tr ); - else if( i < hits - 1 ) - { - tent = G_TempEntity( tr.endpos, EV_MISSILE_MISS ); - tent->s.eventParm = DirToByte( tr.plane.normal ); - tent->s.weapon = ent->s.weapon; - tent->s.generic1 = ent->s.generic1; // weaponMode - } - - if( traceEnt->takedamage ) - G_Damage( traceEnt, ent, ent, forward, tr.endpos, - MDRIVER_DMG, 0, MOD_MDRIVER ); + traceEnt = &g_entities[ tr.entityNum ]; + + // snap the endpos to integers, but nudged towards the line + SnapVectorTowards( tr.endpos, muzzle ); + + // send impact + if( traceEnt->takedamage && traceEnt->client ) + { + tent = G_TempEntity( tr.endpos, EV_MISSILE_HIT ); + tent->s.otherEntityNum = traceEnt->s.number; + tent->s.eventParm = DirToByte( tr.plane.normal ); + tent->s.weapon = ent->s.weapon; + tent->s.generic1 = ent->s.generic1; //weaponMode + } + else + { + tent = G_TempEntity( tr.endpos, EV_MISSILE_MISS ); + tent->s.eventParm = DirToByte( tr.plane.normal ); + tent->s.weapon = ent->s.weapon; + tent->s.generic1 = ent->s.generic1; //weaponMode } - // create an event entity for the trail, doubles as an impact event - SnapVectorNormal( end, tr.plane.normal ); - tent = G_TempEntity( end, EV_MASS_DRIVER ); - tent->s.eventParm = DirToByte( tr.plane.normal ); - tent->s.weapon = ent->s.weapon; - tent->s.generic1 = ent->s.generic1; // weaponMode - VectorCopy( origin, tent->s.origin2 ); - - G_UnlaggedOff( ); + if( traceEnt->takedamage ) + { + G_Damage( traceEnt, ent, ent, forward, tr.endpos, + MDRIVER_DMG, 0, MOD_MDRIVER ); + } } /* diff --git a/src/game/tremulous.h b/src/game/tremulous.h index e2723529..47049842 100644 --- a/src/game/tremulous.h +++ b/src/game/tremulous.h @@ -83,11 +83,6 @@ 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 1.0f // magnitude scale from surface -#define LEVEL2_WALLJUMP_FORWARD 1.5f // magnitude scale in view direction -#define LEVEL2_WALLJUMP_UP 0.0f // magnitude scale up -#define LEVEL2_WALLJUMP_REPEAT 400 // msec before new jump -#define LEVEL2_WALLJUMP_RANGE 8.0f // how far away the wall can be #define LEVEL3_CLAW_DMG ADM(80) #define LEVEL3_CLAW_UPG_RANGE 96.0f @@ -357,11 +352,6 @@ 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.71f // scales jump magnitude for a mini-jump - -// Uncomment to allow Aliens to wallwalk on any entity (buildables, players, etc) -//#define ALIEN_WALLWALK_ENTITIES - /* * HUMAN weapons * |