Only AICharacters use simplephysics, AICharacter bleeding syncing, resetting limb velocities in MP when doing full position reset, characters aren't updated if health <= 0, monsterevent initialization using synced seed, GetRandomWaypoint uses synced seed, disabling debug stuff when starting a client, netconfig changes

This commit is contained in:
Regalis
2016-01-30 15:18:19 +02:00
parent a1770427a0
commit 92a162cbf5
9 changed files with 39 additions and 28 deletions
+20 -2
View File
@@ -34,8 +34,18 @@ namespace Barotrauma
public override void Update(Camera cam, float deltaTime) public override void Update(Camera cam, float deltaTime)
{ {
base.Update(cam, deltaTime); base.Update(cam, deltaTime);
float dist = Vector2.Distance(cam.WorldViewCenter, WorldPosition);
if (dist > 8000.0f)
{
AnimController.SimplePhysicsEnabled = true;
}
else if (dist < 7000.0f)
{
AnimController.SimplePhysicsEnabled = false;
}
if (isDead) return; if (isDead || health <= 0.0f) return;
if (Controlled == this) return; if (Controlled == this) return;
@@ -92,6 +102,9 @@ namespace Barotrauma
message.WriteRangedSingle(MathHelper.Clamp(AnimController.StunTimer, 0.0f, 60.0f), 0.0f, 60.0f, 8); message.WriteRangedSingle(MathHelper.Clamp(AnimController.StunTimer, 0.0f, 60.0f), 0.0f, 60.0f, 8);
message.Write((byte)((health / maxHealth) * 255.0f)); message.Write((byte)((health / maxHealth) * 255.0f));
Bleeding = MathHelper.Clamp(Bleeding, 0.0f, 5.0f);
message.WriteRangedSingle(Bleeding, 0.0f, 5.0f, 8);
aiController.FillNetworkData(message); aiController.FillNetworkData(message);
return true; return true;
case NetworkEventType.EntityUpdate: case NetworkEventType.EntityUpdate:
@@ -160,18 +173,23 @@ namespace Barotrauma
} }
//} //}
float newStunTimer = 0.0f, newHealth = 0.0f; float newStunTimer = 0.0f, newHealth = 0.0f, newBleeding = 0.0f;
try try
{ {
newStunTimer = message.ReadRangedSingle(0.0f, 60.0f, 8); newStunTimer = message.ReadRangedSingle(0.0f, 60.0f, 8);
newHealth = (message.ReadByte() / 255.0f) * maxHealth; newHealth = (message.ReadByte() / 255.0f) * maxHealth;
newBleeding = message.ReadRangedSingle(0.0f, 5.0f, 8);
} }
catch { return; } catch { return; }
AnimController.StunTimer = newStunTimer; AnimController.StunTimer = newStunTimer;
health = newHealth; health = newHealth;
Bleeding = newBleeding;
aiController.ReadNetworkData(message); aiController.ReadNetworkData(message);
return; return;
case NetworkEventType.EntityUpdate: case NetworkEventType.EntityUpdate:
@@ -393,13 +393,13 @@ namespace Barotrauma
if (impact > 0.8f && l.HitSound != null && l.soundTimer <= 0.0f) l.HitSound.Play(volume, impact * 100.0f, l.WorldPosition); if (impact > 0.8f && l.HitSound != null && l.soundTimer <= 0.0f) l.HitSound.Play(volume, impact * 100.0f, l.WorldPosition);
if (impact > l.impactTolerance) if (impact > l.impactTolerance)
{ {
if (!character.IsNetworkPlayer) if (!character.IsNetworkPlayer)
{ {
character.AddDamage(CauseOfDeath.Damage, impact - l.impactTolerance * 0.1f); character.AddDamage(CauseOfDeath.Damage, impact - l.impactTolerance * 0.1f);
}
strongestImpact = Math.Max(strongestImpact, impact - l.impactTolerance); strongestImpact = Math.Max(strongestImpact, impact - l.impactTolerance);
}
SoundPlayer.PlayDamageSound(DamageSoundType.LimbBlunt, strongestImpact, l.body); SoundPlayer.PlayDamageSound(DamageSoundType.LimbBlunt, strongestImpact, l.body);
@@ -824,8 +824,10 @@ namespace Barotrauma
//if (character is AICharacter) SetRotation(refLimb.body.TargetRotation); //if (character is AICharacter) SetRotation(refLimb.body.TargetRotation);
//foreach (Limb limb in Limbs) foreach (Limb limb in Limbs)
//{ {
limb.body.LinearVelocity = Vector2.Zero;
limb.body.AngularVelocity = Vector2.Zero;
// if (limb.body.TargetPosition == Vector2.Zero) // if (limb.body.TargetPosition == Vector2.Zero)
// { // {
// limb.body.SetTransform(limb.body.SimPosition + diff, limb.body.Rotation); // limb.body.SetTransform(limb.body.SimPosition + diff, limb.body.Rotation);
@@ -837,7 +839,7 @@ namespace Barotrauma
// limb.body.SetTransform(limb.body.TargetPosition, limb.body.TargetRotation); // limb.body.SetTransform(limb.body.TargetPosition, limb.body.TargetRotation);
// limb.body.TargetPosition = Vector2.Zero; // limb.body.TargetPosition = Vector2.Zero;
//} }
} }
} }
+1 -11
View File
@@ -873,7 +873,7 @@ namespace Barotrauma
{ {
foreach (Character c in CharacterList) foreach (Character c in CharacterList)
{ {
if (c.isDead || !c.Enabled) continue; if (c.isDead || c.health <= 0.0f || !c.Enabled) continue;
c.AnimController.UpdateAnim(deltaTime); c.AnimController.UpdateAnim(deltaTime);
} }
} }
@@ -897,16 +897,6 @@ namespace Barotrauma
obstructVisionAmount = Math.Max(obstructVisionAmount - deltaTime, 0.0f); obstructVisionAmount = Math.Max(obstructVisionAmount - deltaTime, 0.0f);
float dist = Vector2.Distance(cam.WorldViewCenter, WorldPosition);
if (dist > 8000.0f)
{
AnimController.SimplePhysicsEnabled = true;
}
else if (dist < 7000.0f)
{
AnimController.SimplePhysicsEnabled = false;
}
if (isDead) return; if (isDead) return;
if (!(AnimController is FishAnimController)) if (!(AnimController is FishAnimController))
+2 -2
View File
@@ -42,8 +42,8 @@ namespace Barotrauma
position.Y -= Level.Loaded.Size.Y; position.Y -= Level.Loaded.Size.Y;
} }
position.X += Rand.Range(-0.5f, 0.5f); position.X += Rand.Range(-0.5f, 0.5f, false);
position.Y += Rand.Range(-0.5f, 0.5f); position.Y += Rand.Range(-0.5f, 0.5f, false);
monsters[i] = Character.Create(characterFile, position); monsters[i] = Character.Create(characterFile, position);
} }
} }
+1 -1
View File
@@ -617,7 +617,7 @@ namespace Barotrauma
if (!wayPoints.Any()) return null; if (!wayPoints.Any()) return null;
return wayPoints[Rand.Int(wayPoints.Count())]; return wayPoints[Rand.Int(wayPoints.Count(), false)];
} }
public static WayPoint[] SelectCrewSpawnPoints(List<CharacterInfo> crew) public static WayPoint[] SelectCrewSpawnPoints(List<CharacterInfo> crew)
@@ -30,6 +30,10 @@ namespace Barotrauma.Networking
public GameClient(string newName) public GameClient(string newName)
{ {
GameMain.DebugDraw = false;
Hull.EditFire = false;
Hull.EditWater = false;
name = newName; name = newName;
characterInfo = new CharacterInfo(Character.HumanConfigFile, name); characterInfo = new CharacterInfo(Character.HumanConfigFile, name);
+2 -2
View File
@@ -16,7 +16,7 @@ namespace Barotrauma.Networking
//if a Character is further than this from the sub, the server will ignore it //if a Character is further than this from the sub, the server will ignore it
//(in sim units) //(in sim units)
public const float CharacterIgnoreDistance = 100.0f; public const float CharacterIgnoreDistance = 300.0f;
//if a ragdoll is further than this from the correct position, teleport it there //if a ragdoll is further than this from the correct position, teleport it there
//(in sim units) //(in sim units)
@@ -32,7 +32,7 @@ namespace Barotrauma.Networking
public const float IdSendInterval = 0.2f; public const float IdSendInterval = 0.2f;
public const float RerequestInterval = 0.2f; public const float RerequestInterval = 0.2f;
public const int ReliableMessageBufferSize = 100; public const int ReliableMessageBufferSize = 500;
public const int ResendAttempts = 10; public const int ResendAttempts = 10;
} }
} }
+1 -4
View File
@@ -884,10 +884,7 @@ namespace Barotrauma
public bool TrySelectSub(string subName, string md5Hash) public bool TrySelectSub(string subName, string md5Hash)
{ {
Submarine sub = Submarine.SavedSubmarines.Find(m => m.Name == subName);
subName = subName.ToLower();
Submarine sub = Submarine.SavedSubmarines.Find(m => m.Name.ToLower() == subName);
if (sub == null) if (sub == null)
{ {
new GUIMessageBox("Submarine not found!","The submarine ''" + subName + "'' has been selected by the server. Matching file not found in your map folder."); new GUIMessageBox("Submarine not found!","The submarine ''" + subName + "'' has been selected by the server. Matching file not found in your map folder.");
Binary file not shown.