summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2020-04-06 11:03:23 +0200
committerPaweł Redman <pawel.redman@gmail.com>2020-04-06 22:20:59 +0200
commitc77c95816fbbecba5994825d9b68b749ac7c0fe4 (patch)
treecc2a034dd2ea4dc9c75884c57a01c8a63ad14d8f
parentf675e7ad5e18e4fd67ddfc00702710b3f1b158e9 (diff)
Fractional evos - initial commit
I probably missed something; this needs proper testing.
-rw-r--r--src/cgame/cg_draw.c7
-rw-r--r--src/cgame/cg_main.c3
-rw-r--r--src/game/g_admin.c21
-rw-r--r--src/game/g_cmds.c94
-rw-r--r--src/game/tremulous.h38
5 files changed, 103 insertions, 60 deletions
diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c
index 33a275a..cea2527 100644
--- a/src/cgame/cg_draw.c
+++ b/src/cgame/cg_draw.c
@@ -539,10 +539,11 @@ static void CG_DrawPlayerCreditsValue( rectDef_t *rect, vec4_t color, qboolean p
value = ps->persistant[ PERS_CREDIT ];
if( value > -1 )
{
- if( cg.predictedPlayerState.stats[ STAT_PTEAM ] == PTE_ALIENS &&
- !CG_AtHighestClass( ) )
+ if( cg.predictedPlayerState.stats[ STAT_PTEAM ] == PTE_ALIENS )
{
- if( cg.time - cg.lastEvolveAttempt <= NO_CREDITS_TIME )
+ value = floor( value / EVO_TO_CREDS_RATE );
+
+ if( !CG_AtHighestClass( ) && cg.time - cg.lastEvolveAttempt <= NO_CREDITS_TIME )
{
if( ( ( cg.time - cg.lastEvolveAttempt ) / 300 ) % 2 )
color[ 3 ] = 0.0f;
diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c
index 89a4c5c..36a9577 100644
--- a/src/cgame/cg_main.c
+++ b/src/cgame/cg_main.c
@@ -489,6 +489,7 @@ static void CG_SetPVars( void )
trap_Cvar_Set( "player_stage", va( "%d", cgs.alienStage+1 ) );
trap_Cvar_Set( "player_bp", va( "%d", cgs.alienBuildPoints ));
trap_Cvar_Set( "player_maxbp", va( "%d", cgs.alienBuildPointsTotal ));
+ trap_Cvar_Set( "player_credits", va( "%f", ps->persistant[ PERS_CREDIT ] / EVO_TO_CREDS_RATE ) );
break;
case PTE_HUMANS:
@@ -498,10 +499,10 @@ static void CG_SetPVars( void )
trap_Cvar_Set( "player_kns", va( "%d",((cgs.humanStage==2)?0:abs(cgs.humanNextStageThreshold-cgs.humanKills))));
trap_Cvar_Set( "player_bp", va( "%d", cgs.humanBuildPoints ));
trap_Cvar_Set( "player_maxbp", va( "%d", cgs.humanBuildPointsTotal ));
+ trap_Cvar_Set( "player_credits", va( "%d", ps->persistant[ PERS_CREDIT ] ) );
break;
}
- trap_Cvar_Set( "player_credits", va( "%d", ps->persistant[ PERS_CREDIT ] ) );
trap_Cvar_Set( "player_score", va( "%d", ps->persistant[ PERS_SCORE ] ) );
trap_Cvar_Set( "player_deaths", va( "%d", ps->persistant[ PERS_KILLED ] ) );
diff --git a/src/game/g_admin.c b/src/game/g_admin.c
index a616f41..93fee5c 100644
--- a/src/game/g_admin.c
+++ b/src/game/g_admin.c
@@ -7982,7 +7982,6 @@ qboolean G_admin_give(gentity_t *ent, int skiparg)
char arg_amount[30];
int target_id, amount;
gentity_t *target;
- const char *currency;
if (G_SayArgc() < 3 + skiparg) {
ADMP("^3!give: ^7usage: !give [player] [amount]\n");
@@ -8024,24 +8023,31 @@ qboolean G_admin_give(gentity_t *ent, int skiparg)
}
G_SayArgv(2 + skiparg, arg_amount, sizeof(arg_amount));
+
amount = atoi(arg_amount);
switch (target->client->pers.teamSelection) {
case PTE_ALIENS:
- if (amount < -9 || amount > 9) {
+ amount = floor(EVOS(atof(arg_amount)));
+ if (amount < -ALIEN_MAX_KILLS || amount > ALIEN_MAX_KILLS) {
too_big:
ADMP("^3!give: ^7amount is too big\n");
return qfalse;
}
- currency = "evo";
+ AP(va("print \"^3!give: ^7%s^7 was given %.3f evo%s by ^7%s^7\n\"",
+ target->client->pers.netname, amount / EVO_TO_CREDS_RATE,
+ (abs(amount) != 1 ? "s" : ""),
+ ent ? G_admin_adminPrintName(ent) : "console"));
break;
case PTE_HUMANS:
- if (amount < -2000 || amount > 2000)
+ if (amount < -HUMAN_MAX_CREDITS || amount > HUMAN_MAX_CREDITS)
goto too_big;
- currency = "credit";
+ AP(va("print \"^3!give: ^7%s^7 was given %d credit%s by ^7%s^7\n\"",
+ target->client->pers.netname, amount, (abs(amount) != 1 ? "s" : ""),
+ ent ? G_admin_adminPrintName(ent) : "console"));
break;
default:
@@ -8049,11 +8055,6 @@ qboolean G_admin_give(gentity_t *ent, int skiparg)
}
G_AddCreditToClient(target->client, amount, qtrue);
- AP(va("print \"^3!give: ^7%s^7 was given %i %s%s by ^7%s^7\n\"",
- target->client->pers.netname, amount, currency,
- (abs(amount) != 1 ? "s" : ""),
- ent ? G_admin_adminPrintName(ent) : "console"));
-
return qtrue;
}
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c
index 506b657..d19bb02 100644
--- a/src/game/g_cmds.c
+++ b/src/game/g_cmds.c
@@ -681,17 +681,10 @@ void G_ChangeTeam( gentity_t *ent, pTeam_t newTeam )
// under certain circumstances, clients can keep their kills and credits
// when switching teams
- if( G_admin_permission( ent, ADMF_TEAMCHANGEFREE ) ||
- ( g_teamImbalanceWarnings.integer && isFixingImbalance ) ||
- ( ( oldTeam == PTE_HUMANS || oldTeam == PTE_ALIENS )
- && ( level.time - ent->client->pers.teamChangeTime ) > 60000 ) )
- {
- if( oldTeam == PTE_ALIENS )
- ent->client->pers.credit *= (float)FREEKILL_HUMAN / FREEKILL_ALIEN;
- else if( newTeam == PTE_ALIENS )
- ent->client->pers.credit *= (float)FREEKILL_ALIEN / FREEKILL_HUMAN;
- }
- else
+ if( !G_admin_permission( ent, ADMF_TEAMCHANGEFREE ) &&
+ !( g_teamImbalanceWarnings.integer && isFixingImbalance ) &&
+ !( ( oldTeam == PTE_HUMANS || oldTeam == PTE_ALIENS )
+ && ( level.time - ent->client->pers.teamChangeTime ) > 60000 ) )
{
ent->client->pers.credit = 0;
ent->client->pers.score = 0;
@@ -4978,7 +4971,14 @@ void Cmd_Share_f( gentity_t *ent )
}
// credit count from parameter
- creds = atoi( arg2 );
+ if( team == PTE_ALIENS )
+ {
+ creds = floor( EVOS( atof( arg2 ) ) );
+ }
+ else
+ {
+ creds = atoi( arg2 );
+ }
}
// player specified "0" to transfer
@@ -5026,15 +5026,28 @@ void Cmd_Share_f( gentity_t *ent )
// transfer credits
G_AddCreditToClient( ent->client, -creds, qfalse );
- trap_SendServerCommand( ent-g_entities,
- va( "print \"share: transferred %d %s to %s^7.\n\"", creds,
- ( team == PTE_HUMANS ) ? "credits" : "evolvepoints",
- level.clients[ clientNum ].pers.netname ) );
G_AddCreditToClient( &(level.clients[ clientNum ]), creds, qtrue );
- trap_SendServerCommand( clientNum,
- va( "print \"You have received %d %s from %s^7.\n\"", creds,
- ( team == PTE_HUMANS ) ? "credits" : "evolvepoints",
- ent->client->pers.netname ) );
+
+ if( team == PTE_ALIENS )
+ {
+ float evos = creds / EVO_TO_CREDS_RATE;
+
+ trap_SendServerCommand( ent-g_entities,
+ va( "print \"share: transferred %.3f evolvepoints to %s^7.\n\"", evos,
+ level.clients[ clientNum ].pers.netname ) );
+ trap_SendServerCommand( clientNum,
+ va( "print \"You have received %.3f evolvepoints from %s^7.\n\"", evos,
+ ent->client->pers.netname ) );
+ }
+ else
+ {
+ trap_SendServerCommand( ent-g_entities,
+ va( "print \"share: transferred %d credits to %s^7.\n\"", creds,
+ level.clients[ clientNum ].pers.netname ) );
+ trap_SendServerCommand( clientNum,
+ va( "print \"You have received %d credits from %s^7.\n\"", creds,
+ ent->client->pers.netname ) );
+ }
G_LogPrintf( "Share: %i %i %i %d: %s^7 transferred %d%s to %s^7\n",
ent->client->ps.clientNum,
@@ -5055,7 +5068,7 @@ Alms for the poor
=================
*/
void Cmd_Donate_f( gentity_t *ent ) {
- char s[ MAX_TOKEN_CHARS ] = "", *type = "evo(s)";
+ char s[ MAX_TOKEN_CHARS ] = "";
int i, value, divisor, portion, new_credits, total=0,
max = ALIEN_MAX_KILLS, *amounts, *totals;
qboolean donated = qtrue;
@@ -5079,7 +5092,6 @@ void Cmd_Donate_f( gentity_t *ent ) {
else if( ent->client->pers.teamSelection == PTE_HUMANS ) {
divisor = level.numHumanClients-1;
max = HUMAN_MAX_CREDITS;
- type = "credit(s)";
} else {
trap_SendServerCommand( ent-g_entities,
va( "print \"donate: spectators cannot be so gracious\n\"" ) );
@@ -5093,7 +5105,14 @@ void Cmd_Donate_f( gentity_t *ent ) {
}
trap_Argv( 1, s, sizeof( s ) );
- value = atoi(s);
+ if( ent->client->pers.teamSelection == PTE_ALIENS )
+ {
+ value = floor( EVOS( atof( s ) ) );
+ }
+ else
+ {
+ value = atoi( s );
+ }
if( value <= 0 ) {
trap_SendServerCommand( ent-g_entities,
"print \"donate: very funny\n\"" );
@@ -5142,18 +5161,31 @@ void Cmd_Donate_f( gentity_t *ent ) {
// transfer funds
G_AddCreditToClient( ent->client, value - total, qtrue );
for( i = 0; i < level.maxclients; i++ )
- if( totals[ i ] ) {
- trap_SendServerCommand( i,
- va( "print \"%s^7 donated %d %s to you, don't forget to say 'thank you'!\n\"",
- ent->client->pers.netname, totals[ i ], type ) );
+ {
+ if( totals[ i ] )
+ {
+ if( ent->client->pers.teamSelection == PTE_ALIENS )
+ {
+ trap_SendServerCommand( i,
+ va( "print \"%s^7 donated %.3f evo(s) to you, don't forget to say 'thank you'!\n\"",
+ ent->client->pers.netname, totals[ i ] / EVO_TO_CREDS_RATE ) );
+ trap_SendServerCommand( ent-g_entities,
+ va( "print \"Donated %.3f evo(s) to the cause.\n\"",
+ total-value / EVO_TO_CREDS_RATE ) );
+ }
+ else
+ {
+ trap_SendServerCommand( i,
+ va( "print \"%s^7 donated %d credit(s) to you, don't forget to say 'thank you'!\n\"",
+ ent->client->pers.netname, totals[ i ] ) );
+ trap_SendServerCommand( ent-g_entities,
+ va( "print \"Donated %d credit(s) to the cause.\n\"", total-value ) );
+ }
}
+ }
G_Free( amounts );
G_Free( totals );
-
- trap_SendServerCommand( ent-g_entities,
- va( "print \"Donated %d %s to the cause.\n\"",
- total-value, type ) );
}
commands_t cmds[ ] = {
diff --git a/src/game/tremulous.h b/src/game/tremulous.h
index 97738f2..2bd267e 100644
--- a/src/game/tremulous.h
+++ b/src/game/tremulous.h
@@ -21,6 +21,14 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
+/*
+ * For simplicity and finer granularity, both alien evos and human credits
+ * are now stored as a number from 0 to 2000. This means that dealing with
+ * evos is a bit more involved and requires exchanging between the old 0-9
+ * range and the new one when appropriate (hardcoded stats and display code).
+ */
+#define EVO_TO_CREDS_RATE 222.0f // 9 * 222 = 1998, close enough
+#define EVOS(x) ( ( x ) * EVO_TO_CREDS_RATE )
/*
* ALIEN weapons
@@ -142,61 +150,61 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define ABUILDER_VALUE AVM(200)
#define ABUILDER_HEALTH AHM(50)
#define ABUILDER_REGEN 2
-#define ABUILDER_COST 0
+#define ABUILDER_COST EVOS(0)
#define ABUILDER_UPG_SPEED 1.0f
#define ABUILDER_UPG_VALUE AVM(250)
#define ABUILDER_UPG_HEALTH AHM(75)
#define ABUILDER_UPG_REGEN 3
-#define ABUILDER_UPG_COST 0
+#define ABUILDER_UPG_COST EVOS(0)
#define LEVEL0_SPEED 1.3f
#define LEVEL0_VALUE AVM(175)
#define LEVEL0_HEALTH AHM(25)
#define LEVEL0_REGEN 1
-#define LEVEL0_COST 0
+#define LEVEL0_COST EVOS(0)
#define LEVEL1_SPEED 1.25f
#define LEVEL1_VALUE AVM(225)
#define LEVEL1_HEALTH AHM(75)
#define LEVEL1_REGEN 2
-#define LEVEL1_COST 1
+#define LEVEL1_COST EVOS(1)
#define LEVEL1_UPG_SPEED 1.25f
#define LEVEL1_UPG_VALUE AVM(275)
#define LEVEL1_UPG_HEALTH AHM(100)
#define LEVEL1_UPG_REGEN 3
-#define LEVEL1_UPG_COST 1
+#define LEVEL1_UPG_COST EVOS(1)
#define LEVEL2_SPEED 1.2f
#define LEVEL2_VALUE AVM(350)
#define LEVEL2_HEALTH AHM(150)
#define LEVEL2_REGEN 4
-#define LEVEL2_COST 1
+#define LEVEL2_COST EVOS(1)
#define LEVEL2_UPG_SPEED 1.2f
#define LEVEL2_UPG_VALUE AVM(450)
#define LEVEL2_UPG_HEALTH AHM(175)
#define LEVEL2_UPG_REGEN 5
-#define LEVEL2_UPG_COST 1
+#define LEVEL2_UPG_COST EVOS(1)
#define LEVEL3_SPEED 1.1f
#define LEVEL3_VALUE AVM(500)
#define LEVEL3_HEALTH AHM(200)
#define LEVEL3_REGEN 6
-#define LEVEL3_COST 1
+#define LEVEL3_COST EVOS(1)
#define LEVEL3_UPG_SPEED 1.1f
#define LEVEL3_UPG_VALUE AVM(600)
#define LEVEL3_UPG_HEALTH AHM(250)
#define LEVEL3_UPG_REGEN 7
-#define LEVEL3_UPG_COST 1
+#define LEVEL3_UPG_COST EVOS(1)
#define LEVEL4_SPEED 1.2f
#define LEVEL4_VALUE AVM(800)
#define LEVEL4_HEALTH AHM(400)
#define LEVEL4_REGEN 7
-#define LEVEL4_COST 2
+#define LEVEL4_COST EVOS(2)
@@ -513,7 +521,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define HSPAWN_HEALTH HBHM(310)
#define HSPAWN_SPLASHDAMAGE 50
#define HSPAWN_SPLASHRADIUS 100
-#define HSPAWN_VALUE 1
+#define HSPAWN_VALUE EVOS(1)
#define MEDISTAT_BP 8
#define MEDISTAT_BT 10000
@@ -569,7 +577,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define REACTOR_ATTACK_RANGE 100.0f
#define REACTOR_ATTACK_REPEAT 1000
#define REACTOR_ATTACK_DAMAGE 40
-#define REACTOR_VALUE 2
+#define REACTOR_VALUE EVOS(2)
#define REPEATER_BP 0
#define REPEATER_BT 10000
@@ -604,11 +612,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define HUMAN_MAXED 900 //a human with a strong selection of weapons/upgrades
#define HUMAN_MAX_CREDITS 2000
-#define ALIEN_MAX_KILLS 9
-#define ALIEN_MAX_SINGLE_KILLS 3
+#define ALIEN_MAX_KILLS EVOS(9)
+#define ALIEN_MAX_SINGLE_KILLS EVOS(3)
#define FREEKILL_PERIOD 120000 //msec
-#define FREEKILL_ALIEN 1
+#define FREEKILL_ALIEN EVOS(1)
#define FREEKILL_HUMAN LEVEL0_VALUE
#define DEFAULT_ALIEN_BUILDPOINTS "130"