├── .vs └── slnx.sqlite ├── Screenshots ├── AfterGame.png ├── JesterWin.png ├── MiniJester.png ├── MiniJester.xcf ├── MiniJesterBG.png ├── JesterAnnouncement.png └── JesterConfirmation.png ├── Jester ├── Jester.csproj ├── Class.cs └── GameEventListener.cs ├── Jester.sln ├── .gitattributes ├── README.md └── .gitignore /.vs/slnx.sqlite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maartii/Jester/HEAD/.vs/slnx.sqlite -------------------------------------------------------------------------------- /Screenshots/AfterGame.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maartii/Jester/HEAD/Screenshots/AfterGame.png -------------------------------------------------------------------------------- /Screenshots/JesterWin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maartii/Jester/HEAD/Screenshots/JesterWin.png -------------------------------------------------------------------------------- /Screenshots/MiniJester.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maartii/Jester/HEAD/Screenshots/MiniJester.png -------------------------------------------------------------------------------- /Screenshots/MiniJester.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maartii/Jester/HEAD/Screenshots/MiniJester.xcf -------------------------------------------------------------------------------- /Screenshots/MiniJesterBG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maartii/Jester/HEAD/Screenshots/MiniJesterBG.png -------------------------------------------------------------------------------- /Screenshots/JesterAnnouncement.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maartii/Jester/HEAD/Screenshots/JesterAnnouncement.png -------------------------------------------------------------------------------- /Screenshots/JesterConfirmation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Maartii/Jester/HEAD/Screenshots/JesterConfirmation.png -------------------------------------------------------------------------------- /Jester/Jester.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.1 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Jester/Class.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | using Impostor.Api.Events.Managers; 4 | using Impostor.Api.Plugins; 5 | using Impostor.Plugins.Example.Handlers; 6 | using Microsoft.Extensions.Logging; 7 | 8 | namespace Impostor.Plugins.Example 9 | { 10 | [ImpostorPlugin( 11 | package: "maartii.jester", 12 | name: "JesterPlugin", 13 | author: "Maartii", 14 | version: "1.0.0")] 15 | public class ExamplePlugin : PluginBase 16 | { 17 | private readonly ILogger _logger; 18 | // Add the line below! 19 | private readonly IEventManager _eventManager; 20 | // Add the line below! 21 | private IDisposable _unregister; 22 | 23 | public ExamplePlugin(ILogger logger, IEventManager eventManager) 24 | { 25 | _logger = logger; 26 | // Add the line below! 27 | _eventManager = eventManager; 28 | } 29 | 30 | public override ValueTask EnableAsync() 31 | { 32 | _logger.LogInformation("Example is being enabled."); 33 | // Add the line below! 34 | _unregister = _eventManager.RegisterListener(new GameEventListener(_logger)); 35 | return default; 36 | } 37 | 38 | public override ValueTask DisableAsync() 39 | { 40 | _logger.LogInformation("Example is being disabled."); 41 | // Add the line below! 42 | _unregister.Dispose(); 43 | return default; 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /Jester.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.26124.0 5 | MinimumVisualStudioVersion = 15.0.26124.0 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Jester", "Jester\Jester.csproj", "{E4616C2D-152F-4823-862D-0C5C83AB3838}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Debug|x64 = Debug|x64 12 | Debug|x86 = Debug|x86 13 | Release|Any CPU = Release|Any CPU 14 | Release|x64 = Release|x64 15 | Release|x86 = Release|x86 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 21 | {E4616C2D-152F-4823-862D-0C5C83AB3838}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 22 | {E4616C2D-152F-4823-862D-0C5C83AB3838}.Debug|Any CPU.Build.0 = Debug|Any CPU 23 | {E4616C2D-152F-4823-862D-0C5C83AB3838}.Debug|x64.ActiveCfg = Debug|Any CPU 24 | {E4616C2D-152F-4823-862D-0C5C83AB3838}.Debug|x64.Build.0 = Debug|Any CPU 25 | {E4616C2D-152F-4823-862D-0C5C83AB3838}.Debug|x86.ActiveCfg = Debug|Any CPU 26 | {E4616C2D-152F-4823-862D-0C5C83AB3838}.Debug|x86.Build.0 = Debug|Any CPU 27 | {E4616C2D-152F-4823-862D-0C5C83AB3838}.Release|Any CPU.ActiveCfg = Release|Any CPU 28 | {E4616C2D-152F-4823-862D-0C5C83AB3838}.Release|Any CPU.Build.0 = Release|Any CPU 29 | {E4616C2D-152F-4823-862D-0C5C83AB3838}.Release|x64.ActiveCfg = Release|Any CPU 30 | {E4616C2D-152F-4823-862D-0C5C83AB3838}.Release|x64.Build.0 = Release|Any CPU 31 | {E4616C2D-152F-4823-862D-0C5C83AB3838}.Release|x86.ActiveCfg = Release|Any CPU 32 | {E4616C2D-152F-4823-862D-0C5C83AB3838}.Release|x86.Build.0 = Release|Any CPU 33 | EndGlobalSection 34 | EndGlobal 35 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Note: 2 | ## Due to time restraints I'm no longer maintaining this plugin. JohnTranQUT will probably maintain his fork [here](https://github.com/JohnTranQUT/Jester) and might update it to the new Impostor version. 3 | 4 | # Jester 5 | 6 | 7 | 8 | **If you're having issues, please try updating to the latest [experimental build](https://ci.appveyor.com/project/Impostor/Impostor/branch/dev/artifacts) of the Impostor server and the latest version of this plugin!** 9 | 10 | *Jester* is a plugin for the Among Us private server called [Impostor](https://github.com/Impostor/Impostor) that adds a new role to the game Among Us. The plugin will add a special **Jester role** to the game. The idea behind this Jester role is that if this Jester gets **voted out** during a meeting they **win**, and all other players **lose**. At the start of each game, one player will be assigned this role. 11 | 12 | This adds a special twist to the usual dynamic of Among Us and you now have to be extra careful who you vote. Your very suspicious crewmate standing on a body is probably the imposter... unless the **Jester** is among us. 13 | 14 | ## Installation 15 | 16 | 1. Set up an [Impostor server](https://github.com/Impostor/Impostor) by following the instructions on their Github page. **For now, please use the latest [experimental build](https://ci.appveyor.com/project/Impostor/Impostor/branch/dev/artifacts).** 17 | 2. Find the [latest release](https://github.com/Maartii/Jester/releases) of the plugin. 18 | 3. Drop the Jester.dll file in the `plugins` folder of your Impostor server. 19 | 4. To play with your client on your private server, see the instructions on the [Impostor](https://github.com/Impostor/Impostor) page. 20 | 5. Don't forget to open chat before you start a game! :wink: 21 | 22 | ## How it works 23 | 24 | - When the hosts clicks the 'start' button in the lobby, every player has to **open the ingame chat** to see whether they could become the Jester. 25 | 26 |
27 | Screenshot of the message (click to open) 28 | 29 |
30 | 31 | - If a player that gets the *"You're the Jester"*-message happens to be Imposter, there will be no Jester that game. 32 | - If a player that gets the *"You're the Jester"*-message happens to be a **crewmate**, that player will have the **special Jester role** that game! 33 | - You will also get a **confirmation message** during the **first meeting**. So if you're unsure if you're the Jester you can always press the emergency button. 34 | 35 |
36 | Screenshot of confirmation message (click to open) 37 | 38 |
39 | 40 | - The Jester is also a crewmate and wins when the crewmates completed all their tasks (including the Jester). 41 | - The Jester has an **additional win-condition**: if the Jester gets **voted out**, the **Jester will win** and all other players will lose. 42 | - When the Jester wins, they are shown in the victory screen with a **Elf Hat**. The other players are shown with a **Dum-sticker** to make clear that they have lost. 43 | 44 |
45 | Screenshot of this special Jester victory screen (click to open) 46 | 47 |
48 | 49 | - In the Among Us lobby, the host can use the `/jester on` and `/jester off` commands in the chat to turn the jester role on and off. Additionally, any player can write `/jester help` to get an explanation about the Jester role. 50 | 51 | ## Credits 52 | 53 | - All the developers and contributors to the [Impostor](https://github.com/Impostor/Impostor) project. 54 | - My good friend Theo who helped writing this readme. 55 | - And a huge thanks to all of my friends who helped test this plugin! 56 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Dd]ebugPublic/ 19 | [Rr]elease/ 20 | [Rr]eleases/ 21 | x64/ 22 | x86/ 23 | [Aa][Rr][Mm]/ 24 | [Aa][Rr][Mm]64/ 25 | bld/ 26 | [Bb]in/ 27 | [Oo]bj/ 28 | [Ll]og/ 29 | 30 | # Visual Studio 2015/2017 cache/options directory 31 | .vs/ 32 | # Uncomment if you have tasks that create the project's static files in wwwroot 33 | #wwwroot/ 34 | 35 | # Visual Studio 2017 auto generated files 36 | Generated\ Files/ 37 | 38 | # MSTest test Results 39 | [Tt]est[Rr]esult*/ 40 | [Bb]uild[Ll]og.* 41 | 42 | # NUNIT 43 | *.VisualState.xml 44 | TestResult.xml 45 | 46 | # Build Results of an ATL Project 47 | [Dd]ebugPS/ 48 | [Rr]eleasePS/ 49 | dlldata.c 50 | 51 | # Benchmark Results 52 | BenchmarkDotNet.Artifacts/ 53 | 54 | # .NET Core 55 | project.lock.json 56 | project.fragment.lock.json 57 | artifacts/ 58 | 59 | # StyleCop 60 | StyleCopReport.xml 61 | 62 | # Files built by Visual Studio 63 | *_i.c 64 | *_p.c 65 | *_h.h 66 | *.ilk 67 | *.meta 68 | *.obj 69 | *.iobj 70 | *.pch 71 | *.pdb 72 | *.ipdb 73 | *.pgc 74 | *.pgd 75 | *.rsp 76 | *.sbr 77 | *.tlb 78 | *.tli 79 | *.tlh 80 | *.tmp 81 | *.tmp_proj 82 | *_wpftmp.csproj 83 | *.log 84 | *.vspscc 85 | *.vssscc 86 | .builds 87 | *.pidb 88 | *.svclog 89 | *.scc 90 | 91 | # Chutzpah Test files 92 | _Chutzpah* 93 | 94 | # Visual C++ cache files 95 | ipch/ 96 | *.aps 97 | *.ncb 98 | *.opendb 99 | *.opensdf 100 | *.sdf 101 | *.cachefile 102 | *.VC.db 103 | *.VC.VC.opendb 104 | 105 | # Visual Studio profiler 106 | *.psess 107 | *.vsp 108 | *.vspx 109 | *.sap 110 | 111 | # Visual Studio Trace Files 112 | *.e2e 113 | 114 | # TFS 2012 Local Workspace 115 | $tf/ 116 | 117 | # Guidance Automation Toolkit 118 | *.gpState 119 | 120 | # ReSharper is a .NET coding add-in 121 | _ReSharper*/ 122 | *.[Rr]e[Ss]harper 123 | *.DotSettings.user 124 | 125 | # JustCode is a .NET coding add-in 126 | .JustCode 127 | 128 | # TeamCity is a build add-in 129 | _TeamCity* 130 | 131 | # DotCover is a Code Coverage Tool 132 | *.dotCover 133 | 134 | # AxoCover is a Code Coverage Tool 135 | .axoCover/* 136 | !.axoCover/settings.json 137 | 138 | # Visual Studio code coverage results 139 | *.coverage 140 | *.coveragexml 141 | 142 | # NCrunch 143 | _NCrunch_* 144 | .*crunch*.local.xml 145 | nCrunchTemp_* 146 | 147 | # MightyMoose 148 | *.mm.* 149 | AutoTest.Net/ 150 | 151 | # Web workbench (sass) 152 | .sass-cache/ 153 | 154 | # Installshield output folder 155 | [Ee]xpress/ 156 | 157 | # DocProject is a documentation generator add-in 158 | DocProject/buildhelp/ 159 | DocProject/Help/*.HxT 160 | DocProject/Help/*.HxC 161 | DocProject/Help/*.hhc 162 | DocProject/Help/*.hhk 163 | DocProject/Help/*.hhp 164 | DocProject/Help/Html2 165 | DocProject/Help/html 166 | 167 | # Click-Once directory 168 | publish/ 169 | 170 | # Publish Web Output 171 | *.[Pp]ublish.xml 172 | *.azurePubxml 173 | # Note: Comment the next line if you want to checkin your web deploy settings, 174 | # but database connection strings (with potential passwords) will be unencrypted 175 | *.pubxml 176 | *.publishproj 177 | 178 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 179 | # checkin your Azure Web App publish settings, but sensitive information contained 180 | # in these scripts will be unencrypted 181 | PublishScripts/ 182 | 183 | # NuGet Packages 184 | *.nupkg 185 | # The packages folder can be ignored because of Package Restore 186 | **/[Pp]ackages/* 187 | # except build/, which is used as an MSBuild target. 188 | !**/[Pp]ackages/build/ 189 | # Uncomment if necessary however generally it will be regenerated when needed 190 | #!**/[Pp]ackages/repositories.config 191 | # NuGet v3's project.json files produces more ignorable files 192 | *.nuget.props 193 | *.nuget.targets 194 | 195 | # Microsoft Azure Build Output 196 | csx/ 197 | *.build.csdef 198 | 199 | # Microsoft Azure Emulator 200 | ecf/ 201 | rcf/ 202 | 203 | # Windows Store app package directories and files 204 | AppPackages/ 205 | BundleArtifacts/ 206 | Package.StoreAssociation.xml 207 | _pkginfo.txt 208 | *.appx 209 | 210 | # Visual Studio cache files 211 | # files ending in .cache can be ignored 212 | *.[Cc]ache 213 | # but keep track of directories ending in .cache 214 | !?*.[Cc]ache/ 215 | 216 | # Others 217 | ClientBin/ 218 | ~$* 219 | *~ 220 | *.dbmdl 221 | *.dbproj.schemaview 222 | *.jfm 223 | *.pfx 224 | *.publishsettings 225 | orleans.codegen.cs 226 | 227 | # Including strong name files can present a security risk 228 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 229 | #*.snk 230 | 231 | # Since there are multiple workflows, uncomment next line to ignore bower_components 232 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 233 | #bower_components/ 234 | 235 | # RIA/Silverlight projects 236 | Generated_Code/ 237 | 238 | # Backup & report files from converting an old project file 239 | # to a newer Visual Studio version. Backup files are not needed, 240 | # because we have git ;-) 241 | _UpgradeReport_Files/ 242 | Backup*/ 243 | UpgradeLog*.XML 244 | UpgradeLog*.htm 245 | ServiceFabricBackup/ 246 | *.rptproj.bak 247 | 248 | # SQL Server files 249 | *.mdf 250 | *.ldf 251 | *.ndf 252 | 253 | # Business Intelligence projects 254 | *.rdl.data 255 | *.bim.layout 256 | *.bim_*.settings 257 | *.rptproj.rsuser 258 | *- Backup*.rdl 259 | 260 | # Microsoft Fakes 261 | FakesAssemblies/ 262 | 263 | # GhostDoc plugin setting file 264 | *.GhostDoc.xml 265 | 266 | # Node.js Tools for Visual Studio 267 | .ntvs_analysis.dat 268 | node_modules/ 269 | 270 | # Visual Studio 6 build log 271 | *.plg 272 | 273 | # Visual Studio 6 workspace options file 274 | *.opt 275 | 276 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 277 | *.vbw 278 | 279 | # Visual Studio LightSwitch build output 280 | **/*.HTMLClient/GeneratedArtifacts 281 | **/*.DesktopClient/GeneratedArtifacts 282 | **/*.DesktopClient/ModelManifest.xml 283 | **/*.Server/GeneratedArtifacts 284 | **/*.Server/ModelManifest.xml 285 | _Pvt_Extensions 286 | 287 | # Paket dependency manager 288 | .paket/paket.exe 289 | paket-files/ 290 | 291 | # FAKE - F# Make 292 | .fake/ 293 | 294 | # JetBrains Rider 295 | .idea/ 296 | *.sln.iml 297 | 298 | # CodeRush personal settings 299 | .cr/personal 300 | 301 | # Python Tools for Visual Studio (PTVS) 302 | __pycache__/ 303 | *.pyc 304 | 305 | # Cake - Uncomment if you are using it 306 | # tools/** 307 | # !tools/packages.config 308 | 309 | # Tabs Studio 310 | *.tss 311 | 312 | # Telerik's JustMock configuration file 313 | *.jmconfig 314 | 315 | # BizTalk build output 316 | *.btp.cs 317 | *.btm.cs 318 | *.odx.cs 319 | *.xsd.cs 320 | 321 | # OpenCover UI analysis results 322 | OpenCover/ 323 | 324 | # Azure Stream Analytics local run output 325 | ASALocalRun/ 326 | 327 | # MSBuild Binary and Structured Log 328 | *.binlog 329 | 330 | # NVidia Nsight GPU debugger configuration file 331 | *.nvuser 332 | 333 | # MFractors (Xamarin productivity tool) working folder 334 | .mfractor/ 335 | 336 | # Local History for Visual Studio 337 | .localhistory/ 338 | 339 | # BeatPulse healthcheck temp database 340 | healthchecksdb -------------------------------------------------------------------------------- /Jester/GameEventListener.cs: -------------------------------------------------------------------------------- 1 | using Impostor.Api.Events; 2 | using Impostor.Api.Events.Player; 3 | using Impostor.Api.Net; 4 | using Impostor.Api.Net.Inner.Objects; 5 | using Impostor.Api.Innersloth; 6 | using Impostor.Api.Innersloth.Customization; 7 | using Microsoft.Extensions.Logging; 8 | using System.Collections.Generic; 9 | using System.Threading.Tasks; 10 | using System; 11 | 12 | namespace Impostor.Plugins.Example.Handlers 13 | { 14 | /// 15 | /// A class that listens for two events. 16 | /// It may be more but this is just an example. 17 | /// 18 | /// Make sure your class implements . 19 | /// 20 | 21 | 22 | public class GameEventListener : IEventListener 23 | { 24 | private readonly ILogger _logger; 25 | 26 | static System.Random rnd = new System.Random(); 27 | 28 | struct JesterGame 29 | { 30 | public int JesterClientId; 31 | public bool JesterOn; 32 | public bool JesterWin; 33 | public bool JesterImp; 34 | public bool GameEnded; 35 | public bool CountingDown; 36 | public bool JesterInGame; 37 | public string Jestername; 38 | } 39 | 40 | Dictionary JesterGames = new Dictionary(); 41 | 42 | public GameEventListener(ILogger logger) 43 | { 44 | _logger = logger; 45 | } 46 | 47 | /// 48 | /// An example event listener. 49 | /// 50 | /// 51 | /// The event you want to listen for. 52 | /// 53 | 54 | private async Task ServerSendChatToPlayerAsync(string text, IInnerPlayerControl player) 55 | { 56 | string playername = player.PlayerInfo.PlayerName; 57 | await player.SetNameAsync($"PrivateMsg").ConfigureAwait(false); 58 | await player.SendChatToPlayerAsync($"{text}", player).ConfigureAwait(false); 59 | await player.SetNameAsync(playername); 60 | } 61 | 62 | private async Task ServerSendChatAsync(string text, IInnerPlayerControl player) 63 | { 64 | string playername = player.PlayerInfo.PlayerName; 65 | await player.SetNameAsync($"PublicMsg").ConfigureAwait(false); 66 | await player.SendChatAsync($"{text}").ConfigureAwait(false); 67 | await player.SetNameAsync(playername); 68 | } 69 | 70 | [EventListener] 71 | public void OnGameCreated(IGameCreatedEvent e) 72 | { 73 | JesterGame jgame = new JesterGame(); 74 | jgame.JesterOn = true; 75 | jgame.JesterWin = false; 76 | jgame.JesterImp = false; 77 | jgame.GameEnded = false; 78 | jgame.CountingDown = false; 79 | jgame.JesterInGame = false; 80 | JesterGames.Add(e.Game.Code, jgame); 81 | } 82 | 83 | [EventListener] 84 | public void OnSetStartCounter(IPlayerSetStartCounterEvent e) 85 | { 86 | if (e.SecondsLeft == 5) 87 | { 88 | JesterGame jgame = JesterGames[e.Game.Code]; 89 | jgame.CountingDown = true; 90 | JesterGames[e.Game.Code] = jgame; 91 | 92 | _logger.LogInformation($"Countdown started."); 93 | if (JesterGames[e.Game.Code].JesterOn) 94 | { 95 | Task.Run(async () => await AssignJester(e).ConfigureAwait(false)); 96 | foreach (var player in e.Game.Players) 97 | { 98 | Task.Run(async () => await MakePlayerLookAtChat(player).ConfigureAwait(false)); 99 | } 100 | } 101 | } 102 | } 103 | 104 | private async Task AssignJester(IPlayerSetStartCounterEvent e) 105 | { 106 | List gameplayers = new List(); 107 | foreach (var player in e.Game.Players) 108 | { 109 | gameplayers.Add(player); 110 | } 111 | int r = rnd.Next(gameplayers.Count); 112 | 113 | JesterGame jgame = JesterGames[e.Game.Code]; 114 | jgame.JesterClientId = gameplayers[r].Client.Id; 115 | jgame.Jestername = gameplayers[r].Character.PlayerInfo.PlayerName; 116 | JesterGames[e.Game.Code] = jgame; 117 | 118 | foreach (IClientPlayer player in e.Game.Players) 119 | { 120 | if (jgame.JesterClientId == player.Client.Id) 121 | { 122 | await ServerSendChatToPlayerAsync($"You are the JESTER! (unless you've become an imposter)", player.Character).ConfigureAwait(false); 123 | } 124 | else 125 | { 126 | await ServerSendChatToPlayerAsync($"You are NOT the JESTER.", player.Character).ConfigureAwait(false); 127 | } 128 | } 129 | _logger.LogInformation($"- {JesterGames[e.Game.Code].Jestername} is probably the jester."); 130 | } 131 | 132 | private async Task MakePlayerLookAtChat(IClientPlayer player) 133 | { 134 | await Task.Delay(TimeSpan.FromSeconds(0.5)).ConfigureAwait(false); 135 | string playername = player.Character.PlayerInfo.PlayerName; 136 | await player.Character.SetNameAsync($"OPEN CHAT").ConfigureAwait(false); 137 | await Task.Delay(TimeSpan.FromSeconds(3)).ConfigureAwait(false); 138 | await player.Character.SetNameAsync(playername).ConfigureAwait(false); 139 | } 140 | 141 | [EventListener] 142 | public void OnGamePlayerJoined(IGamePlayerJoinedEvent e) 143 | { 144 | if (JesterGames[e.Game.Code].CountingDown) 145 | { 146 | _logger.LogInformation($"Assigning Jester interrupted. {JesterGames[e.Game.Code].Jestername} is NOT the jester."); 147 | Task.Run(async () => await SorryNotJester(e.Game.GetClientPlayer(JesterGames[e.Game.Code].JesterClientId)).ConfigureAwait(false)); 148 | 149 | JesterGame jgame = JesterGames[e.Game.Code]; 150 | jgame.CountingDown = false; 151 | JesterGames[e.Game.Code] = jgame; 152 | } 153 | } 154 | 155 | [EventListener] 156 | public void OnGamePlayerLeft(IGamePlayerLeftEvent e) 157 | { 158 | if (JesterGames[e.Game.Code].CountingDown) 159 | { 160 | _logger.LogInformation($"Assigning Jester interrupted. {JesterGames[e.Game.Code].Jestername} is NOT the jester."); 161 | Task.Run(async () => await SorryNotJester(e.Game.GetClientPlayer(JesterGames[e.Game.Code].JesterClientId)).ConfigureAwait(false)); 162 | 163 | JesterGame jgame = JesterGames[e.Game.Code]; 164 | jgame.CountingDown = false; 165 | JesterGames[e.Game.Code] = jgame; 166 | } 167 | } 168 | 169 | private async Task SorryNotJester(IClientPlayer player) 170 | { 171 | await ServerSendChatToPlayerAsync($"Startup interrupted. You're NOT the Jester.", player.Character).ConfigureAwait(false); 172 | } 173 | 174 | [EventListener] 175 | public void OnGameStarted(IGameStartedEvent e) 176 | { 177 | JesterGame jgame = JesterGames[e.Game.Code]; 178 | jgame.GameEnded = false; 179 | jgame.CountingDown = false; 180 | jgame.JesterInGame = false; 181 | jgame.JesterWin = false; 182 | jgame.JesterImp = false; 183 | JesterGames[e.Game.Code] = jgame; 184 | 185 | _logger.LogInformation($"Game is starting."); 186 | if (JesterGames[e.Game.Code].JesterOn) 187 | { 188 | Task.Run(async () => await InformJester(e).ConfigureAwait(false)); 189 | } 190 | // This prints out for all players if they are impostor or crewmate. 191 | foreach (var player in e.Game.Players) 192 | { 193 | if (JesterGames[e.Game.Code].JesterOn && (player.Character.PlayerInfo.HatId == 27 || player.Character.PlayerInfo.HatId == 84)) 194 | { 195 | Task.Run(async () => await OffWithYourHat(player).ConfigureAwait(false)); 196 | } 197 | var info = player.Character.PlayerInfo; 198 | var isImpostor = info.IsImpostor; 199 | if (isImpostor) 200 | { 201 | _logger.LogInformation($"- {info.PlayerName} is an impostor."); 202 | } 203 | else 204 | { 205 | _logger.LogInformation($"- {info.PlayerName} is a crewmate."); 206 | } 207 | } 208 | } 209 | 210 | private async Task InformJester(IGameStartedEvent e) 211 | { 212 | if (e.Game.GetClientPlayer(JesterGames[e.Game.Code].JesterClientId).Character.PlayerInfo.IsImpostor) 213 | { 214 | _logger.LogInformation($"- {e.Game.GetClientPlayer(JesterGames[e.Game.Code].JesterClientId).Character.PlayerInfo.PlayerName} isn't jester but impostor."); 215 | _ = ServerSendChatToPlayerAsync($"You happen to be IMPOSTER! No Jester this game.", e.Game.GetClientPlayer(JesterGames[e.Game.Code].JesterClientId).Character).ConfigureAwait(false); 216 | 217 | JesterGame jgame = JesterGames[e.Game.Code]; 218 | jgame.JesterImp = true; 219 | JesterGames[e.Game.Code] = jgame; 220 | } 221 | else 222 | { 223 | _logger.LogInformation($"- {e.Game.GetClientPlayer(JesterGames[e.Game.Code].JesterClientId).Character.PlayerInfo.PlayerName} is indeed jester."); 224 | _ = ServerSendChatToPlayerAsync($"You're indeed the JESTER!", e.Game.GetClientPlayer(JesterGames[e.Game.Code].JesterClientId).Character).ConfigureAwait(false); 225 | 226 | JesterGame jgame = JesterGames[e.Game.Code]; 227 | jgame.JesterInGame = true; 228 | JesterGames[e.Game.Code] = jgame; 229 | } 230 | } 231 | 232 | private async Task OffWithYourHat(IClientPlayer player) 233 | { 234 | await player.Character.SetHatAsync(HatType.NoHat).ConfigureAwait(false); 235 | } 236 | 237 | [EventListener] 238 | public void OnPlayerExiled(IPlayerExileEvent e) 239 | { 240 | if (JesterGames[e.Game.Code].JesterInGame && e.PlayerControl == e.Game.GetClientPlayer(JesterGames[e.Game.Code].JesterClientId).Character) 241 | { 242 | JesterGame jgame = JesterGames[e.Game.Code]; 243 | jgame.JesterWin = true; 244 | JesterGames[e.Game.Code] = jgame; 245 | 246 | _logger.LogInformation($"Jester has won!"); 247 | Task.Run(async () => await TurnTheTables(e).ConfigureAwait(false)); 248 | } 249 | } 250 | 251 | private async Task TurnTheTables(IPlayerExileEvent e) 252 | { 253 | await e.Game.GetClientPlayer(JesterGames[e.Game.Code].JesterClientId).Character.SetHatAsync(HatType.ElfHat).ConfigureAwait(false); 254 | foreach (var player in e.Game.Players) 255 | { 256 | if (player.Client.Id != JesterGames[e.Game.Code].JesterClientId) 257 | { 258 | await player.Character.SetHatAsync(HatType.DumSticker).ConfigureAwait(false); 259 | } 260 | } 261 | foreach (var player in e.Game.Players) 262 | { 263 | if (!player.Character.PlayerInfo.IsDead && player.Character.PlayerInfo.IsImpostor) 264 | { 265 | _logger.LogInformation($"- {player.Character.PlayerInfo.PlayerName} is murdered by plugin."); 266 | await player.Character.SetMurderedByAsync(player); 267 | } 268 | } 269 | 270 | } 271 | 272 | [EventListener] 273 | public void OnGameEnded(IGameEndedEvent e) 274 | { 275 | _logger.LogInformation($"Game has ended."); 276 | 277 | JesterGame jgame = JesterGames[e.Game.Code]; 278 | jgame.GameEnded = true; 279 | JesterGames[e.Game.Code] = jgame; 280 | } 281 | 282 | [EventListener] 283 | public void OnPlayerSpawned(IPlayerSpawnedEvent e) 284 | { 285 | if (JesterGames[e.Game.Code].GameEnded && (JesterGames[e.Game.Code].JesterInGame || JesterGames[e.Game.Code].JesterImp)) 286 | { 287 | Task.Run(async () => await JesterAnnouncement(e).ConfigureAwait(false)); 288 | } 289 | } 290 | 291 | private async Task JesterAnnouncement(IPlayerSpawnedEvent e) 292 | { 293 | if (JesterGames[e.Game.Code].JesterWin) 294 | { 295 | await Task.Delay(TimeSpan.FromSeconds(5)).ConfigureAwait(false); 296 | await ServerSendChatToPlayerAsync($"{JesterGames[e.Game.Code].Jestername} was Jester and won by getting ejected!", e.PlayerControl).ConfigureAwait(false); 297 | } 298 | else if (JesterGames[e.Game.Code].JesterImp) 299 | { 300 | await Task.Delay(TimeSpan.FromSeconds(5)).ConfigureAwait(false); 301 | await ServerSendChatToPlayerAsync($"{JesterGames[e.Game.Code].Jestername} was Jester!, but became an impostor instead.", e.PlayerControl).ConfigureAwait(false); 302 | } 303 | else 304 | { 305 | await Task.Delay(TimeSpan.FromSeconds(5)).ConfigureAwait(false); 306 | await ServerSendChatToPlayerAsync($"{JesterGames[e.Game.Code].Jestername} was Jester, but didn't get voted out.", e.PlayerControl).ConfigureAwait(false); 307 | } 308 | } 309 | 310 | [EventListener] 311 | public void OnGameDestroyed(IGameDestroyedEvent e) 312 | { 313 | JesterGames.Remove(e.Game.Code); 314 | } 315 | 316 | [EventListener] 317 | public void OnPlayerChat(IPlayerChatEvent e) 318 | { 319 | _logger.LogInformation($"{e.PlayerControl.PlayerInfo.PlayerName} said {e.Message}"); 320 | if (e.Game.GameState == GameStates.NotStarted && !JesterGames[e.Game.Code].CountingDown && e.Message.StartsWith("/")) 321 | { 322 | Task.Run(async () => await RunCommands(e).ConfigureAwait(false)); 323 | } 324 | } 325 | 326 | private async Task RunCommands(IPlayerChatEvent e) 327 | { 328 | switch (e.Message.ToLowerInvariant()) 329 | { 330 | case "/j on": 331 | case "/jester on": 332 | if (e.ClientPlayer.IsHost) 333 | { 334 | JesterGame jgame = JesterGames[e.Game.Code]; 335 | jgame.JesterOn = true; 336 | JesterGames[e.Game.Code] = jgame; 337 | 338 | await ServerSendChatAsync("The Jester role is now on!", e.PlayerControl).ConfigureAwait(false); 339 | } 340 | else 341 | { 342 | await ServerSendChatAsync("You need to be host to change roles.", e.PlayerControl).ConfigureAwait(false); 343 | } 344 | break; 345 | case "/j off": 346 | case "/jester off": 347 | if (e.ClientPlayer.IsHost) 348 | { 349 | JesterGame jgame = JesterGames[e.Game.Code]; 350 | jgame.JesterOn = false; 351 | JesterGames[e.Game.Code] = jgame; 352 | 353 | await ServerSendChatAsync("The Jester role is now off!", e.PlayerControl).ConfigureAwait(false); 354 | } 355 | else 356 | { 357 | await ServerSendChatAsync("You need to be host to change roles.", e.PlayerControl).ConfigureAwait(false); 358 | } 359 | break; 360 | case "/j help": 361 | case "/jester help": 362 | await ServerSendChatAsync("When the special Jester role is on, one crewmate is Jester.", e.PlayerControl).ConfigureAwait(false); 363 | await ServerSendChatAsync("In addition to the ways in which a normal crewmate can win, the Jester can win by getting voted out.", e.PlayerControl).ConfigureAwait(false); 364 | await ServerSendChatAsync("If this happens all the other players lose, so be careful who you vote during meetings!", e.PlayerControl).ConfigureAwait(false); 365 | await ServerSendChatAsync("The host can turn the Jester role on and off by typing '/jester on' or '/jester off'.", e.PlayerControl).ConfigureAwait(false); 366 | break; 367 | default: 368 | await ServerSendChatAsync("Error. Possible commands are '/jester help', '/jester on', '/jester off'.", e.PlayerControl).ConfigureAwait(false); 369 | break; 370 | } 371 | } 372 | 373 | } 374 | } --------------------------------------------------------------------------------