Re-enabled repairtool character damage

This commit is contained in:
Regalis
2016-02-13 21:24:41 +02:00
parent 08f1d05507
commit 9b5e78fce4
4 changed files with 31 additions and 7 deletions

View File

@@ -69,6 +69,13 @@ namespace Barotrauma
if (GameMain.DebugDraw && !isDead) aiController.DebugDraw(spriteBatch);
}
public override void AddDamage(CauseOfDeath causeOfDeath, float amount, IDamageable attacker)
{
base.AddDamage(causeOfDeath, amount, attacker);
if (attacker!=null) aiController.OnAttacked(attacker, amount);
}
public override AttackResult AddDamage(IDamageable attacker, Vector2 position, Attack attack, float deltaTime, bool playSound = false)
{
AttackResult result = base.AddDamage(attacker, position, attack, deltaTime, playSound);

View File

@@ -1044,9 +1044,14 @@ namespace Barotrauma
if (isDead) return;
Vector2 healthBarPos = new Vector2(pos.X - 50, pos.Y - 100.0f);
GUI.DrawRectangle(spriteBatch, new Rectangle((int)healthBarPos.X - 2, (int)healthBarPos.Y - 2, 100 + 4, 15 + 4), Color.Black, false);
GUI.DrawRectangle(spriteBatch, new Rectangle((int)healthBarPos.X, (int)healthBarPos.Y, (int)(100.0f * (health / maxHealth)), 15), Color.Red, true);
Vector2 healthBarPos = new Vector2(pos.X - 50, DrawPosition.Y + 100.0f);
GUI.DrawProgressBar(spriteBatch, healthBarPos, new Vector2(100.0f, 15.0f), health/maxHealth, Color.Lerp(Color.Red, Color.Green, health/maxHealth)*0.8f);
//GUI.DrawRectangle(spriteBatch, new Rectangle((int)healthBarPos.X - 2, (int)healthBarPos.Y - 2, 100 + 4, 15 + 4), Color.Black, false);
//GUI.DrawRectangle(spriteBatch, new Rectangle((int)healthBarPos.X, (int)healthBarPos.Y, (int)(100.0f * (health / maxHealth)), 15), Color.Red, true);
}
public void PlaySound(AIController.AiState state)
@@ -1069,7 +1074,7 @@ namespace Barotrauma
}
}
public void AddDamage(CauseOfDeath causeOfDeath, float amount)
public virtual void AddDamage(CauseOfDeath causeOfDeath, float amount, IDamageable attacker)
{
health = MathHelper.Clamp(health-amount, 0.0f, maxHealth);
if (amount>0.0f) lastAttackCauseOfDeath = causeOfDeath;
@@ -1105,7 +1110,7 @@ namespace Barotrauma
AttackResult attackResult = closestLimb.AddDamage(simPosition, damageType, amount, bleedingAmount, playSound);
AddDamage(damageType == DamageType.Burn ? CauseOfDeath.Burn : causeOfDeath, attackResult.Damage);
AddDamage(damageType == DamageType.Burn ? CauseOfDeath.Burn : causeOfDeath, attackResult.Damage, null);
//health -= attackResult.Damage;
//if (health <= 0.0f && damageType == DamageType.Burn) Kill(CauseOfDeath.Burn);

View File

@@ -205,6 +205,18 @@ namespace Barotrauma
}
}
public static void DrawProgressBar(SpriteBatch sb, Vector2 start, Vector2 size, float progress, Color clr, float depth = 0.0f)
{
//outlinecolor = "0.5, 0.57, 0.6, 1.0" >
DrawRectangle(sb, new Vector2(start.X, -start.Y), size, new Color(0.5f, 0.57f, 0.6f, 1.0f), false, depth);
int padding = 2;
DrawRectangle(sb, new Rectangle((int)start.X + padding, -(int)(start.Y - padding), (int)((size.X - padding * 2)*progress), (int)size.Y - padding * 2),
clr, true, depth);
}
public static Texture2D CreateCircle(int radius)
{
int outerRadius = radius * 2 + 2; // So circle doesn't go out of bounds

View File

@@ -132,7 +132,7 @@ namespace Barotrauma.Items.Components
List<Body> ignoredBodies = new List<Body>();
foreach (Limb limb in character.AnimController.Limbs)
{
if (Rand.Range(0.0f, 1.0f) > degreeOfSuccess) continue;
if (Rand.Range(0.0f, 0.5f) > degreeOfSuccess) continue;
ignoredBodies.Add(limb.body.FarseerBody);
}
@@ -182,7 +182,7 @@ namespace Barotrauma.Items.Components
{
if (character.IsKeyDown(InputType.Aim))
{
targetLimb.character.AddDamage(CauseOfDeath.Damage, LimbFixAmount * degreeOfSuccess);
targetLimb.character.AddDamage(CauseOfDeath.Damage, -LimbFixAmount * degreeOfSuccess, character);
//isActive = true;
}
}