- sonar shows the outlines of docked subs (instead of normal sonar blips)

- fixed lights not being removed if the same explosion is triggered again before the previous one is finished
- fixed electrical shocks from junction boxes stunning nearby players (and not just the player using the jb)
- showing restart timer as mins + secs
- more server settings
This commit is contained in:
Regalis
2016-07-25 18:30:13 +03:00
parent dd9b78f8ff
commit 09782be231
8 changed files with 127 additions and 43 deletions

View File

@@ -23,7 +23,7 @@
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]">
<RequiredSkill name="Electrical Engineering" level="30"/>
<StatusEffect type="OnFailure" target="Character">
<Explosion range="100.0" damage="5" stun="10" force="2.0" flames="false" shockwave="false" sparks="true"/>
<Explosion range="50.0" damage="0" stun="0" force="2.0" flames="false" shockwave="false" sparks="true"/>
</StatusEffect>
<requireditem name="Screwdriver" type="Equipped"/>

View File

@@ -114,7 +114,7 @@ namespace Barotrauma.Items.Components
private void DrawRadar(SpriteBatch spriteBatch, Rectangle rect)
{
Vector2 center = new Vector2(rect.X + rect.Width*0.75f, rect.Center.Y);
Vector2 center = new Vector2(rect.X + rect.Width*0.5f, rect.Center.Y);
if (!IsActive) return;
@@ -128,6 +128,8 @@ namespace Barotrauma.Items.Components
foreach (Submarine submarine in Submarine.Loaded)
{
if (item.Submarine == submarine && !DetectSubmarineWalls) continue;
if (item.Submarine != null && item.Submarine.DockedTo.Contains(submarine)) continue;
if (submarine.HullVertices == null) continue;
for (int i = 0; i < submarine.HullVertices.Count; i++)
{
@@ -152,16 +154,21 @@ namespace Barotrauma.Items.Components
{
float simScale = displayScale * Physics.DisplayToSimRation;
Vector2 offset = ConvertUnits.ToSimUnits(item.Submarine.WorldPosition - item.WorldPosition);
for (int i = 0; i < item.Submarine.HullVertices.Count; i++)
foreach (Submarine submarine in Submarine.Loaded)
{
Vector2 start = (item.Submarine.HullVertices[i] + offset) * simScale;
start.Y = -start.Y;
Vector2 end = (item.Submarine.HullVertices[(i + 1) % item.Submarine.HullVertices.Count] + offset) * simScale;
end.Y = -end.Y;
if (submarine != item.Submarine && !submarine.DockedTo.Contains(item.Submarine)) continue;
GUI.DrawLine(spriteBatch, center + start, center + end, Color.Green);
Vector2 offset = ConvertUnits.ToSimUnits(submarine.WorldPosition - item.WorldPosition);
for (int i = 0; i < submarine.HullVertices.Count; i++)
{
Vector2 start = (submarine.HullVertices[i] + offset) * simScale;
start.Y = -start.Y;
Vector2 end = (submarine.HullVertices[(i + 1) % submarine.HullVertices.Count] + offset) * simScale;
end.Y = -end.Y;
GUI.DrawLine(spriteBatch, center + start, center + end, Color.Green);
}
}
}

View File

@@ -89,6 +89,8 @@ namespace Barotrauma.Items.Components
float degreeOfSuccess = DegreeOfSuccess(character);
if (Rand.Range(0.0f, 50.0f) < degreeOfSuccess) return false;
character.StartStun(5.0f);
item.ApplyStatusEffects(ActionType.OnFailure, 1.0f, character);
return true;

View File

@@ -11,9 +11,7 @@ namespace Barotrauma
private Attack attack;
private float force;
private LightSource light;
public float CameraShake;
private bool sparks, shockwave, flames;
@@ -30,7 +28,7 @@ namespace Barotrauma
CameraShake = ToolBox.GetAttributeFloat(element, "camerashake", attack.Range*0.1f);
}
public void Explode(Vector2 worldPosition)
{
Hull hull = Hull.FindHull(worldPosition);
@@ -62,8 +60,8 @@ namespace Barotrauma
float displayRange = attack.Range;
if (displayRange < 0.1f) return;
light = new LightSource(worldPosition, displayRange, Color.LightYellow, null);
CoroutineManager.StartCoroutine(DimLight());
var light = new LightSource(worldPosition, displayRange, Color.LightYellow, null);
CoroutineManager.StartCoroutine(DimLight(light));
float cameraDist = Vector2.Distance(GameMain.GameScreen.Cam.Position, worldPosition)/2.0f;
GameMain.GameScreen.Cam.Shake = CameraShake * Math.Max((displayRange - cameraDist) / displayRange, 0.0f);
@@ -92,7 +90,7 @@ namespace Barotrauma
}
private IEnumerable<object> DimLight()
private IEnumerable<object> DimLight(LightSource light)
{
float currBrightness= 1.0f;
float startRange = light.Range;
@@ -102,7 +100,7 @@ namespace Barotrauma
light.Color = new Color(light.Color.R, light.Color.G, light.Color.B, currBrightness);
light.Range = startRange * currBrightness;
currBrightness -= 0.05f;
currBrightness -= CoroutineManager.DeltaTime*10.0f;
yield return CoroutineStatus.Running;
}

View File

@@ -34,7 +34,6 @@ namespace Barotrauma.Networking
private TimeSpan sparseUpdateInterval = new TimeSpan(0, 0, 0, 3);
private SelectionMode subSelectionMode, modeSelectionMode;
private bool registeredToMaster;
@@ -57,6 +56,29 @@ namespace Barotrauma.Networking
private set;
}
[HasDefaultValue(120.0f, true)]
public float RespawnInterval
{
get;
private set;
}
[HasDefaultValue(60.0f, true)]
public float MaxTransportTime
{
get;
private set;
}
[HasDefaultValue(0.2f, true)]
public float MinRespawnRatio
{
get;
private set;
}
[HasDefaultValue(60.0f, true)]
public float AutoRestartInterval
{
@@ -150,9 +172,19 @@ namespace Barotrauma.Networking
private set;
}
public float EndVoteRequiredRatio = 0.5f;
[HasDefaultValue(0.6f, true)]
public float EndVoteRequiredRatio
{
get;
private set;
}
public float KickVoteRequiredRatio = 0.5f;
[HasDefaultValue(0.6f, true)]
public float KickVoteRequiredRatio
{
get;
private set;
}
private void SaveSettings()
{
@@ -195,7 +227,9 @@ namespace Barotrauma.Networking
Enum.TryParse<SelectionMode>(ToolBox.GetAttributeString(doc.Root, "ModeSelection", "Manual"), out modeSelectionMode);
Voting.AllowModeVoting = modeSelectionMode == SelectionMode.Vote;
FileStreamSender.MaxTransferDuration = new TimeSpan(0,0,ToolBox.GetAttributeInt(doc.Root, "MaxFileTransferDuration", 150));
FileStreamSender.MaxTransferDuration = new TimeSpan(0,0,ToolBox.GetAttributeInt(doc.Root, "MaxFileTransferDuration", 150));
showLogButton.Visible = SaveServerLogs;
}
private void CreateSettingsFrame()
@@ -221,14 +255,6 @@ namespace Barotrauma.Networking
settingsTabs[2].Padding = Vector4.Zero;
//var gameTabButton = new GUIButton(new Rectangle(0, 35, 100, 20), "Rounds", GUI.Style, innerFrame);
//gameTabButton.UserData = 0;
//gameTabButton.OnClicked = SelectSettingsTab;
//var serverTabButton = new GUIButton(new Rectangle(105, 35, 100, 20), "Server", GUI.Style, innerFrame);
//serverTabButton.UserData = 1;
//serverTabButton.OnClicked = SelectSettingsTab;
SelectSettingsTab(null, 0);
var closeButton = new GUIButton(new Rectangle(10, 10, 100, 20), "Close", Alignment.BottomRight, GUI.Style, innerFrame);
@@ -306,22 +332,48 @@ namespace Barotrauma.Networking
return true;
};
y += 40;
var respawnIntervalText = new GUITextBlock(new Rectangle(20, y + 20, 20, 20), "Respawn interval", GUI.Style, settingsTabs[0], GUI.SmallFont);
var randomizeLevelBox = new GUITickBox(new Rectangle(0, y, 20, 20), "Randomize level seed between rounds", Alignment.Left, settingsTabs[0]);
randomizeLevelBox.Selected = RandomizeSeed;
randomizeLevelBox.OnSelected = (GUITickBox) =>
var respawnIntervalSlider = new GUIScrollBar(new Rectangle(150, y + 22, 100, 10), GUI.Style, 0.1f, settingsTabs[0]);
respawnIntervalSlider.UserData = respawnIntervalText;
respawnIntervalSlider.Step = 0.05f;
respawnIntervalSlider.BarScroll = RespawnInterval / 600.0f;
respawnIntervalSlider.OnMoved = (GUIScrollBar scrollBar, float barScroll) =>
{
RandomizeSeed = GUITickBox.Selected;
GUITextBlock text = scrollBar.UserData as GUITextBlock;
RespawnInterval = Math.Max(barScroll * 600.0f, 10.0f);
text.Text = "Interval: " + ToolBox.SecondsToReadableTime(RespawnInterval);
return true;
};
respawnIntervalSlider.OnMoved(respawnIntervalSlider, respawnIntervalSlider.BarScroll);
y += 40;
var minRespawnText = new GUITextBlock(new Rectangle(0, y, 200, 20), "Minimum players to respawn", GUI.Style, settingsTabs[0]);
minRespawnText.ToolTip = "What percentage of players has to be dead/spectating until a respawn shuttle is dispatched";
var minRespawnSlider = new GUIScrollBar(new Rectangle(150, y + 22, 100, 10), GUI.Style, 0.1f, settingsTabs[0]);
minRespawnSlider.ToolTip = minRespawnText.ToolTip;
minRespawnSlider.UserData = minRespawnText;
minRespawnSlider.Step = 0.1f;
minRespawnSlider.BarScroll = MinRespawnRatio;
minRespawnSlider.OnMoved = (GUIScrollBar scrollBar, float barScroll) =>
{
GUITextBlock voteText = scrollBar.UserData as GUITextBlock;
MinRespawnRatio = barScroll;
voteText.Text = "Minimum players to respawn: " + (int)MathUtils.Round(MinRespawnRatio * 100.0f, 10.0f) + " %";
return true;
};
minRespawnSlider.OnMoved(minRespawnSlider, MinRespawnRatio);
y += 40;
//--------------------------------------------------------------------------------
// game settings
// server settings
//--------------------------------------------------------------------------------
y = 0;
@@ -330,7 +382,7 @@ namespace Barotrauma.Networking
var startIntervalText = new GUITextBlock(new Rectangle(-10, y, 100, 20), "Autorestart delay", GUI.Style, settingsTabs[1]);
var startIntervalSlider = new GUIScrollBar(new Rectangle(10, y + 22, 100, 10), GUI.Style, 0.1f, settingsTabs[1]);
startIntervalSlider.UserData = startIntervalText;
startIntervalSlider.Step = 0.1f;
startIntervalSlider.Step = 0.05f;
startIntervalSlider.BarScroll = AutoRestartInterval / 300.0f;
startIntervalSlider.OnMoved = (GUIScrollBar scrollBar, float barScroll) =>
{
@@ -338,9 +390,7 @@ namespace Barotrauma.Networking
AutoRestartInterval = Math.Max(barScroll * 300.0f, 10.0f);
var timeSpan = new TimeSpan(0, 0, (int)AutoRestartInterval);
text.Text = "Autorestart delay: " + timeSpan.ToString("mm':'ss");
text.Text = "Autorestart delay: " + ToolBox.SecondsToReadableTime(AutoRestartInterval);
return true;
};
startIntervalSlider.OnMoved(startIntervalSlider, startIntervalSlider.BarScroll);
@@ -392,6 +442,15 @@ namespace Barotrauma.Networking
return true;
};
y += 40;
var randomizeLevelBox = new GUITickBox(new Rectangle(0, y, 20, 20), "Randomize level seed between rounds", Alignment.Left, settingsTabs[1]);
randomizeLevelBox.Selected = RandomizeSeed;
randomizeLevelBox.OnSelected = (GUITickBox) =>
{
RandomizeSeed = GUITickBox.Selected;
return true;
};
y += 40;

View File

@@ -92,7 +92,8 @@ namespace Barotrauma
if (PlayerInput.KeyDown(Keys.J)) targetMovement.X -= 1.0f;
if (PlayerInput.KeyDown(Keys.L)) targetMovement.X += 1.0f;
GameMain.GameSession.Submarine.ApplyForce(targetMovement * 100000.0f);
if (targetMovement != Vector2.Zero)
GameMain.GameSession.Submarine.ApplyForce(targetMovement * GameMain.GameSession.Submarine.SubBody.Body.Mass * 100.0f);
}
#endif

View File

@@ -136,10 +136,10 @@ namespace Barotrauma
if (GameMain.Server != null)
{
if (!GameMain.Server.AutoRestart) return "";
return "Restarting in " + (int)GameMain.Server.AutoRestartTimer;
return "Restarting in " + ToolBox.SecondsToReadableTime(GameMain.Server.AutoRestartTimer);
}
if (autoRestartTimer == 0.0f) return "";
return "Restarting in " + (int)autoRestartTimer;
return "Restarting in " + ToolBox.SecondsToReadableTime(autoRestartTimer);
}
public NetLobbyScreen()

View File

@@ -411,6 +411,23 @@ namespace Barotrauma
return wrappedText.ToString();
}
public static string SecondsToReadableTime(float seconds)
{
if (seconds <= 60.0f)
{
return (int)seconds + " s";
}
else
{
int m = (int)(seconds / 60.0f);
int s = (int)(seconds % 60.0f);
return s == 0 ?
m + " m" :
m + " m " + s + " s";
}
}
public static string GetRandomLine(string filePath)
{
try