Overhaul DelayedEffect to support application to multiple targets

Fix DelayedEffect being unusable by monsters due to monsters calling Single Target Apply in their Attack, which DelayedEffect doesn't override, by making Apply (single target) call Apply (multiple targets) which THEN calls the protected Apply function.
Nerf Amanitin to require two injections to be lethal. First injection only stops oxygen from regenerating and slightly saps HP.
Add Cause of Death to Health HUD
This commit is contained in:
Alex Noir
2017-12-21 21:40:54 +03:00
parent b9e0c97c9d
commit 9251dbf83a
5 changed files with 37 additions and 36 deletions

View File

@@ -115,6 +115,7 @@ namespace Barotrauma.Items.Components
if (target.IsDead)
{
texts.Add("Deceased");
texts.Add("Cause of Death: " + target.CauseOfDeath.ToString());
}
else
{

View File

@@ -175,7 +175,6 @@
<StatusEffect type="OnUse" target="Character" Health="-5.0" disabledeltatime="true">
<RequiredItem name="Medical Syringe" type="Container"/>
</StatusEffect>
<!-- InWater is horribly broken right now. https://github.com/Regalis11/Barotrauma/issues/187 -->
<StatusEffect type="InWater" target="This" Condition="0.0" setvalue="true">
<Sound file="Content/Items/Reactor/explosion.ogg"/>
<Explosion range="250.0" structuredamage="10" damage="20" stun="5" force="5.0"/>
@@ -502,7 +501,7 @@
category="Material"
spritecolor="1.0,0.3,0.3,1.0"
Tags="smallitem,chem,medical"
description="A devious poison with a delayed effect.">
description="A devious poison with a delayed effect. Requires higher dosage to be lethal.">
<!-- price="2000" Should be mixed by traitor medics more than anything -->
<!-- Direct counter to Amanitin is Liquid Oxygenite -->
<Sprite texture ="med.png" sourcerect="24,16,8,16" depth="0.6"/>
@@ -515,7 +514,7 @@
</StatusEffect>
<!-- Here's a problem: if a chemical with delay is injected into more than one person, only the last person will get that delayed effect.
Everyone else gets off scott free! Woo!!!..... -->
<StatusEffect type="OnUse" target="Character" Oxygen="-15.0" Health="-1.0" duration="60.0" delay="20.0">
<StatusEffect type="OnUse" target="Character" Oxygen="-10.0" Health="-0.5" duration="60.0" delay="20.0">
<RequiredItem name="Medical Syringe" type="Container"/>
</StatusEffect>
</Throwable>

View File

@@ -371,6 +371,7 @@ namespace Barotrauma
{
if (!MathUtils.IsValid(value)) return;
if (GameMain.Client != null) return;
if (!DoesBleed) return;
float newBleeding = MathHelper.Clamp(value, 0.0f, 5.0f);
if (newBleeding == bleeding) return;
@@ -1585,8 +1586,11 @@ namespace Barotrauma
if (needsAir) UpdateOxygen(deltaTime);
Health -= bleeding * deltaTime;
Bleeding -= BleedingDecreaseSpeed * deltaTime;
if (DoesBleed)
{
Health -= bleeding * deltaTime;
Bleeding -= BleedingDecreaseSpeed * deltaTime;
}
if (health <= minHealth) Kill(CauseOfDeath.Bloodloss);

View File

@@ -3,23 +3,19 @@ using System.Xml.Linq;
namespace Barotrauma
{
class DelayedListElement
{
public DelayedEffect Parent;
public Entity Entity;
public List<ISerializableEntity> Targets;
public float StartTimer;
}
class DelayedEffect : StatusEffect
{
public static List<DelayedEffect> List = new List<DelayedEffect>();
public static List<DelayedListElement> List = new List<DelayedListElement>();
private float delay;
private float startTimer;
private Entity entity;
private List<ISerializableEntity> targets;
public float StartTimer
{
get { return startTimer; }
}
public DelayedEffect(XElement element)
: base(element)
{
@@ -29,24 +25,28 @@ namespace Barotrauma
public override void Apply(ActionType type, float deltaTime, Entity entity, List<ISerializableEntity> targets)
{
if (this.type != type) return;
startTimer = delay;
this.entity = entity;
DelayedListElement element = new DelayedListElement();
element.Parent = this;
element.StartTimer = delay;
element.Entity = entity;
element.Targets = targets;
this.targets = targets;
List.Add(this);
List.Add(element);
}
public void Update(float deltaTime)
public static void Update(float deltaTime)
{
startTimer -= deltaTime;
for (int i = DelayedEffect.List.Count - 1; i >= 0; i--)
{
DelayedListElement element = DelayedEffect.List[i];
if (startTimer > 0.0f) return;
element.StartTimer -= deltaTime;
base.Apply(1.0f, entity, targets);
List.Remove(this);
if (element.StartTimer > 0.0f) continue;
element.Parent.Apply(1.0f, element.Entity, element.Targets);
List.Remove(element);
}
}
}
}
}

View File

@@ -190,7 +190,7 @@ namespace Barotrauma
}
}
private bool HasRequiredItems(Entity entity)
public virtual bool HasRequiredItems(Entity entity)
{
if (requiredItems == null) return true;
foreach (RelatedItem requiredItem in requiredItems)
@@ -218,7 +218,7 @@ namespace Barotrauma
List<ISerializableEntity> targets = new List<ISerializableEntity>();
targets.Add(target);
Apply(deltaTime, entity, targets);
Apply(type, deltaTime, entity, targets);
}
public virtual void Apply(ActionType type, float deltaTime, Entity entity, List<ISerializableEntity> targets)
@@ -359,10 +359,7 @@ namespace Barotrauma
public static void UpdateAll(float deltaTime)
{
for (int i = DelayedEffect.List.Count-1; i>= 0; i--)
{
DelayedEffect.List[i].Update(deltaTime);
}
DelayedEffect.Update(deltaTime);
}
public static void StopAll()