Unstable 0.17.2.0

This commit is contained in:
Markus Isberg
2022-03-30 00:06:59 +09:00
parent 4206f6db42
commit 2968e23ae8
100 changed files with 654 additions and 1379 deletions
@@ -520,9 +520,8 @@ namespace Barotrauma.MapCreatures.Behavior
if (branch.Health > branch.MaxHealth * 0.9f || branch.DisconnectedFromRoot) { continue; }
float branchHealAmount = (float)(MaxBranchHealthRegenDistance - branch.BranchDepth) / MaxBranchHealthRegenDistance * healAmount;
if (branchHealAmount <= 0.0f) { continue; }
float prevHealth = branch.Health;
branch.Health += branchHealAmount;
branch.AccumulatedDamage += (prevHealth - branch.Health);
branch.AccumulatedDamage -= branchHealAmount;
}
}
StateMachine.Update(deltaTime);
@@ -634,8 +633,7 @@ namespace Barotrauma.MapCreatures.Behavior
{
if (branch.ParentBranch != null && (branch.ParentBranch.DisconnectedFromRoot || branch.ParentBranch.Health <= 0.0f))
{
float speed = MathHelper.Lerp(5.0f, 0.1f, branch.ParentBranch.Health / branch.ParentBranch.MaxHealth);
DamageBranch(branch, speed * speed * deltaTime, AttackType.CutFromRoot);
DamageBranch(branch, deltaTime * MathHelper.Lerp(10.0f, 0.01f, branch.ParentBranch.Health / branch.ParentBranch.MaxHealth), AttackType.CutFromRoot);
}
if (branch.Health <= 0.0f)
{
@@ -838,7 +836,7 @@ namespace Barotrauma.MapCreatures.Behavior
}
#if SERVER
CreateNetworkMessage(new BranchCreateEventData(newBranch, parent));
SendNetworkMessage(new BranchCreateEventData(newBranch, parent));
#endif
return true;
}
@@ -880,7 +878,7 @@ namespace Barotrauma.MapCreatures.Behavior
#if SERVER
if (!load)
{
CreateNetworkMessage(new InfectEventData(target, InfectEventData.InfectState.Yes, branch));
SendNetworkMessage(new InfectEventData(target, InfectEventData.InfectState.Yes, branch));
}
#endif
}
@@ -957,6 +955,8 @@ namespace Barotrauma.MapCreatures.Behavior
/// <param name="branch"></param>
private void CreateBody(BallastFloraBranch branch)
{
if (GameMain.NetworkMember != null && GameMain.NetworkMember.IsClient) { return; }
Rectangle rect = branch.Rect;
Vector2 pos = Parent.Position + Offset + branch.Position;
@@ -975,14 +975,6 @@ namespace Barotrauma.MapCreatures.Behavior
public void DamageBranch(BallastFloraBranch branch, float amount, AttackType type, Character? attacker = null)
{
float damage = amount;
if (damage > 0)
{
damage = Math.Min(damage, branch.Health);
}
else
{
damage = Math.Max(damage, branch.Health - branch.MaxHealth);
}
if (type != AttackType.Other && type != AttackType.CutFromRoot)
{
@@ -991,28 +983,8 @@ namespace Barotrauma.MapCreatures.Behavior
if (branch.IsRootGrowth && root != null && root.Health > 0.0f) { return; }
if (type != AttackType.Other && type != AttackType.CutFromRoot)
{
branch.AccumulatedDamage += damage;
Anger += damage * 0.001f;
}
if (GameMain.NetworkMember != null)
{
// damage is handled server side
if (GameMain.NetworkMember.IsClient)
{
return;
}
else
{
//accumulate damage on the server's side to ensure clients get notified
if (type == AttackType.Other || type == AttackType.CutFromRoot)
{
branch.AccumulatedDamage += damage;
}
}
}
// damage is handled server side currently
if (GameMain.NetworkMember != null && GameMain.NetworkMember.IsClient) { return; }
if (attacker != null && toxinsCooldown <= 0)
{
@@ -1042,6 +1014,11 @@ namespace Barotrauma.MapCreatures.Behavior
}
branch.Health -= damage;
if (type != AttackType.Other && type != AttackType.CutFromRoot)
{
branch.AccumulatedDamage += damage;
Anger += damage * 0.001f;
}
#if SERVER
GameMain.Server?.KarmaManager?.OnBallastFloraDamaged(attacker, damage);
@@ -1133,7 +1110,7 @@ namespace Barotrauma.MapCreatures.Behavior
#if SERVER
if (!wasRemoved)
{
CreateNetworkMessage(new BranchRemoveEventData(branch));
SendNetworkMessage(new BranchRemoveEventData(branch));
}
#endif
}
@@ -1164,7 +1141,7 @@ namespace Barotrauma.MapCreatures.Behavior
}
});
#if SERVER
CreateNetworkMessage(new InfectEventData(item, InfectEventData.InfectState.No, null));
SendNetworkMessage(new InfectEventData(item, InfectEventData.InfectState.No, null));
#endif
}
@@ -1182,7 +1159,7 @@ namespace Barotrauma.MapCreatures.Behavior
StateMachine?.State?.Exit();
#if SERVER
CreateNetworkMessage(new KillEventData());
SendNetworkMessage(new KillEventData());
#endif
}
@@ -1204,7 +1181,7 @@ namespace Barotrauma.MapCreatures.Behavior
_entityList.Remove(this);
#if SERVER
CreateNetworkMessage(new KillEventData());
SendNetworkMessage(new KillEventData());
#endif
}