diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Character.cs b/Barotrauma/BarotraumaShared/Source/Characters/Character.cs index 8dc37bdde..22c01cc53 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Character.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Character.cs @@ -1526,6 +1526,27 @@ namespace Barotrauma public virtual void AddDamage(CauseOfDeath causeOfDeath, float amount, IDamageable attacker) { + if (GameMain.Server != null) + { + if (attacker is Character) + { + Character attackerCharacter = attacker as Character; + Barotrauma.Networking.Client attackerClient = GameMain.Server.ConnectedClients.Find(c => c.Character == attackerCharacter); + if (attackerClient != null) + { + Barotrauma.Networking.Client targetClient = GameMain.Server.ConnectedClients.Find(c => c.Character == this); + if (targetClient != null || this == Character.Controlled) + { + if (attackerCharacter.TeamID == TeamID) + { + attackerClient.Karma -= amount * 0.01f; + if (health <= minHealth) attackerClient.Karma = 0.0f; + } + } + } + } + } + Health = health-amount; if (amount > 0.0f) { diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/RangedWeapon.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/RangedWeapon.cs index 6a5cd4597..dca9b5c3a 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/RangedWeapon.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/RangedWeapon.cs @@ -108,10 +108,11 @@ namespace Barotrauma.Items.Components projectile.body.ResetDynamics(); projectile.SetTransform(TransformedBarrelPos, rotation); + projectileComponent.User = character; projectileComponent.IgnoredBodies = new List(limbBodies); - projectile.Use(deltaTime); + projectileComponent.User = character; projectile.body.ApplyTorque(projectile.body.Mass * degreeOfFailure * Rand.Range(-10.0f, 10.0f)); diff --git a/Barotrauma/BarotraumaShared/Source/Networking/Client.cs b/Barotrauma/BarotraumaShared/Source/Networking/Client.cs index 5a0caf60e..307d26daf 100644 --- a/Barotrauma/BarotraumaShared/Source/Networking/Client.cs +++ b/Barotrauma/BarotraumaShared/Source/Networking/Client.cs @@ -29,6 +29,13 @@ namespace Barotrauma.Networking public string Name; public byte ID; + private float karma = 1.0f; + public float Karma + { + get { return karma; } + set { karma = Math.Min(Math.Max(value,0.0f),1.0f); DebugConsole.NewMessage(Name+"'s karma set to "+karma,Microsoft.Xna.Framework.Color.Yellow); } + } + public byte TeamID = 0; public Character Character;