summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authorAsa Kravets <norfenstein@gmail.com>2011-04-04 23:34:28 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:18:03 +0000
commit99436a23e7f2ca74401f90b79c865280c5086ff1 (patch)
treed6e2e826f0266075c05a838410b1a4246b0b328b /src/game
parenta8bd455bbcc8c5e582ce0526a8b5453052c26610 (diff)
* Change trample to not lose all charge on hitting a structure, and keep track of structures to only allow one hit each (thanks Lakitu7)
Diffstat (limited to 'src/game')
-rw-r--r--src/game/g_active.c9
-rw-r--r--src/game/g_local.h5
-rw-r--r--src/game/g_weapon.c22
3 files changed, 31 insertions, 5 deletions
diff --git a/src/game/g_active.c b/src/game/g_active.c
index a7cd08c0..6a149f90 100644
--- a/src/game/g_active.c
+++ b/src/game/g_active.c
@@ -1602,6 +1602,15 @@ void ClientThink_real( gentity_t *ent )
}
break;
+ case WP_ALEVEL4:
+ // If not currently in a trample, reset the trample bookkeeping data
+ if( !( client->ps.pm_flags & PMF_CHARGE ) && client->trampleBuildablesHitPos )
+ {
+ ent->client->trampleBuildablesHitPos = 0;
+ memset( ent->client->trampleBuildablesHit, 0, sizeof( ent->client->trampleBuildablesHit ) );
+ }
+ break;
+
case WP_HBUILD:
CheckCkitRepair( ent );
break;
diff --git a/src/game/g_local.h b/src/game/g_local.h
index a420d39e..9132d69e 100644
--- a/src/game/g_local.h
+++ b/src/game/g_local.h
@@ -353,6 +353,7 @@ typedef struct unlagged_s {
qboolean used;
} unlagged_t;
+#define MAX_TRAMPLE_BUILDABLES_TRACKED 20
// this structure is cleared on each ClientSpawn(),
// except for 'client->pers' and 'client->sess'
struct gclient_s
@@ -434,11 +435,13 @@ struct gclient_s
unlagged_t unlaggedBackup;
unlagged_t unlaggedCalc;
int unlaggedTime;
-
+
float voiceEnthusiasm;
char lastVoiceCmd[ MAX_VOICE_CMD_LEN ];
int lcannonStartTime;
+ int trampleBuildablesHitPos;
+ int trampleBuildablesHit[ MAX_TRAMPLE_BUILDABLES_TRACKED ];
int lastCrushTime; // Tyrant crush
};
diff --git a/src/game/g_weapon.c b/src/game/g_weapon.c
index a6566d72..1c227ffd 100644
--- a/src/game/g_weapon.c
+++ b/src/game/g_weapon.c
@@ -1366,6 +1366,7 @@ G_ChargeAttack
void G_ChargeAttack( gentity_t *ent, gentity_t *victim )
{
int damage;
+ int i;
vec3_t forward, normal;
if( ent->client->ps.stats[ STAT_MISC ] <= 0 ||
@@ -1376,10 +1377,26 @@ void G_ChargeAttack( gentity_t *ent, gentity_t *victim )
VectorSubtract( victim->s.origin, ent->s.origin, forward );
VectorNormalize( forward );
VectorNegate( forward, normal );
-
+
if( !victim->takedamage )
return;
+ // For buildables, track the last MAX_TRAMPLE_BUILDABLES_TRACKED buildables
+ // hit, and do not do damage if the current buildable is in that list
+ // in order to prevent dancing over stuff to kill it very quickly
+ if( !victim->client )
+ {
+ for( i = 0; i < MAX_TRAMPLE_BUILDABLES_TRACKED; i++ )
+ {
+ if( ent->client->trampleBuildablesHit[ i ] == victim - g_entities )
+ return;
+ }
+
+ ent->client->trampleBuildablesHit[
+ ent->client->trampleBuildablesHitPos++ % MAX_TRAMPLE_BUILDABLES_TRACKED ] =
+ victim - g_entities;
+ }
+
WideBloodSpurt( ent, victim, NULL );
damage = LEVEL4_TRAMPLE_DMG * ent->client->ps.stats[ STAT_MISC ] /
@@ -1389,9 +1406,6 @@ void G_ChargeAttack( gentity_t *ent, gentity_t *victim )
DAMAGE_NO_LOCDAMAGE, MOD_LEVEL4_TRAMPLE );
ent->client->ps.weaponTime += LEVEL4_TRAMPLE_REPEAT;
-
- if( !victim->client )
- ent->client->ps.stats[ STAT_MISC ] = 0;
}
/*