v1.0.13.1 (first post-1.0 patch)
This commit is contained in:
@@ -95,6 +95,8 @@ namespace Barotrauma
|
||||
|
||||
public Reputation Reputation => Faction?.Reputation;
|
||||
|
||||
public bool IsFactionHostile => Faction?.Reputation.NormalizedValue < Reputation.HostileThreshold;
|
||||
|
||||
public int TurnsInRadiation { get; set; }
|
||||
|
||||
#region Store
|
||||
@@ -177,29 +179,30 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public static PurchasedItem CreateInitialStockItem(ItemPrefab itemPrefab, PriceInfo priceInfo)
|
||||
{
|
||||
int quantity = PriceInfo.DefaultAmount;
|
||||
if (priceInfo.MaxAvailableAmount > 0)
|
||||
{
|
||||
quantity =
|
||||
priceInfo.MaxAvailableAmount > priceInfo.MinAvailableAmount ?
|
||||
Rand.Range(priceInfo.MinAvailableAmount, priceInfo.MaxAvailableAmount + 1) :
|
||||
priceInfo.MaxAvailableAmount;
|
||||
}
|
||||
else if (priceInfo.MinAvailableAmount > 0)
|
||||
{
|
||||
quantity = priceInfo.MinAvailableAmount;
|
||||
}
|
||||
return new PurchasedItem(itemPrefab, quantity, buyer: null);
|
||||
}
|
||||
|
||||
public List<PurchasedItem> CreateStock()
|
||||
{
|
||||
var stock = new List<PurchasedItem>();
|
||||
foreach (var prefab in ItemPrefab.Prefabs)
|
||||
{
|
||||
if (!prefab.CanBeBoughtFrom(this, out var priceInfo)) { continue; }
|
||||
int quantity = PriceInfo.DefaultAmount;
|
||||
if (priceInfo.MaxAvailableAmount > 0)
|
||||
{
|
||||
if (priceInfo.MaxAvailableAmount > priceInfo.MinAvailableAmount)
|
||||
{
|
||||
quantity = Rand.Range(priceInfo.MinAvailableAmount, priceInfo.MaxAvailableAmount + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
quantity = priceInfo.MaxAvailableAmount;
|
||||
}
|
||||
}
|
||||
else if (priceInfo.MinAvailableAmount > 0)
|
||||
{
|
||||
quantity = priceInfo.MinAvailableAmount;
|
||||
}
|
||||
stock.Add(new PurchasedItem(prefab, quantity, buyer: null));
|
||||
stock.Add(CreateInitialStockItem(prefab, priceInfo));
|
||||
}
|
||||
return stock;
|
||||
}
|
||||
@@ -304,6 +307,7 @@ namespace Barotrauma
|
||||
if (!faction.IsEmpty && GameMain.GameSession.Campaign.GetFactionAffiliation(faction) is FactionAffiliation.Positive)
|
||||
{
|
||||
price *= 1f - characters.Max(static c => c.GetStatValue(StatTypes.StoreBuyMultiplierAffiliated, includeSaved: false));
|
||||
price *= 1f - characters.Max(static c => c.Info.GetSavedStatValue(StatTypes.StoreBuyMultiplierAffiliated, new Identifier("all")));
|
||||
price *= 1f - characters.Max(c => item.Tags.Sum(tag => c.Info.GetSavedStatValue(StatTypes.StoreBuyMultiplierAffiliated, tag)));
|
||||
}
|
||||
price *= 1f - characters.Max(static c => c.GetStatValue(StatTypes.StoreBuyMultiplier, includeSaved: false));
|
||||
@@ -811,30 +815,36 @@ namespace Barotrauma
|
||||
return null;
|
||||
}
|
||||
AddMission(mission);
|
||||
DebugConsole.NewMessage($"Unlocked a mission by \"{identifier}\".", debugOnly: true);
|
||||
return mission;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Mission UnlockMissionByTag(Identifier tag)
|
||||
public Mission UnlockMissionByTag(Identifier tag, Random random = null)
|
||||
{
|
||||
if (AvailableMissions.Any(m => !m.Prefab.AllowOtherMissionsInLevel)) { return null; }
|
||||
var matchingMissions = MissionPrefab.Prefabs.Where(mp => mp.Tags.Contains(tag));
|
||||
if (!matchingMissions.Any())
|
||||
if (matchingMissions.None())
|
||||
{
|
||||
DebugConsole.ThrowError($"Failed to unlock a mission with the tag \"{tag}\": no matching missions found.");
|
||||
}
|
||||
else
|
||||
{
|
||||
var unusedMissions = matchingMissions.Where(m => !availableMissions.Any(mission => mission.Prefab == m));
|
||||
var unusedMissions = matchingMissions.Where(m => availableMissions.None(mission => mission.Prefab == m));
|
||||
if (unusedMissions.Any())
|
||||
{
|
||||
var suitableMissions = unusedMissions.Where(m => Connections.Any(c => m.IsAllowed(this, c.OtherLocation(this)) || m.IsAllowed(this, this)));
|
||||
if (!suitableMissions.Any())
|
||||
if (suitableMissions.None())
|
||||
{
|
||||
suitableMissions = unusedMissions;
|
||||
}
|
||||
MissionPrefab missionPrefab = ToolBox.SelectWeightedRandom(suitableMissions.ToList(), suitableMissions.Select(m => (float)m.Commonness).ToList(), Rand.RandSync.Unsynced);
|
||||
|
||||
MissionPrefab missionPrefab =
|
||||
random != null ?
|
||||
ToolBox.SelectWeightedRandom(suitableMissions.OrderBy(m => m.Identifier), m => m.Commonness, random) :
|
||||
ToolBox.SelectWeightedRandom(suitableMissions.OrderBy(m => m.Identifier), m => m.Commonness, Rand.RandSync.Unsynced);
|
||||
|
||||
var mission = InstantiateMission(missionPrefab, out LocationConnection connection);
|
||||
//don't allow duplicate missions in the same connection
|
||||
if (AvailableMissions.Any(m => m.Prefab == missionPrefab && m.Locations.Contains(mission.Locations[0]) && m.Locations.Contains(mission.Locations[1])))
|
||||
@@ -842,6 +852,7 @@ namespace Barotrauma
|
||||
return null;
|
||||
}
|
||||
AddMission(mission);
|
||||
DebugConsole.NewMessage($"Unlocked a random mission by \"{tag}\".", debugOnly: true);
|
||||
return mission;
|
||||
}
|
||||
else
|
||||
@@ -876,7 +887,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
var suitableConnections = Connections.Where(c => prefab.IsAllowed(this, c.OtherLocation(this)));
|
||||
if (!suitableConnections.Any())
|
||||
if (suitableConnections.None())
|
||||
{
|
||||
suitableConnections = Connections.ToList();
|
||||
}
|
||||
@@ -1270,25 +1281,31 @@ namespace Barotrauma
|
||||
}
|
||||
var stock = new List<PurchasedItem>(store.Stock);
|
||||
var stockToRemove = new List<PurchasedItem>();
|
||||
foreach (var item in stock)
|
||||
|
||||
foreach (var itemPrefab in ItemPrefab.Prefabs)
|
||||
{
|
||||
if (item.ItemPrefab.CanBeBoughtFrom(store, out PriceInfo priceInfo))
|
||||
var existingStock = stock.FirstOrDefault(s => s.ItemPrefab == itemPrefab);
|
||||
if (itemPrefab.CanBeBoughtFrom(store, out PriceInfo priceInfo))
|
||||
{
|
||||
item.Quantity += 1;
|
||||
if (priceInfo.MaxAvailableAmount > 0)
|
||||
if (existingStock == null)
|
||||
{
|
||||
item.Quantity = Math.Min(item.Quantity, priceInfo.MaxAvailableAmount);
|
||||
//can be bought from the location, but not in stock - some new item added by an update or mod?
|
||||
stock.Add(StoreInfo.CreateInitialStockItem(itemPrefab, priceInfo));
|
||||
}
|
||||
else
|
||||
{
|
||||
item.Quantity = Math.Min(item.Quantity, CargoManager.MaxQuantity);
|
||||
existingStock.Quantity =
|
||||
Math.Min(
|
||||
existingStock.Quantity + 1,
|
||||
priceInfo.MaxAvailableAmount > 0 ? priceInfo.MaxAvailableAmount : CargoManager.MaxQuantity);
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (existingStock != null)
|
||||
{
|
||||
stockToRemove.Add(item);
|
||||
stockToRemove.Add(existingStock);
|
||||
}
|
||||
}
|
||||
|
||||
stockToRemove.ForEach(i => stock.Remove(i));
|
||||
store.Stock.Clear();
|
||||
store.Stock.AddRange(stock);
|
||||
|
||||
@@ -1456,7 +1456,13 @@ namespace Barotrauma
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
case "location":
|
||||
Location location = Locations[subElement.GetAttributeInt("i", 0)];
|
||||
int locationIndex = subElement.GetAttributeInt("i", -1);
|
||||
if (locationIndex < 0 || locationIndex >= Locations.Count)
|
||||
{
|
||||
DebugConsole.AddWarning($"Error while loading the campaign map: location index out of bounds ({locationIndex})");
|
||||
continue;
|
||||
}
|
||||
Location location = Locations[locationIndex];
|
||||
location.ProximityTimer.Clear();
|
||||
for (int i = 0; i < location.Type.CanChangeTo.Count; i++)
|
||||
{
|
||||
@@ -1502,9 +1508,17 @@ namespace Barotrauma
|
||||
|
||||
break;
|
||||
case "connection":
|
||||
int connectionIndex = subElement.GetAttributeInt("i", 0);
|
||||
//the index wasn't saved previously, skip if that's the case
|
||||
if (subElement.Attribute("i") == null) { continue; }
|
||||
|
||||
int connectionIndex = subElement.GetAttributeInt("i", -1);
|
||||
if (connectionIndex < 0 || connectionIndex >= Connections.Count)
|
||||
{
|
||||
DebugConsole.AddWarning($"Error while loading the campaign map: connection index out of bounds ({connectionIndex})");
|
||||
continue;
|
||||
}
|
||||
Connections[connectionIndex].Passed = subElement.GetAttributeBool("passed", false);
|
||||
Connections[connectionIndex].Locked = subElement.GetAttributeBool("locked", false);
|
||||
Connections[connectionIndex].Locked = subElement.GetAttributeBool("locked", false);
|
||||
break;
|
||||
case "radiation":
|
||||
Radiation = new Radiation(this, generationParams.RadiationParams, subElement);
|
||||
@@ -1635,6 +1649,7 @@ namespace Barotrauma
|
||||
new XAttribute("locked", connection.Locked),
|
||||
new XAttribute("difficulty", connection.Difficulty),
|
||||
new XAttribute("biome", connection.Biome.Identifier),
|
||||
new XAttribute("i", i),
|
||||
new XAttribute("locations", Locations.IndexOf(connection.Locations[0]) + "," + Locations.IndexOf(connection.Locations[1])));
|
||||
connection.LevelData.Save(connectionElement);
|
||||
mapElement.Add(connectionElement);
|
||||
|
||||
Reference in New Issue
Block a user