Syncing StatusEffects applied by meleeweapons or using an item on self
This commit is contained in:
@@ -96,8 +96,16 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (Items[slotIndex] == null) return false;
|
if (Items[slotIndex] == null) return false;
|
||||||
|
|
||||||
//save the ID in a variable in case the statuseffect causes the item to be dropped/destroyed
|
if (GameMain.Client != null)
|
||||||
ushort itemID = Items[slotIndex].ID;
|
{
|
||||||
|
GameMain.Client.CreateEntityEvent(Items[slotIndex], new object[] { NetEntityEvent.Type.ApplyStatusEffect });
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GameMain.Server != null)
|
||||||
|
{
|
||||||
|
GameMain.Server.CreateEntityEvent(Items[slotIndex], new object[] { NetEntityEvent.Type.ApplyStatusEffect, character.ID });
|
||||||
|
}
|
||||||
|
|
||||||
Items[slotIndex].ApplyStatusEffects(ActionType.OnUse, 1.0f, character);
|
Items[slotIndex].ApplyStatusEffects(ActionType.OnUse, 1.0f, character);
|
||||||
|
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
private bool OnCollision(Fixture f1, Fixture f2, Contact contact)
|
private bool OnCollision(Fixture f1, Fixture f2, Contact contact)
|
||||||
{
|
{
|
||||||
IDamageable target = null;
|
Character target = null;
|
||||||
|
|
||||||
Limb limb = f2.Body.UserData as Limb;
|
Limb limb = f2.Body.UserData as Limb;
|
||||||
if (limb != null)
|
if (limb != null)
|
||||||
@@ -227,16 +227,23 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
if (target == null)
|
if (target == null)
|
||||||
{
|
{
|
||||||
target = f2.Body.UserData as IDamageable;
|
target = f2.Body.UserData as Character;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target == null) return false;
|
if (target == null) return false;
|
||||||
|
|
||||||
if (attack!=null) attack.DoDamage(user, target, item.WorldPosition, 1.0f);
|
if (attack != null) attack.DoDamage(user, target, item.WorldPosition, 1.0f);
|
||||||
|
|
||||||
RestoreCollision();
|
RestoreCollision();
|
||||||
hitting = false;
|
hitting = false;
|
||||||
|
|
||||||
|
if (GameMain.Client != null) return true;
|
||||||
|
|
||||||
|
if (GameMain.Server != null)
|
||||||
|
{
|
||||||
|
GameMain.Server.CreateEntityEvent(item, new object[] { Barotrauma.Networking.NetEntityEvent.Type.ApplyStatusEffect, target.ID });
|
||||||
|
}
|
||||||
|
|
||||||
ApplyStatusEffects(ActionType.OnUse, 1.0f, limb.character);
|
ApplyStatusEffects(ActionType.OnUse, 1.0f, limb.character);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -660,7 +660,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
foreach (string s in effect.OnContainingNames)
|
foreach (string s in effect.OnContainingNames)
|
||||||
{
|
{
|
||||||
if (!containedItems.Any(x => x!=null && x.Name==s && x.Condition > 0.0f)) return;
|
if (!containedItems.Any(x => x != null && x.Name == s && x.Condition > 0.0f)) return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -699,7 +699,6 @@ namespace Barotrauma
|
|||||||
targets.Add(CurrentHull);
|
targets.Add(CurrentHull);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (effect.Targets.HasFlag(StatusEffect.TargetType.This))
|
if (effect.Targets.HasFlag(StatusEffect.TargetType.This))
|
||||||
{
|
{
|
||||||
foreach (var pobject in AllPropertyObjects)
|
foreach (var pobject in AllPropertyObjects)
|
||||||
@@ -707,21 +706,12 @@ namespace Barotrauma
|
|||||||
targets.Add(pobject);
|
targets.Add(pobject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//effect.Apply(type, deltaTime, this);
|
|
||||||
//ApplyStatusEffect(effect, type, deltaTime, this);
|
|
||||||
|
|
||||||
if (effect.Targets.HasFlag(StatusEffect.TargetType.Character)) targets.Add(character);
|
if (effect.Targets.HasFlag(StatusEffect.TargetType.Character)) targets.Add(character);
|
||||||
//effect.Apply(type, deltaTime, null, Character);
|
|
||||||
//ApplyStatusEffect(effect, type, deltaTime, null, Character, limb);
|
|
||||||
|
|
||||||
if (Container != null && effect.Targets.HasFlag(StatusEffect.TargetType.Parent)) targets.Add(Container);
|
if (Container != null && effect.Targets.HasFlag(StatusEffect.TargetType.Parent)) targets.Add(Container);
|
||||||
//{
|
|
||||||
// effect.Apply(type, deltaTime, container);
|
|
||||||
// //container.ApplyStatusEffect(effect, type, deltaTime, container);
|
|
||||||
//}
|
|
||||||
|
|
||||||
effect.Apply(type, deltaTime, this, targets);
|
effect.Apply(type, deltaTime, this, targets);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1670,7 +1660,8 @@ namespace Barotrauma
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg.WriteRangedInteger(0, 2, (int)((NetEntityEvent.Type)extraData[0]));
|
//TODO: use WriteRangedInteger to write the event type
|
||||||
|
msg.Write((byte)((int)extraData[0]));
|
||||||
switch ((NetEntityEvent.Type)extraData[0])
|
switch ((NetEntityEvent.Type)extraData[0])
|
||||||
{
|
{
|
||||||
case NetEntityEvent.Type.ComponentState:
|
case NetEntityEvent.Type.ComponentState:
|
||||||
@@ -1691,12 +1682,16 @@ namespace Barotrauma
|
|||||||
msg.Write(FixRequirements[i].Fixed);
|
msg.Write(FixRequirements[i].Fixed);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case NetEntityEvent.Type.ApplyStatusEffect:
|
||||||
|
ushort targetID = (ushort)extraData[1];
|
||||||
|
msg.Write(targetID);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClientRead(ServerNetObject type, NetIncomingMessage msg, float sendingTime)
|
public void ClientRead(ServerNetObject type, NetIncomingMessage msg, float sendingTime)
|
||||||
{
|
{
|
||||||
NetEntityEvent.Type eventType = (NetEntityEvent.Type)msg.ReadRangedInteger(0, 2);
|
NetEntityEvent.Type eventType = (NetEntityEvent.Type)msg.ReadByte();
|
||||||
switch (eventType)
|
switch (eventType)
|
||||||
{
|
{
|
||||||
case NetEntityEvent.Type.ComponentState:
|
case NetEntityEvent.Type.ComponentState:
|
||||||
@@ -1723,6 +1718,15 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case NetEntityEvent.Type.ApplyStatusEffect:
|
||||||
|
ushort targetID = msg.ReadUInt16();
|
||||||
|
|
||||||
|
Character target = FindEntityByID(targetID) as Character;
|
||||||
|
|
||||||
|
if (target == null) return;
|
||||||
|
|
||||||
|
ApplyStatusEffects(ActionType.OnUse, (float)Timing.Step, target);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1753,6 +1757,8 @@ namespace Barotrauma
|
|||||||
msg.WriteRangedInteger(0, FixRequirements.Count - 1, requirementIndex);
|
msg.WriteRangedInteger(0, FixRequirements.Count - 1, requirementIndex);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case NetEntityEvent.Type.ApplyStatusEffect:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1775,12 +1781,20 @@ namespace Barotrauma
|
|||||||
int requirementIndex = FixRequirements.Count == 1 ?
|
int requirementIndex = FixRequirements.Count == 1 ?
|
||||||
0 : msg.ReadRangedInteger(0, FixRequirements.Count - 1);
|
0 : msg.ReadRangedInteger(0, FixRequirements.Count - 1);
|
||||||
|
|
||||||
if (!c.Character.CanAccessItem(this)) return;
|
if (c.Character == null || !c.Character.CanAccessItem(this)) return;
|
||||||
if (!FixRequirements[requirementIndex].CanBeFixed(c.Character)) return;
|
if (!FixRequirements[requirementIndex].CanBeFixed(c.Character)) return;
|
||||||
|
|
||||||
FixRequirements[requirementIndex].Fixed = true;
|
FixRequirements[requirementIndex].Fixed = true;
|
||||||
GameMain.Server.CreateEntityEvent(this, new object[] { NetEntityEvent.Type.Status });
|
GameMain.Server.CreateEntityEvent(this, new object[] { NetEntityEvent.Type.Status });
|
||||||
|
|
||||||
|
break;
|
||||||
|
case NetEntityEvent.Type.ApplyStatusEffect:
|
||||||
|
if (c.Character == null || !c.Character.CanAccessItem(this)) return;
|
||||||
|
|
||||||
|
ApplyStatusEffects(ActionType.OnUse, (float)Timing.Step, c.Character);
|
||||||
|
|
||||||
|
GameMain.Server.CreateEntityEvent(this, new object[] { NetEntityEvent.Type.ApplyStatusEffect, c.Character.ID });
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ namespace Barotrauma.Networking
|
|||||||
ComponentState,
|
ComponentState,
|
||||||
InventoryState,
|
InventoryState,
|
||||||
Status,
|
Status,
|
||||||
RepairItem
|
RepairItem,
|
||||||
|
ApplyStatusEffect
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly Entity Entity;
|
public readonly Entity Entity;
|
||||||
|
|||||||
Reference in New Issue
Block a user