diff --git a/src/Module.Server/Modes/Dtv/CrpgDtvServer.cs b/src/Module.Server/Modes/Dtv/CrpgDtvServer.cs
index be5b0d42a..04633e567 100644
--- a/src/Module.Server/Modes/Dtv/CrpgDtvServer.cs
+++ b/src/Module.Server/Modes/Dtv/CrpgDtvServer.cs
@@ -23,6 +23,7 @@ internal class CrpgDtvServer : MissionMultiplayerGameModeBase
private bool _waveStarted;
private MissionTimer? _waveStartTimer;
private MissionTimer? _endGameTimer;
+ private MissionTime _currentRoundStartTime;
public CrpgDtvServer(CrpgRewardServer rewardServer)
{
@@ -173,6 +174,7 @@ private void StartNextRound()
_currentWave = -1;
SpawningBehavior.RequestSpawnSessionForRoundStart(firstRound: _currentRound == 0);
SendDataToPeers(new CrpgDtvRoundStartMessage { Round = _currentRound });
+ _currentRoundStartTime = MissionTime.Now;
_waveStartTimer = new MissionTimer(15f);
_waveStarted = false;
}
@@ -191,11 +193,13 @@ private void CheckForWaveEnd()
{
bool viscountDead = !Mission.DefenderTeam.HasBots;
bool defendersDepleted = Mission.DefenderTeam.ActiveAgents.Count == (viscountDead ? 0 : 1);
+ float roundDuration = _currentRoundStartTime.ElapsedSeconds;
if (viscountDead || defendersDepleted)
{
SendDataToPeers(new CrpgDtvGameEnd { ViscountDead = viscountDead });
_ = _rewardServer.UpdateCrpgUsersAsync(
durationRewarded: ComputeRoundReward(CurrentRoundData, wavesWon: _currentWave),
+ durationUpkeep: roundDuration,
updateUserStats: false,
constantMultiplier: RewardMultiplier);
EndGame(Mission.AttackerTeam);
@@ -216,6 +220,7 @@ private void CheckForWaveEnd()
_ = _rewardServer.UpdateCrpgUsersAsync(
durationRewarded: ComputeRoundReward(CurrentRoundData, wavesWon: _currentWave + 1),
+ durationUpkeep: roundDuration,
updateUserStats: false,
constantMultiplier: RewardMultiplier);
diff --git a/src/Module.Server/Rewards/CrpgRewardServer.cs b/src/Module.Server/Rewards/CrpgRewardServer.cs
index cf5e9221b..3a3a15c95 100644
--- a/src/Module.Server/Rewards/CrpgRewardServer.cs
+++ b/src/Module.Server/Rewards/CrpgRewardServer.cs
@@ -121,6 +121,7 @@ public override void OnScoreHit(
/// Update rating and statistics from the last time this method was called and also give rewards.
///
/// Duration for which the users should be rewarded.
+ /// Duration for which the users will pay for their equipment.
/// Multiplier to add to the defenders. Can be negative.
/// Multiplier to add to the attackers. Can be negative.
/// Team to give valour to.
@@ -128,6 +129,7 @@ public override void OnScoreHit(
/// True if score and rating should be saved.
public async Task UpdateCrpgUsersAsync(
float durationRewarded,
+ float? durationUpkeep = null,
int defenderMultiplierGain = 0,
int attackerMultiplierGain = 0,
BattleSideEnum? valourTeamSide = null,
@@ -157,7 +159,7 @@ public async Task UpdateCrpgUsersAsync(
Dictionary crpgPeerByCrpgUserId = new();
List userUpdates = new();
- Dictionary> brokenItems = lowPopulationServer ? new() : GetBrokenItemsByCrpgUserId(networkPeers, durationRewarded);
+ Dictionary> brokenItems = lowPopulationServer ? new() : GetBrokenItemsByCrpgUserId(networkPeers, durationUpkeep ?? durationRewarded);
var compensationByCrpgUserId = _isTeamHitCompensationsEnabled ? CalculateCompensationByCrpgUserId(brokenItems) : new();
foreach (NetworkCommunicator networkPeer in networkPeers)
@@ -245,7 +247,7 @@ public async Task UpdateCrpgUsersAsync(
}
}
- private Dictionary> GetBrokenItemsByCrpgUserId(NetworkCommunicator[] networkPeers, float durationRewarded)
+ private Dictionary> GetBrokenItemsByCrpgUserId(NetworkCommunicator[] networkPeers, float duration)
{
Dictionary> brokenItems = new();
foreach (NetworkCommunicator networkPeer in networkPeers)
@@ -260,7 +262,7 @@ private Dictionary> GetBrokenItemsByCrpgUserId(N
if (crpgPeer.LastSpawnInfo != null)
{
int crpgUserId = crpgPeer.User.Id;
- var crpgUserDamagedItems = BreakItems(crpgPeer, durationRewarded);
+ var crpgUserDamagedItems = BreakItems(crpgPeer, duration);
brokenItems[crpgUserId] = crpgUserDamagedItems;
}
}