diff --git a/Barotrauma/BarotraumaClient/Source/GUI/GUI.cs b/Barotrauma/BarotraumaClient/Source/GUI/GUI.cs index ec5b88851..cbb751f50 100644 --- a/Barotrauma/BarotraumaClient/Source/GUI/GUI.cs +++ b/Barotrauma/BarotraumaClient/Source/GUI/GUI.cs @@ -656,6 +656,13 @@ namespace Barotrauma msg.Timer -= deltaTime; msg.Pos += msg.Velocity * deltaTime; } + + foreach (GUIMessage msg in messages) + { + if (!msg.WorldSpace) continue; + msg.Timer -= deltaTime; + msg.Pos += msg.Velocity * deltaTime; + } } messages.RemoveAll(m => m.Timer <= 0.0f); diff --git a/Barotrauma/BarotraumaServer/Source/Networking/NetEntityEvent/ServerEntityEventManager.cs b/Barotrauma/BarotraumaServer/Source/Networking/NetEntityEvent/ServerEntityEventManager.cs index 31c6a76d6..a4be15f3c 100644 --- a/Barotrauma/BarotraumaServer/Source/Networking/NetEntityEvent/ServerEntityEventManager.cs +++ b/Barotrauma/BarotraumaServer/Source/Networking/NetEntityEvent/ServerEntityEventManager.cs @@ -332,7 +332,7 @@ namespace Barotrauma.Networking } } - if (client.NeedsMidRoundSync) + foreach (NetEntityEvent entityEvent in sentEvents) { msg.Write((byte)ServerNetObject.ENTITY_EVENT_INITIAL); msg.Write(client.UnreceivedEntityEventCount); @@ -340,36 +340,13 @@ namespace Barotrauma.Networking Write(msg, eventsToSync, out sentEvents, client); } - else + + foreach (NetEntityEvent entityEvent in sentEvents) { msg.Write((byte)ServerNetObject.ENTITY_EVENT); Write(msg, eventsToSync, out sentEvents, client); } - foreach (NetEntityEvent entityEvent in sentEvents) - { - (entityEvent as ServerEntityEvent).Sent = true; - client.EntityEventLastSent[entityEvent.ID] = NetTime.Now; - } - - foreach (NetEntityEvent entityEvent in sentEvents) - { - (entityEvent as ServerEntityEvent).Sent = true; - client.EntityEventLastSent[entityEvent.ID] = NetTime.Now; - } - - foreach (NetEntityEvent entityEvent in sentEvents) - { - (entityEvent as ServerEntityEvent).Sent = true; - client.EntityEventLastSent[entityEvent.ID] = NetTime.Now; - } - - foreach (NetEntityEvent entityEvent in sentEvents) - { - (entityEvent as ServerEntityEvent).Sent = true; - client.EntityEventLastSent[entityEvent.ID] = NetTime.Now; - } - foreach (NetEntityEvent entityEvent in sentEvents) { (entityEvent as ServerEntityEvent).Sent = true; diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs index e3ebb7c80..8b57c71ba 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/EnemyAIController.cs @@ -726,7 +726,8 @@ namespace Barotrauma if (!canAttack && !IsCoolDownRunning) { // If not, reset the attacking limb, if the cooldown is not running - AttackingLimb = null; + // Don't use the property, because we don't want cancel reversing, if we are reversing. + _attackingLimb = null; } } @@ -1133,49 +1134,6 @@ namespace Barotrauma } } else if (targetCharacter.Submarine != null && Character.Submarine == null) - { - targetingTag = "dead"; - if (targetCharacter.Submarine != Character.Submarine) - { - // In a different sub or the target is outside when we are inside or vice versa -> Ignore the target - continue; - } - else if (targetCharacter.CurrentHull != Character.CurrentHull) - { - // In the same sub, halve the priority, if not in the same hull. - valueModifier = 0.5f; - } - } - else if (targetCharacter.AIController is EnemyAIController enemy) - { - if (enemy.combatStrength > combatStrength) - { - targetingTag = "stronger"; - } - else if (enemy.combatStrength < combatStrength) - { - targetingTag = "weaker"; - } - if (State == AIState.Escape && targetingTag == "stronger") - { - // Frightened - valueModifier = 2; - } - else - { - if (targetCharacter.Submarine != Character.Submarine) - { - // In a different sub or the target is outside when we are inside or vice versa -> Ignore the target - continue; - } - else if (targetCharacter.CurrentHull != Character.CurrentHull) - { - // In the same sub, halve the priority, if not in the same hull. - valueModifier = 0.5f; - } - } - } - else if (targetCharacter.Submarine != null && Character.Submarine == null) { //target inside, AI outside -> we'll be attacking a wall between the characters so use the priority for attacking rooms targetingTag = "room"; @@ -1259,11 +1217,49 @@ namespace Barotrauma valueModifier = isOutdoor ? 1 : 0; valueModifier *= isOpen ? 5 : 1; } - for (int i = 0; i < s.Sections.Length; i++) + } + } + else if (targetCharacter.Submarine != null && Character.Submarine == null) + { + targetingTag = "dead"; + if (targetCharacter.Submarine != Character.Submarine) + { + // In a different sub or the target is outside when we are inside or vice versa -> Ignore the target + continue; + } + else if (targetCharacter.CurrentHull != Character.CurrentHull) + { + // In the same sub, halve the priority, if not in the same hull. + valueModifier = 0.5f; + } + } + else if (targetCharacter.AIController is EnemyAIController enemy) + { + if (enemy.combatStrength > combatStrength) + { + targetingTag = "stronger"; + } + else if (enemy.combatStrength < combatStrength) + { + targetingTag = "weaker"; + } + if (State == AIState.Escape && targetingTag == "stronger") + { + // Frightened + valueModifier = 2; + } + else + { + if (targetCharacter.Submarine != Character.Submarine) { valueModifier = isOutdoor ? 0 : 1; valueModifier *= isOpen ? 0 : 1; } + else if (targetCharacter.CurrentHull != Character.CurrentHull) + { + // In the same sub, halve the priority, if not in the same hull. + valueModifier = 0.5f; + } } else if (isOpen) //ignore broken and open doors { @@ -1281,6 +1277,11 @@ namespace Barotrauma valueModifier *= targetingPriorities[targetingTag].Priority; + if (targetingTag == null) continue; + if (!targetingPriorities.ContainsKey(targetingTag)) continue; + + valueModifier *= targetingPriorities[targetingTag].Priority; + if (valueModifier == 0.0f) continue; Vector2 toTarget = target.WorldPosition - character.WorldPosition; diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/ItemComponent.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/ItemComponent.cs index d74524d9e..e0050c17c 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/ItemComponent.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/ItemComponent.cs @@ -538,6 +538,7 @@ namespace Barotrauma.Items.Components GameAnalyticsManager.AddErrorEventOnce("ItemComponent.DegreeOfSuccess:CharacterNull", GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg); return 0.0f; } + float average = skillSuccessSum / requiredSkills.Count; float skillSuccessSum = 0.0f; for (int i = 0; i < requiredSkills.Count; i++) @@ -734,13 +735,15 @@ namespace Barotrauma.Items.Components private void OverrideRequiredItems(XElement element) { var prevRequiredItems = new Dictionary>(requiredItems); - requiredItems.Clear(); - + bool overrideRequiredItems = false; foreach (XElement subElement in element.Elements()) { switch (subElement.Name.ToString().ToLowerInvariant()) { case "requireditem": + if (!overrideRequiredItems) requiredItems.Clear(); + overrideRequiredItems = true; + RelatedItem newRequiredItem = RelatedItem.Load(subElement, item.Name); if (newRequiredItem == null) continue; diff --git a/Barotrauma/BarotraumaShared/Source/Items/ItemPrefab.cs b/Barotrauma/BarotraumaShared/Source/Items/ItemPrefab.cs index 6b479da1d..4569eb0b6 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/ItemPrefab.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/ItemPrefab.cs @@ -719,6 +719,39 @@ namespace Barotrauma AllowedLinks = element.GetAttributeStringArray("allowedlinks", new string[0], convertToLowerInvariant: true).ToList(); + if (sprite == null) + { + DebugConsole.ThrowError("Item \"" + Name + "\" has no sprite!"); +#if SERVER + sprite = new Sprite("", Vector2.Zero); + sprite.SourceRect = new Rectangle(0, 0, 32, 32); +#else + sprite = new Sprite(TextureLoader.PlaceHolderTexture, null, null) + { + Origin = TextureLoader.PlaceHolderTexture.Bounds.Size.ToVector2() / 2 + }; +#endif + size = sprite.size; + sprite.EntityID = identifier; + } + + if (!category.HasFlag(MapEntityCategory.Legacy) && string.IsNullOrEmpty(identifier)) + { + DebugConsole.ThrowError( + "Item prefab \"" + name + "\" has no identifier. All item prefabs have a unique identifier string that's used to differentiate between items during saving and loading."); + } + if (!string.IsNullOrEmpty(identifier)) + { + MapEntityPrefab existingPrefab = List.Find(e => e.Identifier == identifier); + if (existingPrefab != null) + { + DebugConsole.ThrowError( + "Map entity prefabs \"" + name + "\" and \"" + existingPrefab.Name + "\" have the same identifier!"); + } + } + + AllowedLinks = element.GetAttributeStringArray("allowedlinks", new string[0], convertToLowerInvariant: true).ToList(); + List.Add(this); }