From 70e3c40490609473274e0735d8818e25f83d1df8 Mon Sep 17 00:00:00 2001 From: Tim Joiner <31621879+Xynth22@users.noreply.github.com> Date: Tue, 14 Nov 2017 07:49:12 -0600 Subject: [PATCH] Update score (#38) * 33% reduction in score awarded for nanning I was seeing scores for nan scout too high when playing real games. * Rework points from repair Points are awarded baswed on percental of hull repaired so healing anything from 0 to 100% is worth 10 points. Also fixed an error that was inflating scores from healing. --- src/FedSrv/CSteamAchievements.cpp | 7 ++++--- src/FedSrv/CSteamAchievements.h | 4 ++-- src/FedSrv/FedSrv.CPP | 2 +- src/Igc/common.cpp | 2 +- src/Igc/igc.h | 11 ++++++++--- src/Igc/shipIGC.cpp | 11 ++++++++--- src/Igc/shipIGC.h | 2 +- 7 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/FedSrv/CSteamAchievements.cpp b/src/FedSrv/CSteamAchievements.cpp index f9870a15..68bf537a 100644 --- a/src/FedSrv/CSteamAchievements.cpp +++ b/src/FedSrv/CSteamAchievements.cpp @@ -408,11 +408,12 @@ void CSteamAchievements::AddUserStats(PlayerScoreObject* ppso, IshipIGC * pIshi SetStat(EStats::PLAYER_LOSS, tempStat + 1); } - if (pIship->GetRepair() > 0.0) + int repair = floor(100 * ppso->GetRepair()); + if (repair > 0.0) { - getSucceed = GetStat(EStats::REPAIR_AMOUNT, &tempStat); + getSucceed = GetStat(EStats::REPAIR_PERCENT, &tempStat); if (getSucceed) - SetStat(EStats::REPAIR_AMOUNT, tempStat + floor(pIship->GetRepair())); + SetStat(EStats::REPAIR_PERCENT, tempStat + repair); } } diff --git a/src/FedSrv/CSteamAchievements.h b/src/FedSrv/CSteamAchievements.h index 1003d9b1..b2038615 100644 --- a/src/FedSrv/CSteamAchievements.h +++ b/src/FedSrv/CSteamAchievements.h @@ -41,7 +41,7 @@ enum EStats PLAYER_RANK = 6, PLAYER_WINS = 7, PLAYER_LOSS = 8, - REPAIR_AMOUNT = 9 + REPAIR_PERCENT = 9 // Don't forget to update g_nMaximumSteamStatCount and m_Stats! }; @@ -107,7 +107,7 @@ class CSteamAchievements "PLAYER_RANK", "PLAYER_WINS", "PLAYER_LOSS", - "REPAIR_AMOUNT" + "REPAIR_PERCENT" }; bool GetAchievement(EAchievements achievement); diff --git a/src/FedSrv/FedSrv.CPP b/src/FedSrv/FedSrv.CPP index d6e30d0e..34074ea7 100644 --- a/src/FedSrv/FedSrv.CPP +++ b/src/FedSrv/FedSrv.CPP @@ -3662,7 +3662,7 @@ void SendShipUpdates(CFSMission * pfsMission) if ((pship->GetAchievementMask() & c_achmProbeSpot) > 0) pso->AddProbeSpot(); if ((pship->GetAchievementMask() & c_achmNewRepair) > 0) - pso->SetRepair(int(pship->GetRepair())); + pso->SetRepair(pship->GetRepair()); pSteamAchievements->AwardIGCAchievements(pship->GetAchievementMask()); pship->ClearAchievementMask(); diff --git a/src/Igc/common.cpp b/src/Igc/common.cpp index ceea82be..4c519e47 100644 --- a/src/Igc/common.cpp +++ b/src/Igc/common.cpp @@ -2557,7 +2557,7 @@ void PlayerScoreObject::CalculateScore(ImissionIGC* pmission) float(m_cArtifacts) * pmission->GetFloatConstant(c_fcidPointsArtifacts) + float(m_cFlags) * pmission->GetFloatConstant(c_fcidPointsFlags) + float(m_cProbeSpot) * 10 + - float(m_cRepair) * 0.0004; + float(m_cRepair) * 10; if (m_bWin) m_fScore *= 2.0f; diff --git a/src/Igc/igc.h b/src/Igc/igc.h index f2122929..3081f980 100644 --- a/src/Igc/igc.h +++ b/src/Igc/igc.h @@ -5605,9 +5605,14 @@ class PlayerScoreObject { m_cProbeSpot++; } - void SetRepair(int repair) + void SetRepair(float repair) { - m_cRepair += repair; + m_cRepair = repair; + } + + float GetRepair(void) const + { + return m_cRepair; } @@ -5868,7 +5873,7 @@ class PlayerScoreObject float m_cBaseKills; float m_cBaseCaptures; short m_cProbeSpot; - int m_cRepair; + float m_cRepair; short m_cTechsRecovered; short m_cFlags; diff --git a/src/Igc/shipIGC.cpp b/src/Igc/shipIGC.cpp index d6c66a58..892c4479 100644 --- a/src/Igc/shipIGC.cpp +++ b/src/Igc/shipIGC.cpp @@ -1225,6 +1225,7 @@ DamageResult CshipIGC::ReceiveDamage(DamageTypeID type, float maxHP = m_myHullType.GetHitPoints(); float dtmArmor = GetMyMission()->GetDamageConstant(type, m_myHullType.GetDefenseType()); + float repairFraction; assert (dtmArmor >= 0.0f); float leakage; @@ -1234,18 +1235,22 @@ DamageResult CshipIGC::ReceiveDamage(DamageTypeID type, m_fraction -= amount * dtmArmor / maxHP; if (m_fraction > 1.0f) { - amount += (m_fraction - 1.0) * maxHP / dtmArmor; //Set amount to amount that had effect for stat + amount += (m_fraction - 1.0) * maxHP / dtmArmor; //Set amount to amount that had effect for stat m_fraction = 1.0f; } GetThingSite ()->RemoveDamage (m_fraction); - + if (GetMyMission()->GetMissionParams()->bAllowFriendlyFire || //no points when FF is on + !((pside == launcher->GetSide()) || IsideIGC::AlliedSides(pside, launcher->GetSide()))) //no points for healing the enemy + repairFraction = 0; + else + repairFraction = fabs(amount * dtmArmor / maxHP); leakage = 0.0f; dr = c_drNoDamage; if (launcher->GetObjectType() == OT_ship && (pside == launcher->GetSide()) || IsideIGC::AlliedSides(pside, launcher->GetSide())) { IshipIGC * pIship = ((IshipIGC*)launcher); - pIship->AddRepair(-amount); + pIship->AddRepair(repairFraction); pIship->SetAchievementMask(c_achmNewRepair); } } diff --git a/src/Igc/shipIGC.h b/src/Igc/shipIGC.h index 0a174e07..72ecca29 100644 --- a/src/Igc/shipIGC.h +++ b/src/Igc/shipIGC.h @@ -1851,7 +1851,7 @@ class CshipIGC : public TmodelIGC } virtual void AddRepair(float repair) { - m_repair += repair; //Xynth amount of nanning performed by ship + m_repair += repair; //Xynth amount of nanning performed by ship as a fraction of hull repaired } virtual float GetRepair(void) const {