Molochs can damage characters, server log UI, stun weapons have a longer stun time, characters can't breathe when wearing a diving suit with no oxygen tank

This commit is contained in:
Regalis
2016-02-14 19:05:03 +02:00
parent bec6d95198
commit 94e34c0ed9
18 changed files with 136 additions and 68 deletions

View File

@@ -11,7 +11,7 @@
<!-- head -->
<limb id = "0" radius="230" height="500" type="Head" steerforce="1.0" flip="true" armorsector="0.0,180.0" armorvalue="100.0" impacttolerance="100">
<sprite texture="Content/Characters/Moloch/moloch.png" sourcerect="0,0,628,1024" depth="0.02" origin ="0.4,0.5"/>
<attack type="Hit" range="700" duration="0.2" force="400" damagetype="blunt"/>
<attack type="Hit" range="700" duration="0.2" damage="200" stun="5" force="400" damagetype="blunt"/>
</limb>
<limb id = "1" width="50" height="440" flip="true">

View File

@@ -86,12 +86,10 @@
<sprite texture="DivingSuit.png" limb="LeftLeg" sourcerect="17,47,21,51" origin="0.5,0.55" depth="0.02" hidelimb="true"/>
<StatusEffect type="OnWearing" target="Character" ObstructVision="true" PressureProtection="100.0" SpeedMultiplier="0.6" LowPassMultiplier="0.2" setvalue="true" disabledeltatime="true"/>
<StatusEffect type="OnWearing" target="Contained,Character" Oxygen="20.0" Condition="-0.5">
<StatusEffect type="OnWearing" target="Contained,Character" Oxygen="30.0" Condition="-0.5">
<RequiredItem type="Contained" name="Oxygen Tank"/>
</StatusEffect>
<StatusEffect type="OnWearing" target="Contained,Character" Oxygen="-30.0" Condition="-0.5">
<RequiredItem type="Contained" name="Welding Fuel Tank"/>
</StatusEffect>
<StatusEffect type="OnWearing" target="Character" Oxygen="-15.0"/>
</Wearable>
<ItemContainer capacity="1" hideitems="true">

View File

@@ -66,7 +66,7 @@
<Throwable slots="Any,RightHand,LeftHand" holdpos="0,0" handle1="0,0" throwforce="4.0" aimpos="35,-10">
<StatusEffect type="OnUse" target="This" Condition="-100.0" delay="3.0" sound="Content/Items/Weapons/stungrenade.ogg">
<Explosion range="500" damage="5" stun="10" force="0.1"/>
<Explosion range="500" damage="5" stun="25" force="0.1"/>
</StatusEffect>
</Throwable>
</Item>
@@ -109,11 +109,11 @@
<MeleeWeapon slots="Any,RightHand,LeftHand"
aimpos="50,0" handle1="-5,0" holdangle="10" reload="1.0">
<Attack damage="2" stun="0.2" damagetype="Blunt" sound="Content/Items/Weapons/smack.ogg"/>
<StatusEffect type="OnUse" target="Contained,Character" Condition="-25.0" stun="10.0" disabledeltatime="true" sound="Content/Items/Weapons/stunbaton.ogg">
<StatusEffect type="OnUse" target="Contained,Character" Condition="-25.0" stun="15.0" disabledeltatime="true" sound="Content/Items/Weapons/stunbaton.ogg">
<RequiredItem name="Battery Cell" type="Contained" msg="Loaded Battery Cell required"/>
<Explosion range="100.0" force="0.1" shockwave="false" flames="false" camerashake="5.0"/>
</StatusEffect>
<StatusEffect type="OnUse" target="Contained,Character" Condition="-15.0" stun="15.0" disabledeltatime="true" sound="Content/Items/Weapons/stunbaton.ogg">
<StatusEffect type="OnUse" target="Contained,Character" Condition="-15.0" stun="30.0" disabledeltatime="true" sound="Content/Items/Weapons/stunbaton.ogg">
<RequiredItem name="Fulgurium Battery Cell" type="Contained" msg="Loaded Battery Cell required"/>
<Explosion range="100.0" force="0.5" shockwave="false" flames="false" camerashake="5.0"/>
</StatusEffect>

View File

@@ -311,6 +311,8 @@ namespace Barotrauma
{
IDamageable damageTarget = null;
float dist = ConvertUnits.ToDisplayUnits(Vector2.Distance(limb.SimPosition, attackPosition));
switch (limb.attack.Type)
{
case AttackType.PinchCW:
@@ -328,7 +330,6 @@ namespace Barotrauma
break;
}
float dist = ConvertUnits.ToDisplayUnits(Vector2.Distance(limb.SimPosition, attackPosition));
if (dist < limb.attack.Range * 0.5f)
{
attackTimer += deltaTime;
@@ -361,10 +362,16 @@ namespace Barotrauma
break;
}
if (ConvertUnits.ToDisplayUnits(Vector2.Distance(limb.SimPosition, attackPosition)) < limb.attack.Range)
if (dist < limb.attack.Range)
{
attackTimer += deltaTime;
limb.body.ApplyForce(limb.Mass * limb.attack.Force * Vector2.Normalize(attackPosition - limb.SimPosition));
if (damageTarget is Character && dist<limb.attack.Range*0.5f)
{
limb.attack.DoDamage(Character, damageTarget, limb.WorldPosition, deltaTime, false);
}
}
steeringManager.SteeringSeek(attackPosition + (limb.SimPosition-SimPosition), 5.0f);

View File

@@ -1096,7 +1096,7 @@ namespace Barotrauma
var attackingCharacter = attacker as Character;
if (attackingCharacter != null && attackingCharacter.AIController == null)
{
GameServer.Log(Name + " attacked by " + attackingCharacter.Name+". Damage: "+attackResult.Damage+" Bleeding damage: "+attackResult.Bleeding);
GameServer.Log(Name + " attacked by " + attackingCharacter.Name+". Damage: "+attackResult.Damage+" Bleeding damage: "+attackResult.Bleeding, Color.Orange);
}
return attackResult;
@@ -1259,7 +1259,7 @@ namespace Barotrauma
}
}
GameServer.Log(Name+" has died (cause of death: "+causeOfDeath+")");
GameServer.Log(Name+" has died (Cause of death: "+causeOfDeath+")", Color.Red);
if (OnDeath != null) OnDeath(this, causeOfDeath);
@@ -1464,11 +1464,11 @@ namespace Barotrauma
{
if (item == selectedConstruction)
{
GameServer.Log(Name + " deselected " + item.Name);
GameServer.Log(Name + " deselected " + item.Name, Color.Orange);
}
else
{
GameServer.Log(Name + " selected " + item.Name);
GameServer.Log(Name + " selected " + item.Name, Color.Orange);
}
item.Pick(this, false, pickHit, actionHit);
}

View File

@@ -176,7 +176,7 @@ namespace Barotrauma
string header = index < headers.Count ? headers[index] : "";
string message = index < messages.Count ? messages[index] : "";
Barotrauma.Networking.GameServer.Log("Mission info: " + header + " - " + message);
Barotrauma.Networking.GameServer.Log("Mission info: " + header + " - " + message, Color.Cyan);
new GUIMessageBox(header, message);
}

View File

@@ -38,8 +38,8 @@ namespace Barotrauma
new GUIMessageBox(mission.Name, mission.Description, 400, 400);
Networking.GameServer.Log("Mission: " + mission.Name);
Networking.GameServer.Log(mission.Description);
Networking.GameServer.Log("Mission: " + mission.Name, Color.Cyan);
Networking.GameServer.Log(mission.Description, Color.Cyan);
//quest.Start(Level.Loaded);
}

View File

@@ -109,7 +109,7 @@ namespace Barotrauma
{
if (Items[i] != null || limbSlots[i] != LimbSlot.Any) continue;
GameServer.Log(character.Name + " picked up " + item.Name);
GameServer.Log(character.Name + " picked up " + item.Name, Color.Orange);
PutItem(item, i, createNetworkEvent);
item.Unequip(character);
return true;
@@ -144,7 +144,7 @@ namespace Barotrauma
if (placed)
{
if (!alreadyInInventory) GameServer.Log(character.Name + " picked up " + item.Name);
if (!alreadyInInventory) GameServer.Log(character.Name + " picked up " + item.Name, Color.Orange);
return true;
}
}

View File

@@ -164,7 +164,7 @@ namespace Barotrauma.Items.Components
item.body.Enabled = true;
IsActive = true;
if (!alreadySelected) Barotrauma.Networking.GameServer.Log(character.Name+" equipped "+item.Name);
if (!alreadySelected) Barotrauma.Networking.GameServer.Log(character.Name+" equipped "+item.Name, Color.Orange);
}
}
@@ -174,7 +174,7 @@ namespace Barotrauma.Items.Components
picker.DeselectItem(item);
Barotrauma.Networking.GameServer.Log(character.Name + " unequipped " + item.Name);
Barotrauma.Networking.GameServer.Log(character.Name + " unequipped " + item.Name, Color.Orange);
item.body.Enabled = false;
IsActive = false;

View File

@@ -236,8 +236,8 @@ namespace Barotrauma.Items.Components
var sender = GameMain.Server.ConnectedClients.Find(c => c.Connection == message.SenderConnection);
if (sender != null)
{
Networking.GameServer.Log("Pump settings adjusted by " + sender.name);
Networking.GameServer.Log("Active: " + (IsActive ? "yes" : "no ") + " Pumping speed: " + (int)flowPercentage + " %");
Networking.GameServer.Log("Pump settings adjusted by " + sender.name, Color.Orange);
Networking.GameServer.Log("Active: " + (IsActive ? "yes" : "no ") + " Pumping speed: " + (int)flowPercentage + " %", Color.Orange);
}
}
}

View File

@@ -226,7 +226,7 @@ namespace Barotrauma.Items.Components
fissionRate = Math.Min(fissionRate, AvailableFuel);
float heat = 100 * fissionRate * (AvailableFuel/2000.0f);
float heatDissipation = 50 * coolingRate + ExtraCooling;
float heatDissipation = 50 * coolingRate + Math.Max(ExtraCooling, 5.0f);
float deltaTemp = (((heat - heatDissipation) * 5) - temperature) / 10000.0f;
Temperature = temperature + deltaTemp;
@@ -362,7 +362,7 @@ namespace Barotrauma.Items.Components
{
if (item.Condition <= 0.0f) return;
GameServer.Log("Reactor meltdown!");
GameServer.Log("Reactor meltdown!", Color.Red);
new RepairTask(item, 60.0f, "Reactor meltdown!");
item.Condition = 0.0f;
@@ -583,8 +583,8 @@ namespace Barotrauma.Items.Components
var sender = GameMain.Server.ConnectedClients.Find(c => c.Connection == message.SenderConnection);
if (sender != null)
{
Networking.GameServer.Log("Reactor settings adjusted by " + sender.name);
Networking.GameServer.Log("Autotemp: " +(autoTemp ? "ON " : "OFF") + " Shutdown temp: "+shutDownTemp+" Cooling rate: "+coolingRate+" Fission rate: "+fissionRate);
Networking.GameServer.Log("Reactor settings adjusted by " + sender.name+": ", Color.Orange);
Networking.GameServer.Log("Autotemp: " +(autoTemp ? "ON " : "OFF") + " Shutdown temp: "+shutDownTemp+" Cooling rate: "+(int)coolingRate+" Fission rate: "+(int)fissionRate, Color.Orange);
}
}

View File

@@ -146,7 +146,7 @@ namespace Barotrauma.Items.Components
var sender = GameMain.Server.ConnectedClients.Find(c => c.Connection == message.SenderConnection);
if (sender != null)
{
Networking.GameServer.Log(item.Name + " rewired by " + sender.name);
Networking.GameServer.Log(item.Name + " rewired by " + sender.name, Color.Orange);
}
}
@@ -172,7 +172,7 @@ namespace Barotrauma.Items.Components
wireComponent.Connect(c, false);
var otherConnection = c.Wires[i].OtherConnection(c);
Networking.GameServer.Log(c.Name + " -> " + (otherConnection == null ? "none" : otherConnection.Name));
Networking.GameServer.Log(c.Name + " -> " + (otherConnection == null ? "none" : otherConnection.Name), Color.Orange);
}
c.UpdateRecipients();
}

View File

@@ -1125,7 +1125,7 @@ namespace Barotrauma
// new NetworkEvent(NetworkEventType.DropItem, ID, true);
if (dropper != null) GameServer.Log(dropper.Name + " dropped " + Name);
if (dropper != null) GameServer.Log(dropper.Name + " dropped " + Name, Color.Orange);
foreach (ItemComponent ic in components) ic.Drop(dropper);

View File

@@ -33,18 +33,12 @@ namespace Barotrauma.Networking
private bool masterServerResponded;
private ServerLog log;
private GUIButton showLogButton;
public TraitorManager TraitorManager;
public GameServer(string name, int port, bool isPublic = false, string password = "", bool attemptUPnP = false, int maxPlayers = 10)
{
var endRoundButton = new GUIButton(new Rectangle(GameMain.GraphicsWidth - 170, 20, 150, 25), "End round", Alignment.TopLeft, GUI.Style, inGameHUD);
endRoundButton.OnClicked = EndButtonHit;
banList = new BanList();
log = new ServerLog(name);
this.name = name;
this.password = password;
@@ -74,6 +68,31 @@ namespace Barotrauma.Networking
NetIncomingMessageType.UnconnectedData);
config.EnableMessageType(NetIncomingMessageType.ConnectionApproval);
//----------------------------------------
var endRoundButton = new GUIButton(new Rectangle(GameMain.GraphicsWidth - 170, 20, 150, 20), "End round", Alignment.TopLeft, GUI.Style, inGameHUD);
endRoundButton.OnClicked = EndButtonHit;
log = new ServerLog(name);
showLogButton = new GUIButton(new Rectangle(GameMain.GraphicsWidth - 170 - 170, 20, 150, 20), "Server Log", Alignment.TopLeft, GUI.Style, inGameHUD);
showLogButton.OnClicked = (GUIButton button, object userData) =>
{
if (log.LogFrame == null)
{
log.CreateLogFrame();
}
else
{
log.LogFrame = null;
}
return true;
};
banList = new BanList();
//----------------------------------------
CoroutineManager.StartCoroutine(StartServer(isPublic));
}
@@ -82,14 +101,14 @@ namespace Barotrauma.Networking
{
try
{
Log("Starting the server...");
Log("Starting the server...", Color.Cyan);
server = new NetServer(config);
netPeer = server;
server.Start();
}
catch (Exception e)
{
Log("Error while starting the server ("+e.Message+")");
Log("Error while starting the server ("+e.Message+")", Color.Red);
DebugConsole.ThrowError("Couldn't start the server", e);
}
@@ -173,7 +192,7 @@ namespace Barotrauma.Networking
request.AddParameter("gamestarted", gameStarted ? 1 : 0);
request.AddParameter("playercount", PlayerCountToByte(ConnectedClients.Count, config.MaximumConnections));
Log("Refreshing connection with master server...");
Log("Refreshing connection with master server...", Color.Cyan);
var sw = new Stopwatch();
sw.Start();
@@ -189,7 +208,7 @@ namespace Barotrauma.Networking
restRequestHandle.Abort();
DebugConsole.NewMessage("Couldn't connect to master server (request timed out)", Color.Red);
Log("Couldn't connect to master server (request timed out)");
Log("Couldn't connect to master server (request timed out)", Color.Red);
break;
//registeredToMaster = false;
@@ -210,24 +229,25 @@ namespace Barotrauma.Networking
if (response.ErrorException != null)
{
DebugConsole.NewMessage("Error while registering to master server (" + response.ErrorException + ")", Color.Red);
Log("Error while registering to master server (" + response.ErrorException + ")");
Log("Error while registering to master server (" + response.ErrorException + ")", Color.Red);
return;
}
if (response.StatusCode != System.Net.HttpStatusCode.OK)
{
DebugConsole.NewMessage("Error while reporting to master server (" + response.StatusCode + ": " + response.StatusDescription + ")", Color.Red);
Log("Error while reporting to master server (" + response.StatusCode + ": " + response.StatusDescription + ")");
Log("Error while reporting to master server (" + response.StatusCode + ": " + response.StatusDescription + ")", Color.Red);
return;
}
Log("Master server responded");
Log("Master server responded", Color.Cyan);
}
public override void Update(float deltaTime)
{
if (ShowNetStats) netStats.Update(deltaTime);
if (settingsFrame != null) settingsFrame.Update(deltaTime);
if (log.LogFrame != null) log.LogFrame.Update(deltaTime);
if (!started) return;
@@ -248,11 +268,11 @@ namespace Barotrauma.Networking
{
if (AutoRestart && isCrewDead)
{
Log("Ending round (entire crew dead)");
Log("Ending round (entire crew dead)", Color.Cyan);
}
else
{
Log("Ending round (submarine reached the end of the level)");
Log("Ending round (submarine reached the end of the level)", Color.Cyan);
}
EndButtonHit(null, null);
@@ -499,7 +519,7 @@ namespace Barotrauma.Networking
if (Voting.AllowEndVoting && EndVoteMax > 0 &&
((float)EndVoteCount / (float)EndVoteMax) >= EndVoteRequiredRatio)
{
Log("Ending round by votes ("+EndVoteCount+"/"+(EndVoteMax-EndVoteCount)+")");
Log("Ending round by votes ("+EndVoteCount+"/"+(EndVoteMax-EndVoteCount)+")", Color.Cyan);
EndButtonHit(null,null);
}
break;
@@ -791,10 +811,10 @@ namespace Barotrauma.Networking
GameMain.GameSession = new GameSession(selectedSub, "", selectedMode);
GameMain.GameSession.StartShift(GameMain.NetLobbyScreen.LevelSeed);
GameServer.Log("Starting a new round...");
GameServer.Log("Submarine: " + selectedSub.Name);
GameServer.Log("Game mode: " + selectedMode.Name);
GameServer.Log("Level seed: " + GameMain.NetLobbyScreen.LevelSeed);
GameServer.Log("Starting a new round...", Color.Cyan);
GameServer.Log("Submarine: " + selectedSub.Name, Color.Cyan);
GameServer.Log("Game mode: " + selectedMode.Name, Color.Cyan);
GameServer.Log("Level seed: " + GameMain.NetLobbyScreen.LevelSeed, Color.Cyan);
yield return CoroutineStatus.Running;
@@ -1007,7 +1027,7 @@ namespace Barotrauma.Networking
if (string.IsNullOrWhiteSpace(msg)) msg = client.name + " has left the server";
if (string.IsNullOrWhiteSpace(targetmsg)) targetmsg = "You have left the server";
Log(msg);
Log(msg, messageColor[(int)ChatMessageType.Server]);
NetOutgoingMessage outmsg = server.CreateMessage();
outmsg.Write((byte)PacketTypes.KickedOut);
@@ -1115,7 +1135,7 @@ namespace Barotrauma.Networking
return;
}
Log(traitor.Info.Name + " is the traitor and the target is " + target.Info.Name);
Log(traitor.Info.Name + " is the traitor and the target is " + target.Info.Name, Color.Cyan);
Client traitorClient = null;
foreach (Client c in ConnectedClients)
@@ -1138,7 +1158,14 @@ namespace Barotrauma.Networking
{
base.Draw(spriteBatch);
if (settingsFrame != null) settingsFrame.Draw(spriteBatch);
if (settingsFrame != null)
{
settingsFrame.Draw(spriteBatch);
}
else if (log.LogFrame!=null)
{
log.LogFrame.Draw(spriteBatch);
}
if (!ShowNetStats) return;
@@ -1428,11 +1455,11 @@ namespace Barotrauma.Networking
return preferredClient;
}
public static void Log(string line)
public static void Log(string line, Color? color)
{
if (GameMain.Server == null || GameMain.Server.saveServerLogs) return;
if (GameMain.Server == null || !GameMain.Server.saveServerLogs) return;
GameMain.Server.log.WriteLine(line);
GameMain.Server.log.WriteLine(line, color);
}
/// <summary>
@@ -1478,7 +1505,7 @@ namespace Barotrauma.Networking
if (saveServerLogs)
{
Log("Shutting down server...");
Log("Shutting down server...", Color.Cyan);
log.Save();
}

View File

@@ -167,8 +167,9 @@ namespace Barotrauma.Networking
saveLogsBox.OnSelected = (GUITickBox) =>
{
saveServerLogs = GUITickBox.Selected;
showLogButton.Visible = saveServerLogs;
return true;
}; ;
};
var closeButton = new GUIButton(new Rectangle(0, 0, 100, 20), "Close", Alignment.BottomRight, GUI.Style, innerFrame);
closeButton.OnClicked = ToggleSettingsFrame;

View File

@@ -59,7 +59,7 @@ namespace Barotrauma.Networking
protected GUIFrame inGameHUD;
protected GUIListBox chatBox;
protected GUITextBox chatMsgBox;
public int EndVoteCount, EndVoteMax;
//private GUITextBlock endVoteText;
@@ -186,7 +186,7 @@ namespace Barotrauma.Networking
{
GameMain.NetLobbyScreen.NewChatMessage(message, messageColor[(int)messageType]);
GameServer.Log(message);
GameServer.Log(message, messageColor[(int)messageType]);
while (chatBox.CountChildren > 20)
{

View File

@@ -1,4 +1,5 @@
using System;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -14,20 +15,24 @@ namespace Barotrauma.Networking
private string serverName;
private Queue<string> lines;
public GUIFrame LogFrame;
private Queue<ColoredText> lines;
public ServerLog(string serverName)
{
this.serverName = serverName;
lines = new Queue<string>();
lines = new Queue<ColoredText>();
}
public void WriteLine(string line)
public void WriteLine(string line, Color? color)
{
string logLine = "[" + DateTime.Now.ToLongTimeString() + "] " + line;
lines.Enqueue(logLine);
lines.Enqueue(new ColoredText(logLine, color == null ? Color.White : (Color)color));
if (LogFrame != null) CreateLogFrame();
if (lines.Count>=LinesPerFile)
{
@@ -35,6 +40,36 @@ namespace Barotrauma.Networking
}
}
public void CreateLogFrame()
{
LogFrame = new GUIFrame(new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.Black * 0.5f);
GUIFrame innerFrame = new GUIFrame(new Rectangle(0,0,400, 400), null, Alignment.Center, GUI.Style, LogFrame);
innerFrame.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
GUIListBox listBox = new GUIListBox(new Rectangle(0,0,0,355), GUI.Style, innerFrame);
var currLines = lines.ToList();
foreach (ColoredText line in currLines)
{
var textBlock = new GUITextBlock(new Rectangle(0, 0, 0, 0), line.Text, GUI.Style, Alignment.TopLeft, Alignment.TopLeft, listBox, true, GUI.SmallFont);
//textBlock.Rect = new Rectangle(textBlock.Rect.X, textBlock.Rect.Y, textBlock.Rect.Width, (line.Text.Count(c => c == '\n') + 1) * 15);
textBlock.TextColor = line.Color;
textBlock.CanBeFocused = false;
}
listBox.BarScroll = 1.0f;
GUIButton closeButton = new GUIButton(new Rectangle(0,0,100, 15), "Close", Alignment.BottomRight, GUI.Style, innerFrame);
closeButton.OnClicked = (GUIButton button, object userData) =>
{
LogFrame = null;
return true;
};
}
public void Save()
{
if (!Directory.Exists(SavePath))
@@ -55,10 +90,10 @@ namespace Barotrauma.Networking
fileName = fileName.Replace(":", "");
string filePath = Path.Combine(SavePath, fileName);
try
{
File.WriteAllLines(filePath, lines);
File.WriteAllLines(filePath, lines.Select(l => l.Text));
}
catch (Exception e)
{

Binary file not shown.