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

View File

@@ -34,8 +34,18 @@ namespace Barotrauma
public override void Update(Camera cam, float 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;
@@ -92,6 +102,9 @@ namespace Barotrauma
message.WriteRangedSingle(MathHelper.Clamp(AnimController.StunTimer, 0.0f, 60.0f), 0.0f, 60.0f, 8);
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);
return true;
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
{
newStunTimer = message.ReadRangedSingle(0.0f, 60.0f, 8);
newHealth = (message.ReadByte() / 255.0f) * maxHealth;
newBleeding = message.ReadRangedSingle(0.0f, 5.0f, 8);
}
catch { return; }
AnimController.StunTimer = newStunTimer;
health = newHealth;
Bleeding = newBleeding;
aiController.ReadNetworkData(message);
return;
case NetworkEventType.EntityUpdate:

View File

@@ -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 > l.impactTolerance)
{
{
if (!character.IsNetworkPlayer)
{
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);
@@ -824,8 +824,10 @@ namespace Barotrauma
//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)
// {
// 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.TargetPosition = Vector2.Zero;
//}
}
}
}

View File

@@ -873,7 +873,7 @@ namespace Barotrauma
{
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);
}
}
@@ -897,16 +897,6 @@ namespace Barotrauma
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 (!(AnimController is FishAnimController))

View File

@@ -42,8 +42,8 @@ namespace Barotrauma
position.Y -= Level.Loaded.Size.Y;
}
position.X += Rand.Range(-0.5f, 0.5f);
position.Y += Rand.Range(-0.5f, 0.5f);
position.X += Rand.Range(-0.5f, 0.5f, false);
position.Y += Rand.Range(-0.5f, 0.5f, false);
monsters[i] = Character.Create(characterFile, position);
}
}

View File

@@ -617,7 +617,7 @@ namespace Barotrauma
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)

View File

@@ -30,6 +30,10 @@ namespace Barotrauma.Networking
public GameClient(string newName)
{
GameMain.DebugDraw = false;
Hull.EditFire = false;
Hull.EditWater = false;
name = newName;
characterInfo = new CharacterInfo(Character.HumanConfigFile, name);

View File

@@ -16,7 +16,7 @@ namespace Barotrauma.Networking
//if a Character is further than this from the sub, the server will ignore it
//(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
//(in sim units)
@@ -32,7 +32,7 @@ namespace Barotrauma.Networking
public const float IdSendInterval = 0.2f;
public const float RerequestInterval = 0.2f;
public const int ReliableMessageBufferSize = 100;
public const int ReliableMessageBufferSize = 500;
public const int ResendAttempts = 10;
}
}

View File

@@ -884,10 +884,7 @@ namespace Barotrauma
public bool TrySelectSub(string subName, string md5Hash)
{
subName = subName.ToLower();
Submarine sub = Submarine.SavedSubmarines.Find(m => m.Name.ToLower() == subName);
Submarine sub = Submarine.SavedSubmarines.Find(m => m.Name == subName);
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.");

Binary file not shown.