diff --git a/Subsurface/Source/Items/CharacterInventory.cs b/Subsurface/Source/Items/CharacterInventory.cs index 49a0d64ed..f04985292 100644 --- a/Subsurface/Source/Items/CharacterInventory.cs +++ b/Subsurface/Source/Items/CharacterInventory.cs @@ -104,7 +104,7 @@ namespace Barotrauma if (GameMain.Server != null) { - GameMain.Server.CreateEntityEvent(Items[slotIndex], new object[] { NetEntityEvent.Type.ApplyStatusEffect, character.ID }); + GameMain.Server.CreateEntityEvent(Items[slotIndex], new object[] { NetEntityEvent.Type.ApplyStatusEffect, ActionType.OnUse, character.ID }); } Items[slotIndex].ApplyStatusEffects(ActionType.OnUse, 1.0f, character); diff --git a/Subsurface/Source/Items/Components/Holdable/MeleeWeapon.cs b/Subsurface/Source/Items/Components/Holdable/MeleeWeapon.cs index b8c6acdb1..b8be537c3 100644 --- a/Subsurface/Source/Items/Components/Holdable/MeleeWeapon.cs +++ b/Subsurface/Source/Items/Components/Holdable/MeleeWeapon.cs @@ -242,7 +242,7 @@ namespace Barotrauma.Items.Components if (GameMain.Server != null) { - GameMain.Server.CreateEntityEvent(item, new object[] { Networking.NetEntityEvent.Type.ApplyStatusEffect, target.ID }); + GameMain.Server.CreateEntityEvent(item, new object[] { Networking.NetEntityEvent.Type.ApplyStatusEffect, ActionType.OnUse, target.ID }); string logStr = picker?.Name + " used " + item.Name; if (item.ContainedItems != null && item.ContainedItems.Length > 0) diff --git a/Subsurface/Source/Items/Item.cs b/Subsurface/Source/Items/Item.cs index 6e7b2e829..a6d46d672 100644 --- a/Subsurface/Source/Items/Item.cs +++ b/Subsurface/Source/Items/Item.cs @@ -645,7 +645,7 @@ namespace Barotrauma } - public void ApplyStatusEffects(ActionType type, float deltaTime, Character character = null) + public void ApplyStatusEffects(ActionType type, float deltaTime, Character character = null, bool isNetworkEvent = false) { if (statusEffectLists == null) return; @@ -654,13 +654,16 @@ namespace Barotrauma foreach (StatusEffect effect in statusEffects) { - ApplyStatusEffect(effect, type, deltaTime, character); + ApplyStatusEffect(effect, type, deltaTime, character, isNetworkEvent); } } - public void ApplyStatusEffect(StatusEffect effect, ActionType type, float deltaTime, Character character = null) + public void ApplyStatusEffect(StatusEffect effect, ActionType type, float deltaTime, Character character = null, bool isNetworkEvent = false) { - if (condition == 0.0f && effect.type != ActionType.OnBroken) return; + if (!isNetworkEvent) + { + if (condition == 0.0f && effect.type != ActionType.OnBroken) return; + } if (effect.type != type) return; bool hasTargets = (effect.TargetNames == null); @@ -1718,7 +1721,10 @@ namespace Barotrauma } break; case NetEntityEvent.Type.ApplyStatusEffect: - ushort targetID = (ushort)extraData[1]; + ActionType actionType = (ActionType)extraData[1]; + ushort targetID = extraData.Length > 2 ? (ushort)extraData[2] : (ushort)0; + + msg.WriteRangedInteger(0, Enum.GetValues(typeof(ActionType)).Length - 1, (int)actionType); msg.Write(targetID); break; case NetEntityEvent.Type.ChangeProperty: @@ -1765,13 +1771,11 @@ namespace Barotrauma } break; case NetEntityEvent.Type.ApplyStatusEffect: + ActionType actionType = (ActionType)msg.ReadRangedInteger(0, Enum.GetValues(typeof(ActionType)).Length -1); ushort targetID = msg.ReadUInt16(); Character target = FindEntityByID(targetID) as Character; - - if (target == null) return; - - ApplyStatusEffects(ActionType.OnUse, (float)Timing.Step, target); + ApplyStatusEffects(actionType, (float)Timing.Step, target, true); break; case NetEntityEvent.Type.ChangeProperty: ReadPropertyChange(msg); @@ -1856,7 +1860,7 @@ namespace Barotrauma GameServer.Log(c.Character.Name + " used item " + Name, ServerLog.MessageType.ItemInteraction); - GameMain.Server.CreateEntityEvent(this, new object[] { NetEntityEvent.Type.ApplyStatusEffect, c.Character.ID }); + GameMain.Server.CreateEntityEvent(this, new object[] { NetEntityEvent.Type.ApplyStatusEffect, ActionType.OnUse, c.Character.ID }); break; case NetEntityEvent.Type.ChangeProperty: diff --git a/Subsurface/Source/Map/Explosion.cs b/Subsurface/Source/Map/Explosion.cs index 11ec803a0..2040e6d03 100644 --- a/Subsurface/Source/Map/Explosion.cs +++ b/Subsurface/Source/Map/Explosion.cs @@ -3,6 +3,7 @@ using Barotrauma.Lights; using System; using System.Collections.Generic; using System.Xml.Linq; +using Barotrauma.Networking; using FarseerPhysics; namespace Barotrauma @@ -91,6 +92,11 @@ namespace Barotrauma if (Vector2.Distance(item.WorldPosition, worldPosition) > attack.Range * 0.1f) continue; item.ApplyStatusEffects(ActionType.OnFire, 1.0f); + + if (item.Condition <= 0.0f) + { + GameMain.Server.CreateEntityEvent(item, new object[] { NetEntityEvent.Type.ApplyStatusEffect, ActionType.OnFire }); + } } } diff --git a/Subsurface/Source/Map/FireSource.cs b/Subsurface/Source/Map/FireSource.cs index c0a67531d..b15b307fd 100644 --- a/Subsurface/Source/Map/FireSource.cs +++ b/Subsurface/Source/Map/FireSource.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; +using Barotrauma.Networking; namespace Barotrauma { @@ -267,7 +268,7 @@ namespace Barotrauma private void DamageItems(float deltaTime) { - if (size.X <= 0.0f) return; + if (size.X <= 0.0f || GameMain.Client != null) return; foreach (Item item in Item.ItemList) { @@ -277,8 +278,12 @@ namespace Barotrauma float range = (float)Math.Sqrt(size.X) * 10.0f; if (item.Position.X < position.X - range || item.Position.X > position.X + size.X + range) continue; if (item.Position.Y < position.Y - size.Y || item.Position.Y > hull.Rect.Y) continue; - - if (GameMain.Client == null) item.ApplyStatusEffects(ActionType.OnFire, deltaTime); + + item.ApplyStatusEffects(ActionType.OnFire, deltaTime); + if (item.Condition <= 0.0f) + { + GameMain.Server.CreateEntityEvent(item, new object[] { NetEntityEvent.Type.ApplyStatusEffect, ActionType.OnFire }); + } } }