diff --git a/Subsurface/Source/Characters/AICharacter.cs b/Subsurface/Source/Characters/AICharacter.cs index 6e0dddc60..d8b2716be 100644 --- a/Subsurface/Source/Characters/AICharacter.cs +++ b/Subsurface/Source/Characters/AICharacter.cs @@ -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); diff --git a/Subsurface/Source/Characters/Character.cs b/Subsurface/Source/Characters/Character.cs index 1a7c16bac..bdbf8fc3c 100644 --- a/Subsurface/Source/Characters/Character.cs +++ b/Subsurface/Source/Characters/Character.cs @@ -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); diff --git a/Subsurface/Source/GUI/GUI.cs b/Subsurface/Source/GUI/GUI.cs index 0d4d8b8b4..8a7e2be2e 100644 --- a/Subsurface/Source/GUI/GUI.cs +++ b/Subsurface/Source/GUI/GUI.cs @@ -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 diff --git a/Subsurface/Source/Items/Components/Holdable/RepairTool.cs b/Subsurface/Source/Items/Components/Holdable/RepairTool.cs index f40c34d5a..7690b5a3d 100644 --- a/Subsurface/Source/Items/Components/Holdable/RepairTool.cs +++ b/Subsurface/Source/Items/Components/Holdable/RepairTool.cs @@ -132,7 +132,7 @@ namespace Barotrauma.Items.Components List ignoredBodies = new List(); 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; } }