Bug. If you do not remove the frostbite (or even frostbite risk) save editor crashes.
Closed this issue · 5 comments
Quick fix:
AfflictionsContainer.cs =>
var frostbiteRisks = afflictionDict.GetOrDefault(AfflictionType.FrostbiteRisk, new List<Affliction>()).Cast<Frostbite>().ToList();
- proxy.m_LocationsCurrentFrostbiteDamage = new List<float>();
+ proxy.m_LocationsCurrentFrostbiteDamage = new List<float>() { 0,0,0,0,0,0,0,0,0,0,0,0 };
proxy.m_LocationsWithActiveFrostbite = new List<int>();
foreach (var frostbite in frostbites)
{
proxy.m_LocationsWithActiveFrostbite.Add(frostbite.Location);
But need to add some temporary affliction to compensate lost unnamed forstbite damage (usualy small but who knows). Example:
m_LocationsCurrentFrostbiteDamage before ConvertBackFrostBite()
[100.6508,0,0.001715953,0.5878856,0.001715953,0.5878856,0.001715953,0,0.001715953,97.51201,0.001715953,97.51201]
m_LocationsCurrentFrostbiteDamage after ConvertBackFrostBite()
[100.6508,0,0,0.5878856,0,0.5878856,0,0,0,97.51201,0,97.51201]
Workaround about lost frostbite damage:
Enums.cs:
[Description("Frostbite risk")]
FrostbiteRisk,
+ [Description("Frostbite damage")]
+ FrostbiteDamage,
[Description("Electric burn")]
BurnsElectric,
AfflictionsContainer.cs:
private void ConvertFrostbite(FrostbiteSaveDataProxy proxy)
{
if (proxy == null)
return;
+ var FrostbiteDamage = new List<float>(proxy.m_LocationsCurrentFrostbiteDamage);
foreach (int bodyArea in proxy.m_LocationsWithActiveFrostbite)
{
Negative.Add(new Frostbite(negative)
{
AfflictionType = AfflictionType.Frostbite,
Location = bodyArea,
Damage = proxy.m_LocationsCurrentFrostbiteDamage[bodyArea],
});
+ FrostbiteDamage[bodyArea] = 0;
}
foreach (int bodyArea in proxy.m_LocationsWithFrostbiteRisk)
{
Negative.Add(new Frostbite(negative)
{
AfflictionType = AfflictionType.FrostbiteRisk,
Location = bodyArea,
Damage = proxy.m_LocationsCurrentFrostbiteDamage[bodyArea],
});
+ FrostbiteDamage[bodyArea] = 0;
}
+ int bodyPart = 0;
+ foreach (float damage in FrostbiteDamage)
+ {
+ if (damage > 0)
+ {
+ Negative.Add(new Frostbite(negative)
+ {
+ AfflictionType = AfflictionType.FrostbiteDamage,
+ Location = bodyPart,
+ Damage = damage ,
+ });
+ }
+ bodyPart ++;
+ }
}
private FrostbiteSaveDataProxy ConvertBackFrostBite(FrostbiteSaveDataProxy proxy, Dictionary<AfflictionType, List<Affliction>> afflictionDict)
{
proxy = proxy ?? new FrostbiteSaveDataProxy();
var frostbites = afflictionDict.GetOrDefault(AfflictionType.Frostbite, new List<Affliction>()).Cast<Frostbite>().ToList();
var frostbiteRisks = afflictionDict.GetOrDefault(AfflictionType.FrostbiteRisk, new List<Affliction>()).Cast<Frostbite>().ToList();
+ var frostbiteDamage = afflictionDict.GetOrDefault(AfflictionType.FrostbiteDamage, new List<Affliction>()).Cast<Frostbite>().ToList();
- proxy.m_LocationsCurrentFrostbiteDamage = new List<float>();
+ proxy.m_LocationsCurrentFrostbiteDamage = new List<float>() { 0,0,0,0,0,0,0,0,0,0,0,0 };
proxy.m_LocationsWithActiveFrostbite = new List<int>();
foreach (var frostbite in frostbites)
{
proxy.m_LocationsWithActiveFrostbite.Add(frostbite.Location);
proxy.m_LocationsCurrentFrostbiteDamage[frostbite.Location] = frostbite.Damage;
}
foreach (var frostbite in frostbiteRisks)
{
proxy.m_LocationsWithFrostbiteRisk.Add(frostbite.Location);
proxy.m_LocationsCurrentFrostbiteDamage[frostbite.Location] = frostbite.Damage;
}
+ foreach (var frostbite in frostbiteDamage)
+ {
+ proxy.m_LocationsCurrentFrostbiteDamage[frostbite.Location] = frostbite.Damage;
+ }
return proxy;
}
Thanks, you could also create pull requests if you wish. Even if not, you're being a big help, thanks!
So is it so you can have frostbite damage while not having active frostbite? I assume adding frostbiteDamage as frostbite risk in convertBack is not intentional?
Example from my real save:
"m_FrostbiteSerialized":"{
\"m_LocationsWithActiveFrostbite\":[3,5],
\"m_LocationsWithFrostbiteRisk\":[11,9,0],
\"m_LocationsCurrentFrostbiteDamage\":[100.6508, 0 ,0.001715953, 0.5878856, 0.001715953, 0.5878856, 0.001715953, 0, 0.001715953, 97.51201, 0.001715953, 97.51201]}",
As you can see ActiveFrostbite at 3 and 5, FrostbiteRisk at 11,9 and 0, But lil damage almost all over the body. Small damage but who knows how game calculate frostbite risk for example.
Without my addings editor just throw away damage like 0.001715953 even if just load and save.
"frostbite risk in convertBack" my bad. Just m_LocationsCurrentFrostbiteDamage.
Don't think that pull request will be fine. Because I don't know c# well and don`t want to know it better. May be you prefer other method.