Skip to content

Commit

Permalink
ammo prices receive a discount for the losing team depending on how b…
Browse files Browse the repository at this point in the history
…adly they are losing in a range from 10% to up to 75% off
  • Loading branch information
DarthFutuza committed Jul 6, 2018
1 parent c595023 commit 809c2d0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
24 changes: 21 additions & 3 deletions codemp/game/g_cmds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4590,8 +4590,9 @@ void Cmd_BuyAmmo_f(gentity_t* ent) {

cost = perUnitCost * unitsRequested;

//if passiveUnderdogBonus is enabled and our team is losing, our ammo is half off! Awww, thanks vendor!
if (jkg_passiveUnderdogBonus.integer > 0)

//if passiveUnderdogBonus is enabled and our team is losing, our ammo is discounted! Awww, thanks vendor!
if (jkg_passiveUnderdogBonus.integer > 0) //--Futuza: this is only done game logic side, and needs to be added to the display in jkg_shop.cpp because right now it will just display the usual price
{
//who is currently winning?
auto my_team = ent->client->sess.sessionTeam;
Expand All @@ -4603,8 +4604,25 @@ void Cmd_BuyAmmo_f(gentity_t* ent) {
else
curr_winner = -1; //tie

//we're losing - give us discount ammo please!
if (my_team != curr_winner && curr_winner != -1)
cost = cost / 2;
{
float ammoAdjust = 0.9;

//evaluate how badly the losing team is losing by and reduce ammo accordingly
int diff = level.teamScores[curr_winner] - level.teamScores[my_team];
ammoAdjust = (1 - (float)diff / level.teamScores[curr_winner]);

if (ammoAdjust > 0.9) //minimum discount is 10% off
ammoAdjust = 0.9;

if (ammoAdjust < 0.25)
ammoAdjust = 0.25; //maximum discount is 75% off

cost = cost * ammoAdjust;
if (cost < 1)
cost = 1;
}
}

if (cost > myCredits) {
Expand Down
4 changes: 2 additions & 2 deletions codemp/game/g_xcvar.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ XCVAR_DEF( g_siegeTeam2, "none", NULL, CVAR_ARCHIVE|CVAR_SERVERINFO,
XCVAR_DEF( g_siegeTeamSwitch, "1", NULL, CVAR_SERVERINFO|CVAR_ARCHIVE, qfalse )
XCVAR_DEF( g_slowmoDuelEnd, "0", NULL, CVAR_ARCHIVE, qtrue )
XCVAR_DEF( g_smoothClients, "1", NULL, CVAR_NONE, qfalse )
XCVAR_DEF( g_spawnInvulnerability, "4000", NULL, CVAR_ARCHIVE, qtrue )
XCVAR_DEF( g_spawnInvulnerability, "5000", NULL, CVAR_ARCHIVE, qtrue )
XCVAR_DEF( g_speed, "250", NULL, CVAR_NONE, qtrue )
XCVAR_DEF( g_statLog, "0", NULL, CVAR_ARCHIVE, qfalse )
XCVAR_DEF( g_statLogFile, "statlog.log", NULL, CVAR_ARCHIVE, qfalse )
Expand Down Expand Up @@ -174,7 +174,7 @@ XCVAR_DEF( jkg_startingCredits, "500", NULL, CVAR_ARCHIVE|CVAR_LATCH|CVAR
XCVAR_DEF( jkg_bounty, "225", NULL, CVAR_ARCHIVE, true )
XCVAR_DEF( jkg_killsPerBounty, "3", NULL, CVAR_ARCHIVE, true )
XCVAR_DEF( jkg_maxKillStreakBounty, "7", NULL, CVAR_ARCHIVE, true ) //the max number of killstreaks
XCVAR_DEF( jkg_creditsPerKill, "175", NULL, CVAR_ARCHIVE, true )
XCVAR_DEF( jkg_creditsPerKill, "150", NULL, CVAR_ARCHIVE, true )
XCVAR_DEF( jkg_passiveCreditsAmount, "15", NULL, CVAR_ARCHIVE|CVAR_SERVERINFO|CVAR_LATCH, true ) //0 >= disables, default: 15
XCVAR_DEF( jkg_passiveCreditsRate, "30000", NULL, CVAR_ARCHIVE|CVAR_SERVERINFO|CVAR_LATCH, true ) //default: 30000
XCVAR_DEF( jkg_passiveCreditsWait, "60000", NULL, CVAR_ARCHIVE|CVAR_SERVERINFO|CVAR_LATCH, true ) //how long to wait before starting passiveCredits, default: 60000 (60 seconds)
Expand Down
10 changes: 5 additions & 5 deletions codemp/ui/jkg_shop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ void JKG_Shop_UpdatePriceCheck()
return;
}

//todo: (see g_cmds.cpp Cmd_BuyAmmo_f()) - when on losing team ammo is 50% off (currently happens with game logic, just isn't displayed)
if (atoi(Info_ValueForKey(info, "jkg_passiveUnderdogBonus")) > 0)
//todo: (see g_cmds.cpp Cmd_BuyAmmo_f()) - when on losing team ammo is discounted (currently happens with game logic, just isn't displayed in g_cmds)
/*if (atoi(Info_ValueForKey(info, "jkg_passiveUnderdogBonus")) > 0)
{
//who is currently winning?
/*
auto my_team = ent->client->sess.sessionTeam;
int curr_winner = -1;
if (level.teamScores[TEAM_RED] > level.teamScores[TEAM_BLUE])
Expand All @@ -64,8 +64,8 @@ void JKG_Shop_UpdatePriceCheck()
bPriceCheckComplete = true;
nPriceCheckCost = it->second / 2;
return;
*/
}
}*/

for (auto it = vPriceCheckedAmmo.begin(); it != vPriceCheckedAmmo.end(); ++it)
{
Expand Down

0 comments on commit 809c2d0

Please sign in to comment.