Allow multiple calls of <Use/> for repeat-use chemicals or autoinjectors or something
This commit is contained in:
@@ -55,6 +55,10 @@
|
|||||||
<StatusEffect type="OnUse" target="This, Character" bleeding="-0.1" duration="5.0">
|
<StatusEffect type="OnUse" target="This, Character" bleeding="-0.1" duration="5.0">
|
||||||
<Sound file="Content/Items/Medical/bandage.ogg" range="500"/>
|
<Sound file="Content/Items/Medical/bandage.ogg" range="500"/>
|
||||||
</StatusEffect>
|
</StatusEffect>
|
||||||
|
<StatusEffect type="OnUse" target="This, Character" health="0.1" duration="5.0" checkconditionalalways="true">
|
||||||
|
<!-- Only give healing effect if their health is more than 50 -->
|
||||||
|
<Conditional Health="gt 50">
|
||||||
|
</StatusEffect>
|
||||||
</MeleeWeapon>
|
</MeleeWeapon>
|
||||||
</Item>
|
</Item>
|
||||||
|
|
||||||
@@ -73,7 +77,7 @@
|
|||||||
<StatusEffect type="OnUse" target="Character" Health="-2" duration="10">
|
<StatusEffect type="OnUse" target="Character" Health="-2" duration="10">
|
||||||
<RequiredItem name="Medical Syringe" type="Container"/>
|
<RequiredItem name="Medical Syringe" type="Container"/>
|
||||||
</StatusEffect>
|
</StatusEffect>
|
||||||
</Throwable>>
|
</Throwable>
|
||||||
</Item>
|
</Item>
|
||||||
|
|
||||||
<Item
|
<Item
|
||||||
@@ -363,6 +367,26 @@
|
|||||||
</Throwable>
|
</Throwable>
|
||||||
</Item>
|
</Item>
|
||||||
|
|
||||||
|
<Item
|
||||||
|
name="Morbusanide"
|
||||||
|
category="Material"
|
||||||
|
spritecolor="0.0,0.0,0.2,1.0"
|
||||||
|
Tags="smallitem,chem,medical"
|
||||||
|
description="A morbusine antidote.">
|
||||||
|
|
||||||
|
<Sprite texture ="med.png" sourcerect="24,16,8,16" depth="0.6"/>
|
||||||
|
|
||||||
|
<Body width="8" height="16" density="10"/>
|
||||||
|
|
||||||
|
<Throwable canBeCombined="true" slots="Any,RightHand,LeftHand" throwforce="4.0" aimpos="35,-10">
|
||||||
|
<StatusEffect type="OnUse" target="Character">
|
||||||
|
<RequiredItem name="Medical Syringe" type="Container"/>
|
||||||
|
<Conditional hasstatustag="morbusine"/>
|
||||||
|
<Cancel/>
|
||||||
|
</StatusEffect>
|
||||||
|
</Throwable>
|
||||||
|
</Item>
|
||||||
|
|
||||||
<Item
|
<Item
|
||||||
name="Liquid Oxygenite"
|
name="Liquid Oxygenite"
|
||||||
category="Material"
|
category="Material"
|
||||||
@@ -457,7 +481,7 @@
|
|||||||
<Body width="8" height="16" density="25"/>
|
<Body width="8" height="16" density="25"/>
|
||||||
|
|
||||||
<Throwable canBeCombined="true" slots="Any,RightHand,LeftHand" throwforce="4.0" aimpos="35,-10">
|
<Throwable canBeCombined="true" slots="Any,RightHand,LeftHand" throwforce="4.0" aimpos="35,-10">
|
||||||
<StatusEffect type="OnUse" target="Character" bleeding="0.1" duration="60.0">
|
<StatusEffect tags="poison,uranium" type="OnUse" target="Character" bleeding="0.1" duration="60.0">
|
||||||
<RequiredItem name="Medical Syringe" type="Container"/>
|
<RequiredItem name="Medical Syringe" type="Container"/>
|
||||||
</StatusEffect>
|
</StatusEffect>
|
||||||
</Throwable>
|
</Throwable>
|
||||||
@@ -497,7 +521,7 @@
|
|||||||
<Body width="8" height="16" density="10"/>
|
<Body width="8" height="16" density="10"/>
|
||||||
|
|
||||||
<Throwable canBeCombined="true" slots="Any,RightHand,LeftHand" throwforce="4.0" aimpos="35,-10">
|
<Throwable canBeCombined="true" slots="Any,RightHand,LeftHand" throwforce="4.0" aimpos="35,-10">
|
||||||
<StatusEffect type="OnUse" target="Character" Health="-5.0" duration="60.0">
|
<StatusEffect tags="poison,morbusine" type="OnUse" target="Character" Health="-5.0" duration="60.0">
|
||||||
<RequiredItem name="Medical Syringe" type="Container"/>
|
<RequiredItem name="Medical Syringe" type="Container"/>
|
||||||
</StatusEffect>
|
</StatusEffect>
|
||||||
</Throwable>
|
</Throwable>
|
||||||
@@ -531,24 +555,21 @@
|
|||||||
</Item>
|
</Item>
|
||||||
|
|
||||||
<Item
|
<Item
|
||||||
name="Amanitin"
|
name="Sufforin"
|
||||||
category="Material"
|
category="Material"
|
||||||
spritecolor="1.0,0.3,0.3,1.0"
|
spritecolor="1.0,0.3,0.3,1.0"
|
||||||
Tags="smallitem,chem,medical"
|
Tags="smallitem,chem,medical"
|
||||||
description="A devious poison with a delayed effect. Requires higher dosage to be lethal.">
|
description="A devious poison with a delayed effect.">
|
||||||
<!-- price="2000" Should be mixed by traitor medics more than anything -->
|
<!-- Can only be crafted. Direct counter to Sufforin is Liquid Oxygenite, though it's not strictly an antidote. -->
|
||||||
<!-- Direct counter to Amanitin is Liquid Oxygenite -->
|
|
||||||
<Sprite texture ="med.png" sourcerect="24,16,8,16" depth="0.6"/>
|
<Sprite texture ="med.png" sourcerect="24,16,8,16" depth="0.6"/>
|
||||||
|
|
||||||
<Body width="8" height="16" density="10"/>
|
<Body width="8" height="16" density="10"/>
|
||||||
|
|
||||||
<Throwable canBeCombined="true" slots="Any,RightHand,LeftHand" throwforce="4.0" aimpos="35,-10">
|
<Throwable canBeCombined="true" slots="Any,RightHand,LeftHand" throwforce="4.0" aimpos="35,-10">
|
||||||
<StatusEffect type="OnUse" target="Character" Oxygen="-15.0" Health="-5.0">
|
<StatusEffect type="OnUse" target="Character" Health="-5.0">
|
||||||
<RequiredItem name="Medical Syringe" type="Container"/>
|
<RequiredItem name="Medical Syringe" type="Container"/>
|
||||||
</StatusEffect>
|
</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.
|
<StatusEffect tags="poison,sufforin" type="OnUse" target="Character" Oxygen="-15.0" Health="-0.5" duration="60.0" delay="20.0">
|
||||||
Everyone else gets off scott free! Woo!!!..... -->
|
|
||||||
<StatusEffect type="OnUse" target="Character" Oxygen="-10.0" Health="-0.5" duration="60.0" delay="20.0">
|
|
||||||
<RequiredItem name="Medical Syringe" type="Container"/>
|
<RequiredItem name="Medical Syringe" type="Container"/>
|
||||||
</StatusEffect>
|
</StatusEffect>
|
||||||
</Throwable>
|
</Throwable>
|
||||||
|
|||||||
@@ -135,7 +135,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public bool Stackable; //Can the same status effect be applied several times to the same targets?
|
public bool Stackable; //Can the same status effect be applied several times to the same targets?
|
||||||
|
|
||||||
private readonly bool useItem;
|
private readonly int useItemCount;
|
||||||
|
private readonly int cancelStatusEffect;
|
||||||
|
|
||||||
public readonly ActionType type;
|
public readonly ActionType type;
|
||||||
|
|
||||||
@@ -288,7 +289,14 @@ namespace Barotrauma
|
|||||||
break;
|
break;
|
||||||
case "use":
|
case "use":
|
||||||
case "useitem":
|
case "useitem":
|
||||||
useItem = true;
|
useItemCount++;
|
||||||
|
break;
|
||||||
|
case "cancel":
|
||||||
|
case "cancelstatuseffect":
|
||||||
|
//This only works if there's a conditional checking for status effect tags. There is no way to cancel *all* status effects atm.
|
||||||
|
cancelStatusEffect = 1;
|
||||||
|
if (subElement.GetAttributeBool("all", false) == true)
|
||||||
|
cancelStatusEffect = 2;
|
||||||
break;
|
break;
|
||||||
case "requireditem":
|
case "requireditem":
|
||||||
case "requireditems":
|
case "requireditems":
|
||||||
@@ -324,6 +332,7 @@ namespace Barotrauma
|
|||||||
case "ne":
|
case "ne":
|
||||||
case "neq":
|
case "neq":
|
||||||
case "notequals":
|
case "notequals":
|
||||||
|
case "!":
|
||||||
case "!e":
|
case "!e":
|
||||||
case "!eq":
|
case "!eq":
|
||||||
case "!equals":
|
case "!equals":
|
||||||
@@ -396,14 +405,66 @@ namespace Barotrauma
|
|||||||
foreach (ISerializableEntity target in targets)
|
foreach (ISerializableEntity target in targets)
|
||||||
{
|
{
|
||||||
foreach (PropertyConditional pc in propertyConditionals)
|
foreach (PropertyConditional pc in propertyConditionals)
|
||||||
{
|
{
|
||||||
string op = pc.Operator;
|
if (target == null || target.SerializableProperties == null) continue;
|
||||||
object value = pc.Value;
|
|
||||||
|
|
||||||
//TODO: Somehow check for non-serialized properties like SpeciesName for even more robust conditional conditioning
|
|
||||||
if (target == null || target.SerializableProperties == null || !target.SerializableProperties.TryGetValue(pc.Attribute, out SerializableProperty property)) continue;
|
|
||||||
|
|
||||||
if (!pc.Matches(property))
|
if (!target.SerializableProperties.TryGetValue(pc.Attribute, out SerializableProperty property))
|
||||||
|
{
|
||||||
|
//Do special conditional checks
|
||||||
|
|
||||||
|
string valStr = pc.Value.ToString();
|
||||||
|
if (pc.Attribute == "name")
|
||||||
|
return pc.Operator == "==" ? target.Name == valStr : target.Name != valStr;
|
||||||
|
|
||||||
|
if (pc.Attribute == "speciesname" && target is Character)
|
||||||
|
return pc.Operator == "==" ? ((Character)target).SpeciesName == valStr : ((Character)target).SpeciesName != valStr;
|
||||||
|
|
||||||
|
if ((pc.Attribute == "hastag" || pc.Attribute == "hastags") && target is Item)
|
||||||
|
{
|
||||||
|
string[] readTags = valStr.Split(',');
|
||||||
|
int matches = 0;
|
||||||
|
foreach (string tag in readTags)
|
||||||
|
if (((Item)target).HasTag(tag)) matches++;
|
||||||
|
|
||||||
|
//If operator is == then it needs to match everything, otherwise if its != there must be zero matches.
|
||||||
|
return pc.Operator == "==" ? matches >= readTags.Length : matches <= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<DurationListElement> durations = DurationList.FindAll(d => d.Targets.Contains(target));
|
||||||
|
List<DelayedListElement> delays = DelayedEffect.DelayList.FindAll(d => d.Targets.Contains(target));
|
||||||
|
|
||||||
|
bool success = false;
|
||||||
|
if (pc.Attribute == "hasstatustag" || pc.Attribute == "hasstatustags" && (durations.Any() || delays.Any()))
|
||||||
|
{
|
||||||
|
string[] readTags = valStr.Split(',');
|
||||||
|
foreach (DurationListElement duration in durations)
|
||||||
|
{
|
||||||
|
int matches = 0;
|
||||||
|
foreach (string tag in readTags)
|
||||||
|
if (duration.Parent.HasTag(tag)) matches++;
|
||||||
|
|
||||||
|
success = pc.Operator == "==" ? matches >= readTags.Length : matches <= 0;
|
||||||
|
if (cancelStatusEffect > 0 && success)
|
||||||
|
DurationList.Remove(duration);
|
||||||
|
if (cancelStatusEffect != 2) //cancelStatusEffect 1 = only cancel once, cancelStatusEffect 2 = cancel all of matching tags
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
foreach (DelayedListElement delay in delays)
|
||||||
|
{
|
||||||
|
int matches = 0;
|
||||||
|
foreach (string tag in readTags)
|
||||||
|
if (delay.Parent.HasTag(tag)) matches++;
|
||||||
|
|
||||||
|
success = pc.Operator == "==" ? matches >= readTags.Length : matches <= 0;
|
||||||
|
if (cancelStatusEffect > 0 && success)
|
||||||
|
DelayedEffect.DelayList.Remove(delay);
|
||||||
|
if (cancelStatusEffect != 2) //ditto
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
else if (!pc.Matches(property))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -456,11 +517,14 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (useItem)
|
if (useItemCount > 0)
|
||||||
{
|
{
|
||||||
foreach (Item item in targets.FindAll(t => t is Item).Cast<Item>())
|
for (int i=0; i<useItemCount; i++)
|
||||||
{
|
{
|
||||||
item.Use(deltaTime, targets.FirstOrDefault(t => t is Character) as Character);
|
foreach (Item item in targets.FindAll(t => t is Item).Cast<Item>())
|
||||||
|
{
|
||||||
|
item.Use(deltaTime, targets.FirstOrDefault(t => t is Character) as Character);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user