Skip to content

Commit

Permalink
add mp_min_score_mult
Browse files Browse the repository at this point in the history
in a long series the multiplier is too punishing. I'll get 100 points in the first map but die 10 times. Then get 20 points in the next 5 maps. You pretty much stop getting points once the multiplier is a single digit.

also removed negative score from hurting yourself.
  • Loading branch information
wootguy committed Dec 16, 2024
1 parent 5c95a13 commit 3ef13aa
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 3 deletions.
4 changes: 4 additions & 0 deletions dlls/CBaseEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1289,6 +1289,10 @@ void CBaseEntity::GiveScorePoints(entvars_t* pevAttacker, float damageDealt) {
CBaseEntity* baseEnt = CBaseEntity::Instance(pevAttacker);
CBaseMonster* attackMon = baseEnt ? baseEnt->MyMonsterPointer() : NULL;

if (pevAttacker == pev) {
return;
}

// give points proportional to how much damage will be dealt, ignoring overkill damage
if (attackMon && (pevAttacker->flags & FL_CLIENT) && pev->health > 0) {
float damageAmt = damageDealt > 0 ? V_min(damageDealt, pev->health) : V_min(damageDealt, pev->max_health - pev->health);
Expand Down
2 changes: 2 additions & 0 deletions dlls/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ cvar_t mp_score_mode ={"mp_score_mode", "0", FCVAR_SERVER, 0, 0 };
cvar_t mp_damage_points ={"mp_damage_points", "0.01", FCVAR_SERVER, 0, 0 };
cvar_t mp_antiblock ={"mp_antiblock", "1", FCVAR_SERVER, 0, 0 };
cvar_t mp_antiblock_cooldown ={"mp_antiblock_cooldown", "3", FCVAR_SERVER, 0, 0 };
cvar_t mp_min_score_mult ={"mp_min_score_mult", "20", FCVAR_SERVER, 0, 0 };

cvar_t soundvariety={"mp_soundvariety","0", FCVAR_SERVER, 0, 0 };
cvar_t mp_npcidletalk={"mp_npcidletalk","1", FCVAR_SERVER, 0, 0 };
Expand Down Expand Up @@ -409,6 +410,7 @@ void GameDLLInit( void )
CVAR_REGISTER (&mp_damage_points);
CVAR_REGISTER (&mp_antiblock);
CVAR_REGISTER (&mp_antiblock_cooldown);
CVAR_REGISTER (&mp_min_score_mult);

CVAR_REGISTER (&mp_chattime);

Expand Down
1 change: 1 addition & 0 deletions dlls/game/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ EXPORT extern cvar_t mp_score_mode; // 0 = get points for damage, 1 = point mult
EXPORT extern cvar_t mp_damage_points; // score points given per point of damage dealt
EXPORT extern cvar_t mp_antiblock; // enables player swapping with +use
EXPORT extern cvar_t mp_antiblock_cooldown; // how long a player needs to wait before swapping again after a "rude" swap
EXPORT extern cvar_t mp_min_score_mult; // minimum score multiplier for death penalties

// Enables classic func_pushable physics (which is horribly broken, but fun)
// The higher your FPS, the faster you can boost pushables. You also get boosted.
Expand Down
21 changes: 18 additions & 3 deletions dlls/player/CBasePlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1486,8 +1486,16 @@ void CBasePlayer::PlayerDeathThink(void)
std::string pointsMessage;
if (mp_score_mode.value == 1) {
// deaths are penalized. Show current score multiplier
pointsMessage = UTIL_VarArgs("\n\nNew score multiplier: %d%% (%d death%s)",
(int)roundf(m_scoreMultiplier*100.0f), m_iDeaths, m_iDeaths == 1 ? "" : "s");
bool sameAsLast = m_iDeaths > 1 && GetScoreMultiplier() == GetScoreMultiplier(m_iDeaths - 1);

if (sameAsLast) {
pointsMessage = UTIL_VarArgs("\n\nScore multiplier: %d%%",
(int)roundf(m_scoreMultiplier * 100.0f), m_iDeaths == 1 ? "" : "s");
}
else {
pointsMessage = UTIL_VarArgs("\n\nNew score multiplier: %d%% (%d death%s)",
(int)roundf(m_scoreMultiplier * 100.0f), m_iDeaths, m_iDeaths == 1 ? "" : "s");
}
}

const char* msg = UTIL_VarArgs("%s%s", delayMsg.c_str(), pointsMessage.c_str());
Expand Down Expand Up @@ -6047,7 +6055,14 @@ float CBasePlayer::GetDamageModifier() {

void CBasePlayer::PenalizeDeath() {
m_iDeaths += 1;
m_scoreMultiplier = V_max(0.01f, 1.0f / (m_iDeaths+1));
m_scoreMultiplier = GetScoreMultiplier();
}

float CBasePlayer::GetScoreMultiplier(int deaths) {
if (deaths < 0) {
deaths = m_iDeaths;
}
return V_max(mp_min_score_mult.value / 100.0f, 1.0f / (deaths + 1));
}

float CBasePlayer::GetIdleTime() {
Expand Down
3 changes: 3 additions & 0 deletions dlls/player/CBasePlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,9 @@ class EXPORT CBasePlayer : public CBaseMonster
// for scoring
void PenalizeDeath();

// -1 deaths = use current death counter
float GetScoreMultiplier(int deaths = -1);

// how long has it been since the player last pressed any buttons or typed in chat
float GetIdleTime();

Expand Down

0 comments on commit 3ef13aa

Please sign in to comment.