v1.0.13.1 (first post-1.0 patch)
This commit is contained in:
@@ -260,10 +260,12 @@ namespace Barotrauma
|
||||
}
|
||||
bool success = false;
|
||||
bool isCampaign = GameMain.GameSession?.GameMode is CampaignMode;
|
||||
float levelDifficulty = Level.Loaded?.Difficulty ?? 0.0f;
|
||||
foreach (PreferredContainer preferredContainer in itemPrefab.PreferredContainers)
|
||||
{
|
||||
if (preferredContainer.CampaignOnly && !isCampaign) { continue; }
|
||||
if (preferredContainer.NotCampaign && isCampaign) { continue; }
|
||||
if (levelDifficulty < preferredContainer.MinLevelDifficulty || levelDifficulty > preferredContainer.MaxLevelDifficulty) { continue; }
|
||||
if (preferredContainer.SpawnProbability <= 0.0f || preferredContainer.MaxAmount <= 0 && preferredContainer.Amount <= 0) { continue; }
|
||||
validContainers = GetValidContainers(preferredContainer, containers, validContainers, primary: true);
|
||||
if (validContainers.None())
|
||||
|
||||
@@ -420,20 +420,18 @@ namespace Barotrauma
|
||||
{
|
||||
List<Character> availableSpeakers = new List<Character>() { npc, player };
|
||||
List<Identifier> dialogFlags = new List<Identifier>() { "OutpostNPC".ToIdentifier(), "EnterOutpost".ToIdentifier() };
|
||||
if (npc.HumanPrefab != null)
|
||||
{
|
||||
foreach (var tag in npc.HumanPrefab.GetTags())
|
||||
{
|
||||
dialogFlags.Add(tag);
|
||||
}
|
||||
}
|
||||
if (GameMain.GameSession?.GameMode is CampaignMode campaignMode)
|
||||
{
|
||||
if (campaignMode.Map?.CurrentLocation?.Type?.Identifier == "abandoned")
|
||||
{
|
||||
if (npc.TeamID == CharacterTeamType.None)
|
||||
{
|
||||
dialogFlags.Remove("OutpostNPC".ToIdentifier());
|
||||
dialogFlags.Add("Bandit".ToIdentifier());
|
||||
}
|
||||
else if (npc.TeamID == CharacterTeamType.FriendlyNPC)
|
||||
{
|
||||
dialogFlags.Remove("OutpostNPC".ToIdentifier());
|
||||
dialogFlags.Add("Hostage".ToIdentifier());
|
||||
}
|
||||
dialogFlags.Remove("OutpostNPC".ToIdentifier());
|
||||
}
|
||||
else if (campaignMode.Map?.CurrentLocation?.Reputation != null)
|
||||
{
|
||||
|
||||
@@ -1,16 +1,26 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
class Reputation
|
||||
{
|
||||
public const float HostileThreshold = 0.2f;
|
||||
public const float ReputationLossPerNPCDamage = 0.05f;
|
||||
public const float ReputationLossPerWallDamage = 0.05f;
|
||||
public const float ReputationLossPerStolenItemPrice = 0.005f;
|
||||
public const float MinReputationLossPerStolenItem = 0.05f;
|
||||
public const float MaxReputationLossPerStolenItem = 1.0f;
|
||||
public const float ReputationLossPerNPCDamage = 0.025f;
|
||||
public const float ReputationLossPerWallDamage = 0.025f;
|
||||
public const float ReputationLossPerStolenItemPrice = 0.0025f;
|
||||
public const float MinReputationLossPerStolenItem = 0.025f;
|
||||
public const float MaxReputationLossPerStolenItem = 0.5f;
|
||||
|
||||
/// <summary>
|
||||
/// Maximum amount of reputation loss you can get from damaging outpost NPCs per round
|
||||
/// </summary>
|
||||
public const float MaxReputationLossFromNPCDamage = 20.0f;
|
||||
/// <summary>
|
||||
/// Maximum amount of reputation loss you can get from damaging outpost walls per round
|
||||
/// </summary>
|
||||
public const float MaxReputationLossFromWallDamage = 10.0f;
|
||||
|
||||
public Identifier Identifier { get; }
|
||||
public int MinReputation { get; }
|
||||
@@ -18,6 +28,8 @@ namespace Barotrauma
|
||||
public int InitialReputation { get; }
|
||||
public CampaignMetadata Metadata { get; }
|
||||
|
||||
public float ReputationAtRoundStart { get; set; }
|
||||
|
||||
private readonly Identifier metaDataIdentifier;
|
||||
|
||||
/// <summary>
|
||||
@@ -60,32 +72,50 @@ namespace Barotrauma
|
||||
|
||||
public float GetReputationChangeMultiplier(float reputationChange)
|
||||
{
|
||||
if (reputationChange > 0f)
|
||||
return reputationChange switch
|
||||
{
|
||||
float reputationGainMultiplier = 1f;
|
||||
foreach (Character character in GameSession.GetSessionCrewCharacters(CharacterType.Both))
|
||||
{
|
||||
reputationGainMultiplier *= 1f + character.GetStatValue(StatTypes.ReputationGainMultiplier, includeSaved: false);
|
||||
reputationGainMultiplier *= 1f + character.Info?.GetSavedStatValue(StatTypes.ReputationGainMultiplier, Identifier) ?? 0;
|
||||
}
|
||||
return reputationGainMultiplier;
|
||||
}
|
||||
else if (reputationChange < 0f)
|
||||
> 0f => GetMultiplierForStatType(StatTypes.ReputationGainMultiplier, Identifier),
|
||||
< 0f => GetMultiplierForStatType(StatTypes.ReputationLossMultiplier, Identifier),
|
||||
_ => 1.0f
|
||||
};
|
||||
|
||||
static float GetMultiplierForStatType(StatTypes statTypes, Identifier identifier)
|
||||
{
|
||||
float reputationLossMultiplier = 1f;
|
||||
foreach (Character character in GameSession.GetSessionCrewCharacters(CharacterType.Both))
|
||||
float multiplier = 1f;
|
||||
var crew = GameSession.GetSessionCrewCharacters(CharacterType.Both);
|
||||
if (crew != null && crew.Any())
|
||||
{
|
||||
reputationLossMultiplier *= 1f + character.GetStatValue(StatTypes.ReputationLossMultiplier, includeSaved: false);
|
||||
reputationLossMultiplier *= 1f + character.Info?.GetSavedStatValue(StatTypes.ReputationLossMultiplier, Identifier) ?? 0;
|
||||
multiplier *= 1f + crew.Max(c => c.GetStatValue(statTypes, includeSaved: false));
|
||||
multiplier *= 1f + crew.Max(c => c.Info?.GetSavedStatValue(statTypes, identifier) ?? 0);
|
||||
}
|
||||
return reputationLossMultiplier;
|
||||
return multiplier;
|
||||
}
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
public void AddReputation(float reputationChange)
|
||||
public void AddReputation(float reputationChange, float maxReputationChangePerRound = float.MaxValue)
|
||||
{
|
||||
Value += reputationChange * GetReputationChangeMultiplier(reputationChange);
|
||||
float prevValue = Value;
|
||||
//if we're already over the limit, do nothing (assuming the change is in the "same direction" that we've gone over the limit)
|
||||
if (doesReputationChangeGoOverLimit(prevValue, reputationChange))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
float newValue = Value + reputationChange * GetReputationChangeMultiplier(reputationChange);
|
||||
if (doesReputationChangeGoOverLimit(newValue, newValue - prevValue))
|
||||
{
|
||||
newValue = ReputationAtRoundStart + maxReputationChangePerRound * Math.Sign(reputationChange);
|
||||
}
|
||||
|
||||
Value = newValue;
|
||||
|
||||
bool doesReputationChangeGoOverLimit(float newValue, float change)
|
||||
{
|
||||
float totalReputationChange = newValue - ReputationAtRoundStart;
|
||||
return
|
||||
Math.Abs(totalReputationChange) > maxReputationChangePerRound &&
|
||||
Math.Sign(totalReputationChange) == Math.Sign(change);
|
||||
}
|
||||
}
|
||||
|
||||
public readonly NamedEvent<Reputation> OnReputationValueChanged = new NamedEvent<Reputation>();
|
||||
@@ -114,6 +144,7 @@ namespace Barotrauma
|
||||
metaDataIdentifier = $"reputation.{Identifier}".ToIdentifier();
|
||||
MinReputation = minReputation;
|
||||
MaxReputation = maxReputation;
|
||||
ReputationAtRoundStart = initialReputation;
|
||||
InitialReputation = initialReputation;
|
||||
Faction = faction;
|
||||
Location = location;
|
||||
|
||||
@@ -105,24 +105,30 @@ namespace Barotrauma
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Map.CurrentLocation != null)
|
||||
//map can be null if we're in the process of loading the save
|
||||
if (Map != null)
|
||||
{
|
||||
foreach (Mission mission in map.CurrentLocation.SelectedMissions)
|
||||
if (Map.CurrentLocation != null)
|
||||
{
|
||||
if (mission.Locations[0] == mission.Locations[1] ||
|
||||
mission.Locations.Contains(Map.SelectedLocation))
|
||||
foreach (Mission mission in map.CurrentLocation.SelectedMissions)
|
||||
{
|
||||
yield return mission;
|
||||
if (mission.Locations[0] == mission.Locations[1] ||
|
||||
mission.Locations.Contains(Map.SelectedLocation))
|
||||
{
|
||||
yield return mission;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (Mission mission in extraMissions)
|
||||
{
|
||||
yield return mission;
|
||||
foreach (Mission mission in extraMissions)
|
||||
{
|
||||
yield return mission;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Location CurrentLocation => Map?.CurrentLocation;
|
||||
|
||||
public Wallet Bank;
|
||||
|
||||
public LevelData NextLevel
|
||||
@@ -247,6 +253,11 @@ namespace Barotrauma
|
||||
prevCampaignUIAutoOpenType = TransitionType.None;
|
||||
#endif
|
||||
|
||||
foreach (var faction in factions)
|
||||
{
|
||||
faction.Reputation.ReputationAtRoundStart = faction.Reputation.Value;
|
||||
}
|
||||
|
||||
if (PurchasedHullRepairsInLatestSave)
|
||||
{
|
||||
foreach (Structure wall in Structure.WallList)
|
||||
@@ -907,6 +918,10 @@ namespace Barotrauma
|
||||
{
|
||||
location.TurnsInRadiation = 0;
|
||||
}
|
||||
foreach (var faction in Factions)
|
||||
{
|
||||
faction.Reputation.SetReputation(faction.Prefab.InitialReputation);
|
||||
}
|
||||
EndCampaignProjSpecific();
|
||||
|
||||
if (CampaignMetadata != null)
|
||||
@@ -1154,15 +1169,12 @@ namespace Barotrauma
|
||||
|
||||
if (npc.Faction != null && Factions.FirstOrDefault(f => f.Prefab.Identifier == npc.Faction) is Faction faction)
|
||||
{
|
||||
faction.Reputation?.AddReputation(-attackResult.Damage * Reputation.ReputationLossPerNPCDamage);
|
||||
faction.Reputation?.AddReputation(-attackResult.Damage * Reputation.ReputationLossPerNPCDamage, Reputation.MaxReputationLossFromNPCDamage);
|
||||
}
|
||||
else
|
||||
{
|
||||
Location location = Map?.CurrentLocation;
|
||||
if (location != null)
|
||||
{
|
||||
location.Reputation?.AddReputation(-attackResult.Damage * Reputation.ReputationLossPerNPCDamage);
|
||||
}
|
||||
location?.Reputation?.AddReputation(-attackResult.Damage * Reputation.ReputationLossPerNPCDamage, Reputation.MaxReputationLossFromNPCDamage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,9 @@ namespace Barotrauma
|
||||
{
|
||||
internal sealed partial class MedicalClinic
|
||||
{
|
||||
private const int RateLimitMaxRequests = 20,
|
||||
RateLimitExpiry = 5;
|
||||
|
||||
public enum NetworkHeader
|
||||
{
|
||||
REQUEST_AFFLICTIONS,
|
||||
|
||||
Reference in New Issue
Block a user