Added Karma, harming players reduces it

This commit is contained in:
juanjp600
2017-12-03 21:51:12 -03:00
parent 4a1eea8c30
commit 6841bb154b
3 changed files with 30 additions and 1 deletions
@@ -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)
{