From 63f8760b86bcc7b14f9f6335e34a0a2f1e25bc04 Mon Sep 17 00:00:00 2001 From: Alex Noir Date: Sun, 3 Dec 2017 19:39:31 +0300 Subject: [PATCH] Added traitor code words Fixed host never being traitor --- .../BarotraumaShared.projitems | 3 + .../BarotraumaShared/Content/CodeWords.txt | 75 +++++++++++++++++++ .../BarotraumaShared/Source/DebugConsole.cs | 10 +++ .../GameSession/GameModes/TraitorManager.cs | 46 +++++++++++- 4 files changed, 132 insertions(+), 2 deletions(-) create mode 100644 Barotrauma/BarotraumaShared/Content/CodeWords.txt diff --git a/Barotrauma/BarotraumaShared/BarotraumaShared.projitems b/Barotrauma/BarotraumaShared/BarotraumaShared.projitems index b2beaca84..0f3ac76c9 100644 --- a/Barotrauma/BarotraumaShared/BarotraumaShared.projitems +++ b/Barotrauma/BarotraumaShared/BarotraumaShared.projitems @@ -222,6 +222,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest diff --git a/Barotrauma/BarotraumaShared/Content/CodeWords.txt b/Barotrauma/BarotraumaShared/Content/CodeWords.txt new file mode 100644 index 000000000..e34ad11d5 --- /dev/null +++ b/Barotrauma/BarotraumaShared/Content/CodeWords.txt @@ -0,0 +1,75 @@ +carrier +charybdis +coelanth +crawler +endworm +guardian +husk +mantis +moloch +thresher +watcher +water +submarine +red +green +blue +yellow +toxic +explosive +combustible +crate +renegade +ally +teamwork +railgun +nonsense +abyss +artifact +party +signal +airlock +scooter +ruins +C4 +Compound-N +hyperzine +plasma +morbusine +oxygenite +revolver +harpoon +ocean +wrench +door +man +comrade +mask +diving +monitor +lights +battery +junction +button +locker +crate +honk +clown +horn +grenade +stun +baton +circuit +death +life +fish +shark +damage +ruins +shaft +aft +starboard +ice +cold +hot +fire \ No newline at end of file diff --git a/Barotrauma/BarotraumaShared/Source/DebugConsole.cs b/Barotrauma/BarotraumaShared/Source/DebugConsole.cs index 7c237cb9d..7ffd85c78 100644 --- a/Barotrauma/BarotraumaShared/Source/DebugConsole.cs +++ b/Barotrauma/BarotraumaShared/Source/DebugConsole.cs @@ -102,6 +102,16 @@ namespace Barotrauma NewMessage("***************", Color.Cyan); })); + commands.Add(new Command("traitorlist", "traitorlist: List all the traitors and their targets.", (string[] args) => + { + if (GameMain.Server == null) return; + TraitorManager traitorManager = GameMain.Server.TraitorManager; + if (traitorManager == null) return; + foreach (Traitor T in traitorManager.TraitorList) + { + NewMessage("- Traitor " + T.Character.Name + "'s target is " + T.TargetCharacter.Name + ".", Color.Cyan); + } + })); commands.Add(new Command("createfilelist", "", (string[] args) => { diff --git a/Barotrauma/BarotraumaShared/Source/GameSession/GameModes/TraitorManager.cs b/Barotrauma/BarotraumaShared/Source/GameSession/GameModes/TraitorManager.cs index 6c8e2574b..0b18a72f1 100644 --- a/Barotrauma/BarotraumaShared/Source/GameSession/GameModes/TraitorManager.cs +++ b/Barotrauma/BarotraumaShared/Source/GameSession/GameModes/TraitorManager.cs @@ -1,5 +1,6 @@ using Barotrauma.Networking; using System.Collections.Generic; +using System.IO; namespace Barotrauma { @@ -16,6 +17,8 @@ namespace Barotrauma partial class TraitorManager { + private static string CodeWords = Path.Combine("Content", "CodeWords.txt"); + public List TraitorList { get { return traitorList; } @@ -47,14 +50,21 @@ namespace Barotrauma traitorCandidates.Add(client.Character); } } - - if (server.Character!= null) characters.Add(server.Character); //Add host character + + if (server.Character != null) + { + characters.Add(server.Character); //Add host character + traitorCandidates.Add(server.Character); + } if (characters.Count < 2) { return; } + string codeWords = ToolBox.GetRandomLine(CodeWords) + ", " + ToolBox.GetRandomLine(CodeWords); + string codeResponse = ToolBox.GetRandomLine(CodeWords) + ", " + ToolBox.GetRandomLine(CodeWords); + traitorList = new List(); while (TraitorCount-- >= 0) { @@ -75,6 +85,34 @@ namespace Barotrauma //Add them to the list traitorList.Add(new Traitor(traitorCharacter, targetCharacter)); + string greetingMessage = "You are the Traitor! Your secret task is to assassinate " + targetCharacter.Name + "! Discretion is an utmost concern; sinking the submarine and killing the entire crew " + + "will arouse suspicion amongst the Fleet. If possible, make the death look like an accident."; + string moreAgentsMessage = "It is possible that there are other agents on this submarine. You don't know their names, but you do have a method of communication. " + + "Use the code words to greet the agent and code response to respond. Disguise such words in a normal-looking phrase so the crew doesn't suspect anything."; + moreAgentsMessage += "\nThe code words are: " + codeWords + "."; + moreAgentsMessage += "\nThe code response is: " + codeResponse + "."; + + if (server.Character != traitorCharacter) + { + var chatMsg = ChatMessage.Create( + null, + greetingMessage + "\n" + moreAgentsMessage, + (ChatMessageType)ChatMessageType.Server, + null); + + var msgBox = ChatMessage.Create( + null, + "There might be other agents. Use these to communicate with them." + + "\nThe code words are: " + codeWords + "." + + "\nThe code response is: " + codeResponse + ".", + (ChatMessageType)ChatMessageType.MessageBox, + null); + + Client client = server.ConnectedClients.Find(c => c.Character == traitorCharacter); + GameMain.Server.SendChatMessage(chatMsg, client); + GameMain.Server.SendChatMessage(msgBox, client); + } + #if CLIENT if (server.Character == null) { @@ -83,6 +121,10 @@ namespace Barotrauma else if (server.Character == traitorCharacter) { CreateStartPopUp(targetCharacter.Name); + GameMain.NetworkMember.AddChatMessage(greetingMessage + "\n" + moreAgentsMessage, ChatMessageType.Server); + GameMain.NetworkMember.AddChatMessage("There might be other agents. Use these to communicate with them." + + "\nThe code words are: " + codeWords + "." + + "\nThe code response is: " + codeResponse + ".", ChatMessageType.MessageBox); return; } #endif