Unstable 0.1300.0.8

This commit is contained in:
Markus Isberg
2021-04-09 15:07:09 +03:00
parent 538c3dbfc3
commit 29bd4d6f49
38 changed files with 162 additions and 76 deletions
@@ -617,7 +617,7 @@ namespace Barotrauma
} }
else if (bossHealthBar.Character.AIController is EnemyAIController enemyAI && !enemyAI.IsTargetingPlayerTeam) else if (bossHealthBar.Character.AIController is EnemyAIController enemyAI && !enemyAI.IsTargetingPlayerTeam)
{ {
bossHealthBar.FadeTimer = Math.Min(bossHealthBar.FadeTimer, 10.0f); bossHealthBar.FadeTimer = Math.Min(bossHealthBar.FadeTimer, 60.0f);
} }
bossHealthBar.FadeTimer -= deltaTime; bossHealthBar.FadeTimer -= deltaTime;
} }
@@ -138,7 +138,7 @@ namespace Barotrauma
// onstartedinteracting.lootingisstealing // onstartedinteracting.lootingisstealing
if (item.Submarine?.Info?.Type == SubmarineType.Outpost && if (item.Submarine?.Info?.Type == SubmarineType.Outpost &&
item.ContainedItems.Any(i => i.SpawnedInOutpost)) item.ContainedItems.Any(i => !i.AllowStealing))
{ {
if (DisplayHint($"{hintIdentifierBase}.lootingisstealing")) { return; } if (DisplayHint($"{hintIdentifierBase}.lootingisstealing")) { return; }
} }
@@ -379,7 +379,7 @@ namespace Barotrauma
{ {
if (!CanDisplayHints()) { return; } if (!CanDisplayHints()) { return; }
if (character != Character.Controlled) { return; } if (character != Character.Controlled) { return; }
if (item == null || !item.SpawnedInOutpost || !item.StolenDuringRound) { return; } if (item == null || item.AllowStealing || !item.StolenDuringRound) { return; }
DisplayHint("onstoleitem", onUpdate: () => DisplayHint("onstoleitem", onUpdate: () =>
{ {
if (item == null || item.Removed || item.GetRootInventoryOwner() != character) if (item == null || item.Removed || item.GetRootInventoryOwner() != character)
@@ -70,17 +70,15 @@ namespace Barotrauma.Items.Components
public override void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime) public override void ClientRead(ServerNetObject type, IReadMessage msg, float sendingTime)
{ {
base.ClientRead(type, msg, sendingTime); base.ClientRead(type, msg, sendingTime);
bool readAttachData = msg.ReadBoolean();
if (!readAttachData) { return; }
bool shouldBeAttached = msg.ReadBoolean(); bool shouldBeAttached = msg.ReadBoolean();
Vector2 simPosition = new Vector2(msg.ReadSingle(), msg.ReadSingle()); Vector2 simPosition = new Vector2(msg.ReadSingle(), msg.ReadSingle());
UInt16 submarineID = msg.ReadUInt16(); UInt16 submarineID = msg.ReadUInt16();
Submarine sub = Entity.FindEntityByID(submarineID) as Submarine; Submarine sub = Entity.FindEntityByID(submarineID) as Submarine;
if (!attachable)
{
DebugConsole.ThrowError("Received an attachment event for an item that's not attachable.");
return;
}
if (shouldBeAttached) if (shouldBeAttached)
{ {
if (!attached) if (!attached)
@@ -96,7 +94,6 @@ namespace Barotrauma.Items.Components
if (attached) if (attached)
{ {
DropConnectedWires(null); DropConnectedWires(null);
if (body != null) if (body != null)
{ {
item.body = body; item.body = body;
@@ -288,7 +288,7 @@ namespace Barotrauma
} }
} }
string colorStr = XMLExtensions.ColorToString(item.SpawnedInOutpost ? GUI.Style.Red : Color.White); string colorStr = XMLExtensions.ColorToString(!item.AllowStealing ? GUI.Style.Red : Color.White);
toolTip = $"‖color:{colorStr}‖{item.Name}‖color:end‖"; toolTip = $"‖color:{colorStr}‖{item.Name}‖color:end‖";
if (itemsInSlot.All(it => it.NonInteractable || it.NonPlayerTeamInteractable)) if (itemsInSlot.All(it => it.NonInteractable || it.NonPlayerTeamInteractable))
@@ -1552,7 +1552,7 @@ namespace Barotrauma
} }
sprite.Draw(spriteBatch, itemPos, spriteColor, rotation, scale); sprite.Draw(spriteBatch, itemPos, spriteColor, rotation, scale);
if (item.SpawnedInOutpost && CharacterInventory.LimbSlotIcons.ContainsKey(InvSlotType.LeftHand)) if (!item.AllowStealing && CharacterInventory.LimbSlotIcons.ContainsKey(InvSlotType.LeftHand))
{ {
var stealIcon = CharacterInventory.LimbSlotIcons[InvSlotType.LeftHand]; var stealIcon = CharacterInventory.LimbSlotIcons[InvSlotType.LeftHand];
Vector2 iconSize = new Vector2(25 * GUI.Scale); Vector2 iconSize = new Vector2(25 * GUI.Scale);
@@ -1464,6 +1464,7 @@ namespace Barotrauma
byte bodyType = msg.ReadByte(); byte bodyType = msg.ReadByte();
bool spawnedInOutpost = msg.ReadBoolean(); bool spawnedInOutpost = msg.ReadBoolean();
bool allowStealing = msg.ReadBoolean();
byte teamID = msg.ReadByte(); byte teamID = msg.ReadByte();
bool tagsChanged = msg.ReadBoolean(); bool tagsChanged = msg.ReadBoolean();
string tags = ""; string tags = "";
@@ -1535,7 +1536,8 @@ namespace Barotrauma
var item = new Item(itemPrefab, pos, sub, id: itemId) var item = new Item(itemPrefab, pos, sub, id: itemId)
{ {
SpawnedInOutpost = spawnedInOutpost SpawnedInOutpost = spawnedInOutpost,
AllowStealing = allowStealing
}; };
if (item.body != null) if (item.body != null)
@@ -53,7 +53,7 @@ namespace Barotrauma
campaign.Map.OnLocationSelected += SelectLocation; campaign.Map.OnLocationSelected += SelectLocation;
campaign.Map.OnMissionSelected += (connection, mission) => campaign.Map.OnMissionSelected += (connection, mission) =>
{ {
missionList.Select(mission); missionList?.Select(mission);
}; };
} }
@@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace> <RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors> <Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma</Product> <Product>Barotrauma</Product>
<Version>0.1300.0.7</Version> <Version>0.1300.0.8</Version>
<Copyright>Copyright © FakeFish 2018-2020</Copyright> <Copyright>Copyright © FakeFish 2018-2020</Copyright>
<Platforms>AnyCPU;x64</Platforms> <Platforms>AnyCPU;x64</Platforms>
<AssemblyName>Barotrauma</AssemblyName> <AssemblyName>Barotrauma</AssemblyName>
+1 -1
View File
@@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace> <RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors> <Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma</Product> <Product>Barotrauma</Product>
<Version>0.1300.0.7</Version> <Version>0.1300.0.8</Version>
<Copyright>Copyright © FakeFish 2018-2020</Copyright> <Copyright>Copyright © FakeFish 2018-2020</Copyright>
<Platforms>AnyCPU;x64</Platforms> <Platforms>AnyCPU;x64</Platforms>
<AssemblyName>Barotrauma</AssemblyName> <AssemblyName>Barotrauma</AssemblyName>
@@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace> <RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors> <Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma</Product> <Product>Barotrauma</Product>
<Version>0.1300.0.7</Version> <Version>0.1300.0.8</Version>
<Copyright>Copyright © FakeFish 2018-2020</Copyright> <Copyright>Copyright © FakeFish 2018-2020</Copyright>
<Platforms>AnyCPU;x64</Platforms> <Platforms>AnyCPU;x64</Platforms>
<AssemblyName>Barotrauma</AssemblyName> <AssemblyName>Barotrauma</AssemblyName>
@@ -1 +1,2 @@
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$PWD/linux64"
./DedicatedServer ./DedicatedServer
@@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace> <RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors> <Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma Dedicated Server</Product> <Product>Barotrauma Dedicated Server</Product>
<Version>0.1300.0.7</Version> <Version>0.1300.0.8</Version>
<Copyright>Copyright © FakeFish 2018-2020</Copyright> <Copyright>Copyright © FakeFish 2018-2020</Copyright>
<Platforms>AnyCPU;x64</Platforms> <Platforms>AnyCPU;x64</Platforms>
<AssemblyName>DedicatedServer</AssemblyName> <AssemblyName>DedicatedServer</AssemblyName>
+1 -1
View File
@@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace> <RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors> <Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma Dedicated Server</Product> <Product>Barotrauma Dedicated Server</Product>
<Version>0.1300.0.7</Version> <Version>0.1300.0.8</Version>
<Copyright>Copyright © FakeFish 2018-2020</Copyright> <Copyright>Copyright © FakeFish 2018-2020</Copyright>
<Platforms>AnyCPU;x64</Platforms> <Platforms>AnyCPU;x64</Platforms>
<AssemblyName>DedicatedServer</AssemblyName> <AssemblyName>DedicatedServer</AssemblyName>
@@ -8,7 +8,10 @@ namespace Barotrauma.Items.Components
public override void ServerWrite(IWriteMessage msg, Client c, object[] extraData = null) public override void ServerWrite(IWriteMessage msg, Client c, object[] extraData = null)
{ {
base.ServerWrite(msg, c, extraData); base.ServerWrite(msg, c, extraData);
if (!attachable || body == null) { return; }
bool writeAttachData = attachable && body != null;
msg.Write(writeAttachData);
if (!writeAttachData) { return; }
msg.Write(Attached); msg.Write(Attached);
msg.Write(body.SimPosition.X); msg.Write(body.SimPosition.X);
@@ -269,6 +269,7 @@ namespace Barotrauma
msg.Write(body == null ? (byte)0 : (byte)body.BodyType); msg.Write(body == null ? (byte)0 : (byte)body.BodyType);
msg.Write(SpawnedInOutpost); msg.Write(SpawnedInOutpost);
msg.Write(AllowStealing);
byte teamID = 0; byte teamID = 0;
foreach (WifiComponent wifiComponent in GetComponents<WifiComponent>()) foreach (WifiComponent wifiComponent in GetComponents<WifiComponent>())
@@ -3752,11 +3752,11 @@ namespace Barotrauma.Networking
private Client FindClientWithJobPreference(List<Client> clients, JobPrefab job, bool forceAssign = false) private Client FindClientWithJobPreference(List<Client> clients, JobPrefab job, bool forceAssign = false)
{ {
int bestPreference = 0; int bestPreference = int.MaxValue;
Client preferredClient = null; Client preferredClient = null;
foreach (Client c in clients) foreach (Client c in clients)
{ {
if (c.Karma < job.MinKarma) { continue; } if (ServerSettings.KarmaEnabled && c.Karma < job.MinKarma) { continue; }
int index = c.JobPreferences.IndexOf(c.JobPreferences.Find(j => j.First == job)); int index = c.JobPreferences.IndexOf(c.JobPreferences.Find(j => j.First == job));
if (index > -1 && index < bestPreference) if (index > -1 && index < bestPreference)
{ {
@@ -19,9 +19,16 @@ namespace Barotrauma.Networking
if (c.SpectateOnly && (GameMain.Server.ServerSettings.AllowSpectating || GameMain.Server.OwnerConnection == c.Connection)) { continue; } if (c.SpectateOnly && (GameMain.Server.ServerSettings.AllowSpectating || GameMain.Server.OwnerConnection == c.Connection)) { continue; }
if (c.Character != null && !c.Character.IsDead) { continue; } if (c.Character != null && !c.Character.IsDead) { continue; }
//don't allow respawn if the client already has a character (they'll regain control once they're in sync)
var matchingData = campaign?.GetClientCharacterData(c);
if (matchingData != null && matchingData.HasSpawned &&
Character.CharacterList.Any(c => c.Info == matchingData.CharacterInfo && !c.IsDead))
{
continue;
}
if (UseRespawnPrompt) if (UseRespawnPrompt)
{ {
var matchingData = campaign?.GetClientCharacterData(c);
if (matchingData != null && matchingData.HasSpawned) if (matchingData != null && matchingData.HasSpawned)
{ {
if (!c.WaitForNextRoundRespawn.HasValue || c.WaitForNextRoundRespawn.Value) { continue; } if (!c.WaitForNextRoundRespawn.HasValue || c.WaitForNextRoundRespawn.Value) { continue; }
@@ -6,7 +6,7 @@
<RootNamespace>Barotrauma</RootNamespace> <RootNamespace>Barotrauma</RootNamespace>
<Authors>FakeFish, Undertow Games</Authors> <Authors>FakeFish, Undertow Games</Authors>
<Product>Barotrauma Dedicated Server</Product> <Product>Barotrauma Dedicated Server</Product>
<Version>0.1300.0.7</Version> <Version>0.1300.0.8</Version>
<Copyright>Copyright © FakeFish 2018-2020</Copyright> <Copyright>Copyright © FakeFish 2018-2020</Copyright>
<Platforms>AnyCPU;x64</Platforms> <Platforms>AnyCPU;x64</Platforms>
<AssemblyName>DedicatedServer</AssemblyName> <AssemblyName>DedicatedServer</AssemblyName>
@@ -1401,7 +1401,7 @@ namespace Barotrauma
Character thief = character; Character thief = character;
bool someoneSpoke = false; bool someoneSpoke = false;
if (item.SpawnedInOutpost && thief.TeamID != CharacterTeamType.FriendlyNPC && !item.HasTag("handlocker")) if (item.SpawnedInOutpost && !item.AllowStealing && thief.TeamID != CharacterTeamType.FriendlyNPC && !item.HasTag("handlocker"))
{ {
foreach (Character otherCharacter in Character.CharacterList) foreach (Character otherCharacter in Character.CharacterList)
{ {
@@ -1453,7 +1453,7 @@ namespace Barotrauma
} }
} }
} }
else if (item.OwnInventory?.FindItem(it => it.SpawnedInOutpost, true) is { } foundItem) else if (item.OwnInventory?.FindItem(it => it.SpawnedInOutpost && !item.AllowStealing, true) is { } foundItem)
{ {
ItemTaken(foundItem, character); ItemTaken(foundItem, character);
} }
@@ -320,6 +320,7 @@ namespace Barotrauma
public void ClearForcedOrder() public void ClearForcedOrder()
{ {
ForcedOrder = null; ForcedOrder = null;
SortObjectives();
} }
private CoroutineHandle speakRoutine; private CoroutineHandle speakRoutine;
@@ -429,8 +429,7 @@ namespace Barotrauma
float t = 0.5f; float t = 0.5f;
if (!SimplePhysicsEnabled && CurrentSwimParams.RotateTowardsMovement) if (!SimplePhysicsEnabled && CurrentSwimParams.RotateTowardsMovement)
{ {
float offset = mainLimb.Params.GetSpriteOrientation() - MathHelper.PiOver2; Vector2 forward = VectorExtensions.Forward(Collider.Rotation + MathHelper.PiOver2);
Vector2 forward = VectorExtensions.Forward(mainLimb.body.TransformedRotation - offset * Character.AnimController.Dir);
float dot = Vector2.Dot(forward, Vector2.Normalize(movement)); float dot = Vector2.Dot(forward, Vector2.Normalize(movement));
if (dot < 0) if (dot < 0)
{ {
@@ -3440,7 +3440,10 @@ namespace Barotrauma
if (statusEffect.type != actionType) { continue; } if (statusEffect.type != actionType) { continue; }
if (statusEffect.type == ActionType.OnDamaged) if (statusEffect.type == ActionType.OnDamaged)
{ {
if (LastDamage.Afflictions == null || LastDamage.Afflictions.None(a => a.Prefab.AfflictionType == "damage")) { continue; } if (statusEffect.AllowedAfflictions != null && (LastDamage.Afflictions == null || LastDamage.Afflictions.None(a => statusEffect.AllowedAfflictions.Contains(a.Prefab.AfflictionType) || statusEffect.AllowedAfflictions.Contains(a.Prefab.Identifier))))
{
continue;
}
if (statusEffect.OnlyPlayerTriggered) if (statusEffect.OnlyPlayerTriggered)
{ {
if (LastAttacker == null || !LastAttacker.IsPlayer) if (LastAttacker == null || !LastAttacker.IsPlayer)
@@ -1127,7 +1127,10 @@ namespace Barotrauma
if (statusEffect.type != actionType) { continue; } if (statusEffect.type != actionType) { continue; }
if (statusEffect.type == ActionType.OnDamaged) if (statusEffect.type == ActionType.OnDamaged)
{ {
if (character.LastDamage.Afflictions == null || character.LastDamage.Afflictions.None(a => a.Prefab.AfflictionType == "damage")) { continue; } if (statusEffect.AllowedAfflictions != null && (character.LastDamage.Afflictions == null || character.LastDamage.Afflictions.None(a => statusEffect.AllowedAfflictions.Contains(a.Prefab.AfflictionType) || statusEffect.AllowedAfflictions.Contains(a.Prefab.Identifier))))
{
continue;
}
if (statusEffect.OnlyPlayerTriggered) if (statusEffect.OnlyPlayerTriggered)
{ {
if (character.LastAttacker == null || !character.LastAttacker.IsPlayer) if (character.LastAttacker == null || !character.LastAttacker.IsPlayer)
@@ -27,25 +27,24 @@ namespace Barotrauma
if (string.IsNullOrWhiteSpace(Identifier) || string.IsNullOrWhiteSpace(TargetTag)) { return false; } if (string.IsNullOrWhiteSpace(Identifier) || string.IsNullOrWhiteSpace(TargetTag)) { return false; }
List<Character> targets = ParentEvent.GetTargets(TargetTag).OfType<Character>().ToList(); List<Character> targets = ParentEvent.GetTargets(TargetTag).OfType<Character>().ToList();
if (!(targets.FirstOrDefault() is { } target)) { return false; } foreach (var target in targets)
if (TargetLimb == LimbType.None)
{ {
Affliction? affliction = target.CharacterHealth?.GetAffliction(Identifier, AllowLimbAfflictions); if (target.CharacterHealth == null) { continue; }
return affliction != null; if (TargetLimb == LimbType.None)
{
if (target.CharacterHealth.GetAffliction(Identifier, AllowLimbAfflictions) != null) { return true; }
}
IEnumerable<Affliction> afflictions = target.CharacterHealth.GetAllAfflictions().Where(affliction =>
{
LimbType? limbType = target.CharacterHealth.GetAfflictionLimb(affliction)?.type;
if (limbType == null) { return false; }
return limbType == TargetLimb || true;
});
if (afflictions.Any(a => a.Identifier.Equals(Identifier, StringComparison.OrdinalIgnoreCase))) { return true; }
} }
return false;
if (target.CharacterHealth == null) { return false; }
IEnumerable<Affliction> afflictions = target.CharacterHealth.GetAllAfflictions().Where(affliction =>
{
LimbType? limbType = target.CharacterHealth.GetAfflictionLimb(affliction)?.type;
if (limbType == null) { return false; }
return limbType == TargetLimb || true;
});
return afflictions.Any(a => a.Identifier.Equals(Identifier, StringComparison.OrdinalIgnoreCase));
} }
public override string ToDebugString() public override string ToDebugString()
@@ -190,6 +190,7 @@ namespace Barotrauma
humanAI.ClearForcedOrder(); humanAI.ClearForcedOrder();
if (prevIdleObjective != null) { humanAI.ObjectiveManager.AddObjective(prevIdleObjective); } if (prevIdleObjective != null) { humanAI.ObjectiveManager.AddObjective(prevIdleObjective); }
if (prevGotoObjective != null) { humanAI.ObjectiveManager.AddObjective(prevGotoObjective); } if (prevGotoObjective != null) { humanAI.ObjectiveManager.AddObjective(prevGotoObjective); }
humanAI.ObjectiveManager.SortObjectives();
} }
} }
@@ -117,6 +117,7 @@ namespace Barotrauma
foreach (Item item in newCharacter.Inventory.AllItems) foreach (Item item in newCharacter.Inventory.AllItems)
{ {
item.SpawnedInOutpost = true; item.SpawnedInOutpost = true;
item.AllowStealing = false;
} }
} }
humanPrefab.InitializeCharacter(newCharacter, spawnPos); humanPrefab.InitializeCharacter(newCharacter, spawnPos);
@@ -45,15 +45,15 @@ namespace Barotrauma
} }
} }
private void TagBots() private void TagBots(bool playerCrewOnly)
{ {
if (IgnoreIncapacitatedCharacters) if (IgnoreIncapacitatedCharacters)
{ {
ParentEvent.AddTargetPredicate(Tag, e => e is Character c && c.IsBot && !c.IsIncapacitated); ParentEvent.AddTargetPredicate(Tag, e => e is Character c && c.IsBot && !c.IsIncapacitated && (!playerCrewOnly || c.TeamID == CharacterTeamType.Team1));
} }
else else
{ {
ParentEvent.AddTargetPredicate(Tag, e => e is Character c && c.IsBot); ParentEvent.AddTargetPredicate(Tag, e => e is Character c && c.IsBot && (!playerCrewOnly || c.TeamID == CharacterTeamType.Team1));
} }
} }
@@ -62,7 +62,8 @@ namespace Barotrauma
#if CLIENT #if CLIENT
GameMain.GameSession.CrewManager.GetCharacters().ForEach(c => ParentEvent.AddTarget(Tag, c)); GameMain.GameSession.CrewManager.GetCharacters().ForEach(c => ParentEvent.AddTarget(Tag, c));
#else #else
TagPlayers(); TagBots(); //TODO: this seems like it would tag more than it should, fix TagPlayers();
TagBots(playerCrewOnly: true);
#endif #endif
} }
@@ -116,7 +117,7 @@ namespace Barotrauma
TagPlayers(); TagPlayers();
break; break;
case "bot": case "bot":
TagBots(); TagBots(playerCrewOnly: false);
break; break;
case "crew": case "crew":
TagCrew(); TagCrew();
@@ -321,14 +321,23 @@ namespace Barotrauma
} }
} }
RagdollParams ragdollParams; RagdollParams ragdollParams;
if (humanoid) try
{ {
ragdollParams = RagdollParams.GetRagdollParams<HumanRagdollParams>(speciesName); if (humanoid)
{
ragdollParams = RagdollParams.GetRagdollParams<HumanRagdollParams>(characterPrefab.VariantOf ?? speciesName);
}
else
{
ragdollParams = RagdollParams.GetRagdollParams<FishRagdollParams>(characterPrefab.VariantOf ?? speciesName);
}
} }
else catch (Exception e)
{ {
ragdollParams = RagdollParams.GetRagdollParams<FishRagdollParams>(speciesName); DebugConsole.ThrowError($"Failed to preload a ragdoll file for the character \"{characterPrefab.Name}\"", e);
continue;
} }
if (ragdollParams != null) if (ragdollParams != null)
{ {
HashSet<string> texturePaths = new HashSet<string> HashSet<string> texturePaths = new HashSet<string>
@@ -96,7 +96,8 @@ namespace Barotrauma
var item = new Item(itemPrefab, position, cargoRoom.Submarine) var item = new Item(itemPrefab, position, cargoRoom.Submarine)
{ {
SpawnedInOutpost = true SpawnedInOutpost = true,
AllowStealing = false
}; };
item.FindHull(); item.FindHull();
items.Add(item); items.Add(item);
@@ -205,6 +205,7 @@ namespace Barotrauma
var item = new Item(itemPrefab, validContainer.Key.Item.Position, validContainer.Key.Item.Submarine) var item = new Item(itemPrefab, validContainer.Key.Item.Position, validContainer.Key.Item.Submarine)
{ {
SpawnedInOutpost = validContainer.Key.Item.SpawnedInOutpost, SpawnedInOutpost = validContainer.Key.Item.SpawnedInOutpost,
AllowStealing = validContainer.Key.Item.AllowStealing,
OriginalModuleIndex = validContainer.Key.Item.OriginalModuleIndex, OriginalModuleIndex = validContainer.Key.Item.OriginalModuleIndex,
OriginalContainerID = validContainer.Key.Item.ID OriginalContainerID = validContainer.Key.Item.ID
}; };
@@ -461,12 +461,15 @@ namespace Barotrauma
leavingSubAtStart ??= Submarine.MainSub; leavingSubAtStart ??= Submarine.MainSub;
leavingSubAtEnd ??= Submarine.MainSub; leavingSubAtEnd ??= Submarine.MainSub;
} }
int playersInSubAtStart = leavingSubAtStart == null ? 0 : int playersInSubAtStart = leavingSubAtStart == null || !leavingSubAtStart.AtStartExit ? 0 :
leavingPlayers.Count(c => c.Submarine == leavingSubAtStart || leavingSubAtStart.DockedTo.Contains(c.Submarine) || (Level.Loaded.StartOutpost != null && c.Submarine == Level.Loaded.StartOutpost)); leavingPlayers.Count(c => c.Submarine == leavingSubAtStart || leavingSubAtStart.DockedTo.Contains(c.Submarine) || (Level.Loaded.StartOutpost != null && c.Submarine == Level.Loaded.StartOutpost));
int playersInSubAtEnd = leavingSubAtEnd == null ? 0 : int playersInSubAtEnd = leavingSubAtEnd == null || !leavingSubAtStart.AtEndExit ? 0 :
leavingPlayers.Count(c => c.Submarine == leavingSubAtEnd || leavingSubAtEnd.DockedTo.Contains(c.Submarine) || (Level.Loaded.EndOutpost != null && c.Submarine == Level.Loaded.EndOutpost)); leavingPlayers.Count(c => c.Submarine == leavingSubAtEnd || leavingSubAtEnd.DockedTo.Contains(c.Submarine) || (Level.Loaded.EndOutpost != null && c.Submarine == Level.Loaded.EndOutpost));
if (playersInSubAtStart == 0 && playersInSubAtEnd == 0) { return null; } if (playersInSubAtStart == 0 && playersInSubAtEnd == 0)
{
return null;
}
return playersInSubAtStart > playersInSubAtEnd ? leavingSubAtStart : leavingSubAtEnd; return playersInSubAtStart > playersInSubAtEnd ? leavingSubAtStart : leavingSubAtEnd;
@@ -474,7 +477,7 @@ namespace Barotrauma
{ {
if (Level.Loaded.StartOutpost == null) if (Level.Loaded.StartOutpost == null)
{ {
Submarine closestSub = Submarine.FindClosest(Level.Loaded.StartExitPosition, ignoreOutposts: true, ignoreRespawnShuttle: true); Submarine closestSub = Submarine.FindClosest(Level.Loaded.StartExitPosition, ignoreOutposts: true, ignoreRespawnShuttle: true, teamType: leavingPlayers.FirstOrDefault()?.TeamID);
return closestSub.DockedTo.Contains(Submarine.MainSub) ? Submarine.MainSub : closestSub; return closestSub.DockedTo.Contains(Submarine.MainSub) ? Submarine.MainSub : closestSub;
} }
else else
@@ -488,7 +491,7 @@ namespace Barotrauma
//nothing docked, check if there's a sub close enough to the outpost and someone inside the outpost //nothing docked, check if there's a sub close enough to the outpost and someone inside the outpost
if (Level.Loaded.Type == LevelData.LevelType.LocationConnection && !leavingPlayers.Any(s => s.Submarine == Level.Loaded.StartOutpost)) { return null; } if (Level.Loaded.Type == LevelData.LevelType.LocationConnection && !leavingPlayers.Any(s => s.Submarine == Level.Loaded.StartOutpost)) { return null; }
Submarine closestSub = Submarine.FindClosest(Level.Loaded.StartOutpost.WorldPosition, ignoreOutposts: true, ignoreRespawnShuttle: true); Submarine closestSub = Submarine.FindClosest(Level.Loaded.StartOutpost.WorldPosition, ignoreOutposts: true, ignoreRespawnShuttle: true, teamType: leavingPlayers.FirstOrDefault()?.TeamID);
if (closestSub == null || !closestSub.AtStartExit) { return null; } if (closestSub == null || !closestSub.AtStartExit) { return null; }
return closestSub.DockedTo.Contains(Submarine.MainSub) ? Submarine.MainSub : closestSub; return closestSub.DockedTo.Contains(Submarine.MainSub) ? Submarine.MainSub : closestSub;
} }
@@ -501,7 +504,7 @@ namespace Barotrauma
if (Level.Loaded.EndOutpost == null) if (Level.Loaded.EndOutpost == null)
{ {
Submarine closestSub = Submarine.FindClosest(Level.Loaded.EndPosition, ignoreOutposts: true, ignoreRespawnShuttle: true); Submarine closestSub = Submarine.FindClosest(Level.Loaded.EndExitPosition, ignoreOutposts: true, ignoreRespawnShuttle: true, teamType: leavingPlayers.FirstOrDefault()?.TeamID);
return closestSub.DockedTo.Contains(Submarine.MainSub) ? Submarine.MainSub : closestSub; return closestSub.DockedTo.Contains(Submarine.MainSub) ? Submarine.MainSub : closestSub;
} }
else else
@@ -515,7 +518,7 @@ namespace Barotrauma
//nothing docked, check if there's a sub close enough to the outpost and someone inside the outpost //nothing docked, check if there's a sub close enough to the outpost and someone inside the outpost
if (Level.Loaded.Type == LevelData.LevelType.LocationConnection && !leavingPlayers.Any(s => s.Submarine == Level.Loaded.EndOutpost)) { return null; } if (Level.Loaded.Type == LevelData.LevelType.LocationConnection && !leavingPlayers.Any(s => s.Submarine == Level.Loaded.EndOutpost)) { return null; }
Submarine closestSub = Submarine.FindClosest(Level.Loaded.EndOutpost.WorldPosition, ignoreOutposts: true, ignoreRespawnShuttle: true); Submarine closestSub = Submarine.FindClosest(Level.Loaded.EndOutpost.WorldPosition, ignoreOutposts: true, ignoreRespawnShuttle: true, teamType: leavingPlayers.FirstOrDefault()?.TeamID);
if (closestSub == null || !closestSub.AtEndExit) { return null; } if (closestSub == null || !closestSub.AtEndExit) { return null; }
return closestSub.DockedTo.Contains(Submarine.MainSub) ? Submarine.MainSub : closestSub; return closestSub.DockedTo.Contains(Submarine.MainSub) ? Submarine.MainSub : closestSub;
} }
@@ -528,7 +531,8 @@ namespace Barotrauma
foreach (Item item in Item.ItemList) foreach (Item item in Item.ItemList)
{ {
if (!item.SpawnedInOutpost || item.OriginalModuleIndex < 0) { continue; } if (!item.SpawnedInOutpost || item.OriginalModuleIndex < 0) { continue; }
if ((!(item.GetRootInventoryOwner()?.Submarine?.Info?.IsOutpost ?? false)) || item.Submarine == null || !item.Submarine.Info.IsOutpost) var owner = item.GetRootInventoryOwner();
if ((!(owner?.Submarine?.Info?.IsOutpost ?? false)) || (owner is Character character && character.TeamID == CharacterTeamType.Team1) || item.Submarine == null || !item.Submarine.Info.IsOutpost)
{ {
takenItems.Add(item); takenItems.Add(item);
} }
@@ -1,13 +1,11 @@
using Barotrauma.Networking; using Barotrauma.Networking;
using System;
using System.Xml.Linq; using System.Xml.Linq;
namespace Barotrauma.Items.Components namespace Barotrauma.Items.Components
{ {
partial class MemoryComponent : ItemComponent, IServerSerializable partial class MemoryComponent : ItemComponent, IServerSerializable
{ {
const int MaxValueLength = ChatMessage.MaxLength;
private string value; private string value;
[InGameEditable, Serialize("", true, description: "The currently stored signal the item outputs.", alwaysUseInstanceValues: true)] [InGameEditable, Serialize("", true, description: "The currently stored signal the item outputs.", alwaysUseInstanceValues: true)]
@@ -17,7 +15,22 @@ namespace Barotrauma.Items.Components
set set
{ {
if (value == null) { return; } if (value == null) { return; }
this.value = value.Length <= MaxValueLength ? value : value.Substring(0, MaxValueLength); this.value = value;
if (this.value.Length > MaxValueLength && (item.Submarine == null || !item.Submarine.Loading))
{
this.value = this.value.Substring(0, MaxValueLength);
}
}
}
private int maxValueLength;
[Editable, Serialize(200, false, description: "The maximum length of the stored value. Warning: Large values can lead to large memory usage or networking issues.")]
public int MaxValueLength
{
get { return maxValueLength; }
set
{
maxValueLength = Math.Max(value, 0);
} }
} }
@@ -43,9 +56,12 @@ namespace Barotrauma.Items.Components
case "signal_in": case "signal_in":
if (writeable) if (writeable)
{ {
if (Value == signal.value) { return; } string prevValue = Value;
Value = signal.value; Value = signal.value;
OnStateChanged(); if (Value != prevValue)
{
OnStateChanged();
}
} }
break; break;
case "signal_store": case "signal_store":
@@ -527,6 +527,8 @@ namespace Barotrauma
} }
} }
public bool AllowStealing = true;
private string originalOutpost; private string originalOutpost;
[Serialize("", true, alwaysUseInstanceValues: true)] [Serialize("", true, alwaysUseInstanceValues: true)]
public string OriginalOutpost public string OriginalOutpost
@@ -1066,6 +1066,7 @@ namespace Barotrauma
case "connection": case "connection":
int connectionIndex = subElement.GetAttributeInt("i", 0); int connectionIndex = subElement.GetAttributeInt("i", 0);
Connections[connectionIndex].Passed = subElement.GetAttributeBool("passed", false); Connections[connectionIndex].Passed = subElement.GetAttributeBool("passed", false);
Connections[connectionIndex].Locked = subElement.GetAttributeBool("locked", false);
break; break;
case "radiation": case "radiation":
Radiation = new Radiation(this, generationParams.RadiationParams, subElement); Radiation = new Radiation(this, generationParams.RadiationParams, subElement);
@@ -1425,7 +1425,8 @@ namespace Barotrauma
humanPrefab.GiveItems(npc, outpost, Rand.RandSync.Server); humanPrefab.GiveItems(npc, outpost, Rand.RandSync.Server);
foreach (Item item in npc.Inventory.FindAllItems(it => it != null, recursive: true)) foreach (Item item in npc.Inventory.FindAllItems(it => it != null, recursive: true))
{ {
item.SpawnedInOutpost = !outpost.Info.OutpostGenerationParams.AllowStealing; item.AllowStealing = outpost.Info.OutpostGenerationParams.AllowStealing;
item.SpawnedInOutpost = true;
} }
npc.GiveIdCardTags(gotoTarget as WayPoint); npc.GiveIdCardTags(gotoTarget as WayPoint);
humanPrefab.InitializeCharacter(npc, gotoTarget); humanPrefab.InitializeCharacter(npc, gotoTarget);
@@ -1175,7 +1175,8 @@ namespace Barotrauma
subBody.SetPosition(subBody.Position + amount); subBody.SetPosition(subBody.Position + amount);
} }
public static Submarine FindClosest(Vector2 worldPosition, bool ignoreOutposts = false, bool ignoreOutsideLevel = true, bool ignoreRespawnShuttle = false) /// <param name="teamType">If has value, the sub must match the team type.</param>
public static Submarine FindClosest(Vector2 worldPosition, bool ignoreOutposts = false, bool ignoreOutsideLevel = true, bool ignoreRespawnShuttle = false, CharacterTeamType? teamType = null)
{ {
Submarine closest = null; Submarine closest = null;
float closestDist = 0.0f; float closestDist = 0.0f;
@@ -1187,6 +1188,7 @@ namespace Barotrauma
{ {
if (sub == GameMain.NetworkMember?.RespawnManager?.RespawnShuttle) { continue; } if (sub == GameMain.NetworkMember?.RespawnManager?.RespawnShuttle) { continue; }
} }
if (teamType.HasValue && sub.TeamID != teamType) { continue; }
float dist = Vector2.DistanceSquared(worldPosition, sub.WorldPosition); float dist = Vector2.DistanceSquared(worldPosition, sub.WorldPosition);
if (closest == null || dist < closestDist) if (closest == null || dist < closestDist)
{ {
@@ -1359,7 +1361,8 @@ namespace Barotrauma
if (me.Submarine != this) { continue; } if (me.Submarine != this) { continue; }
if (me is Item item) if (me is Item item)
{ {
item.SpawnedInOutpost = info.OutpostGenerationParams != null && !info.OutpostGenerationParams.AllowStealing; item.SpawnedInOutpost = info.OutpostGenerationParams != null;
item.AllowStealing = info.OutpostGenerationParams?.AllowStealing ?? true;
if (item.GetComponent<Repairable>() != null && indestructible) if (item.GetComponent<Repairable>() != null && indestructible)
{ {
item.Indestructible = true; item.Indestructible = true;
@@ -289,6 +289,8 @@ namespace Barotrauma
get { return targetIdentifiers; } get { return targetIdentifiers; }
} }
public HashSet<string> AllowedAfflictions { get; private set; }
public List<Affliction> Afflictions public List<Affliction> Afflictions
{ {
get; get;
@@ -421,6 +423,14 @@ namespace Barotrauma
targetIdentifiers.Add(identifiers[i].Trim().ToLowerInvariant()); targetIdentifiers.Add(identifiers[i].Trim().ToLowerInvariant());
} }
break; break;
case "allowedafflictions":
string[] types = attribute.Value.Split(',');
AllowedAfflictions = new HashSet<string>();
for (int i = 0; i < types.Length; i++)
{
AllowedAfflictions.Add(types[i].Trim().ToLowerInvariant());
}
break;
case "duration": case "duration":
duration = attribute.GetAttributeFloat(0.0f); duration = attribute.GetAttributeFloat(0.0f);
break; break;
+19
View File
@@ -1,3 +1,22 @@
---------------------------------------------------------------------------------------------------------
v0.1300.0.8 (unstable)
---------------------------------------------------------------------------------------------------------
Changes:
- Increased the delay with which the boss health bar is faded from 10 to 60 seconds.
- Modding: Allow to define afflictions (types or identifiers) to trigger the OnDamaged status effects only from certain afflictions and not all that do the damage. If the afflictions property is not defined, no restrictions are used (works as it used to).
- Added MaxValueLength property to memory component.
Fixes:
- Fixed networking errors when the server tries to send an update for a Holdable component that's not attachable, leading to various issues (disconnects, "failed to read ..." errors).
- Fixed "enter location" button not appearing in some levels where there's no outpost at the destination and a beacon station near the exit.
- Fixed event to heal Reaper's Tax not triggering in outposts.
- Fixed server starting the respawn countdown when a disconnected client whose character is still alive rejoins.
- Removed outdated steamclient.so file from the dedicated server (no longer needed because it's automatically installed by Steamworks). Should fix inability to host dedicated servers on Linux.
- Fixed job preferences not having an effect on who gets assigned as the captain.
- Fixed items taken from abandoned outposts reappearing when you leave and re-enter the outpost.
- Fixed crashing/disconnects when preloading content at the start of a round if random events contain character variants. In practice, mods that used character variants in random events occasionally prevented rounds from starting.
--------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------
v0.1300.0.7 (unstable) v0.1300.0.7 (unstable)
--------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------
Binary file not shown.