diff --git a/src/FedSrv/CSteamAchievements.cpp b/src/FedSrv/CSteamAchievements.cpp index 99982cdd..b66e102d 100644 --- a/src/FedSrv/CSteamAchievements.cpp +++ b/src/FedSrv/CSteamAchievements.cpp @@ -301,7 +301,7 @@ void CSteamAchievements::AwardRecoverTechAchievement() } -void CSteamAchievements::AddUserStats(PlayerScoreObject* ppso) +void CSteamAchievements::AddUserStats(PlayerScoreObject* ppso, IshipIGC * pIship) { int tempStat; bool getSucceed; @@ -372,6 +372,12 @@ void CSteamAchievements::AddUserStats(PlayerScoreObject* ppso) SetStat(EStats::PLAYER_LOSS, tempStat + 1); } + if (pIship->GetRepair() > 0.0) + { + getSucceed = GetStat(EStats::REPAIR_AMOUNT, &tempStat); + if (getSucceed) + SetStat(EStats::REPAIR_AMOUNT, tempStat + floor(pIship->GetRepair())); + } } static DWORD WINAPI UpdateLeaderboardThread(LPVOID pThreadParameter) diff --git a/src/FedSrv/CSteamAchievements.h b/src/FedSrv/CSteamAchievements.h index 65a3ee88..edebe855 100644 --- a/src/FedSrv/CSteamAchievements.h +++ b/src/FedSrv/CSteamAchievements.h @@ -30,12 +30,13 @@ enum EStats SUM_SCORE = 5, PLAYER_RANK = 6, PLAYER_WINS = 7, - PLAYER_LOSS = 8 + PLAYER_LOSS = 8, + REPAIR_AMOUNT = 9 // Don't forget to update g_nMaximumSteamStatCount and m_Stats! }; const int g_nMaximumSteamAchievementCount = 11; // Always keep this in sync with the number of achievments in EAchievements! -const int g_nMaximumSteamStatCount = 9; // Always keep this in sync with the number of stats in EStats! +const int g_nMaximumSteamStatCount = 10; // Always keep this in sync with the number of stats in EStats! // BT - STEAM // 0 1 2 3 4 @@ -85,7 +86,8 @@ class CSteamAchievements "SUM_SCORE", "PLAYER_RANK", "PLAYER_WINS", - "PLAYER_LOSS" + "PLAYER_LOSS", + "REPAIR_AMOUNT" }; bool GetAchievement(EAchievements achievement); @@ -115,7 +117,7 @@ class CSteamAchievements void AwardIGCAchievements(AchievementMask am); void AwardRecoverTechAchievement(); - void AddUserStats(PlayerScoreObject* ppso); + void AddUserStats(PlayerScoreObject* ppso, IshipIGC* pIship); void UpdateLeaderboard(PlayerScoreObject* ppso); bool SaveStats(); diff --git a/src/FedSrv/FedSrv.CPP b/src/FedSrv/FedSrv.CPP index 07ee845c..c8e08918 100644 --- a/src/FedSrv/FedSrv.CPP +++ b/src/FedSrv/FedSrv.CPP @@ -3653,11 +3653,16 @@ void SendShipUpdates(CFSMission * pfsMission) pfmShipStatus->status = *pssOld = *pss; //Also update the old status } - //Xynth Add a periodic check for achievements + //Xynth Add a periodic check for achievements and IGC Score triggers if (ISPLAYER(pship)) { CSteamAchievements *pSteamAchievements = pfsShip->GetPlayer()->GetSteamAchievements(); + PlayerScoreObject * pso = pfsShip->GetPlayerScoreObject(); + if ((pship->GetAchievementMask() & c_achmProbeSpot) > 0) + pso->AddProbeSpot(); + if ((pship->GetAchievementMask() & c_achmNewRepair) > 0) + pso->SetRepair(int(pship->GetRepair())); pSteamAchievements->AwardIGCAchievements(pship->GetAchievementMask()); pship->ClearAchievementMask(); diff --git a/src/FedSrv/fsmission.cpp b/src/FedSrv/fsmission.cpp index 82c76e6c..df14cd2b 100644 --- a/src/FedSrv/fsmission.cpp +++ b/src/FedSrv/fsmission.cpp @@ -2930,11 +2930,11 @@ void CFSMission::RecordPlayerResults(IshipIGC* pship, CFSPlayer *player, SideID // BT - STEAM CSteamAchievements *pSteamAchievements = player->GetSteamAchievements(); - + IshipIGC *pIship = player->GetIGCShip(); pSteamAchievements->AwardBetaParticipation(); pSteamAchievements->UpdateLeaderboard(ppso); - pSteamAchievements->AddUserStats(ppso); + pSteamAchievements->AddUserStats(ppso, pIship); pSteamAchievements->SaveStats(); @@ -3070,6 +3070,43 @@ void CFSMission::ProcessGameOver() m_flGameDuration = g.timeNow - m_misdef.misparms.timeStart; + //Xynth Determine Rank Ratio and load it into PlayerScoreObjects + { + int sideCount = 0; + ObjectID sideID[3]; + int rank[3]; + for (SideLinkIGC* psl = m_pMission->GetSides()->first(); psl != NULL && sideCount < 3; psl = psl->next()) + { + IsideIGC* pside = psl->data(); + sideID[sideCount] = pside->GetObjectID(); + rank[sideCount] = GetSideRankSum(pside,false); + sideCount++; + } + if (sideCount == 2) //if more than 2 sides, just use the default 1.0 ratio + { + for (int i = 0; i < 2; i++) + { + if (rank[i] == 0) //avoid divide by zero + rank[i] = 1; + } + float ratio1 = float(rank[0]) / rank[1]; + float ratio0 = float(rank[1]) / rank[0]; + for (pShiplink = pShips->first(); pShiplink; pShiplink = pShiplink->next()) + { + CFSShip * pfsShip = (CFSShip *)pShiplink->data()->GetPrivateData(); + if (pfsShip->IsPlayer()) + { + PlayerScoreObject* ppso = pfsShip->GetPlayerScoreObject(); + if (pfsShip->GetSide()->GetObjectID() == sideID[0]) + ppso->SetRankRatio(ratio0); + else + ppso->SetRankRatio(ratio1); + } + } + } + + } + //Calculate scores for all players and get a running average of time played. float totalExperience = 0.0f; float sideExperience[c_cSidesMax] = {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}; diff --git a/src/Igc/common.cpp b/src/Igc/common.cpp index 2039f2a7..1830d83a 100644 --- a/src/Igc/common.cpp +++ b/src/Igc/common.cpp @@ -2544,21 +2544,25 @@ void PlayerScoreObject::CalculateScore(ImissionIGC* pmission) m_fScore = float(m_cWarpsSpotted) * pmission->GetFloatConstant(c_fcidPointsWarp) + - float(m_cAsteroidsSpotted) * pmission->GetFloatConstant(c_fcidPointsAsteroid) + - m_cTechsRecovered * pmission->GetFloatConstant(c_fcidPointsTech) + - (m_cMinerKills * kMax) * pmission->GetFloatConstant(c_fcidPointsMiner) / (m_cMinerKills + kMax) + - (m_cBuilderKills * kMax) * pmission->GetFloatConstant(c_fcidPointsBuilder) / (m_cBuilderKills + kMax) + - (m_cLayerKills * kMax) * pmission->GetFloatConstant(c_fcidPointsLayer) / (m_cLayerKills + kMax) + - (m_cCarrierKills * kMax) * pmission->GetFloatConstant(c_fcidPointsCarrier) / (m_cCarrierKills + kMax) + - m_cPlayerKills * pmission->GetFloatConstant(c_fcidPointsPlayer) + - (m_cBaseKills * kMax) * pmission->GetFloatConstant(c_fcidPointsBaseKill) / (m_cBaseKills + kMax) + - (m_cBaseCaptures * kMax) * pmission->GetFloatConstant(c_fcidPointsBaseCapture) / (m_cBaseCaptures + kMax) + - float(m_cRescues) * pmission->GetFloatConstant(c_fcidPointsRescues) + - float(m_cArtifacts) * pmission->GetFloatConstant(c_fcidPointsArtifacts) + - float(m_cFlags) * pmission->GetFloatConstant(c_fcidPointsFlags); + float(m_cAsteroidsSpotted) * pmission->GetFloatConstant(c_fcidPointsAsteroid) + + m_cTechsRecovered * pmission->GetFloatConstant(c_fcidPointsTech) + + (m_cMinerKills * kMax) * pmission->GetFloatConstant(c_fcidPointsMiner) / (m_cMinerKills + kMax) + + (m_cBuilderKills * kMax) * pmission->GetFloatConstant(c_fcidPointsBuilder) / (m_cBuilderKills + kMax) + + (m_cLayerKills * kMax) * pmission->GetFloatConstant(c_fcidPointsLayer) / (m_cLayerKills + kMax) + + (m_cCarrierKills * kMax) * pmission->GetFloatConstant(c_fcidPointsCarrier) / (m_cCarrierKills + kMax) + + m_cPlayerKills * pmission->GetFloatConstant(c_fcidPointsPlayer) + + (m_cBaseKills * kMax) * pmission->GetFloatConstant(c_fcidPointsBaseKill) / (m_cBaseKills + kMax) + + (m_cBaseCaptures * kMax) * pmission->GetFloatConstant(c_fcidPointsBaseCapture) / (m_cBaseCaptures + kMax) + + float(m_cRescues) * pmission->GetFloatConstant(c_fcidPointsRescues) + + float(m_cArtifacts) * pmission->GetFloatConstant(c_fcidPointsArtifacts) + + float(m_cFlags) * pmission->GetFloatConstant(c_fcidPointsFlags) + + float(m_cProbeSpot) * 10 + //pmission->GetFloatConstant(c_fcidPointsProbeSpot) + + float(m_cRepair) * 0.0006; // pmission->GetFloatConstant(c_fcidPointsRepair); if (m_bWin) m_fScore *= 2.0f; + + m_fScore *= m_rankRatio; } float PlayerScoreObject::GetScore(void) const diff --git a/src/Igc/igc.h b/src/Igc/igc.h index 2688b2f7..1f69c513 100644 --- a/src/Igc/igc.h +++ b/src/Igc/igc.h @@ -94,8 +94,12 @@ const FloatConstantID c_fcidPlayerCost = 36; const FloatConstantID c_fcidBaseClusterCost = 37; const FloatConstantID c_fcidClusterDivisor = 38; +//const FloatConstantID c_fcidPointsProbeSpot = 39; +//const FloatConstantID c_fcidPointsRepair = 40; + const FloatConstantID c_fcidMax = 40; + // // Note: if you add or change any new ObjectTypes, then please notify // Mark C or John T so that AGCIDL.idl will be updated. @@ -766,6 +770,7 @@ const ExpendableAbilityBitMask c_eabmRescueAny = c_sabmRescueAny; //0x40 typedef short AchievementMask; const AchievementMask c_achmProbeKill = 0x01; const AchievementMask c_achmProbeSpot = 0x02; +const AchievementMask c_achmNewRepair = 0x04; enum ShipControlStateIGC { @@ -5473,6 +5478,8 @@ class PlayerScoreObject m_cPlayerKills = 0.0f; m_cBaseKills = 0.0f; m_cBaseCaptures = 0.0f; + m_cProbeSpot = 0; + m_cRepair = 0; m_cRescues = 0; @@ -5499,10 +5506,16 @@ class PlayerScoreObject m_bCommandCredit = false; m_fScore = 0.0f; + m_rankRatio = 1.0f; assert (!m_bConnected); } + void SetRankRatio(float rankRatio) + { + m_rankRatio = rankRatio; + } + bool Connected(void) const { return m_bConnected; @@ -5578,6 +5591,16 @@ class PlayerScoreObject m_cAsteroidsSpotted++; } + void AddProbeSpot(void) + { + m_cProbeSpot++; + } + void SetRepair(int repair) + { + m_cRepair += repair; + } + + void KillShip(IshipIGC* pship, float fraction) { @@ -5834,6 +5857,8 @@ class PlayerScoreObject float m_cPlayerKills; float m_cBaseKills; float m_cBaseCaptures; + short m_cProbeSpot; + int m_cRepair; short m_cTechsRecovered; short m_cFlags; @@ -5854,6 +5879,7 @@ class PlayerScoreObject float m_fCombatRating; float m_fScore; + float m_rankRatio; bool m_bPlayer; bool m_bConnected; diff --git a/src/Igc/missionigc.cpp b/src/Igc/missionigc.cpp index 416b5d27..4ec7c3cb 100644 --- a/src/Igc/missionigc.cpp +++ b/src/Igc/missionigc.cpp @@ -2709,6 +2709,8 @@ const float c_pointsBaseCapture = 25.0f; const float c_pointsFlags = 10.0f; const float c_pointsArtifacts = 10.0f; const float c_pointsRescues = 5.0f; +const float c_pointsProbeSpot = 10.0f; +const float c_pointsRepair = 0.02f; //1 point for every 50 health restored const float c_crAdd = 1.25f; const float c_crDivide = 100.0f; @@ -2761,6 +2763,8 @@ CstaticIGC::CstaticIGC(void) m_constants.floatConstants[c_fcidPointsFlags] = c_pointsFlags; m_constants.floatConstants[c_fcidPointsArtifacts] = c_pointsArtifacts; m_constants.floatConstants[c_fcidPointsRescues] = c_pointsRescues; + //m_constants.floatConstants[c_fcidPointsProbeSpot] = c_pointsProbeSpot; + //m_constants.floatConstants[c_fcidPointsRepair] = c_pointsRepair; m_constants.floatConstants[c_fcidRatingAdd] = c_crAdd; m_constants.floatConstants[c_fcidRatingDivide] = c_crDivide; diff --git a/src/Igc/shipIGC.cpp b/src/Igc/shipIGC.cpp index 318512b2..2d49b617 100644 --- a/src/Igc/shipIGC.cpp +++ b/src/Igc/shipIGC.cpp @@ -1233,12 +1233,22 @@ DamageResult CshipIGC::ReceiveDamage(DamageTypeID type, { //Repair the target's hull m_fraction -= amount * dtmArmor / maxHP; - if (m_fraction > 1.0f) - m_fraction = 1.0f; + if (m_fraction > 1.0f) + { + amount += (m_fraction - 1.0) * maxHP / dtmArmor; //Set amount to amount that had effect for stat + m_fraction = 1.0f; + } GetThingSite ()->RemoveDamage (m_fraction); 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->SetAchievementMask(c_achmNewRepair); + } } else {