summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
Diffstat (limited to 'src/game')
-rw-r--r--src/game/edge_version.h3
-rw-r--r--src/game/g_buildable.c40
-rw-r--r--src/game/g_combat.c119
-rw-r--r--src/game/g_local.h13
-rw-r--r--src/game/g_main.c28
-rw-r--r--src/game/newedge_version.h3
6 files changed, 126 insertions, 80 deletions
diff --git a/src/game/edge_version.h b/src/game/edge_version.h
deleted file mode 100644
index 55170dc..0000000
--- a/src/game/edge_version.h
+++ /dev/null
@@ -1,3 +0,0 @@
-#ifndef EDGE_MOD_VERSION
-#define EDGE_MOD_VERSION "7.7"
-#endif
diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c
index 18a0fae..22e8376 100644
--- a/src/game/g_buildable.c
+++ b/src/game/g_buildable.c
@@ -322,7 +322,7 @@ buildable_t G_IsPowered( vec3_t origin )
return BA_NONE;
}
- /*
+/*
================
G_IsGathered
@@ -1505,7 +1505,9 @@ void AAcidTube_Think( gentity_t *self )
if (enemy->client && enemy->client->notrackEndTime >= level.time)
continue;
- if( enemy->client && enemy->client->ps.stats[ STAT_TEAM ] == TEAM_HUMANS )
+ if( ( enemy->client && enemy->client->ps.stats[ STAT_TEAM ] == TEAM_HUMANS ) ||
+ ( enemy->s.eType == ET_BUILDABLE &&
+ BG_Buildable( enemy->s.modelindex )->team == TEAM_HUMANS ) )
{
// start the attack animation
if( level.time >= self->timestamp + ACIDTUBE_REPEAT_ANIM )
@@ -2891,9 +2893,20 @@ qboolean HMGTurret_CheckTarget( gentity_t *self, gentity_t *target,
trace_t tr;
vec3_t dir, end;
- if( !target || target->health <= 0 || !target->client ||
- target->client->pers.teamSelection != TEAM_ALIENS )
- return qfalse;
+ if( !target || target->health <= 0 )
+ return qfalse;
+
+ if( target->client )
+ {
+ if( target->client->pers.teamSelection != TEAM_ALIENS )
+ return qfalse;
+ }
+ else
+ {
+ if( !( target->s.eType == ET_BUILDABLE &&
+ BG_Buildable( target->s.modelindex )->team == TEAM_ALIENS ) )
+ return qfalse;
+ }
if( target->flags & FL_NOTARGET )
return qfalse;
@@ -4177,6 +4190,7 @@ itemBuildError_t G_CanBuild( gentity_t *ent, buildable_t buildable, int distance
qboolean invert;
int contents;
playerState_t *ps = &ent->client->ps;
+ float d;
// Stop all buildables from interacting with traces
//G_SetBuildableLinkState( qfalse );
@@ -4244,7 +4258,13 @@ itemBuildError_t G_CanBuild( gentity_t *ent, buildable_t buildable, int distance
break;
case 2: // Creeps/colonies block building for enemy team
if( G_IsGathered( TEAM_HUMANS, entity_origin, qfalse, ent ) )
- reason = IBE_BLOCKEDBYENEMY;
+ {
+ tempent = G_Overmind( );
+ if( tempent != NULL ) {
+ d = Distance( tempent->s.origin, entity_origin );
+ if ( d > CREEP_BASESIZE ) reason = IBE_BLOCKEDBYENEMY;
+ } else reason = IBE_BLOCKEDBYENEMY;
+ }
break;
default:
if( G_IsPowered( entity_origin ) != BA_NONE )
@@ -4292,7 +4312,13 @@ itemBuildError_t G_CanBuild( gentity_t *ent, buildable_t buildable, int distance
reason = IBE_BLOCKEDBYENEMY;
case 2: // Creeps/colonies block building for enemy team
if( G_IsGathered( TEAM_ALIENS, entity_origin, qfalse, ent ) )
- reason = IBE_BLOCKEDBYENEMY;
+ {
+ tempent = G_Reactor( );
+ if( tempent != NULL ) {
+ d = Distance( tempent->s.origin, entity_origin );
+ if ( d > REACTOR_BASESIZE ) reason = IBE_BLOCKEDBYENEMY;
+ } else reason = IBE_BLOCKEDBYENEMY;
+ }
break;
default:
if( G_IsCreepHere( entity_origin ) )
diff --git a/src/game/g_combat.c b/src/game/g_combat.c
index 13441ac..966e595 100644
--- a/src/game/g_combat.c
+++ b/src/game/g_combat.c
@@ -45,15 +45,22 @@ void AddScore( gentity_t *ent, int score )
if( !ent->client )
return;
- // make alien and human scores equivalent
- if ( ent->client->pers.teamSelection == TEAM_ALIENS )
- {
- score = rint( ((float)score) / 2.0f );
- }
-
// scale values down to fit the scoreboard better
score = rint( ((float)score) / 50.0f );
+ switch( ent->client->pers.teamSelection ) {
+ case TEAM_ALIENS:
+ // make alien and human scores equivalent
+ score = rint( ((float)score) / 2.0f );
+ level.alienRewardScore += score;
+ break;
+ case TEAM_HUMANS:
+ level.humanRewardScore += score;
+ break;
+ default:
+ break;
+ }
+
ent->client->ps.persistant[ PERS_SCORE ] += score;
G_admin_add_score( ent, score );
@@ -184,60 +191,69 @@ float G_CamperRewardBonus( gentity_t *self )
return 1.0f;
}
-float G_TeamRewardScaleFactor( gentity_t *target )
-{
- if (level.humanRewardKills <= 0.0f || level.alienRewardKills <= 0.0f) return 1.0f;
- if( !target->client ) return 1.0f;
- if( target->client->ps.stats[ STAT_TEAM ] == TEAM_ALIENS) {
- return level.alienRewardKills/level.humanRewardKills;
- } else if( target->client->ps.stats[ STAT_TEAM ] == TEAM_HUMANS ) {
- return level.humanRewardKills/level.alienRewardKills;
- } else return 0;
-}
-
-float G_RewardScaleFactor( gentity_t *self, gentity_t *target, float teamFactor )
+float G_RewardScaleFactor( gentity_t *self, gentity_t *target )
{
- float result;
-
- if (self->client->pers.kills <= 0 || target->client->pers.kills <= 0) return 1.0f;
-
- result = g_ConstantRewardFactor.value;
- result += g_TeamRewardFactor.value*teamFactor;
- result += g_PlayerRewardFactor.value*target->client->pers.kills/self->client->pers.kills;
-
- if (result > 1.0f) result = 1.0f;
- return result;
+ float targetScore;
+ if( level.humanRewardScore <= 0.0f || level.alienRewardScore <= 0.0f ) return 1.0f;
+ switch( self->client->ps.stats[ STAT_TEAM ] ) {
+ case TEAM_ALIENS:
+ targetScore = level.humanRewardScore/level.alienRewardScore;
+ break;
+ case TEAM_HUMANS:
+ targetScore = level.alienRewardScore/level.humanRewardScore;
+ break;
+ default:
+ return 0;
+ }
+ if ( target->client != NULL ) {
+ if( self->client->ps.persistant[ PERS_SCORE ] <= 0 || target->client->ps.persistant[ PERS_SCORE ] <= 0) return targetScore;
+ targetScore *= target->client->ps.persistant[ PERS_SCORE ]/self->client->ps.persistant[ PERS_SCORE ];
+ }
+ targetScore *= 1.0f-g_ConstantRewardFactor.value;
+ targetScore += g_ConstantRewardFactor.value;
+ if (targetScore < g_MinRewardFactor.value) targetScore = g_MinRewardFactor.value;
+ else if (targetScore > g_MaxRewardFactor.value) targetScore = g_MaxRewardFactor.value;
+ return targetScore;
}
/* Instantly reward the current attacker */
float G_InstantRewardAttacker( gentity_t *self, gentity_t *target, float damage )
{
float value;
- int maxHealth;
+ int maxHealth,targetTeam;
if( damage <= 0.f ) return 0.0f;
if( !self->client ) return 0.0f;
- if( !target->client ) return 0.0f;
- if( OnSameTeam( self, target ) ) return 0.0f;
- if( target->s.eType == ET_BUILDABLE ) return 0.0f;
- maxHealth = target->client->ps.stats[ STAT_MAX_HEALTH ];
+ if( target->client != NULL ) {
+ maxHealth = target->client->ps.stats[ STAT_MAX_HEALTH ];
+ targetTeam = target->client->ps.stats[ STAT_TEAM ];
+ } else {
+ maxHealth = BG_Buildable( target->s.modelindex )->health;
+ targetTeam = target->buildableTeam;
+ }
+ if( targetTeam == self->client->ps.stats[ STAT_TEAM ] ) return 0.0f;
- // Only give credits for attacking players for now
value = damage / maxHealth;
if (value > 1.0f) value = 1.0f;
- value *= G_CamperRewardBonus( target );
- value *= BG_GetValueOfPlayer( &target->client->ps );
- if( target->client->ps.stats[ STAT_TEAM ] == TEAM_ALIENS) {
+ if( target->client != NULL ) {
+ value *= G_CamperRewardBonus( target );
+ value *= BG_GetValueOfPlayer( &target->client->ps );
+ } else {
+ value *= BG_Buildable( target->s.modelindex )->value;
+ value *= g_BuildingCreditsFactor.value;
+ }
+
+ if( targetTeam == TEAM_ALIENS) {
value *= g_InstantRewardMultiplierA.value;
- } else if( target->client->ps.stats[ STAT_TEAM ] == TEAM_HUMANS ) {
+ } else if( targetTeam == TEAM_HUMANS ) {
value *= g_InstantRewardMultiplierH.value;
- } else value = 0;
+ } else value = 0.f;
- value *= G_RewardScaleFactor( self, target, G_TeamRewardScaleFactor( target ) );
+ value *= G_RewardScaleFactor( self, target );
- if( value > 0 ) {
+ if( value > 0.f ) {
G_AddCreditToClient( self->client, value, qtrue );
if( self->client->ps.stats[ STAT_TEAM ] == TEAM_ALIENS ) {
trap_Cvar_Set( "g_alienCredits",
@@ -312,7 +328,6 @@ float G_RewardAttackers( gentity_t *self )
// Give credits and empty the array
- teamFactor = G_TeamRewardScaleFactor( self );
for( i = 0; i < level.maxclients; i++ )
{
int stageValue = value * self->credits[ i ] / totalDamage;
@@ -329,19 +344,17 @@ float G_RewardAttackers( gentity_t *self )
AddScore( player, stageValue );
- // killing buildables earns score, but not credits
- if( self->s.eType != ET_BUILDABLE )
- {
+ // killing buildables earns score, but not credits unless g_BuildingCreditsFactor > 0
+ if( self->s.eType == ET_BUILDABLE ) stageValue *= g_BuildingCreditsFactor.value;
+ if( stageValue > 0 ) {
// Com_Printf(S_COLOR_YELLOW "Killer: kills = %f deaths = %f percent_of_damage = %f -> factor = %f\n",player->client->pers.kills,player->client->pers.deaths,killValue,G_RewardScaleFactor( player, self, teamFactor) );
- stageValue *= G_RewardScaleFactor( player, self, teamFactor );
- player->client->pers.kills += killValue;
+ stageValue *= G_RewardScaleFactor( player, self );
+ player->client->pers.kills += killValue; // NOTE: Building kills will increase this too if g_BuildingCreditsFactor > 0
// add to stage counters
if( player->client->ps.stats[ STAT_TEAM ] == TEAM_ALIENS ) {
- level.alienRewardKills += killValue;
G_AddCreditToClient( player->client, g_KillRewardMultiplierH.value*stageValue, qtrue );
alienCredits += g_KillRewardMultiplierH.value*stageValue;
} else if( player->client->ps.stats[ STAT_TEAM ] == TEAM_HUMANS ) {
- level.humanRewardKills += killValue;
G_AddCreditToClient( player->client, g_KillRewardMultiplierA.value*stageValue, qtrue );
humanCredits += g_KillRewardMultiplierA.value*stageValue;
}
@@ -352,7 +365,7 @@ float G_RewardAttackers( gentity_t *self )
// ++self->client->pers.deaths;
// Com_Printf(S_COLOR_YELLOW "Killed: kills = %f deaths = %d\n",self->client->pers.kills,self->client->pers.deaths);
- // Com_Printf(S_COLOR_YELLOW "Team: kills = %f deaths = %f\n",level.alienRewardKills,level.humanRewardKills);
+ // Com_Printf(S_COLOR_YELLOW "Team: kills = %f deaths = %f\n",level.alienRewardScore,level.humanRewardScore);
if( alienCredits )
{
@@ -1568,8 +1581,10 @@ qboolean G_SelectiveRadiusDamage( vec3_t origin, gentity_t *attacker, float dama
points = damage * ( 1.0 - dist / radius );
- if( CanDamage( ent, origin ) && ent->client &&
- ent->client->ps.stats[ STAT_TEAM ] != team )
+ if( CanDamage( ent, origin ) &&
+ ( ( ent->client && ent->client->ps.stats[ STAT_TEAM ] != team ) ||
+ ( ent->s.eType == ET_BUILDABLE &&
+ BG_Buildable( ent->s.modelindex )->team != team ) ) )
{
VectorSubtract( ent->r.currentOrigin, origin, dir );
// push the center of mass higher than the origin so players
diff --git a/src/game/g_local.h b/src/game/g_local.h
index a46131a..9cc0ff2 100644
--- a/src/game/g_local.h
+++ b/src/game/g_local.h
@@ -694,8 +694,8 @@ typedef struct
int alienKills;
int humanKills;
- float alienRewardKills;
- float humanRewardKills;
+ float alienRewardScore;
+ float humanRewardScore;
qboolean overmindMuted;
@@ -1367,8 +1367,8 @@ extern vmCvar_t g_InstantRewardMultiplierH;
extern vmCvar_t g_KillRewardMultiplierA;
extern vmCvar_t g_KillRewardMultiplierH;
extern vmCvar_t g_ConstantRewardFactor;
-extern vmCvar_t g_TeamRewardFactor;
-extern vmCvar_t g_PlayerRewardFactor;
+extern vmCvar_t g_MinRewardFactor;
+extern vmCvar_t g_MaxRewardFactor;
extern vmCvar_t g_ForceRandomTeams;
extern vmCvar_t g_AutoLevelMinTeamSize;
extern vmCvar_t g_RageQuitScorePenalty;
@@ -1376,6 +1376,11 @@ extern vmCvar_t g_DretchTurretDamage;
extern vmCvar_t g_DretchBuildingDamage;
extern vmCvar_t g_OwnTeamBPFactor;
extern vmCvar_t g_EnemyTeamBPFactor;
+extern vmCvar_t g_MinAlienExtraBuildPoints;
+extern vmCvar_t g_MaxAlienExtraBuildPoints;
+extern vmCvar_t g_MinHumanExtraBuildPoints;
+extern vmCvar_t g_MaxHumanExtraBuildPoints;
+extern vmCvar_t g_BuildingCreditsFactor;
void trap_Print( const char *fmt );
void trap_Error( const char *fmt );
diff --git a/src/game/g_main.c b/src/game/g_main.c
index 7dc5bc8..2d0c788 100644
--- a/src/game/g_main.c
+++ b/src/game/g_main.c
@@ -26,12 +26,9 @@ TREMULOUS EDGE MOD SRC FILE
===========================================================================
*/
#include "g_local.h"
-#include "edge_version.h"
+#include "newedge_version.h"
#define G_MOD_VERSION "Aardvark 0.5x" SVN_VERSION
-#ifndef EDGE_MOD_VERSION
-#define EDGE_MOD_VERSION "7.5.x"
-#endif
level_locals_t level;
typedef struct
@@ -194,8 +191,8 @@ vmCvar_t g_InstantRewardMultiplierH;
vmCvar_t g_KillRewardMultiplierA;
vmCvar_t g_KillRewardMultiplierH;
vmCvar_t g_ConstantRewardFactor;
-vmCvar_t g_TeamRewardFactor;
-vmCvar_t g_PlayerRewardFactor;
+vmCvar_t g_MinRewardFactor;
+vmCvar_t g_MaxRewardFactor;
vmCvar_t g_TimerPeriod;
vmCvar_t g_TimerCommand;
vmCvar_t g_ForceRandomTeams;
@@ -209,6 +206,8 @@ vmCvar_t g_MinAlienExtraBuildPoints;
vmCvar_t g_MaxAlienExtraBuildPoints;
vmCvar_t g_MinHumanExtraBuildPoints;
vmCvar_t g_MaxHumanExtraBuildPoints;
+vmCvar_t g_BuildingCreditsFactor;
+
// copy cvars that can be set in worldspawn so they can be restored later
static char cv_gravity[ MAX_CVAR_VALUE_STRING ];
@@ -224,7 +223,7 @@ static cvarTable_t gameCvarTable[ ] =
{ NULL, "gamename", GAME_VERSION , CVAR_SERVERINFO | CVAR_ROM, 0, qfalse },
{ NULL, "gamedate", __DATE__ , CVAR_ROM, 0, qfalse },
{ NULL, "g_version", G_MOD_VERSION , CVAR_SERVERINFO | CVAR_ROM, 0, qfalse },
- { NULL, "edge_version", EDGE_MOD_VERSION , CVAR_SERVERINFO | CVAR_ROM, 0, qfalse },
+ { NULL, "newedge_version", NEWEDGE_MOD_VERSION , CVAR_SERVERINFO | CVAR_ROM, 0, qfalse },
{ &g_restarted, "g_restarted", "0", CVAR_ROM, 0, qfalse },
{ &g_lockTeamsAtStart, "g_lockTeamsAtStart", "0", CVAR_ROM, 0, qfalse },
{ NULL, "sv_mapname", "", CVAR_SERVERINFO | CVAR_ROM, 0, qfalse },
@@ -369,9 +368,9 @@ static cvarTable_t gameCvarTable[ ] =
{ &g_InstantRewardMultiplierH, "g_InstantRewardMultiplierH", "1", CVAR_ARCHIVE, 0, qfalse },
{ &g_KillRewardMultiplierA, "g_KillRewardMultiplierA", "1", CVAR_ARCHIVE, 0, qfalse },
{ &g_KillRewardMultiplierH, "g_KillRewardMultiplierH", "1", CVAR_ARCHIVE, 0, qfalse },
- { &g_ConstantRewardFactor, "g_ConstantRewardFactor", "0.25", CVAR_ARCHIVE, 0, qfalse },
- { &g_TeamRewardFactor, "g_TeamRewardFactor", "0.5", CVAR_ARCHIVE, 0, qfalse },
- { &g_PlayerRewardFactor, "g_PlayerRewardFactor", "0.25", CVAR_ARCHIVE, 0, qfalse },
+ { &g_ConstantRewardFactor, "g_ConstantRewardFactor", "0", CVAR_ARCHIVE, 0, qfalse },
+ { &g_MinRewardFactor, "g_MinRewardFactor", "0.2", CVAR_ARCHIVE, 0, qfalse },
+ { &g_MaxRewardFactor, "g_MaxRewardFactor", "5.0", CVAR_ARCHIVE, 0, qfalse },
{ &g_TimerPeriod, "g_TimerPeriod", "0", CVAR_ARCHIVE, 0, qfalse },
{ &g_TimerCommand, "g_TimerCommand", "", CVAR_ARCHIVE, 0, qfalse },
{ &g_ForceRandomTeams, "g_ForceRandomTeams", "0", CVAR_ARCHIVE, 0, qfalse },
@@ -384,7 +383,8 @@ static cvarTable_t gameCvarTable[ ] =
{ &g_MinAlienExtraBuildPoints, "g_MinAlienExtraBuildPoints", "-800", CVAR_ARCHIVE, 0, qfalse },
{ &g_MaxAlienExtraBuildPoints, "g_MaxAlienExtraBuildPoints", "800", CVAR_ARCHIVE, 0, qfalse },
{ &g_MinHumanExtraBuildPoints, "g_MinHumanExtraBuildPoints", "-800", CVAR_ARCHIVE, 0, qfalse },
- { &g_MaxHumanExtraBuildPoints, "g_MaxHumanExtraBuildPoints", "800", CVAR_ARCHIVE, 0, qfalse }
+ { &g_MaxHumanExtraBuildPoints, "g_MaxHumanExtraBuildPoints", "800", CVAR_ARCHIVE, 0, qfalse },
+ { &g_BuildingCreditsFactor, "g_BuildingCreditsFactor", "0.25", CVAR_ARCHIVE, 0, qfalse }
};
static int gameCvarTableSize = sizeof( gameCvarTable ) / sizeof( gameCvarTable[ 0 ] );
@@ -651,7 +651,7 @@ void G_InitGame( int levelTime, int randomSeed, int restart )
G_Printf( "------- Game Initialization -------\n" );
G_Printf( "gamename: %s\n", GAME_VERSION );
G_Printf( "gamedate: %s\n", __DATE__ );
- G_Printf( "EDGE VERSION: %s\n", EDGE_MOD_VERSION );
+ G_Printf( "New EDGE version: %s\n", NEWEDGE_MOD_VERSION );
BG_InitMemory( );
// set some level globals
@@ -661,10 +661,10 @@ void G_InitGame( int levelTime, int randomSeed, int restart )
level.alienStage2Time = level.alienStage3Time = level.alienStage4Time = level.alienStage5Time =
level.humanStage2Time = level.humanStage3Time = level.humanStage4Time = level.humanStage5Time = level.startTime;
level.snd_fry = G_SoundIndex( "sound/misc/fry.wav" ); // FIXME standing in lava / slime
- level.humanRewardKills = level.alienRewardKills = 0.0f;
+ level.humanRewardScore = level.alienRewardScore = 0.0f;
level.alienNoBPFlashTime = level.humanNoBPFlashTime = -1;
trap_Cvar_Set( "g_version", G_MOD_VERSION );
- trap_Cvar_Set( "edge_version", EDGE_MOD_VERSION );
+ trap_Cvar_Set( "newedge_version", NEWEDGE_MOD_VERSION );
if( g_logFile.string[ 0 ] )
{
if( g_logFileSync.integer )
diff --git a/src/game/newedge_version.h b/src/game/newedge_version.h
new file mode 100644
index 0000000..39ca7bc
--- /dev/null
+++ b/src/game/newedge_version.h
@@ -0,0 +1,3 @@
+#ifndef NEWEDGE_MOD_VERSION
+#define NEWEDGE_MOD_VERSION "7.7b"
+#endif