(0835d92e6) More reliable throw StatusEffect (= grenade explosion) syncing. Previously the clients would simply apply the statuseffects themselves when a client throws something, which most of the time didn't work because character inputs are sent unreliably and the item may have already been taken out from the character's inventory by a reliable NetEntityEvent by the time the throw input arrives.
This commit is contained in:
@@ -104,8 +104,8 @@ namespace Barotrauma.Items.Components
|
|||||||
#if SERVER
|
#if SERVER
|
||||||
GameServer.Log(picker.LogName + " threw " + item.Name, ServerLog.MessageType.ItemInteraction);
|
GameServer.Log(picker.LogName + " threw " + item.Name, ServerLog.MessageType.ItemInteraction);
|
||||||
#endif
|
#endif
|
||||||
|
Character thrower = picker;
|
||||||
item.Drop(picker, createNetworkEvent: GameMain.NetworkMember == null || GameMain.NetworkMember.IsServer);
|
item.Drop(thrower, createNetworkEvent: GameMain.NetworkMember == null || GameMain.NetworkMember.IsServer);
|
||||||
item.body.ApplyLinearImpulse(throwVector * throwForce * item.body.Mass * 3.0f);
|
item.body.ApplyLinearImpulse(throwVector * throwForce * item.body.Mass * 3.0f);
|
||||||
|
|
||||||
ac.GetLimb(LimbType.Head).body.ApplyLinearImpulse(throwVector*10.0f);
|
ac.GetLimb(LimbType.Head).body.ApplyLinearImpulse(throwVector*10.0f);
|
||||||
@@ -115,7 +115,15 @@ namespace Barotrauma.Items.Components
|
|||||||
item.body.AngularVelocity = rightHand.body.AngularVelocity;
|
item.body.AngularVelocity = rightHand.body.AngularVelocity;
|
||||||
throwPos = 0;
|
throwPos = 0;
|
||||||
throwDone = true;
|
throwDone = true;
|
||||||
ApplyStatusEffects(ActionType.OnSecondaryUse, deltaTime, picker); //Stun grenades, flares, etc. all have their throw-related things handled in "onSecondaryUse"
|
|
||||||
|
if (GameMain.NetworkMember != null && GameMain.NetworkMember.IsServer)
|
||||||
|
{
|
||||||
|
GameMain.NetworkMember.CreateEntityEvent(item, new object[] { NetEntityEvent.Type.ApplyStatusEffect, ActionType.OnSecondaryUse, this, thrower.ID });
|
||||||
|
}
|
||||||
|
if (GameMain.NetworkMember == null || GameMain.NetworkMember.IsServer)
|
||||||
|
{
|
||||||
|
ApplyStatusEffects(ActionType.OnSecondaryUse, deltaTime, thrower); //Stun grenades, flares, etc. all have their throw-related things handled in "onSecondaryUse"
|
||||||
|
}
|
||||||
throwing = false;
|
throwing = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user