Added an artifact that attracts creatures, item max health can be changed & items can be made indestructible
This commit is contained in:
@@ -93,7 +93,7 @@ namespace Barotrauma.Items.Components
|
|||||||
public void Draw(SpriteBatch spriteBatch, bool editing)
|
public void Draw(SpriteBatch spriteBatch, bool editing)
|
||||||
{
|
{
|
||||||
Color color = (item.IsSelected) ? Color.Green : Color.White;
|
Color color = (item.IsSelected) ? Color.Green : Color.White;
|
||||||
color = color * (item.Condition / 100.0f);
|
color = color * (item.Condition / item.Prefab.Health);
|
||||||
color.A = 255;
|
color.A = 255;
|
||||||
|
|
||||||
//prefab.sprite.Draw(spriteBatch, new Vector2(rect.X, -rect.Y), new Vector2(rect.Width, rect.Height), color);
|
//prefab.sprite.Draw(spriteBatch, new Vector2(rect.X, -rect.Y), new Vector2(rect.Width, rect.Height), color);
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
if (!unfixedFound)
|
if (!unfixedFound)
|
||||||
{
|
{
|
||||||
item.Condition = 100.0f;
|
item.Condition = item.Prefab.Health;
|
||||||
frame = null;
|
frame = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -167,21 +167,21 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (item != null && drawItem)
|
if (item != null && drawItem)
|
||||||
{
|
{
|
||||||
if (item.Condition < 100.0f)
|
if (item.Condition < item.Prefab.Health)
|
||||||
{
|
{
|
||||||
GUI.DrawRectangle(spriteBatch, new Rectangle(rect.X, rect.Bottom - 8, rect.Width, 8), Color.Black * 0.8f, true);
|
GUI.DrawRectangle(spriteBatch, new Rectangle(rect.X, rect.Bottom - 8, rect.Width, 8), Color.Black * 0.8f, true);
|
||||||
GUI.DrawRectangle(spriteBatch,
|
GUI.DrawRectangle(spriteBatch,
|
||||||
new Rectangle(rect.X, rect.Bottom - 8, (int)(rect.Width * item.Condition / 100.0f), 8),
|
new Rectangle(rect.X, rect.Bottom - 8, (int)(rect.Width * item.Condition / item.Prefab.Health), 8),
|
||||||
Color.Lerp(Color.Red, Color.Green, item.Condition / 100.0f) * 0.8f, true);
|
Color.Lerp(Color.Red, Color.Green, item.Condition / 100.0f) * 0.8f, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
var containedItems = item.ContainedItems;
|
var containedItems = item.ContainedItems;
|
||||||
if (containedItems != null && containedItems.Length == 1 && containedItems[0].Condition < 100.0f)
|
if (containedItems != null && containedItems.Length == 1 && containedItems[0].Condition < item.Prefab.Health)
|
||||||
{
|
{
|
||||||
GUI.DrawRectangle(spriteBatch, new Rectangle(rect.X, rect.Y, rect.Width, 8), Color.Black * 0.8f, true);
|
GUI.DrawRectangle(spriteBatch, new Rectangle(rect.X, rect.Y, rect.Width, 8), Color.Black * 0.8f, true);
|
||||||
GUI.DrawRectangle(spriteBatch,
|
GUI.DrawRectangle(spriteBatch,
|
||||||
new Rectangle(rect.X, rect.Y, (int)(rect.Width * containedItems[0].Condition / 100.0f), 8),
|
new Rectangle(rect.X, rect.Y, (int)(rect.Width * containedItems[0].Condition / 100.0f), 8),
|
||||||
Color.Lerp(Color.Red, Color.Green, containedItems[0].Condition / 100.0f) * 0.8f, true);
|
Color.Lerp(Color.Red, Color.Green, containedItems[0].Condition / item.Prefab.Health) * 0.8f, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,12 @@
|
|||||||
using Barotrauma.Items.Components;
|
using Barotrauma.Items.Components;
|
||||||
using Barotrauma.Networking;
|
using Barotrauma.Networking;
|
||||||
using FarseerPhysics;
|
using FarseerPhysics;
|
||||||
using FarseerPhysics.Dynamics;
|
|
||||||
using FarseerPhysics.Dynamics.Contacts;
|
|
||||||
using Lidgren.Network;
|
using Lidgren.Network;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
using Microsoft.Xna.Framework.Input;
|
using Microsoft.Xna.Framework.Input;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
@@ -455,7 +452,7 @@ namespace Barotrauma
|
|||||||
ownInventory.ClientRead(type, msg, sendingTime);
|
ownInventory.ClientRead(type, msg, sendingTime);
|
||||||
break;
|
break;
|
||||||
case NetEntityEvent.Type.Status:
|
case NetEntityEvent.Type.Status:
|
||||||
condition = msg.ReadRangedSingle(0.0f, 100.0f, 8);
|
condition = msg.ReadRangedSingle(0.0f, prefab.Health, 8);
|
||||||
|
|
||||||
if (FixRequirements.Count > 0)
|
if (FixRequirements.Count > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 34 KiB |
@@ -6,7 +6,7 @@
|
|||||||
Tags="alien"
|
Tags="alien"
|
||||||
pickdistance="150">
|
pickdistance="150">
|
||||||
|
|
||||||
<Sprite texture="artifact.png" depth="0.7" sourcerect="59,0,60,61"/>
|
<Sprite texture="artifact.png" depth="0.7" sourcerect="58,0,60,60"/>
|
||||||
|
|
||||||
<Deconstruct time="30">
|
<Deconstruct time="30">
|
||||||
<Item name="Steel Bar"/>
|
<Item name="Steel Bar"/>
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<Item name="Uranium Bar"/>
|
<Item name="Uranium Bar"/>
|
||||||
</Deconstruct>
|
</Deconstruct>
|
||||||
|
|
||||||
<Body width="60" height="61" density="50"/>
|
<Body width="60" height="61" density="50" friction="0.95"/>
|
||||||
|
|
||||||
<Holdable slots="RightHand+LeftHand" holdpos="30,-15" handle1="0,10" handle2="0,-10">
|
<Holdable slots="RightHand+LeftHand" holdpos="30,-15" handle1="0,10" handle2="0,-10">
|
||||||
<StatusEffect type="Always" target="Hull" oxygen="-50000.0"/>
|
<StatusEffect type="Always" target="Hull" oxygen="-50000.0"/>
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
Tags="alien"
|
Tags="alien"
|
||||||
pickdistance="150">
|
pickdistance="150">
|
||||||
|
|
||||||
<Sprite texture="artifact.png" depth="0.7" sourcerect="0,0,58,56"/>
|
<Sprite texture="artifact.png" depth="0.7" sourcerect="1,0,57,56"/>
|
||||||
|
|
||||||
<Deconstruct time="30">
|
<Deconstruct time="30">
|
||||||
<Item name="Steel Bar"/>
|
<Item name="Steel Bar"/>
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
<Item name="Incendium Bar"/>
|
<Item name="Incendium Bar"/>
|
||||||
</Deconstruct>
|
</Deconstruct>
|
||||||
|
|
||||||
<Body radius="28" density="50"/>
|
<Body radius="28" density="50" friction="0.95"/>
|
||||||
|
|
||||||
<Holdable slots="RightHand+LeftHand" holdpos="30,-15" handle1="0,10" handle2="0,-10">
|
<Holdable slots="RightHand+LeftHand" holdpos="30,-15" handle1="0,10" handle2="0,-10">
|
||||||
<StatusEffect type="Always">
|
<StatusEffect type="Always">
|
||||||
@@ -48,6 +48,7 @@
|
|||||||
|
|
||||||
<Item
|
<Item
|
||||||
name="Faraday Artifact"
|
name="Faraday Artifact"
|
||||||
|
category="Alien"
|
||||||
Tags="alien"
|
Tags="alien"
|
||||||
pickdistance="150">
|
pickdistance="150">
|
||||||
|
|
||||||
@@ -60,7 +61,30 @@
|
|||||||
<Item name="Fulgurium Bar"/>
|
<Item name="Fulgurium Bar"/>
|
||||||
</Deconstruct>
|
</Deconstruct>
|
||||||
|
|
||||||
<Body radius="25" density="50"/>
|
<Body radius="25" density="50" friction="0.95"/>
|
||||||
|
|
||||||
|
<Holdable slots="RightHand+LeftHand" holdpos="30,-15" handle1="0,10" handle2="0,-10"/>
|
||||||
|
</Item>
|
||||||
|
|
||||||
|
<Item
|
||||||
|
name="Nasonov Artifact"
|
||||||
|
category="Alien"
|
||||||
|
Tags="alien"
|
||||||
|
pickdistance="150"
|
||||||
|
indestructible="true">
|
||||||
|
|
||||||
|
<Sprite texture="artifact.png" depth="0.7" sourcerect="60,61,63,67"/>
|
||||||
|
|
||||||
|
<Deconstruct time="30">
|
||||||
|
<Item name="Steel Bar"/>
|
||||||
|
<Item name="Fulgurium Bar"/>
|
||||||
|
<Item name="Fulgurium Bar"/>
|
||||||
|
<Item name="Fulgurium Bar"/>
|
||||||
|
</Deconstruct>
|
||||||
|
|
||||||
|
<AiTarget sightrange="10000.0" soundrange="10000"/>
|
||||||
|
|
||||||
|
<Body width="55" height="55" density="50" friction="0.95"/>
|
||||||
|
|
||||||
<Holdable slots="RightHand+LeftHand" holdpos="30,-15" handle1="0,10" handle2="0,-10"/>
|
<Holdable slots="RightHand+LeftHand" holdpos="30,-15" handle1="0,10" handle2="0,-10"/>
|
||||||
</Item>
|
</Item>
|
||||||
@@ -72,7 +96,7 @@
|
|||||||
tags="alien,smallitem"
|
tags="alien,smallitem"
|
||||||
impacttolerance="8">
|
impacttolerance="8">
|
||||||
|
|
||||||
<Sprite texture="artifact.png" depth="0.7" sourcerect="119,96,9,32"/>
|
<Sprite texture="artifact.png" depth="0.7" sourcerect="119,0,9,32"/>
|
||||||
|
|
||||||
<Body width="9" height="32" density="15"/>
|
<Body width="9" height="32" density="15"/>
|
||||||
|
|
||||||
@@ -100,7 +124,7 @@
|
|||||||
<Item name="Sulphuric Acid"/>
|
<Item name="Sulphuric Acid"/>
|
||||||
</Deconstruct>
|
</Deconstruct>
|
||||||
|
|
||||||
<Sprite texture="artifact.png" depth="0.7" sourcerect="119,96,9,32"/>
|
<Sprite texture="artifact.png" depth="0.7" sourcerect="119,0,9,32"/>
|
||||||
|
|
||||||
<Body width="9" height="32" density="15"/>
|
<Body width="9" height="32" density="15"/>
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,19 @@
|
|||||||
<message header="Artifact collected" text="The artifact is now on board. Navigate the submarine out of the cavern to claim the reward."/>
|
<message header="Artifact collected" text="The artifact is now on board. Navigate the submarine out of the cavern to claim the reward."/>
|
||||||
</SalvageMission>
|
</SalvageMission>
|
||||||
|
|
||||||
|
<SalvageMission
|
||||||
|
name="Salvaging an artifact"
|
||||||
|
description="Researchers of [location1] have picked up an infrasonic signal highly similar to those emitted by alien artifacts previously discovered on Europa. Investigate the signal and retrieve the potential artifact."
|
||||||
|
commonness="10"
|
||||||
|
reward="2000"
|
||||||
|
radarlabel="Infrasonic signal"
|
||||||
|
failuremessage="Retrieving the artifact failed"
|
||||||
|
successmessage="The artifact has been succesfully retrieved"
|
||||||
|
spawntype="ruin"
|
||||||
|
itemname="Nasonov Artifact">
|
||||||
|
<message header="Artifact collected" text="The artifact is now on board. Navigate the submarine out of the cavern to claim the reward."/>
|
||||||
|
</SalvageMission>
|
||||||
|
|
||||||
<MonsterMission
|
<MonsterMission
|
||||||
name="Killing a Moloch"
|
name="Killing a Moloch"
|
||||||
description="A particularly aggressive Moloch has been terrorizing vessels traveling between [location1] and [location2]. A reward of 1000 credits has been promised to those who kill the creature."
|
description="A particularly aggressive Moloch has been terrorizing vessels traveling between [location1] and [location2]. A reward of 1000 credits has been promised to those who kill the creature."
|
||||||
|
|||||||
@@ -502,7 +502,7 @@ namespace Barotrauma
|
|||||||
case "fixitems":
|
case "fixitems":
|
||||||
foreach (Item it in Item.ItemList)
|
foreach (Item it in Item.ItemList)
|
||||||
{
|
{
|
||||||
it.Condition = 100.0f;
|
it.Condition = it.Prefab.Health;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "fixhull":
|
case "fixhull":
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
public override void Update(float deltaTime)
|
public override void Update(float deltaTime)
|
||||||
{
|
{
|
||||||
if (item.Condition > 50.0f) Finished();
|
if (item.Condition > item.Prefab.Health * 0.5f) Finished();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ namespace Barotrauma.Items.Components
|
|||||||
|
|
||||||
foreach (DeconstructItem deconstructProduct in targetItem.Prefab.DeconstructItems)
|
foreach (DeconstructItem deconstructProduct in targetItem.Prefab.DeconstructItems)
|
||||||
{
|
{
|
||||||
if (deconstructProduct.RequireFullCondition && targetItem.Condition < 100.0f) continue;
|
if (deconstructProduct.RequireFullCondition && targetItem.Condition < targetItem.Prefab.Health) continue;
|
||||||
|
|
||||||
var itemPrefab = MapEntityPrefab.list.FirstOrDefault(ip => ip.Name.ToLowerInvariant() == deconstructProduct.ItemPrefabName.ToLowerInvariant()) as ItemPrefab;
|
var itemPrefab = MapEntityPrefab.list.FirstOrDefault(ip => ip.Name.ToLowerInvariant() == deconstructProduct.ItemPrefabName.ToLowerInvariant()) as ItemPrefab;
|
||||||
if (itemPrefab == null)
|
if (itemPrefab == null)
|
||||||
|
|||||||
@@ -178,10 +178,11 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (GameMain.Client != null) return;
|
if (GameMain.Client != null) return;
|
||||||
if (!MathUtils.IsValid(value)) return;
|
if (!MathUtils.IsValid(value)) return;
|
||||||
|
if (prefab.Indestructible) return;
|
||||||
|
|
||||||
float prev = condition;
|
float prev = condition;
|
||||||
condition = MathHelper.Clamp(value, 0.0f, 100.0f);
|
condition = MathHelper.Clamp(value, 0.0f, prefab.Health);
|
||||||
if (condition == 0.0f && prev>0.0f)
|
if (condition == 0.0f && prev > 0.0f)
|
||||||
{
|
{
|
||||||
ApplyStatusEffects(ActionType.OnBroken, 1.0f, null);
|
ApplyStatusEffects(ActionType.OnBroken, 1.0f, null);
|
||||||
foreach (FixRequirement req in FixRequirements)
|
foreach (FixRequirement req in FixRequirements)
|
||||||
@@ -192,7 +193,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (GameMain.Server != null && lastSentCondition != condition)
|
if (GameMain.Server != null && lastSentCondition != condition)
|
||||||
{
|
{
|
||||||
if (Math.Abs(lastSentCondition - condition) > 1.0f || condition == 0.0f || condition == 100.0f)
|
if (Math.Abs(lastSentCondition - condition) > 1.0f || condition == 0.0f || condition == prefab.Health)
|
||||||
{
|
{
|
||||||
GameMain.Server.CreateEntityEvent(this, new object[] { NetEntityEvent.Type.Status });
|
GameMain.Server.CreateEntityEvent(this, new object[] { NetEntityEvent.Type.Status });
|
||||||
lastSentCondition = condition;
|
lastSentCondition = condition;
|
||||||
@@ -341,8 +342,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (submarine==null || !submarine.Loading) FindHull();
|
if (submarine==null || !submarine.Loading) FindHull();
|
||||||
|
|
||||||
condition = 100.0f;
|
condition = prefab.Health;
|
||||||
lastSentCondition = 100.0f;
|
lastSentCondition = prefab.Health;
|
||||||
|
|
||||||
XElement element = prefab.ConfigElement;
|
XElement element = prefab.ConfigElement;
|
||||||
if (element == null) return;
|
if (element == null) return;
|
||||||
@@ -740,6 +741,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public AttackResult AddDamage(IDamageable attacker, Vector2 worldPosition, Attack attack, float deltaTime, bool playSound = true)
|
public AttackResult AddDamage(IDamageable attacker, Vector2 worldPosition, Attack attack, float deltaTime, bool playSound = true)
|
||||||
{
|
{
|
||||||
|
if (prefab.Indestructible) return new AttackResult();
|
||||||
|
|
||||||
float damageAmount = attack.GetStructureDamage(deltaTime);
|
float damageAmount = attack.GetStructureDamage(deltaTime);
|
||||||
Condition -= damageAmount;
|
Condition -= damageAmount;
|
||||||
|
|
||||||
@@ -1321,9 +1324,9 @@ namespace Barotrauma
|
|||||||
ownInventory.ServerWrite(msg, c, extraData);
|
ownInventory.ServerWrite(msg, c, extraData);
|
||||||
break;
|
break;
|
||||||
case NetEntityEvent.Type.Status:
|
case NetEntityEvent.Type.Status:
|
||||||
//clamp above 0.5f if condition > 0.0f
|
//clamp to (MaxHealth / 255.0f) if condition > 0.0f
|
||||||
//to prevent condition from being rounded down to 0.0 even if the item is not broken
|
//to prevent condition from being rounded down to 0.0 even if the item is not broken
|
||||||
msg.WriteRangedSingle(condition > 0.0f ? Math.Max(condition, 0.5f) : 0.0f, 0.0f, 100.0f, 8);
|
msg.WriteRangedSingle(condition > 0.0f ? Math.Max(condition, prefab.Health / 255.0f) : 0.0f, 0.0f, prefab.Health, 8);
|
||||||
|
|
||||||
if (condition <= 0.0f && FixRequirements.Count > 0)
|
if (condition <= 0.0f && FixRequirements.Count > 0)
|
||||||
{
|
{
|
||||||
@@ -1370,7 +1373,7 @@ namespace Barotrauma
|
|||||||
FixRequirements[requirementIndex].Fixed = true;
|
FixRequirements[requirementIndex].Fixed = true;
|
||||||
if (condition <= 0.0f && FixRequirements.All(f => f.Fixed))
|
if (condition <= 0.0f && FixRequirements.All(f => f.Fixed))
|
||||||
{
|
{
|
||||||
Condition = 100.0f;
|
Condition = prefab.Health;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameMain.Server.CreateEntityEvent(this, new object[] { NetEntityEvent.Type.Status });
|
GameMain.Server.CreateEntityEvent(this, new object[] { NetEntityEvent.Type.Status });
|
||||||
|
|||||||
@@ -104,6 +104,17 @@ namespace Barotrauma
|
|||||||
get { return offsetOnSelected; }
|
get { return offsetOnSelected; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float Health
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Indestructible
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
public float ImpactTolerance
|
public float ImpactTolerance
|
||||||
{
|
{
|
||||||
@@ -242,8 +253,10 @@ namespace Barotrauma
|
|||||||
|
|
||||||
CanUseOnSelf = ToolBox.GetAttributeBool(element, "canuseonself", false);
|
CanUseOnSelf = ToolBox.GetAttributeBool(element, "canuseonself", false);
|
||||||
|
|
||||||
FireProof = ToolBox.GetAttributeBool(element, "fireproof", false);
|
|
||||||
|
|
||||||
|
Health = ToolBox.GetAttributeFloat(element, "health", 100.0f);
|
||||||
|
Indestructible = ToolBox.GetAttributeBool(element, "indestructible", false);
|
||||||
|
FireProof = ToolBox.GetAttributeBool(element, "fireproof", false);
|
||||||
ImpactTolerance = ToolBox.GetAttributeFloat(element, "impacttolerance", 0.0f);
|
ImpactTolerance = ToolBox.GetAttributeFloat(element, "impacttolerance", 0.0f);
|
||||||
|
|
||||||
string aliases = ToolBox.GetAttributeString(element, "aliases", "");
|
string aliases = ToolBox.GetAttributeString(element, "aliases", "");
|
||||||
|
|||||||
@@ -330,7 +330,7 @@ namespace Barotrauma.Networking
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
item.Condition = 100.0f;
|
item.Condition = item.Prefab.Health;
|
||||||
|
|
||||||
var powerContainer = item.GetComponent<PowerContainer>();
|
var powerContainer = item.GetComponent<PowerContainer>();
|
||||||
if (powerContainer != null)
|
if (powerContainer != null)
|
||||||
|
|||||||
@@ -290,7 +290,7 @@ namespace Barotrauma
|
|||||||
body.CollidesWith = Physics.CollisionWall | Physics.CollisionLevel;
|
body.CollidesWith = Physics.CollisionWall | Physics.CollisionLevel;
|
||||||
|
|
||||||
body.Friction = ToolBox.GetAttributeFloat(element, "friction", 0.3f);
|
body.Friction = ToolBox.GetAttributeFloat(element, "friction", 0.3f);
|
||||||
body.Restitution = 0.05f;
|
body.Restitution = ToolBox.GetAttributeFloat(element, "restitution", 0.05f);
|
||||||
|
|
||||||
body.BodyType = BodyType.Dynamic;
|
body.BodyType = BodyType.Dynamic;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user