v1.4.4.1 (Blood in the Water Update)
This commit is contained in:
@@ -307,6 +307,12 @@ namespace Barotrauma
|
||||
// Adjust by current reputation
|
||||
price *= GetReputationModifier(true);
|
||||
|
||||
// Adjust by campaign difficulty settings
|
||||
if (GameMain.GameSession?.Campaign is CampaignMode campaign)
|
||||
{
|
||||
price *= campaign.Settings.ShopPriceMultiplier;
|
||||
}
|
||||
|
||||
var characters = GameSession.GetSessionCrewCharacters(CharacterType.Both);
|
||||
if (characters.Any())
|
||||
{
|
||||
@@ -768,27 +774,22 @@ namespace Barotrauma
|
||||
else
|
||||
{
|
||||
DebugConsole.Log($"Location {DisplayName.Value} changed it's type from {Type} to {newType}");
|
||||
DisplayName =
|
||||
Type.NameFormats == null || !Type.NameFormats.Any() ?
|
||||
TextManager.Get(nameIdentifier) :
|
||||
DisplayName =
|
||||
Type.NameFormats == null || !Type.NameFormats.Any() ?
|
||||
TextManager.Get(nameIdentifier) :
|
||||
Type.NameFormats[nameFormatIndex % Type.NameFormats.Count].Replace("[name]", TextManager.Get(nameIdentifier).Value);
|
||||
}
|
||||
|
||||
TryAssignFactionBasedOnLocationType(campaign);
|
||||
if (Type.HasOutpost && Type.OutpostTeam == CharacterTeamType.FriendlyNPC)
|
||||
{
|
||||
if (Faction == null)
|
||||
{
|
||||
Faction = campaign.GetRandomFaction(Rand.RandSync.Unsynced);
|
||||
}
|
||||
if (SecondaryFaction == null)
|
||||
{
|
||||
SecondaryFaction = campaign.GetRandomSecondaryFaction(Rand.RandSync.Unsynced);
|
||||
}
|
||||
if (Type.Faction == Identifier.Empty) { Faction ??= campaign.GetRandomFaction(Rand.RandSync.Unsynced); }
|
||||
if (Type.SecondaryFaction == Identifier.Empty) { SecondaryFaction ??= campaign.GetRandomSecondaryFaction(Rand.RandSync.Unsynced); }
|
||||
}
|
||||
else
|
||||
{
|
||||
Faction = null;
|
||||
SecondaryFaction = null;
|
||||
if (Type.Faction == Identifier.Empty) { Faction = null; }
|
||||
if (Type.SecondaryFaction == Identifier.Empty) { SecondaryFaction = null; }
|
||||
}
|
||||
|
||||
UnlockInitialMissions(Rand.RandSync.Unsynced);
|
||||
@@ -799,6 +800,30 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public void TryAssignFactionBasedOnLocationType(CampaignMode campaign)
|
||||
{
|
||||
if (campaign == null) { return; }
|
||||
if (Type.Faction != Identifier.Empty)
|
||||
{
|
||||
Faction = Type.Faction == "None" ? null : TryFindFaction(Type.Faction);
|
||||
}
|
||||
if (Type.SecondaryFaction != Identifier.Empty)
|
||||
{
|
||||
SecondaryFaction = Type.SecondaryFaction == "None" ? null : TryFindFaction(Type.SecondaryFaction);
|
||||
}
|
||||
|
||||
Faction TryFindFaction(Identifier identifier)
|
||||
{
|
||||
var faction = campaign.GetFaction(identifier);
|
||||
if (faction == null)
|
||||
{
|
||||
DebugConsole.ThrowError($"Error in location type \"{Type.Identifier}\": failed to find a faction with the identifier \"{identifier}\".",
|
||||
contentPackage: Type.ContentPackage);
|
||||
}
|
||||
return faction;
|
||||
}
|
||||
}
|
||||
|
||||
public void UnlockInitialMissions(Rand.RandSync randSync = Rand.RandSync.ServerAndClient)
|
||||
{
|
||||
if (Type.MissionIdentifiers.Any())
|
||||
@@ -1127,6 +1152,7 @@ namespace Barotrauma
|
||||
nameIdentifier = type.GetRandomNameId(rand, existingLocations);
|
||||
if (nameIdentifier.IsEmpty)
|
||||
{
|
||||
//backwards compatibility
|
||||
rawName = type.GetRandomRawName(rand, existingLocations);
|
||||
if (rawName.IsNullOrEmpty())
|
||||
{
|
||||
@@ -1134,7 +1160,15 @@ namespace Barotrauma
|
||||
rawName = "none";
|
||||
}
|
||||
nameIdentifier = rawName.ToIdentifier();
|
||||
DisplayName = rawName;
|
||||
if (type.NameFormats == null || !type.NameFormats.Any())
|
||||
{
|
||||
DisplayName = rawName;
|
||||
}
|
||||
else
|
||||
{
|
||||
nameFormatIndex = rand.Next() % type.NameFormats.Count;
|
||||
DisplayName = type.NameFormats[nameFormatIndex].Replace("[name]", rawName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -86,6 +86,16 @@ namespace Barotrauma
|
||||
|
||||
public Identifier ReplaceInRadiation { get; }
|
||||
|
||||
/// <summary>
|
||||
/// If set, forces the location to be assigned to this faction. Set to "None" if you don't want the location to be assigned to any faction.
|
||||
/// </summary>
|
||||
public Identifier Faction { get; }
|
||||
|
||||
/// <summary>
|
||||
/// If set, forces the location to be assigned to this secondary faction. Set to "None" if you don't want the location to be assigned to any secondary faction.
|
||||
/// </summary>
|
||||
public Identifier SecondaryFaction { get; }
|
||||
|
||||
public Sprite Sprite { get; private set; }
|
||||
public Sprite RadiationSprite { get; }
|
||||
|
||||
@@ -134,6 +144,9 @@ namespace Barotrauma
|
||||
AllowAsBiomeGate = element.GetAttributeBool(nameof(AllowAsBiomeGate), true);
|
||||
AllowInRandomLevels = element.GetAttributeBool(nameof(AllowInRandomLevels), true);
|
||||
|
||||
Faction = element.GetAttributeIdentifier(nameof(Faction), Identifier.Empty);
|
||||
SecondaryFaction = element.GetAttributeIdentifier(nameof(SecondaryFaction), Identifier.Empty);
|
||||
|
||||
ShowSonarMarker = element.GetAttributeBool("showsonarmarker", true);
|
||||
|
||||
MissionIdentifiers = element.GetAttributeIdentifierArray("missionidentifiers", Array.Empty<Identifier>()).ToImmutableArray();
|
||||
|
||||
@@ -298,7 +298,7 @@ namespace Barotrauma
|
||||
//if no outpost was found (using a mod that replaces the outpost location type?), find any type of outpost
|
||||
if (CurrentLocation == null)
|
||||
{
|
||||
FindStartLocation(l => l.Type.HasOutpost);
|
||||
FindStartLocation(l => l.Type.HasOutpost && l.Type.OutpostTeam == CharacterTeamType.FriendlyNPC);
|
||||
}
|
||||
|
||||
void FindStartLocation(Func<Location, bool> predicate)
|
||||
@@ -313,25 +313,38 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
StartLocation.SecondaryFaction = null;
|
||||
StartLocation.SecondaryFaction = null;
|
||||
var startOutpostFaction = campaign?.Factions.FirstOrDefault(f => f.Prefab.StartOutpost);
|
||||
if (startOutpostFaction != null)
|
||||
{
|
||||
StartLocation.Faction = startOutpostFaction;
|
||||
foreach (var connection in StartLocation.Connections)
|
||||
}
|
||||
foreach (var connection in StartLocation.Connections)
|
||||
{
|
||||
//force locations adjacent to the start location to have an outpost
|
||||
//non-inhabited locations seem to be confusing to new players, particularly
|
||||
//on the first round/mission when they still don't know how transitions between levels work
|
||||
var otherLocation = connection.OtherLocation(StartLocation);
|
||||
if (!otherLocation.HasOutpost())
|
||||
{
|
||||
var otherLocation = connection.OtherLocation(StartLocation);
|
||||
if (otherLocation.HasOutpost() && otherLocation.Type.OutpostTeam == CharacterTeamType.FriendlyNPC)
|
||||
if (LocationType.Prefabs.TryGet("outpost".ToIdentifier(), out LocationType outpostLocationType))
|
||||
{
|
||||
otherLocation.Faction = startOutpostFaction;
|
||||
otherLocation.ChangeType(campaign, outpostLocationType);
|
||||
}
|
||||
}
|
||||
|
||||
if (otherLocation.HasOutpost() &&
|
||||
otherLocation.Type.OutpostTeam == CharacterTeamType.FriendlyNPC &&
|
||||
otherLocation.Type.Faction.IsEmpty)
|
||||
{
|
||||
otherLocation.Faction = startOutpostFaction;
|
||||
}
|
||||
}
|
||||
|
||||
System.Diagnostics.Debug.Assert(StartLocation != null, "Start location not assigned after level generation.");
|
||||
|
||||
int loops = campaign.CampaignMetadata.GetInt("campaign.endings".ToIdentifier(), 0);
|
||||
if (loops == 0 && (campaign.Settings.Difficulty == GameDifficulty.Easy || campaign.Settings.Difficulty == GameDifficulty.Medium))
|
||||
if (loops == 0 && (campaign.Settings.WorldHostility == WorldHostilityOption.Low || campaign.Settings.WorldHostility == WorldHostilityOption.Medium))
|
||||
{
|
||||
if (StartLocation != null)
|
||||
{
|
||||
@@ -705,10 +718,19 @@ namespace Barotrauma
|
||||
foreach (Location location in Locations)
|
||||
{
|
||||
location.LevelData = new LevelData(location, this, CalculateDifficulty(location.MapPosition.X, location.Biome));
|
||||
location.TryAssignFactionBasedOnLocationType(campaign);
|
||||
if (location.Type.HasOutpost && campaign != null && location.Type.OutpostTeam == CharacterTeamType.FriendlyNPC)
|
||||
{
|
||||
location.Faction ??= campaign.GetRandomFaction(Rand.RandSync.ServerAndClient);
|
||||
location.SecondaryFaction ??= campaign.GetRandomSecondaryFaction(Rand.RandSync.ServerAndClient);
|
||||
if (location.Type.Faction.IsEmpty)
|
||||
{
|
||||
//no faction defined in the location type, assign a random one
|
||||
location.Faction ??= campaign.GetRandomFaction(Rand.RandSync.ServerAndClient);
|
||||
}
|
||||
if (location.Type.SecondaryFaction.IsEmpty)
|
||||
{
|
||||
//no secondary faction defined in the location type, assign a random one
|
||||
location.SecondaryFaction ??= campaign.GetRandomSecondaryFaction(Rand.RandSync.ServerAndClient);
|
||||
}
|
||||
}
|
||||
location.CreateStores(force: true);
|
||||
}
|
||||
@@ -1502,6 +1524,10 @@ namespace Barotrauma
|
||||
LocationType prevLocationType = location.Type;
|
||||
LocationType newLocationType = LocationType.Prefabs.Find(lt => lt.Identifier == locationType) ?? LocationType.Prefabs.First();
|
||||
location.ChangeType(campaign, newLocationType);
|
||||
|
||||
var factionIdentifier = subElement.GetAttributeIdentifier("faction", Identifier.Empty);
|
||||
location.Faction = factionIdentifier.IsEmpty ? null : campaign.Factions.Find(f => f.Prefab.Identifier == factionIdentifier);
|
||||
|
||||
if (showNotifications && prevLocationType != location.Type)
|
||||
{
|
||||
var change = prevLocationType.CanChangeTo.Find(c => c.ChangeToType == location.Type.Identifier);
|
||||
@@ -1512,9 +1538,6 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
var factionIdentifier = subElement.GetAttributeIdentifier("faction", Identifier.Empty);
|
||||
location.Faction = factionIdentifier.IsEmpty ? null : campaign.Factions.Find(f => f.Prefab.Identifier == factionIdentifier);
|
||||
|
||||
var secondaryFactionIdentifier = subElement.GetAttributeIdentifier("secondaryfaction", Identifier.Empty);
|
||||
location.SecondaryFaction = secondaryFactionIdentifier.IsEmpty ? null : campaign.Factions.Find(f => f.Prefab.Identifier == secondaryFactionIdentifier);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user