diff options
author | Mikko Tiusanen <ams@daug.net> | 2014-06-02 21:48:10 +0300 |
---|---|---|
committer | Mikko Tiusanen <ams@daug.net> | 2014-06-02 21:48:10 +0300 |
commit | eb96542aefac01d68617f54e92cf4c8bae0c6d44 (patch) | |
tree | c9d6491bd359a9e84b14881ec38d243c528f9240 /src | |
parent | 65ecd185ab744857f738980cc86bbf5cbd26b4c4 (diff) |
Added credit gain scaling based on player and team kill count differences.
Diffstat (limited to 'src')
-rw-r--r-- | src/game/g_client.c | 2 | ||||
-rw-r--r-- | src/game/g_combat.c | 62 | ||||
-rw-r--r-- | src/game/g_local.h | 9 | ||||
-rw-r--r-- | src/game/g_main.c | 8 | ||||
-rw-r--r-- | src/game/tremulous.h | 1 |
5 files changed, 67 insertions, 15 deletions
diff --git a/src/game/g_client.c b/src/game/g_client.c index 56e074f..fc797e5 100644 --- a/src/game/g_client.c +++ b/src/game/g_client.c @@ -1460,7 +1460,7 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn, vec3_t origin, vec3_t angles // clear entity values if( ent->client->pers.classSelection == PCL_HUMAN ) { - //BG_AddUpgradeToInventory( UP_MEDKIT, client->ps.stats ); + if (SPAWN_WITH_MEDKIT) BG_AddUpgradeToInventory( UP_MEDKIT, client->ps.stats ); weapon = client->pers.humanItemSelection; } else if( client->sess.spectatorState == SPECTATOR_NOT ) diff --git a/src/game/g_combat.c b/src/game/g_combat.c index b6de2f4..e616c5a 100644 --- a/src/game/g_combat.c +++ b/src/game/g_combat.c @@ -247,6 +247,30 @@ 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->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; +} + /* Instantly reward the current attacker */ float G_InstantRewardAttacker( gentity_t *self, gentity_t *target, float damage ) { @@ -268,13 +292,15 @@ float G_InstantRewardAttacker( gentity_t *self, gentity_t *target, float damage value *= BG_GetValueOfPlayer( &target->client->ps ); if( target->client->ps.stats[ STAT_TEAM ] == TEAM_ALIENS) { - value *= g_InstantRewardMultiplierA.value; + value *= g_InstantRewardMultiplierA.value; } else if( target->client->ps.stats[ STAT_TEAM ] == TEAM_HUMANS ) { - value *= g_InstantRewardMultiplierH.value; + value *= g_InstantRewardMultiplierH.value; } else value = 0; + value *= G_RewardScaleFactor( self, target, G_TeamRewardScaleFactor( target ) ); + if( value > 0 ) - G_AddCreditToClient( self->client, value, qtrue ); + G_AddCreditToClient( self->client, value, qtrue ); return value; } @@ -292,7 +318,7 @@ float G_RewardAttackers( gentity_t *self ) float value, totalDamage = 0; int team, i, maxHealth = 0; int alienCredits = 0, humanCredits = 0; - + float teamFactor; gentity_t *player; @@ -313,10 +339,10 @@ float G_RewardAttackers( gentity_t *self ) if( self->client ) { value = BG_GetValueOfPlayer( &self->client->ps ); - value *= G_CamperRewardBonus( self ); + value *= G_CamperRewardBonus( self ); team = self->client->pers.teamSelection; maxHealth = self->client->ps.stats[ STAT_MAX_HEALTH ]; - // trap_SendServerCommand( -1, va( "print \"^5You recieved%3i extra evos/credits.\n\"", value ) ); + // trap_SendServerCommand( -1, va( "print \"^5You recieved%3i extra evos/credits.\n\"", value ) ); } else if( self->s.eType == ET_BUILDABLE ) @@ -336,10 +362,13 @@ float G_RewardAttackers( gentity_t *self ) else return totalDamage; + // Give credits and empty the array + teamFactor = G_TeamRewardScaleFactor( self ); for( i = 0; i < level.maxclients; i++ ) { int stageValue = value * self->credits[ i ] / totalDamage; + float killValue = self->credits[ i ] / maxHealth; player = g_entities + i; if( player->client->pers.teamSelection != team ) @@ -351,25 +380,32 @@ float G_RewardAttackers( gentity_t *self ) continue; AddScore( player, stageValue ); - + // killing buildables earns score, but not credits 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 ); + player->client->pers.kills += killValue; // add to stage counters if( player->client->ps.stats[ STAT_TEAM ] == TEAM_ALIENS ) { - G_AddCreditToClient( player->client, g_KillRewardMultiplierH.value*stageValue, qtrue ); + level.alienRewardKills += killValue; + G_AddCreditToClient( player->client, g_KillRewardMultiplierH.value*stageValue, qtrue ); alienCredits += stageValue; - } else if( player->client->ps.stats[ STAT_TEAM ] == TEAM_HUMANS ) { - G_AddCreditToClient( player->client, g_KillRewardMultiplierA.value*stageValue, qtrue ); + } else if( player->client->ps.stats[ STAT_TEAM ] == TEAM_HUMANS ) { + level.humanRewardKills += killValue; + G_AddCreditToClient( player->client, g_KillRewardMultiplierA.value*stageValue, qtrue ); humanCredits += stageValue; - } + } } } self->credits[ i ] = 0; - - } + ++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); + if( alienCredits ) { trap_Cvar_Set( "g_alienCredits", diff --git a/src/game/g_local.h b/src/game/g_local.h index 52bf097..183985b 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -344,6 +344,9 @@ typedef struct int floodDemerits; int floodTime; + float kills; + int deaths; + vec3_t lastDeathLocation; char guid[ 33 ]; addr_t ip; @@ -650,6 +653,9 @@ typedef struct int alienKills; int humanKills; + float alienRewardKills; + float humanRewardKills; + qboolean overmindMuted; int humanBaseAttackTimer; @@ -1253,6 +1259,9 @@ extern vmCvar_t g_InstantRewardMultiplierA; 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; 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 ab799e5..53f36ce 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -182,6 +182,9 @@ vmCvar_t g_InstantRewardMultiplierA; vmCvar_t g_InstantRewardMultiplierH; vmCvar_t g_KillRewardMultiplierA; vmCvar_t g_KillRewardMultiplierH; +vmCvar_t g_ConstantRewardFactor; +vmCvar_t g_TeamRewardFactor; +vmCvar_t g_PlayerRewardFactor; // copy cvars that can be set in worldspawn so they can be restored later static char cv_gravity[ MAX_CVAR_VALUE_STRING ]; @@ -261,7 +264,6 @@ static cvarTable_t gameCvarTable[ ] = { &g_humanStage, "g_humanStage", "0", 0, 0, qfalse }, { &g_humanCredits, "g_humanCredits", "0", 0, 0, qfalse }, { &g_humanStage, "g_humanStage", "0", 0, 0, qfalse }, - { &g_humanCredits, "g_humanCredits", "0", 0, 0, qfalse }, { &g_humanMaxStage, "g_humanMaxStage", DEFAULT_HUMAN_MAX_STAGE, 0, 0, qfalse, cv_humanMaxStage }, { &g_humanStage2Threshold, "g_humanStage2Threshold", DEFAULT_HUMAN_STAGE2_THRESH, 0, 0, qfalse }, { &g_humanStage3Threshold, "g_humanStage3Threshold", DEFAULT_HUMAN_STAGE3_THRESH, 0, 0, qfalse }, @@ -336,6 +338,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 } }; static int gameCvarTableSize = sizeof( gameCvarTable ) / sizeof( gameCvarTable[ 0 ] ); void G_InitGame( int levelTime, int randomSeed, int restart ); @@ -610,6 +615,7 @@ void G_InitGame( int levelTime, int randomSeed, int restart ) level.alienStage2Time = level.alienStage3Time = level.humanStage2Time = level.humanStage3Time = level.startTime; level.snd_fry = G_SoundIndex( "sound/misc/fry.wav" ); // FIXME standing in lava / slime + level.humanRewardKills = level.alienRewardKills = 0.0f; trap_Cvar_Set( "g_version", G_MOD_VERSION ); trap_Cvar_Set( "edge_version", EDGE_MOD_VERSION ); if( g_logFile.string[ 0 ] ) diff --git a/src/game/tremulous.h b/src/game/tremulous.h index 0a82f1f..b6dad3f 100644 --- a/src/game/tremulous.h +++ b/src/game/tremulous.h @@ -544,6 +544,7 @@ TREMULOUS EDGE MOD SRC FILE #define HELMET_INFECTION_PROTECTION 1 #define HELMET_PCLOUD_PROTECTION 1000 +#define SPAWN_WITH_MEDKIT 0 #define MEDKIT_PRICE 50 #define BATTPACK_PRICE 75 |