v1.6.17.0 (Unto the Breach update)

This commit is contained in:
Regalis11
2024-10-22 17:29:04 +03:00
parent e74b3cdb17
commit 6e6c17e100
417 changed files with 17166 additions and 5870 deletions
@@ -344,15 +344,37 @@ namespace Barotrauma
/// Note: Can be null.
/// </summary>
public Character Character;
public Job Job;
public int Salary;
public int ExperiencePoints { get; private set; }
private int talentRefundPoints;
/// <summary>
/// How many times the player is eligible to refund talents
/// </summary>
public int TalentRefundPoints
{
get => talentRefundPoints;
set => talentRefundPoints = MathHelper.Max(value, 0);
}
public HashSet<Identifier> UnlockedTalents { get; private set; } = new HashSet<Identifier>();
private int talentResetCount;
/// <summary>
/// How many times have the characters' talents been reset?
/// </summary>
public int TalentResetCount
{
get => talentResetCount;
set => talentResetCount = MathHelper.Max(value, 0);
}
public (Identifier factionId, float reputation) MinReputationToHire;
/// <summary>
@@ -708,7 +730,9 @@ namespace Barotrauma
SetAttachments(randSync);
SetColors(randSync);
Job = job ?? ((jobPrefab == null) ? Job.Random(Rand.RandSync.Unsynced) : new Job(jobPrefab, randSync, variant));
Job = job ?? ((jobPrefab == null) ?
Job.Random(isPvP: false, Rand.RandSync.Unsynced) :
new Job(jobPrefab, isPvP: false, randSync, variant));
if (!string.IsNullOrEmpty(name))
{
@@ -725,6 +749,8 @@ namespace Barotrauma
}
OriginalName = !string.IsNullOrEmpty(originalName) ? originalName : Name;
TalentRefundPoints = CharacterConfigElement.GetAttributeInt("refundpoints", 0);
int loadedLastRewardDistribution = CharacterConfigElement.GetAttributeInt("lastrewarddistribution", -1);
if (loadedLastRewardDistribution >= 0)
{
@@ -799,6 +825,7 @@ namespace Barotrauma
Salary = infoElement.GetAttributeInt("salary", 1000);
ExperiencePoints = infoElement.GetAttributeInt("experiencepoints", 0);
AdditionalTalentPoints = infoElement.GetAttributeInt("additionaltalentpoints", 0);
TalentResetCount = infoElement.GetAttributeInt(nameof(talentResetCount), 0);
HashSet<Identifier> tags = infoElement.GetAttributeIdentifierArray("tags", Array.Empty<Identifier>()).ToHashSet();
LoadTagsBackwardsCompatibility(infoElement, tags);
SpeciesName = infoElement.GetAttributeIdentifier("speciesname", "");
@@ -1047,6 +1074,7 @@ namespace Barotrauma
public string ReplaceVars(string str)
{
if (Head == null) { return str; }
return Prefab.ReplaceVars(str, Head.Preset);
}
@@ -1271,18 +1299,18 @@ namespace Barotrauma
/// Increases the characters skill at a rate proportional to their current skill.
/// If you want to increase the skill level by a specific amount instead, use <see cref="IncreaseSkillLevel"/>
/// </summary>
public void ApplySkillGain(Identifier skillIdentifier, float baseGain, bool gainedFromAbility = false, float maxGain = 2f)
public void ApplySkillGain(Identifier skillIdentifier, float baseGain, bool gainedFromAbility = false, float maxGain = 2f, bool forceNotification = false)
{
float skillLevel = Job.GetSkillLevel(skillIdentifier);
// The formula is too generous on low skill levels, hence the minimum divider.
float skillDivider = MathF.Pow(Math.Max(skillLevel, 15f), SkillSettings.Current.SkillIncreaseExponent);
IncreaseSkillLevel(skillIdentifier, Math.Min(baseGain / skillDivider, maxGain), gainedFromAbility);
IncreaseSkillLevel(skillIdentifier, Math.Min(baseGain / skillDivider, maxGain), gainedFromAbility, forceNotification);
}
/// <summary>
/// Increase the skill by a specific amount. Talents may affect the actual, final skill increase.
/// </summary>
public void IncreaseSkillLevel(Identifier skillIdentifier, float increase, bool gainedFromAbility = false)
public void IncreaseSkillLevel(Identifier skillIdentifier, float increase, bool gainedFromAbility = false, bool forceNotification = false)
{
if (Job == null || (GameMain.NetworkMember != null && GameMain.NetworkMember.IsClient) || Character == null) { return; }
@@ -1312,14 +1340,14 @@ namespace Barotrauma
}
}
OnSkillChanged(skillIdentifier, prevLevel, newLevel);
OnSkillChanged(skillIdentifier, prevLevel, newLevel, forceNotification);
}
private static readonly ImmutableDictionary<Identifier, StatTypes> skillGainStatValues = new Dictionary<Identifier, StatTypes>
{
{ new("helm"), StatTypes.HelmSkillGainSpeed },
{ new("medical"), StatTypes.WeaponsSkillGainSpeed },
{ new("weapons"), StatTypes.MedicalSkillGainSpeed },
{ new("weapons"), StatTypes.WeaponsSkillGainSpeed },
{ new("medical"), StatTypes.MedicalSkillGainSpeed },
{ new("electrical"), StatTypes.ElectricalSkillGainSpeed },
{ new("mechanical"), StatTypes.MechanicalSkillGainSpeed }
}.ToImmutableDictionary();
@@ -1334,7 +1362,7 @@ namespace Barotrauma
return increase;
}
public void SetSkillLevel(Identifier skillIdentifier, float level)
public void SetSkillLevel(Identifier skillIdentifier, float level, bool forceNotification = false)
{
if (Job == null) { return; }
@@ -1342,17 +1370,17 @@ namespace Barotrauma
if (skill == null)
{
Job.IncreaseSkillLevel(skillIdentifier, level, increasePastMax: false);
OnSkillChanged(skillIdentifier, 0.0f, level);
OnSkillChanged(skillIdentifier, 0.0f, level, forceNotification);
}
else
{
float prevLevel = skill.Level;
skill.Level = level;
OnSkillChanged(skillIdentifier, prevLevel, skill.Level);
OnSkillChanged(skillIdentifier, prevLevel, skill.Level, forceNotification);
}
}
partial void OnSkillChanged(Identifier skillIdentifier, float prevLevel, float newLevel);
partial void OnSkillChanged(Identifier skillIdentifier, float prevLevel, float newLevel, bool forceNotification);
public void GiveExperience(int amount)
{
@@ -1437,10 +1465,11 @@ namespace Barotrauma
experienceRequired += ExperienceRequiredPerLevel(level);
level++;
}
return level;
return Math.Max(level, 0);
}
private static int ExperienceRequiredPerLevel(int level)
public static int ExperienceRequiredPerLevel(int level)
{
return BaseExperienceRequired + AddedExperienceRequiredPerLevel * level;
}
@@ -1449,6 +1478,45 @@ namespace Barotrauma
partial void OnPermanentStatChanged(StatTypes statType);
public void RefundTalents()
{
if (TalentRefundPoints <= 0) { return; }
//e.g. talents from endocrine booster or extra talents some special NPC has
var talentsFromOutsideTree = GetUnlockedTalentsOutsideTree().ToList();
bool applyXpPenalty = talentResetCount > 0;
UnlockedTalents.Clear();
SavedStatValues.Clear();
Character?.ResetTalents(applyXpPenalty);
TalentRefundPoints--;
talentResetCount++;
//it's simpler to just remove everything first and then reapply the "extra" talents than to
//try determining which talent the resistances, ability flags etc came from and only remove specific ones
if (Character == null)
{
talentsFromOutsideTree.ForEach(talentId => UnlockedTalents.Add(talentId));
}
else
{
talentsFromOutsideTree.ForEach(talentId => Character.GiveTalent(talentId, addingFirstTime: true));
}
GameMain.NetworkMember?.CreateEntityEvent(Character, new Character.ConfirmRefundEventData());
}
public void AddRefundPoints(int newRefundPoints)
{
TalentRefundPoints += newRefundPoints;
#if SERVER
GameMain.NetworkMember?.CreateEntityEvent(Character, new Character.UpdateRefundPointsEventData());
#elif CLIENT
ShowTalentResetPopupOnOpen = true;
#endif
}
public void Rename(string newName)
{
if (string.IsNullOrEmpty(newName)) { return; }
@@ -1491,6 +1559,7 @@ namespace Barotrauma
new XAttribute("salary", Salary),
new XAttribute("experiencepoints", ExperiencePoints),
new XAttribute("additionaltalentpoints", AdditionalTalentPoints),
new XAttribute(nameof(talentResetCount), TalentResetCount),
new XAttribute("hairindex", Head.HairIndex),
new XAttribute("beardindex", Head.BeardIndex),
new XAttribute("moustacheindex", Head.MoustacheIndex),
@@ -1500,6 +1569,7 @@ namespace Barotrauma
new XAttribute("facialhaircolor", XMLExtensions.ColorToString(Head.FacialHairColor)),
new XAttribute("startitemsgiven", StartItemsGiven),
new XAttribute("personality", PersonalityTrait?.Identifier ?? Identifier.Empty),
new XAttribute("refundpoints", TalentRefundPoints),
new XAttribute("lastrewarddistribution", LastRewardDistribution.Match(some: value => value, none: () => -1).ToString()),
new XAttribute("permanentlydead", PermanentlyDead),
new XAttribute("renamingenabled", RenamingEnabled)
@@ -1601,7 +1671,7 @@ namespace Barotrauma
targetAvailableInNextLevel =
!isOutside &&
GameMain.GameSession?.Campaign is not { SwitchedSubsThisRound: true } &&
(isOnConnectedLinkedSub || entitySub == Submarine.MainSub);
(isOnConnectedLinkedSub || (Submarine.MainSub != null && entitySub == Submarine.MainSub));
if (!targetAvailableInNextLevel)
{
if (!order.Prefab.CanBeGeneralized)
@@ -1636,7 +1706,7 @@ namespace Barotrauma
}
if (order.TargetSpatialEntity?.Submarine is Submarine targetSub)
{
if (targetSub == Submarine.MainSub)
if (Submarine.MainSub != null && targetSub == Submarine.MainSub)
{
orderElement.Add(new XAttribute("onmainsub", true));
}