Updated transit health system to only remove DestroyedPart effect and not heal limbs by default #300
Exposed values in config Also apply code to PMC transits
This commit is contained in:
@@ -510,5 +510,11 @@
|
||||
"63a898a328e385334e0640a5",
|
||||
"634959225289190e5e773b3b"
|
||||
],
|
||||
"nonMaps": ["Base", "Develop", "Hideout", "PrivateArea", "Suburbs", "Terminal", "Town"]
|
||||
"nonMaps": ["Base", "Develop", "Hideout", "PrivateArea", "Suburbs", "Terminal", "Town"],
|
||||
"transitSettings": {
|
||||
"effectsToRemove": ["DestroyedPart"],
|
||||
"adjustLimbHealthPoints": false,
|
||||
"limbHealPercent": 1
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,6 +233,21 @@ public record LocationConfig : BaseConfig
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
[JsonPropertyName("transitSettings")]
|
||||
public TransitSettings? TransitSettings { get; set; }
|
||||
}
|
||||
|
||||
public record TransitSettings
|
||||
{
|
||||
[JsonPropertyName("effectsToRemove")]
|
||||
public HashSet<string>? EffectsToRemove { get; set; }
|
||||
|
||||
[JsonPropertyName("adjustLimbHealthPoints")]
|
||||
public bool? AdjustLimbHealthPoints { get; set; }
|
||||
|
||||
[JsonPropertyName("limbHealPercent")]
|
||||
public int? LimbHealPercent { get; set; }
|
||||
}
|
||||
|
||||
public record ReserveRaiderSpawnChanceOverrides
|
||||
|
||||
@@ -677,8 +677,8 @@ public class LocationLifecycleService
|
||||
// Transfer over hp and effects - not necessary for runthroughs, but it causes no issues
|
||||
scavProfile.Health = postRaidProfile.Health;
|
||||
|
||||
// Apply minor healing to limb hp and effects
|
||||
ResetLimbHpMidTransit(scavProfile.Health);
|
||||
// Adjust limb hp and effects while transiting
|
||||
UpdateLimbValuesAfterTransit(scavProfile.Health);
|
||||
|
||||
// We want scav inventory to persist into next raid when pscav is moving between maps
|
||||
// Also adjust FiR status when exit was runthrough
|
||||
@@ -790,20 +790,42 @@ public class LocationLifecycleService
|
||||
/// Slightly fix broken limbs and remove effects
|
||||
/// </summary>
|
||||
/// <param name="profileHealth">Profile health data to adjust</param>
|
||||
protected void ResetLimbHpMidTransit(BotBaseHealth? profileHealth)
|
||||
protected void UpdateLimbValuesAfterTransit(BotBaseHealth? profileHealth)
|
||||
{
|
||||
foreach (var (limbId, hpValues) in profileHealth.BodyParts)
|
||||
var transitSettings = _locationConfig.TransitSettings;
|
||||
if (transitSettings == null)
|
||||
{
|
||||
if (hpValues.Health.Minimum <= 0)
|
||||
_logger.Warning("Unable to find: _locationConfig.TransitSettings");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Check each body part
|
||||
foreach (var (_, hpValues) in profileHealth.BodyParts)
|
||||
{
|
||||
if (transitSettings.AdjustLimbHealthPoints.GetValueOrDefault()
|
||||
&& hpValues.Health.Minimum <= 0)
|
||||
{
|
||||
// Limb has been destroyed, reset to 30% TODO: Expose 30% in config
|
||||
hpValues.Health.Current = _randomUtil.GetPercentOfValue(30, hpValues.Health.Maximum.Value);
|
||||
// Limb has been destroyed, reset
|
||||
hpValues.Health.Current = _randomUtil.GetPercentOfValue(
|
||||
transitSettings.LimbHealPercent.GetValueOrDefault(30),
|
||||
hpValues.Health.Maximum.Value);
|
||||
}
|
||||
|
||||
// Limb has effects, remove them all
|
||||
if (hpValues.Effects.Count > 0)
|
||||
if (!(hpValues.Effects?.Count > 0))
|
||||
{
|
||||
hpValues.Effects.Clear();
|
||||
// No effects on limb, skip
|
||||
continue;
|
||||
}
|
||||
|
||||
// Limb has effects, check for blacklisted values and remove
|
||||
var keysToRemove = hpValues.Effects.Keys
|
||||
.Where(key => transitSettings.EffectsToRemove.Contains(key))
|
||||
.ToHashSet();
|
||||
|
||||
foreach (var key in keysToRemove)
|
||||
{
|
||||
hpValues.Effects.Remove(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -896,6 +918,12 @@ public class LocationLifecycleService
|
||||
// Handle temp, hydration, limb hp/effects
|
||||
_healthHelper.UpdateProfileHealthPostRaid(pmcProfile, postRaidProfile.Health, sessionId, isDead);
|
||||
|
||||
if (isTransfer)
|
||||
{
|
||||
// Adjust limb hp and effects while transiting
|
||||
UpdateLimbValuesAfterTransit(pmcProfile.Health);
|
||||
}
|
||||
|
||||
// This must occur _BEFORE_ `deleteInventory`, as that method clears insured items
|
||||
HandleInsuredItemLostEvent(sessionId, pmcProfile, request, locationName);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user