v1.0.13.1 (first post-1.0 patch)
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user