Implemented WarnOnActiveBotReloadSkill and UpdateProfileHealthValues
This commit is contained in:
@@ -3,6 +3,7 @@ using Core.Context;
|
||||
using Core.Helpers;
|
||||
using Core.Models.Eft.Common;
|
||||
using Core.Models.Eft.Game;
|
||||
using Core.Models.Eft.Health;
|
||||
using Core.Models.Eft.Profile;
|
||||
using Core.Models.Enums;
|
||||
using Core.Models.Spt.Config;
|
||||
@@ -356,7 +357,11 @@ public class GameController
|
||||
/// <param name="pmcProfile">Player profile</param>
|
||||
private void WarnOnActiveBotReloadSkill(PmcData pmcProfile)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
var botReloadSkill = _profileHelper.GetSkillFromProfile(pmcProfile, SkillTypes.BotReload);
|
||||
if (botReloadSkill?.Progress > 0)
|
||||
{
|
||||
_logger.Warning(_localisationService.GetText("server_start_player_active_botreload_skill"));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -365,7 +370,98 @@ public class GameController
|
||||
/// <param name="pmcProfile">Profile to adjust values for</param>
|
||||
private void UpdateProfileHealthValues(PmcData pmcProfile)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
var healthLastUpdated = pmcProfile.Health.UpdateTime;
|
||||
var currentTimeStamp = _timeUtil.GetTimeStamp();
|
||||
var diffSeconds = currentTimeStamp - healthLastUpdated;
|
||||
|
||||
// Last update is in past
|
||||
if (healthLastUpdated < currentTimeStamp)
|
||||
{
|
||||
// Base values
|
||||
double energyRegenPerHour = 60;
|
||||
double hydrationRegenPerHour = 60;
|
||||
double hpRegenPerHour = 456.6;
|
||||
|
||||
// Set new values, whatever is smallest
|
||||
energyRegenPerHour += pmcProfile.Bonuses
|
||||
.Where((bonus) => bonus.Type == BonusType.EnergyRegeneration)
|
||||
.Aggregate(0d, (sum, bonus) => sum + (bonus.Value.Value));
|
||||
hydrationRegenPerHour += pmcProfile.Bonuses
|
||||
.Where((bonus) => bonus.Type == BonusType.HydrationRegeneration)
|
||||
.Aggregate(0d, (sum, bonus) => sum + (bonus.Value.Value));
|
||||
hpRegenPerHour += pmcProfile.Bonuses
|
||||
.Where((bonus) => bonus.Type == BonusType.HealthRegeneration)
|
||||
.Aggregate(0d, (sum, bonus) => sum + (bonus.Value.Value));
|
||||
|
||||
// Player has energy deficit
|
||||
if (pmcProfile.Health.Energy.Current != pmcProfile.Health.Energy.Maximum)
|
||||
{
|
||||
// Set new value, whatever is smallest
|
||||
pmcProfile.Health.Energy.Current += Math.Round(energyRegenPerHour * (diffSeconds.Value / 3600));
|
||||
if (pmcProfile.Health.Energy.Current > pmcProfile.Health.Energy.Maximum)
|
||||
{
|
||||
pmcProfile.Health.Energy.Current = pmcProfile.Health.Energy.Maximum;
|
||||
}
|
||||
}
|
||||
|
||||
// Player has hydration deficit
|
||||
if (pmcProfile.Health.Hydration.Current != pmcProfile.Health.Hydration.Maximum)
|
||||
{
|
||||
pmcProfile.Health.Hydration.Current += Math.Round(hydrationRegenPerHour * (diffSeconds.Value / 3600));
|
||||
if (pmcProfile.Health.Hydration.Current > pmcProfile.Health.Hydration.Maximum)
|
||||
{
|
||||
pmcProfile.Health.Hydration.Current = pmcProfile.Health.Hydration.Maximum;
|
||||
}
|
||||
}
|
||||
|
||||
// Check all body parts
|
||||
foreach (var bodyPart in pmcProfile.Health.BodyParts
|
||||
.Select(bodyPartKvP => bodyPartKvP.Value))
|
||||
{
|
||||
// Check part hp
|
||||
if (bodyPart.Health.Current < bodyPart.Health.Maximum)
|
||||
{
|
||||
bodyPart.Health.Current += Math.Round(hpRegenPerHour * (diffSeconds.Value / 3600));
|
||||
}
|
||||
if (bodyPart.Health.Current > bodyPart.Health.Maximum)
|
||||
{
|
||||
bodyPart.Health.Current = bodyPart.Health.Maximum;
|
||||
}
|
||||
|
||||
|
||||
if (bodyPart.Effects is null || bodyPart.Effects.Count == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Look for effects
|
||||
foreach (var effectKvP in bodyPart.Effects) {
|
||||
// remove effects below 1, .e.g. bleeds at -1
|
||||
if (effectKvP.Value.Time < 1)
|
||||
{
|
||||
// More than 30 mins has passed
|
||||
if (diffSeconds > 1800)
|
||||
{
|
||||
bodyPart.Effects.Remove(effectKvP.Key);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// Decrement effect time value by difference between current time and time health was last updated
|
||||
effectKvP.Value.Time -= diffSeconds;
|
||||
if (effectKvP.Value.Time < 1)
|
||||
{
|
||||
// Effect time was sub 1, set floor it can be
|
||||
effectKvP.Value.Time = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update both values as they've both been updated
|
||||
pmcProfile.Health.UpdateTime = currentTimeStamp;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -231,22 +231,11 @@ public class BotBaseHealth
|
||||
public CurrentMax? Hydration { get; set; }
|
||||
public CurrentMax? Energy { get; set; }
|
||||
public CurrentMax? Temperature { get; set; }
|
||||
public BodyPartsHealth? BodyParts { get; set; }
|
||||
public Dictionary<string, BodyPartHealth>? BodyParts { get; set; }
|
||||
public double? UpdateTime { get; set; }
|
||||
public bool? Immortal { get; set; }
|
||||
}
|
||||
|
||||
public class BodyPartsHealth
|
||||
{
|
||||
public BodyPartHealth? Head { get; set; }
|
||||
public BodyPartHealth? Chest { get; set; }
|
||||
public BodyPartHealth? Stomach { get; set; }
|
||||
public BodyPartHealth? LeftArm { get; set; }
|
||||
public BodyPartHealth? RightArm { get; set; }
|
||||
public BodyPartHealth? LeftLeg { get; set; }
|
||||
public BodyPartHealth? RightLeg { get; set; }
|
||||
}
|
||||
|
||||
public class BodyPartHealth
|
||||
{
|
||||
public CurrentMax? Health { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user