Added Karma, harming players reduces it
This commit is contained in:
@@ -1526,6 +1526,27 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public virtual void AddDamage(CauseOfDeath causeOfDeath, float amount, IDamageable attacker)
|
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;
|
Health = health-amount;
|
||||||
if (amount > 0.0f)
|
if (amount > 0.0f)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -108,10 +108,11 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
projectile.body.ResetDynamics();
|
projectile.body.ResetDynamics();
|
||||||
projectile.SetTransform(TransformedBarrelPos, rotation);
|
projectile.SetTransform(TransformedBarrelPos, rotation);
|
||||||
|
|
||||||
projectileComponent.User = character;
|
projectileComponent.User = character;
|
||||||
projectileComponent.IgnoredBodies = new List<Body>(limbBodies);
|
projectileComponent.IgnoredBodies = new List<Body>(limbBodies);
|
||||||
|
|
||||||
projectile.Use(deltaTime);
|
projectile.Use(deltaTime);
|
||||||
|
projectileComponent.User = character;
|
||||||
|
|
||||||
projectile.body.ApplyTorque(projectile.body.Mass * degreeOfFailure * Rand.Range(-10.0f, 10.0f));
|
projectile.body.ApplyTorque(projectile.body.Mass * degreeOfFailure * Rand.Range(-10.0f, 10.0f));
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,13 @@ namespace Barotrauma.Networking
|
|||||||
public string Name;
|
public string Name;
|
||||||
public byte ID;
|
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 byte TeamID = 0;
|
||||||
|
|
||||||
public Character Character;
|
public Character Character;
|
||||||
|
|||||||
Reference in New Issue
Block a user