(7e8f246d2) Fixed clients not seeing turrets rotating at their end when another client is operating the turret. Happened because the cursor position was only synced when the aim key was pressed, and aiming is not required anymore when using turrets.
This commit is contained in:
@@ -181,13 +181,11 @@ namespace Barotrauma
|
||||
bool attackInput = msg.ReadBoolean();
|
||||
keys[(int)InputType.Attack].Held = attackInput;
|
||||
keys[(int)InputType.Attack].SetState(false, attackInput);
|
||||
|
||||
if (aimInput)
|
||||
{
|
||||
double aimAngle = ((double)msg.ReadUInt16() / 65535.0) * 2.0 * Math.PI;
|
||||
cursorPosition = AimRefPosition + new Vector2((float)Math.Cos(aimAngle), (float)Math.Sin(aimAngle)) * 60.0f;
|
||||
TransformCursorPos();
|
||||
}
|
||||
|
||||
double aimAngle = msg.ReadUInt16() / 65535.0 * 2.0 * Math.PI;
|
||||
cursorPosition = AimRefPosition + new Vector2((float)Math.Cos(aimAngle), (float)Math.Sin(aimAngle)) * 60.0f;
|
||||
TransformCursorPos();
|
||||
|
||||
bool ragdollInput = msg.ReadBoolean();
|
||||
keys[(int)InputType.Ragdoll].Held = ragdollInput;
|
||||
keys[(int)InputType.Ragdoll].SetState(false, ragdollInput);
|
||||
|
||||
@@ -354,12 +354,10 @@ namespace Barotrauma
|
||||
tempBuffer.Write(((HumanoidAnimController)AnimController).Crouching);
|
||||
}
|
||||
tempBuffer.Write(attack);
|
||||
|
||||
if (aiming)
|
||||
{
|
||||
Vector2 relativeCursorPos = cursorPosition - AimRefPosition;
|
||||
tempBuffer.Write((UInt16)(65535.0 * Math.Atan2(relativeCursorPos.Y, relativeCursorPos.X) / (2.0 * Math.PI)));
|
||||
}
|
||||
|
||||
Vector2 relativeCursorPos = cursorPosition - AimRefPosition;
|
||||
tempBuffer.Write((UInt16)(65535.0 * Math.Atan2(relativeCursorPos.Y, relativeCursorPos.X) / (2.0 * Math.PI)));
|
||||
|
||||
tempBuffer.Write(IsRagdolled || IsUnconscious || Stun > 0.0f || IsDead);
|
||||
|
||||
tempBuffer.Write(AnimController.Dir > 0.0f);
|
||||
|
||||
@@ -489,24 +489,20 @@ namespace Barotrauma.Items.Components
|
||||
closestDist = dist;
|
||||
}
|
||||
|
||||
if (closestEnemy == null) return false;
|
||||
if (closestEnemy == null) { return false; }
|
||||
|
||||
character.AIController.SelectTarget(closestEnemy.AiTarget);
|
||||
|
||||
character.CursorPosition = closestEnemy.WorldPosition;
|
||||
if (item.Submarine != null) character.CursorPosition -= item.Submarine.Position;
|
||||
|
||||
//force aim input even if the turret doesn't require it,
|
||||
//because the cursor position (and consequently, turret aim direction) is only synced to clients when aiming
|
||||
character.SetInput(InputType.Aim, false, true);
|
||||
|
||||
if (item.Submarine != null) { character.CursorPosition -= item.Submarine.Position; }
|
||||
|
||||
float enemyAngle = MathUtils.VectorToAngle(closestEnemy.WorldPosition - item.WorldPosition);
|
||||
float turretAngle = -rotation;
|
||||
|
||||
if (Math.Abs(MathUtils.GetShortestAngle(enemyAngle, turretAngle)) > 0.15f) return false;
|
||||
if (Math.Abs(MathUtils.GetShortestAngle(enemyAngle, turretAngle)) > 0.15f) { return false; }
|
||||
|
||||
var pickedBody = Submarine.PickBody(ConvertUnits.ToSimUnits(item.WorldPosition), closestEnemy.SimPosition, null);
|
||||
if (pickedBody != null && !(pickedBody.UserData is Limb)) return false;
|
||||
if (pickedBody != null && !(pickedBody.UserData is Limb)) { return false; }
|
||||
|
||||
if (objective.Option.ToLowerInvariant() == "fireatwill")
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user