summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikko Tiusanen <ams@daug.net>2015-02-15 22:46:31 +0200
committerMikko Tiusanen <ams@daug.net>2015-02-15 22:46:31 +0200
commit7f4a2f5a73b086a42b4c139d16fee7622cbdf6ba (patch)
tree006062aa5613a93186dd74806dbaa5f3756759d1
parent756d67c4904334bcd78141fdf6decca2ae4214f7 (diff)
Added support for score based credit gain scaling.
Removed support for kill based credit gain scaling.
-rw-r--r--src/game/edge_version.h2
-rw-r--r--src/game/g_combat.c69
-rw-r--r--src/game/g_local.h12
-rw-r--r--src/game/g_main.c12
4 files changed, 51 insertions, 44 deletions
diff --git a/src/game/edge_version.h b/src/game/edge_version.h
index 55170dc..6cf5772 100644
--- a/src/game/edge_version.h
+++ b/src/game/edge_version.h
@@ -1,3 +1,3 @@
#ifndef EDGE_MOD_VERSION
-#define EDGE_MOD_VERSION "7.7"
+#define EDGE_MOD_VERSION "7.7b"
#endif
diff --git a/src/game/g_combat.c b/src/game/g_combat.c
index 13441ac..4685439 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,29 +191,28 @@ float G_CamperRewardBonus( gentity_t *self )
return 1.0f;
}
-float G_TeamRewardScaleFactor( gentity_t *target )
+float G_RewardScaleFactor( gentity_t *self, gentity_t *target )
{
- if (level.humanRewardKills <= 0.0f || level.alienRewardKills <= 0.0f) return 1.0f;
+ float targetScore;
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 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;
+ if( level.humanRewardScore <= 0.0f || level.alienRewardScore <= 0.0f ) return 1.0f;
+ if( self->client->ps.persistant[ PERS_SCORE ] <= 0 || target->client->ps.persistant[ PERS_SCORE ] <= 0) return 1.0f;
+ targetScore = target->client->ps.persistant[ PERS_SCORE ]/self->client->ps.persistant[ PERS_SCORE ];
+ switch( target->client->ps.stats[ STAT_TEAM ] ) {
+ case TEAM_ALIENS:
+ targetScore *= level.alienRewardScore/level.humanRewardScore;
+ break;
+ case TEAM_HUMANS:
+ targetScore *= level.humanRewardScore/level.alienRewardScore;
+ break;
+ default:
+ return 0;
+ }
+ 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 */
@@ -235,7 +241,7 @@ float G_InstantRewardAttacker( gentity_t *self, gentity_t *target, float damage
value *= g_InstantRewardMultiplierH.value;
} else value = 0;
- value *= G_RewardScaleFactor( self, target, G_TeamRewardScaleFactor( target ) );
+ value *= G_RewardScaleFactor( self, target );
if( value > 0 ) {
G_AddCreditToClient( self->client, value, qtrue );
@@ -312,7 +318,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;
@@ -333,15 +338,13 @@ float G_RewardAttackers( gentity_t *self )
if( self->s.eType != ET_BUILDABLE )
{
// 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 );
+ stageValue *= G_RewardScaleFactor( player, self );
player->client->pers.kills += killValue;
// 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 +355,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 )
{
diff --git a/src/game/g_local.h b/src/game/g_local.h
index a46131a..a8b2323 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,10 @@ 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;
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..0466d01 100644
--- a/src/game/g_main.c
+++ b/src/game/g_main.c
@@ -194,8 +194,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;
@@ -369,9 +369,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 },
@@ -661,7 +661,7 @@ 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 );