From 7e630e1fcdfc61a3c88fffbf49a96cccd636cbf4 Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Sat, 2 Jul 2005 20:47:17 +0000 Subject: * Turrets can now be grabbed by lev1s, which slows them down --- src/game/g_buildable.c | 11 ++++++++++- src/game/g_local.h | 2 ++ src/game/g_weapon.c | 44 +++++++++++++++++++++++++------------------- src/game/tremulous.h | 2 ++ 4 files changed, 39 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index e24edc57..5d09c9b4 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -1743,7 +1743,13 @@ qboolean HMGTurret_TrackEnemy( gentity_t *self ) float temp, rotAngle; float accuracyTolerance, angularSpeed; - if( self->dcced ) + if( self->lev1Grabbed ) + { + //can't turn fast if grabbed + accuracyTolerance = MGTURRET_GRAB_ACCURACYTOLERANCE; + angularSpeed = MGTURRET_GRAB_ANGULARSPEED; + } + else if( self->dcced ) { accuracyTolerance = MGTURRET_DCC_ACCURACYTOLERANCE; angularSpeed = MGTURRET_DCC_ANGULARSPEED; @@ -2310,6 +2316,9 @@ void G_BuildableThink( gentity_t *ent, int msec ) ent->health = bHealth; } + if( ent->lev1Grabbed && ent->lev1GrabTime + LEVEL1_GRAB_TIME < level.time ) + ent->lev1Grabbed = qfalse; + if( ent->clientSpawnTime > 0 ) ent->clientSpawnTime -= msec; diff --git a/src/game/g_local.h b/src/game/g_local.h index 2db714f2..c0f4db88 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -204,6 +204,8 @@ struct gentity_s int nextPhysicsTime; //TA: buildables don't need to check what they're sitting on // every single frame.. so only do it periodically int clientSpawnTime; //TA: the time until this spawn can spawn a client + qboolean lev1Grabbed; //TA: for turrets interacting with lev1s + int lev1GrabTime; //TA: for turrets interacting with lev1s int credits[ MAX_CLIENTS ]; //TA: human credits for each client qboolean creditsHash[ MAX_CLIENTS ]; //TA: track who has claimed credit diff --git a/src/game/g_weapon.c b/src/game/g_weapon.c index c12c82d0..5c26002a 100644 --- a/src/game/g_weapon.c +++ b/src/game/g_weapon.c @@ -790,29 +790,35 @@ void CheckGrabAttack( gentity_t *ent ) if( !traceEnt->takedamage ) return; - if( !traceEnt->client ) - return; - - if( traceEnt->client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS ) - return; - - if( traceEnt->client->ps.stats[ STAT_HEALTH ] <= 0 ) - return; - - if( !( traceEnt->client->ps.stats[ STAT_STATE ] & SS_GRABBED ) ) + if( traceEnt->client ) { - AngleVectors( traceEnt->client->ps.viewangles, dir, NULL, NULL ); - traceEnt->client->ps.stats[ STAT_VIEWLOCK ] = DirToByte( dir ); + if( traceEnt->client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS ) + return; + + if( traceEnt->client->ps.stats[ STAT_HEALTH ] <= 0 ) + return; + + if( !( traceEnt->client->ps.stats[ STAT_STATE ] & SS_GRABBED ) ) + { + AngleVectors( traceEnt->client->ps.viewangles, dir, NULL, NULL ); + traceEnt->client->ps.stats[ STAT_VIEWLOCK ] = DirToByte( dir ); + + //event for client side grab effect + G_AddPredictableEvent( ent, EV_LEV1_GRAB, 0 ); + } + + traceEnt->client->ps.stats[ STAT_STATE ] |= SS_GRABBED; + traceEnt->client->lastGrabTime = level.time; } - - if( !( traceEnt->client->ps.stats[ STAT_STATE ] & SS_GRABBED ) ) + else if( traceEnt->s.eType == ET_BUILDABLE && + traceEnt->s.modelindex == BA_H_MGTURRET ) { - //event for client side grab effect - G_AddPredictableEvent( ent, EV_LEV1_GRAB, 0 ); + if( !traceEnt->lev1Grabbed ) + G_AddPredictableEvent( ent, EV_LEV1_GRAB, 0 ); + + traceEnt->lev1Grabbed = qtrue; + traceEnt->lev1GrabTime = level.time; } - - traceEnt->client->ps.stats[ STAT_STATE ] |= SS_GRABBED; - traceEnt->client->lastGrabTime = level.time; } /* diff --git a/src/game/tremulous.h b/src/game/tremulous.h index 5f7831ec..8c137c23 100644 --- a/src/game/tremulous.h +++ b/src/game/tremulous.h @@ -485,6 +485,8 @@ #define MGTURRET_DMG HDM(4) #define MGTURRET_DCC_ANGULARSPEED 10 #define MGTURRET_DCC_ACCURACYTOLERANCE MGTURRET_DCC_ANGULARSPEED / 1.5f +#define MGTURRET_GRAB_ANGULARSPEED 3 +#define MGTURRET_GRAB_ACCURACYTOLERANCE MGTURRET_GRAB_ANGULARSPEED / 1.5f #define TESLAGEN_BP 10 #define TESLAGEN_BT 15000 -- cgit