- The server doesn't disable client-controlled AI characters that are far from all other players.
- Clients aren't allowed to flip swimming FishAnimControllers unless the server says so (occasionally caused creatures to flip around constantly because the clients ignore the 1-second "flipping cooldown"). - Moved Character.ReadStatus to the client project.
This commit is contained in:
@@ -299,5 +299,81 @@ namespace Barotrauma
|
|||||||
|
|
||||||
return character;
|
return character;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ReadStatus(NetBuffer msg)
|
||||||
|
{
|
||||||
|
bool isDead = msg.ReadBoolean();
|
||||||
|
if (isDead)
|
||||||
|
{
|
||||||
|
causeOfDeath = (CauseOfDeath)msg.ReadByte();
|
||||||
|
byte severedLimbCount = msg.ReadByte();
|
||||||
|
if (!IsDead)
|
||||||
|
{
|
||||||
|
if (causeOfDeath == CauseOfDeath.Pressure)
|
||||||
|
{
|
||||||
|
Implode(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Kill(causeOfDeath, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < severedLimbCount; i++)
|
||||||
|
{
|
||||||
|
int severedJointIndex = msg.ReadByte();
|
||||||
|
AnimController.SeverLimbJoint(AnimController.LimbJoints[severedJointIndex]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.isDead = false;
|
||||||
|
|
||||||
|
health = msg.ReadRangedSingle(minHealth, maxHealth, 8);
|
||||||
|
|
||||||
|
bool lowOxygen = msg.ReadBoolean();
|
||||||
|
if (lowOxygen)
|
||||||
|
{
|
||||||
|
Oxygen = msg.ReadRangedSingle(-100.0f, 100.0f, 8);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Oxygen = 100.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isBleeding = msg.ReadBoolean();
|
||||||
|
if (isBleeding)
|
||||||
|
{
|
||||||
|
bleeding = msg.ReadRangedSingle(0.0f, 5.0f, 8);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bleeding = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool stunned = msg.ReadBoolean();
|
||||||
|
if (stunned)
|
||||||
|
{
|
||||||
|
float newStunTimer = msg.ReadRangedSingle(0.0f, 60.0f, 8);
|
||||||
|
SetStun(newStunTimer, true, true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetStun(0.0f, true, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool huskInfected = msg.ReadBoolean();
|
||||||
|
if (huskInfected)
|
||||||
|
{
|
||||||
|
HuskInfectionState = Math.Max(HuskInfectionState, 0.01f);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HuskInfectionState = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,12 +120,10 @@ namespace Barotrauma
|
|||||||
UpdateWalkAnim(deltaTime);
|
UpdateWalkAnim(deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!character.IsRemotePlayer)
|
||||||
if (mirror || !inWater)
|
|
||||||
{
|
{
|
||||||
if (!character.IsRemotePlayer)
|
if (mirror || !inWater)
|
||||||
{
|
{
|
||||||
//targetDir = (movement.X > 0.0f) ? Direction.Right : Direction.Left;
|
|
||||||
if (targetMovement.X > 0.1f && targetMovement.X > Math.Abs(targetMovement.Y) * 0.5f)
|
if (targetMovement.X > 0.1f && targetMovement.X > Math.Abs(targetMovement.Y) * 0.5f)
|
||||||
{
|
{
|
||||||
TargetDir = Direction.Right;
|
TargetDir = Direction.Right;
|
||||||
@@ -135,25 +133,24 @@ namespace Barotrauma
|
|||||||
TargetDir = Direction.Left;
|
TargetDir = Direction.Left;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Limb head = GetLimb(LimbType.Head);
|
|
||||||
if (head == null) head = GetLimb(LimbType.Torso);
|
|
||||||
|
|
||||||
float rotation = MathUtils.WrapAngleTwoPi(head.Rotation);
|
|
||||||
rotation = MathHelper.ToDegrees(rotation);
|
|
||||||
|
|
||||||
if (rotation < 0.0f) rotation += 360;
|
|
||||||
|
|
||||||
if (rotation > 20 && rotation < 160)
|
|
||||||
{
|
{
|
||||||
TargetDir = Direction.Left;
|
Limb head = GetLimb(LimbType.Head);
|
||||||
}
|
if (head == null) head = GetLimb(LimbType.Torso);
|
||||||
else if (rotation > 200 && rotation < 340)
|
|
||||||
{
|
float rotation = MathUtils.WrapAngleTwoPi(head.Rotation);
|
||||||
TargetDir = Direction.Right;
|
rotation = MathHelper.ToDegrees(rotation);
|
||||||
|
|
||||||
|
if (rotation < 0.0f) rotation += 360;
|
||||||
|
|
||||||
|
if (rotation > 20 && rotation < 160)
|
||||||
|
{
|
||||||
|
TargetDir = Direction.Left;
|
||||||
|
}
|
||||||
|
else if (rotation > 200 && rotation < 340)
|
||||||
|
{
|
||||||
|
TargetDir = Direction.Right;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,7 +160,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (TargetDir != Direction.None && TargetDir != dir)
|
if (TargetDir != Direction.None && TargetDir != dir)
|
||||||
{
|
{
|
||||||
if (flipTimer>1.0f || character.IsRemotePlayer)
|
if (flipTimer > 1.0f || character.IsRemotePlayer)
|
||||||
{
|
{
|
||||||
Flip();
|
Flip();
|
||||||
if (mirror || !inWater) Mirror();
|
if (mirror || !inWater) Mirror();
|
||||||
|
|||||||
@@ -1314,7 +1314,9 @@ namespace Barotrauma
|
|||||||
//disable AI characters that are far away from all clients and the host's character and not controlled by anyone
|
//disable AI characters that are far away from all clients and the host's character and not controlled by anyone
|
||||||
c.Enabled =
|
c.Enabled =
|
||||||
c == controlled ||
|
c == controlled ||
|
||||||
|
c.IsRemotePlayer ||
|
||||||
CharacterList.Any(c2 =>
|
CharacterList.Any(c2 =>
|
||||||
|
c != c2 &&
|
||||||
(c2.IsRemotePlayer || c2 == GameMain.Server.Character) &&
|
(c2.IsRemotePlayer || c2 == GameMain.Server.Character) &&
|
||||||
Vector2.DistanceSquared(c2.WorldPosition, c.WorldPosition) < NetConfig.CharacterIgnoreDistanceSqr);
|
Vector2.DistanceSquared(c2.WorldPosition, c.WorldPosition) < NetConfig.CharacterIgnoreDistanceSqr);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -527,83 +527,6 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReadStatus(NetBuffer msg)
|
|
||||||
{
|
|
||||||
if (GameMain.Server != null)
|
|
||||||
{
|
|
||||||
DebugConsole.ThrowError("Server attempted to read character status from a networked message");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isDead = msg.ReadBoolean();
|
|
||||||
if (isDead)
|
|
||||||
{
|
|
||||||
causeOfDeath = (CauseOfDeath)msg.ReadByte();
|
|
||||||
byte severedLimbCount = msg.ReadByte();
|
|
||||||
if (causeOfDeath == CauseOfDeath.Pressure)
|
|
||||||
{
|
|
||||||
Implode(true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Kill(causeOfDeath, true);
|
|
||||||
}
|
|
||||||
for (int i = 0; i < severedLimbCount; i++)
|
|
||||||
{
|
|
||||||
int severedJointIndex = msg.ReadByte();
|
|
||||||
AnimController.SeverLimbJoint(AnimController.LimbJoints[severedJointIndex]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.isDead = false;
|
|
||||||
|
|
||||||
health = msg.ReadRangedSingle(minHealth, maxHealth, 8);
|
|
||||||
|
|
||||||
bool lowOxygen = msg.ReadBoolean();
|
|
||||||
if (lowOxygen)
|
|
||||||
{
|
|
||||||
Oxygen = msg.ReadRangedSingle(-100.0f, 100.0f, 8);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Oxygen = 100.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isBleeding = msg.ReadBoolean();
|
|
||||||
if (isBleeding)
|
|
||||||
{
|
|
||||||
bleeding = msg.ReadRangedSingle(0.0f, 5.0f, 8);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bleeding = 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool stunned = msg.ReadBoolean();
|
|
||||||
if (stunned)
|
|
||||||
{
|
|
||||||
float newStunTimer = msg.ReadRangedSingle(0.0f, 60.0f, 8);
|
|
||||||
SetStun(newStunTimer, true, true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SetStun(0.0f, true, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool huskInfected = msg.ReadBoolean();
|
|
||||||
if (huskInfected)
|
|
||||||
{
|
|
||||||
HuskInfectionState = Math.Max(HuskInfectionState, 0.01f);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
HuskInfectionState = 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void WriteSpawnData(NetBuffer msg)
|
public void WriteSpawnData(NetBuffer msg)
|
||||||
{
|
{
|
||||||
if (GameMain.Server == null) return;
|
if (GameMain.Server == null) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user