Fire probability and the voltage required for a PowerTransfer item to take damage can be configured in the xml. Docking ports & hatches don't get broken by excess voltage. Closes #589
This commit is contained in:
@@ -103,8 +103,7 @@
|
|||||||
|
|
||||||
<Item
|
<Item
|
||||||
name="Docking Port"
|
name="Docking Port"
|
||||||
linkable="true"
|
linkable="true">
|
||||||
>
|
|
||||||
|
|
||||||
<Sprite texture ="dockingport.png" sourcerect="0,0,112,208" depth="0.94" origin="0.5,0.5"/>
|
<Sprite texture ="dockingport.png" sourcerect="0,0,112,208" depth="0.94" origin="0.5,0.5"/>
|
||||||
|
|
||||||
@@ -116,14 +115,8 @@
|
|||||||
<sound file="Content/Items/Door/doorBreak2.ogg" range="3000"/>
|
<sound file="Content/Items/Door/doorBreak2.ogg" range="3000"/>
|
||||||
</StatusEffect>
|
</StatusEffect>
|
||||||
</DockingPort>
|
</DockingPort>
|
||||||
|
|
||||||
<fixrequirement name="Electrical repairs">
|
<PowerTransfer CanBeOverloaded="false" FireProbability="0.0"/>
|
||||||
<skill name="Electrical Engineering" level="40"/>
|
|
||||||
<item name="Wire"/>
|
|
||||||
<item name="Screwdriver"/>
|
|
||||||
</fixrequirement>
|
|
||||||
|
|
||||||
<PowerTransfer/>
|
|
||||||
<Wire/>
|
<Wire/>
|
||||||
|
|
||||||
<fixrequirement name="Mechanical repairs">
|
<fixrequirement name="Mechanical repairs">
|
||||||
@@ -143,8 +136,7 @@
|
|||||||
|
|
||||||
<Item
|
<Item
|
||||||
name="Docking Hatch"
|
name="Docking Hatch"
|
||||||
linkable="true"
|
linkable="true">
|
||||||
>
|
|
||||||
|
|
||||||
<Sprite texture ="dockingport2.png" sourcerect="0,0,128,112" depth="0.94" origin="0.5,0.5"/>
|
<Sprite texture ="dockingport2.png" sourcerect="0,0,128,112" depth="0.94" origin="0.5,0.5"/>
|
||||||
|
|
||||||
@@ -157,13 +149,7 @@
|
|||||||
</StatusEffect>
|
</StatusEffect>
|
||||||
</DockingPort>
|
</DockingPort>
|
||||||
|
|
||||||
<fixrequirement name="Electrical repairs">
|
<PowerTransfer CanBeOverloaded="false" FireProbability="0.0"/>
|
||||||
<skill name="Electrical Engineering" level="40"/>
|
|
||||||
<item name="Wire"/>
|
|
||||||
<item name="Screwdriver"/>
|
|
||||||
</fixrequirement>
|
|
||||||
|
|
||||||
<PowerTransfer/>
|
|
||||||
<Wire/>
|
<Wire/>
|
||||||
|
|
||||||
<fixrequirement name="Mechanical repairs">
|
<fixrequirement name="Mechanical repairs">
|
||||||
@@ -183,8 +169,7 @@
|
|||||||
|
|
||||||
<Item
|
<Item
|
||||||
name="Duct Block"
|
name="Duct Block"
|
||||||
linkable="true"
|
linkable="true">
|
||||||
>
|
|
||||||
|
|
||||||
<Sprite texture ="duct.png" sourcerect="0,0,33,33" depth="0.01" origin="0.5,0.5"/>
|
<Sprite texture ="duct.png" sourcerect="0,0,33,33" depth="0.01" origin="0.5,0.5"/>
|
||||||
|
|
||||||
|
|||||||
@@ -11,9 +11,7 @@ namespace Barotrauma.Items.Components
|
|||||||
static float fullLoad;
|
static float fullLoad;
|
||||||
|
|
||||||
private int updateCount;
|
private int updateCount;
|
||||||
|
|
||||||
const float FireProbability = 0.15f;
|
|
||||||
|
|
||||||
//affects how fast changes in power/load are carried over the grid
|
//affects how fast changes in power/load are carried over the grid
|
||||||
static float inertia = 5.0f;
|
static float inertia = 5.0f;
|
||||||
|
|
||||||
@@ -42,6 +40,29 @@ namespace Barotrauma.Items.Components
|
|||||||
get { return powerLoad; }
|
get { return powerLoad; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Serialize(true, true), Editable(ToolTip = "Can the item be damaged if too much power is supplied to the power grid.")]
|
||||||
|
public bool CanBeOverloaded
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serialize(2.0f, true), Editable(MinValueFloat = 1.0f, ToolTip =
|
||||||
|
"How much power has to be supplied to the grid relative to the load before item starts taking damage. "
|
||||||
|
+"E.g. a value of 2 means that the grid has to be receiving twice as much power as the devices in the grid are consuming.")]
|
||||||
|
public float OverloadVoltage
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serialize(0.15f, true), Editable(MinValueFloat = 0.0f, MaxValueFloat = 1.0f, ToolTip = "The probability for a fire to start when the item breaks.")]
|
||||||
|
public float FireProbability
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
|
|
||||||
//can the component transfer power
|
//can the component transfer power
|
||||||
private bool canTransfer;
|
private bool canTransfer;
|
||||||
public bool CanTransfer
|
public bool CanTransfer
|
||||||
@@ -147,10 +168,13 @@ namespace Barotrauma.Items.Components
|
|||||||
//(except if running as a client)
|
//(except if running as a client)
|
||||||
if (GameMain.Client != null) continue;
|
if (GameMain.Client != null) continue;
|
||||||
|
|
||||||
|
//if the item can't be fixed, don't allow it to break
|
||||||
|
if (item.FixRequirements.Count == 0 || !CanBeOverloaded) continue;
|
||||||
|
|
||||||
//relays don't blow up if the power is higher than load, only if the output is high enough
|
//relays don't blow up if the power is higher than load, only if the output is high enough
|
||||||
//(i.e. enough power passing through the relay)
|
//(i.e. enough power passing through the relay)
|
||||||
if (this is RelayComponent) continue;
|
if (this is RelayComponent) continue;
|
||||||
if (-pt.currPowerConsumption < Math.Max(pt.powerLoad * Rand.Range(1.9f, 2.1f), 200.0f)) continue;
|
if (-pt.currPowerConsumption < Math.Max(pt.powerLoad, 200.0f) * OverloadVoltage) continue;
|
||||||
|
|
||||||
float prevCondition = pt.item.Condition;
|
float prevCondition = pt.item.Condition;
|
||||||
pt.item.Condition -= deltaTime * 10.0f;
|
pt.item.Condition -= deltaTime * 10.0f;
|
||||||
@@ -170,7 +194,7 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (FireProbability > 0.0f && Rand.Int((int)(1.0f / FireProbability)) == 1)
|
if (FireProbability > 0.0f && FireProbability < Rand.Range(0.0f, 1.0f))
|
||||||
{
|
{
|
||||||
new FireSource(pt.item.WorldPosition);
|
new FireSource(pt.item.WorldPosition);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user