summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony J. White <tjw@tjw.org>2006-10-30 18:20:54 +0000
committerTony J. White <tjw@tjw.org>2006-10-30 18:20:54 +0000
commitd6c597373d0082a43ca33825f612255e383a85bc (patch)
tree0c8d7a983d4d7ff0ccff5c0ab7c00c5cc14d014f
parent342d30ae07f63ac3e8bc84c2a75c59631b459262 (diff)
* (bug 2894) automatic shoving of teammates on collision. set g_shove to a
positive float to adjust the amount of shoving. (recommended value 15.0, default value 0.0)
-rw-r--r--src/game/g_active.c53
-rw-r--r--src/game/g_local.h2
-rw-r--r--src/game/g_main.c3
3 files changed, 58 insertions, 0 deletions
diff --git a/src/game/g_active.c b/src/game/g_active.c
index a496c226..76efa5f1 100644
--- a/src/game/g_active.c
+++ b/src/game/g_active.c
@@ -191,6 +191,56 @@ void G_SetClientSound( gentity_t *ent )
//==============================================================
+static void G_ClientShove( gentity_t *ent, gentity_t *victim )
+{
+ vec3_t dir, push;
+ int entMass = 200, vicMass = 200;
+
+ // shoving enemies changes gameplay too much
+ if( !OnSameTeam( ent, victim ) )
+ return;
+
+ // alien mass is directly related to their health points
+ // human mass is 200, double for bsuit
+ if( ent->client->pers.teamSelection == PTE_ALIENS )
+ {
+ entMass = BG_FindHealthForClass( ent->client->pers.classSelection );
+ }
+ else if( ent->client->pers.teamSelection == PTE_HUMANS )
+ {
+ if( BG_InventoryContainsUpgrade( UP_BATTLESUIT, ent->client->ps.stats ) )
+ entMass *= 2;
+ }
+ else
+ return;
+
+ if( victim->client->pers.teamSelection == PTE_ALIENS )
+ {
+ vicMass = BG_FindHealthForClass( victim->client->pers.classSelection );
+ }
+ else if( BG_InventoryContainsUpgrade( UP_BATTLESUIT,
+ victim->client->ps.stats ) )
+ {
+ vicMass *= 2;
+ }
+
+ if( vicMass <= 0 || entMass <= 0 )
+ return;
+
+ VectorSubtract( victim->r.currentOrigin, ent->r.currentOrigin, dir );
+ VectorNormalizeFast( dir );
+
+ // don't break the dretch elevator
+ if( abs( dir[ 2 ] ) > abs( dir[ 0 ] ) && abs( dir[ 2 ] ) > abs( dir[ 1 ] ) )
+ return;
+
+ VectorScale( dir,
+ ( g_shove.value * ( ( float )entMass / ( float )vicMass ) ), push );
+ VectorAdd( victim->client->ps.velocity, push,
+ victim->client->ps.velocity );
+
+}
+
/*
==============
ClientImpacts
@@ -223,6 +273,9 @@ void ClientImpacts( gentity_t *ent, pmove_t *pm )
ent->client->charging )
ChargeAttack( ent, other );
+ if( ent->client && other->client )
+ G_ClientShove( ent, other );
+
if( !other->touch )
continue;
diff --git a/src/game/g_local.h b/src/game/g_local.h
index 0347d65e..578baf91 100644
--- a/src/game/g_local.h
+++ b/src/game/g_local.h
@@ -1109,6 +1109,8 @@ extern vmCvar_t g_currentMap;
extern vmCvar_t g_initialMapRotation;
extern vmCvar_t g_chatTeamPrefix;
+extern vmCvar_t g_shove;
+
extern vmCvar_t g_mapConfigs;
extern vmCvar_t g_admin;
diff --git a/src/game/g_main.c b/src/game/g_main.c
index ee000e8b..6a8c4b11 100644
--- a/src/game/g_main.c
+++ b/src/game/g_main.c
@@ -112,6 +112,8 @@ vmCvar_t g_currentMapRotation;
vmCvar_t g_currentMap;
vmCvar_t g_initialMapRotation;
+vmCvar_t g_shove;
+
vmCvar_t g_mapConfigs;
vmCvar_t g_chatTeamPrefix;
@@ -219,6 +221,7 @@ static cvarTable_t gameCvarTable[ ] =
{ &g_currentMapRotation, "g_currentMapRotation", "-1", 0, 0, qfalse }, // -1 = NOT_ROTATING
{ &g_currentMap, "g_currentMap", "0", 0, 0, qfalse },
{ &g_initialMapRotation, "g_initialMapRotation", "", CVAR_ARCHIVE, 0, qfalse },
+ { &g_shove, "g_shove", "0.0", CVAR_ARCHIVE, 0, qfalse },
{ &g_mapConfigs, "g_mapConfigs", "", CVAR_ARCHIVE, 0, qfalse },
{ NULL, "g_mapConfigsLoaded", "0", CVAR_ROM, 0, qfalse },