summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/game/g_active.c132
-rw-r--r--src/game/g_buildable.c12
-rw-r--r--src/game/g_local.h4
3 files changed, 69 insertions, 79 deletions
diff --git a/src/game/g_active.c b/src/game/g_active.c
index cc504339..246c68fb 100644
--- a/src/game/g_active.c
+++ b/src/game/g_active.c
@@ -415,6 +415,10 @@ qboolean ClientInactivityTimer( gclient_t *client ) {
return qtrue;
}
+#define STAMINA_STOP_RESTORE 10
+#define STAMINA_WALK_RESTORE 5
+#define STAMINA_SPRINT_TAKE 10
+
/*
==================
ClientTimerActions
@@ -422,52 +426,66 @@ ClientTimerActions
Actions that happen once a second
==================
*/
-void ClientTimerActions( gentity_t *ent, int msec ) {
+void ClientTimerActions( gentity_t *ent, int msec )
+{
gclient_t *client;
+ usercmd_t *ucmd;
+ int aForward, aRight;
+ ucmd = &ent->client->pers.cmd;
+
+ aForward = abs( ucmd->forwardmove );
+ aRight = abs( ucmd->rightmove );
+
client = ent->client;
- client->timeResidual += msec;
+ client->time100 += msec;
+ client->time1000 += msec;
+
+ while ( client->time100 >= 100 )
+ {
+ client->time100 -= 100;
- while ( client->timeResidual >= 1000 ) {
- client->timeResidual -= 1000;
+ //if not trying to run then not trying to sprint
+ if( aForward <= 64 )
+ client->ps.stats[ STAT_STATE ] &= ~SS_SPEEDBOOST;
- // regenerate
- /*if ( client->ps.powerups[PW_REGEN] )
+ if( ( client->ps.stats[ STAT_STATE ] & SS_SPEEDBOOST ) && ucmd->upmove >= 0 )
{
- if ( ent->health < client->ps.stats[STAT_MAX_HEALTH])
- {
- ent->health += 15;
- if ( ent->health > client->ps.stats[STAT_MAX_HEALTH] * 1.1 )
- {
- ent->health = client->ps.stats[STAT_MAX_HEALTH] * 1.1;
- }
- G_AddEvent( ent, EV_POWERUP_REGEN, 0 );
- }
- else if ( ent->health < client->ps.stats[STAT_MAX_HEALTH] * 2)
- {
- ent->health += 5;
- if ( ent->health > client->ps.stats[STAT_MAX_HEALTH] * 2 )
- {
- ent->health = client->ps.stats[STAT_MAX_HEALTH] * 2;
- }
- G_AddEvent( ent, EV_POWERUP_REGEN, 0 );
- }
+ //subtract stamina
+ client->ps.stats[ STAT_STAMINA ] -= STAMINA_SPRINT_TAKE;
+
+ if( client->ps.stats[ STAT_STAMINA ] < -1000 )
+ client->ps.stats[ STAT_STAMINA ] = -1000;
}
- else
+
+ if( ( aForward <= 64 && aForward > 5 ) || ( aRight <= 64 && aRight > 5 ) )
{
- // count down health when over max
- if ( ent->health > client->ps.stats[STAT_MAX_HEALTH] )
- {
- //TA: dont count health and armo(u)r down
- //ent->health--;
- }
- }*/
-
- // count down armor when over max
- if ( client->ps.stats[STAT_ARMOR] > client->ps.stats[STAT_MAX_HEALTH] ) {
- //client->ps.stats[STAT_ARMOR]--;
+ //restore stamina
+ client->ps.stats[ STAT_STAMINA ] += STAMINA_WALK_RESTORE;
+
+ if( client->ps.stats[ STAT_STAMINA ] > 1000 )
+ client->ps.stats[ STAT_STAMINA ] = 1000;
+ }
+ else if( aForward <= 5 && aRight <= 5 )
+ {
+ //restore stamina faster
+ client->ps.stats[ STAT_STAMINA ] += STAMINA_STOP_RESTORE;
+
+ if( client->ps.stats[ STAT_STAMINA ] > 1000 )
+ client->ps.stats[ STAT_STAMINA ] = 1000;
}
+ }
+
+ while( client->time1000 >= 1000 )
+ {
+ client->time1000 -= 1000;
+ //replenish droid health
+ if( client->ps.stats[ STAT_PTEAM ] == PTE_DROIDS )
+ {
+ if( ent->health < client->ps.stats[ STAT_MAX_HEALTH ] )
+ ent->health++;
+ }
}
}
@@ -642,7 +660,6 @@ void ClientThink_real( gentity_t *ent ) {
int msec;
usercmd_t *ucmd;
float speed;
- int aForward, aRight;
//TA: torch
gentity_t *light;
@@ -653,15 +670,6 @@ void ClientThink_real( gentity_t *ent ) {
int i;
qboolean cSlowed = qfalse;
- //TA: time
- static int lastTime;
- int dTime;
-
- dTime = level.time - lastTime;
- lastTime = level.time;
-
- //Com_Printf( "%d\n", G_LuminanceAtPoint( ent->s.origin ) );
-
client = ent->client;
// don't think if the client is not yet connected (and thus not yet spawned in)
@@ -733,21 +741,13 @@ void ClientThink_real( gentity_t *ent ) {
}
if( client->noclip )
- {
client->ps.pm_type = PM_NOCLIP;
- }
else if( client->ps.stats[STAT_HEALTH] <= 0 )
- {
client->ps.pm_type = PM_DEAD;
- }
else if( client->ps.stats[ STAT_STATE ] & SS_INFESTING )
- {
client->ps.pm_type = PM_FREEZE;
- }
else
- {
client->ps.pm_type = PM_NORMAL;
- }
client->ps.gravity = g_gravity.value;
@@ -817,30 +817,6 @@ void ClientThink_real( gentity_t *ent ) {
if( client->torch != NULL )
ShineTorch( client->torch );
- aForward = abs( ucmd->forwardmove );
- aRight = abs( ucmd->rightmove );
-
- //if not trying to run then not trying to sprint
- if( aForward <= 64 )
- client->ps.stats[ STAT_STATE ] &= ~SS_SPEEDBOOST;
-
- if( ( client->ps.stats[ STAT_STATE ] & SS_SPEEDBOOST ) && ucmd->upmove >= 0 )
- {
- //subtract stamina
- client->ps.stats[ STAT_STAMINA ] -= dTime/9.0f;
- }
-
- if( ( aForward <= 64 && aForward > 5 ) || ( aRight <= 64 && aRight > 5 ) )
- {
- //restore stamina
- client->ps.stats[ STAT_STAMINA ] += dTime/6.0f;
- }
- else if( aForward <= 5 && aRight <= 5 )
- {
- //restore stamina faster
- client->ps.stats[ STAT_STAMINA ] += dTime/9.0f;
- }
-
// set up for pmove
oldEventSequence = client->ps.eventSequence;
diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c
index 051c2209..6441a130 100644
--- a/src/game/g_buildable.c
+++ b/src/game/g_buildable.c
@@ -362,9 +362,21 @@ qboolean hdef1_trackenemy( gentity_t *self )
{
vec3_t dirToTarget, angleToTarget, angularDiff;
float temp;
+ float distanceToTarget;
+ float timeTilImpact;
VectorSubtract( self->enemy->s.pos.trBase, self->s.pos.trBase, dirToTarget );
+
+//lead targets
+#if 1
+ distanceToTarget = VectorLength( dirToTarget );
+ timeTilImpact = distanceToTarget / 2000.0f;
+ VectorMA( self->enemy->s.pos.trBase, timeTilImpact, self->enemy->s.pos.trDelta, dirToTarget );
+ VectorSubtract( dirToTarget, self->s.pos.trBase, dirToTarget );
+#endif
+
VectorNormalize( dirToTarget );
+
vectoangles( dirToTarget, angleToTarget );
angularDiff[ PITCH ] = AngleSubtract( self->turloc[ PITCH ], angleToTarget[ PITCH ] );
diff --git a/src/game/g_local.h b/src/game/g_local.h
index a8059a20..f0087b26 100644
--- a/src/game/g_local.h
+++ b/src/game/g_local.h
@@ -323,7 +323,9 @@ struct gclient_s {
// timeResidual is used to handle events that happen every second
// like health / armor countdowns and regeneration
- int timeResidual;
+ //TA: two timers, one every 100 msecs, another every sec
+ int time100;
+ int time1000;
char *areabits;