Server doesn't create an entityevent if the health of a character changes very little, husk infection isn't updated after the infected character dies, clients can't create a "huskified" human NPC until the server says so
This commit is contained in:
@@ -90,7 +90,7 @@ namespace Barotrauma
|
|||||||
protected float oxygen, oxygenAvailable;
|
protected float oxygen, oxygenAvailable;
|
||||||
protected float drowningTime;
|
protected float drowningTime;
|
||||||
|
|
||||||
private float health;
|
private float health, lastSentHealth;
|
||||||
protected float minHealth, maxHealth;
|
protected float minHealth, maxHealth;
|
||||||
|
|
||||||
protected Item closestItem;
|
protected Item closestItem;
|
||||||
@@ -301,7 +301,13 @@ namespace Barotrauma
|
|||||||
health = newHealth;
|
health = newHealth;
|
||||||
|
|
||||||
if (GameMain.Server != null)
|
if (GameMain.Server != null)
|
||||||
GameMain.Server.CreateEntityEvent(this, new object[] { NetEntityEvent.Type.Status });
|
{
|
||||||
|
if (Math.Abs(health - lastSentHealth) > (maxHealth - minHealth) / 255.0f || Math.Sign(health) != Math.Sign(lastSentHealth))
|
||||||
|
{
|
||||||
|
GameMain.Server.CreateEntityEvent(this, new object[] { NetEntityEvent.Type.Status });
|
||||||
|
lastSentHealth = health;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1326,10 +1332,10 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (huskInfection != null) huskInfection.Update(deltaTime, this);
|
|
||||||
|
|
||||||
if (isDead) return;
|
if (isDead) return;
|
||||||
|
|
||||||
|
if (huskInfection != null) huskInfection.Update(deltaTime, this);
|
||||||
|
|
||||||
if (GameMain.NetworkMember != null)
|
if (GameMain.NetworkMember != null)
|
||||||
{
|
{
|
||||||
UpdateNetInput();
|
UpdateNetInput();
|
||||||
|
|||||||
@@ -151,6 +151,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private void CharacterDead(Character character, CauseOfDeath causeOfDeath)
|
private void CharacterDead(Character character, CauseOfDeath causeOfDeath)
|
||||||
{
|
{
|
||||||
|
if (GameMain.Client != null) return;
|
||||||
|
|
||||||
var husk = Character.Create(
|
var husk = Character.Create(
|
||||||
Path.Combine("Content", "Characters", "Human", "humanhusk.xml"),
|
Path.Combine("Content", "Characters", "Human", "humanhusk.xml"),
|
||||||
character.WorldPosition,
|
character.WorldPosition,
|
||||||
@@ -177,6 +179,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
character.Enabled = false;
|
character.Enabled = false;
|
||||||
|
|
||||||
|
Entity.Spawner.AddToRemoveQueue(character);
|
||||||
Entity.Spawner.AddToSpawnedList(husk);
|
Entity.Spawner.AddToSpawnedList(husk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user