Base ItemComponents can apply OnUse statuseffects, grenades can be placed in detonators. Closes #113

This commit is contained in:
Joonas Rikkonen
2018-01-09 14:55:16 +02:00
parent c2e3f60641
commit 18ae9d7820
4 changed files with 26 additions and 11 deletions

View File

@@ -100,7 +100,9 @@
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]">
<requireditem name="Screwdriver,Wire" type="Equipped"/>
<input name="activate">
<StatusEffect type="OnUse" target="Contained" Condition="-100.0"/>
<StatusEffect type="OnUse" target="Contained" Condition="-100.0">
<Use/>
</StatusEffect>
</input>
</ConnectionPanel>
</Item>

View File

@@ -142,7 +142,7 @@
name="Stun Grenade"
category="Equipment"
price="200"
tags="smallitem,weapon">
tags="smallitem,weapon,explosive">
<Deconstruct time="10">
<Item name="Steel Bar"/>
@@ -153,6 +153,14 @@
<Sprite texture="weapons.png" sourcerect="98,0,11,24" depth="0.55"/>
<Body width="11" height="24" density="30"/>
<!-- Empty itemcomponent that explodes the grenade when used by something else than a character (e.g. a detonator) -->
<ItemComponent characterusable="false">
<StatusEffect type="OnUse" target="This" Condition="-100.0">
<sound file="Content/Items/Weapons/stungrenade.ogg"/>
<Explosion range="500" damage="5" stun="25" force="0.1" smoke="false"/>
</StatusEffect>
</ItemComponent>
<Throwable slots="Any,RightHand,LeftHand" holdpos="0,0" handle1="0,0" throwforce="4.0" aimpos="35,-10">
<StatusEffect type="OnSecondaryUse" target="This" Condition="-100.0" delay="3.0">
@@ -165,7 +173,7 @@
<Item
name="Incendium Grenade"
category="Equipment"
tags="smallitem,weapon">
tags="smallitem,weapon,explosive">
<Deconstruct time="10">
<Item name="Steel Bar"/>
@@ -177,6 +185,14 @@
<Body width="11" height="24" density="30"/>
<!-- Empty itemcomponent that explodes the grenade when used by something else than a character (e.g. a detonator) -->
<ItemComponent characterusable="false">
<StatusEffect type="OnUse" target="This" Condition="-100.0">
<sound file="Content/Items/Weapons/stungrenade.ogg"/>
<Explosion range="500" damage="5" stun="25" force="0.1" smoke="false"/>
</StatusEffect>
</ItemComponent>
<Throwable slots="Any,RightHand,LeftHand" holdpos="0,0" handle1="0,0" throwforce="4.0" aimpos="35,-10">
<StatusEffect type="OnSecondaryUse" target="This" Condition="-100.0" delay="3.0">
<sound file="Content/Items/Weapons/stungrenade.ogg"/>

View File

@@ -516,15 +516,12 @@ namespace Barotrauma
}
}
#endif
if (useItemCount > 0)
for (int i = 0; i < useItemCount; i++)
{
for (int i=0; i<useItemCount; i++)
foreach (Item item in targets.FindAll(t => t is Item).Cast<Item>())
{
foreach (Item item in targets.FindAll(t => t is Item).Cast<Item>())
{
item.Use(deltaTime, targets.FirstOrDefault(t => t is Character) as Character);
}
item.Use(deltaTime, targets.FirstOrDefault(t => t is Character) as Character);
}
}

View File

@@ -305,7 +305,7 @@ namespace Barotrauma.Items.Components
//returns true if the item was used succesfully (not out of ammo, reloading, etc)
public virtual bool Use(float deltaTime, Character character = null)
{
return false;
return characterUsable || character == null;
}
//called when the item is equipped and right mouse button is pressed