Skip to content
Beta: this is a preview of the new SplitScreen.Me. Data may be reset before launch.

Contagion · handler “Contagion”

Version 2

Release notes

updated to work on latest steam version.

Released
Size
2.6 KB
Downloads
42
Check
Verified
SHA-256
c301bdba2f800b29fb7d88c6fa52abad3103b136693582bf9b110ae3e994b453
Download v2 (.nc)All versions

Files 1

PathSize
handler.js12 KB

handler.js

Plain text
Hub.Handler.Version = 2; // Released at https://hub.splitscreen.me/ on Sun Jun 14 2020 21:06:46 GMT+0000 (UTC).
Hub.Handler.Id = "eLNoCHEyD2aPnhcoM";
Hub.Maintainer.Name = "Talos91";
Hub.Maintainer.Id = "eeL7HAz8zJovChWw4";

var answers1 = ["No", "Only first instance", "Both instances"];
var answers2 = ["Vertical", "Horizontal"];
Game.AddOption("Are you gonna use native splitscreen?", "Max two horizontal instances with two controllers each (no keyboard)", "Split", answers1);
Game.AddOption("If you use native splitscreen, choose a split mode", "", "Mode", answers2);

Game.FileSymlinkCopyInstead = ["splitscreen_config.txt"];
Game.KillMutex = ["hl2_singleton_mutex"];
Game.DirSymlinkExclusions = ["bin", "contagion\\cfg"];
Game.FileSymlinkExclusions = ["steam_api.dll", "steam_appid.txt", "xinput1_3.dll", "autoexec.cfg", "video.txt"];
Game.UseGoldberg = true;
Game.HandlerInterval = 100;
Game.SymlinkExe = false;
Game.SymlinkGame = true;
Game.SymlinkFolders = false;
Game.SupportsKeyboard = true;
Game.KeyboardPlayerFirst = true;
Game.ExecutableName = "contagion.exe";
Game.SteamID = "238430";
Game.GUID = "Contagion";
Game.GameName = "Contagion";
Game.LauncherTitle = "";
Game.SaveType = Nucleus.SaveType.CFG;
Game.SupportsPositioning = true;
Game.WorkingFolder = "bin";
Game.MaxPlayersOneMonitor = 8;
Game.MaxPlayers = 8;
Game.Hook.ForceFocus = true;
Game.Hook.ForceFocusWindowName = "Contagion";
Game.Hook.DInputEnabled = false;
Game.Hook.DInputForceDisable = true;
Game.Hook.XInputEnabled = true;
Game.Hook.XInputReroute = false; //set on true for play more than 4 controllers . You can use only ONE XboxOne controller and you can't use at the same time the keyboard. You must click/alt+tab on the corresponding instance to make it work. In alternative you can try fix the problem by doing this http://www.snes9x.com/phpbb3/viewtopic.php?t=27510 or try Xoutput.
Game.HookFocus = false;
Game.FakeFocus = true;
Game.Hook.CustomDllEnabled = false;
Game.PromptBetweenInstances = true;
Game.PauseBetweenStarts = 30;
Game.Description =
  "CREATE a LAN server in the first instance and when you are in, start the next one. Native splitscreen only works with two instances that use two controllers each (Just pick two controllers. If on the same monitor use two horizontal instances. Keyboard is not supported.). Alt+tab on keyboard instance for make it work. Set XInputReroute on true in the .js file for play with more than 4 controllers. F9= cap 30fps and F10= cap 60fps (instance selected).";

Game.Play = function() {
  var saveSrc = System.IO.Path.Combine(Context.RootInstallFolder, "contagion\\cfg\\video.txt");
  var savePath = System.IO.Path.Combine(Context.RootFolder, "contagion\\cfg\\video.txt");
  Context.ModifySaveFile(saveSrc, savePath, Nucleus.SaveType.CFG, [
    new Nucleus.CfgSaveInfo("config", "setting.fullscreen", "0"),
    new Nucleus.CfgSaveInfo("config", "setting.defaultres", Math.max(640, Context.Width)),
    new Nucleus.CfgSaveInfo("config", "setting.defaultresheight", Math.max(360, Context.Height)),
    new Nucleus.CfgSaveInfo("config", "setting.nowindowborder", "0"),
    new Nucleus.CfgSaveInfo("VideoConfig", "setting.fullscreen", "0"),
    new Nucleus.CfgSaveInfo("VideoConfig", "setting.defaultres", Math.max(640, Context.Width)),
    new Nucleus.CfgSaveInfo("VideoConfig", "setting.defaultresheight", Math.max(360, Context.Height)),
    new Nucleus.CfgSaveInfo("VideoConfig ", "setting.nowindowborder", "0")
  ]);

  var autoExec = Context.GetFolder(Nucleus.Folder.InstancedGameFolder) + "\\contagion\\cfg\\autoexec.cfg";
  var lines = [
    "sv_lan 1",
    "fps_max 60", // <----------------------------------------------------------------------------------------------------------------FPS CAP, EDIT HERE
    'bind "F9" "fps_max 30"',
    'bind "F10" "fps_max 60"'
  ];

  Context.WriteTextFile(autoExec, lines);

  //If you use a horizontal instance + native splitscreen, this will copy the edited splitscreen_config.txt
  if (Context.AspectRatio == "32:9") {
    var txtPath = Context.GetFolder(Nucleus.Folder.InstancedGameFolder) + "\\contagion\\splitscreen_config.txt"; //Editing a specific file by manually selecting the line and manually edit the text
    var dict = ['13|		"aspect"				"64 by 9"', '21|		"aspect"				"16 by 9"'];
    Context.ReplaceLinesInTextFile(txtPath, dict);
  }

  var split = Context.Options["Split"];
  var mode = Context.Options["Mode"];

  if (split == "No") {
    //If you choose no, the script will use CustomDll and the autoexec.cfg with splitscreen disabled

    Game.Hook.CustomDllEnabled = true;
    if (Context.PlayerID == 0) {
      //using launch options for let the first player create the server and the others to automatically join in server. If is a keyboard player, it will enable the mouse.

      if (Player.IsKeyboardPlayer) {
        var Args = (Context.Args =
          "-steam -nointro -novid -sw " + " -w " + Context.Width + " -h " + Context.Height + " +cl_mouselook 1 +cl_mouselook2 1 +m_rawinput 1 +ss_enable 0 +ss_splitmode 0 +sv_lan 1");
        Context.StartArguments = Args;
      } else {
        var Args = (Context.Args =
          "-steam -nointro -novid -sw " + " -w " + Context.Width + " -h " + Context.Height + " +cl_mouselook 0 +cl_mouselook2 0 +m_rawinput 0 +ss_enable 0 +ss_splitmode 0 +sv_lan 1");
        Context.StartArguments = Args;
      }
    } else {
      var Args = (Context.Args =
        "-steam -nointro -novid -sw " +
        " -w " +
        Context.Width +
        " -h " +
        Context.Height +
        " +cl_mouselook 0 +cl_mouselook2 0 +m_rawinput 0 +ss_enable 0 +ss_splitmode 0 +sv_lan 1 +connect " +
        Context.LocalIP);
      Context.StartArguments = Args;
    }
  }

  if (split == "Only first instance") {
    //this will use native splitscreen only for the instance with controller number 1 (will use second controller) + it will use XInputPlus.	//you can still use the third and the fourth controller on two separeted instances

    Game.KeyboardPlayerFirst = false;
    Game.XInputPlusDll = ["xinput1_3.dll"];

    if (Context.PlayerID == 0) {
      if (mode == "Horizontal") {
        var Args = (Context.Args =
          "-steam -nointro -novid -sw " + " -w " + Context.Width + " -h " + Context.Height + " +cl_mouselook 0 +cl_mouselook2 0 +m_rawinput 0 +ss_enable 1 +ss_splitmode 1 +sv_lan 1");
        Context.StartArguments = Args;
      }
      if (mode == "Vertical") {
        var Args = (Context.Args =
          "-steam -nointro -novid -sw " + " -w " + Context.Width + " -h " + Context.Height + " +cl_mouselook 0 +cl_mouselook2 0 +m_rawinput 0 +ss_enable 1 +ss_splitmode 0 +sv_lan 1");
        Context.StartArguments = Args;
      }
    }

    var savePath = Context.GetFolder(Nucleus.Folder.InstancedGameFolder) + "\\XInputPlus.ini";
    Context.ModifySaveFile(savePath, savePath, Nucleus.SaveType.INI, [
      new Nucleus.IniSaveInfo("ControllerNumber", "Controller1", "1"),
      new Nucleus.IniSaveInfo("ControllerNumber", "Controller2", "2"),
      new Nucleus.IniSaveInfo("ControllerNumber", "Controller3", "0"),
      new Nucleus.IniSaveInfo("ControllerNumber", "Controller4", "0")
    ]);

    if (Context.PlayerID == 1) {
      var Args = (Context.Args =
        "-steam -nointro -novid -sw " +
        " -w " +
        Context.Width +
        " -h " +
        Context.Height +
        " +cl_mouselook 0 +cl_mouselook2 0 +m_rawinput 0 +ss_enable 0 +ss_splitmode 0 +sv_lan 1 +connect " +
        Context.LocalIP);
      Context.StartArguments = Args;

      var savePath = Context.GetFolder(Nucleus.Folder.InstancedGameFolder) + "\\XInputPlus.ini";
      Context.ModifySaveFile(savePath, savePath, Nucleus.SaveType.INI, [
        new Nucleus.IniSaveInfo("ControllerNumber", "Controller1", "3"),
        new Nucleus.IniSaveInfo("ControllerNumber", "Controller2", "0"),
        new Nucleus.IniSaveInfo("ControllerNumber", "Controller3", "0"),
        new Nucleus.IniSaveInfo("ControllerNumber", "Controller4", "0")
      ]);
    }
    if (Context.PlayerID == 2) {
      var Args = (Context.Args =
        "-steam -nointro -novid -sw " +
        " -w " +
        Context.Width +
        " -h " +
        Context.Height +
        " +cl_mouselook 0 +cl_mouselook2 0 +m_rawinput 0 +ss_enable 0 +ss_splitmode 0 +sv_lan 1 +connect " +
        Context.LocalIP);
      Context.StartArguments = Args;

      var savePath = Context.GetFolder(Nucleus.Folder.InstancedGameFolder) + "\\XInputPlus.ini";
      Context.ModifySaveFile(savePath, savePath, Nucleus.SaveType.INI, [
        new Nucleus.IniSaveInfo("ControllerNumber", "Controller1", "4"),
        new Nucleus.IniSaveInfo("ControllerNumber", "Controller2", "0"),
        new Nucleus.IniSaveInfo("ControllerNumber", "Controller3", "0"),
        new Nucleus.IniSaveInfo("ControllerNumber", "Controller4", "0")
      ]);
    }
  }

  if (split == "Both instances") {
    //this will use native splitscreen on instance 1 (1 - 2 controllers) and instance 2 (3 - 4 controllers)

    Game.KeyboardPlayerFirst = false;
    Game.XInputPlusDll = ["xinput1_3.dll"];

    if (Context.PlayerID == 0) {
      if (mode == "Horizontal") {
        var Args = (Context.Args =
          "-steam -nointro -novid -sw " + " -w " + Context.Width + " -h " + Context.Height + " +cl_mouselook 0 +cl_mouselook2 0 +m_rawinput 0 +ss_enable 1 +ss_splitmode 1 +sv_lan 1");
        Context.StartArguments = Args;
      }
      if (mode == "Vertical") {
        var Args = (Context.Args =
          "-steam -nointro -novid -sw " + " -w " + Context.Width + " -h " + Context.Height + " +cl_mouselook 0 +cl_mouselook2 0 +m_rawinput 0 +ss_enable 1 +ss_splitmode 0 +sv_lan 1");
        Context.StartArguments = Args;
      }

      var savePath = Context.GetFolder(Nucleus.Folder.InstancedGameFolder) + "\\XInputPlus.ini";
      Context.ModifySaveFile(savePath, savePath, Nucleus.SaveType.INI, [
        new Nucleus.IniSaveInfo("ControllerNumber", "Controller1", "1"),
        new Nucleus.IniSaveInfo("ControllerNumber", "Controller2", "2"),
        new Nucleus.IniSaveInfo("ControllerNumber", "Controller3", "0"),
        new Nucleus.IniSaveInfo("ControllerNumber", "Controller4", "0")
      ]);
    }
    if (Context.PlayerID == 1) {
      if (mode == "Horizontal") {
        var Args = (Context.Args =
          "-steam -nointro -novid -sw " +
          " -w " +
          Context.Width +
          " -h " +
          Context.Height +
          " +cl_mouselook 0 +cl_mouselook2 0 +m_rawinput 0 +ss_enable 1 +ss_splitmode 1 +sv_lan 1 +connect " +
          Context.LocalIP);
        Context.StartArguments = Args;
      }
      if (mode == "Vertical") {
        var Args = (Context.Args =
          "-steam -nointro -novid -sw " +
          " -w " +
          Context.Width +
          " -h " +
          Context.Height +
          " +cl_mouselook 0 +cl_mouselook2 0 +m_rawinput 0 +ss_enable 1 +ss_splitmode 0 +sv_lan 1 +connect " +
          Context.LocalIP);
        Context.StartArguments = Args;
      }

      var savePath = Context.GetFolder(Nucleus.Folder.InstancedGameFolder) + "\\XInputPlus.ini";
      Context.ModifySaveFile(savePath, savePath, Nucleus.SaveType.INI, [
        new Nucleus.IniSaveInfo("ControllerNumber", "Controller1", "3"),
        new Nucleus.IniSaveInfo("ControllerNumber", "Controller2", "4"),
        new Nucleus.IniSaveInfo("ControllerNumber", "Controller3", "0"),
        new Nucleus.IniSaveInfo("ControllerNumber", "Controller4", "0")
      ]);
    }
  }

  if (Player.IsKeyboardPlayer) {
    //if the player use keyboard (is not supported for native splitscreen)

    Game.Hook.CustomDllEnabled = true;
    Game.FakeFocus = false;

    var Args = (Context.Args =
      "-steam -nointro -novid -sw " + " -w " + Context.Width + " -h " + Context.Height + " +cl_mouselook 1 +cl_mouselook2 1 +m_rawinput 1 +ss_enable 0 +ss_splitmode 0 +sv_lan 1");
    Context.StartArguments = Args;

    var savePath = Context.GetFolder(Nucleus.Folder.InstancedGameFolder) + "\\XInputPlus.ini";
    Context.ModifySaveFile(savePath, savePath, Nucleus.SaveType.INI, [
      new Nucleus.IniSaveInfo("ControllerNumber", "Controller1", "0"),
      new Nucleus.IniSaveInfo("ControllerNumber", "Controller2", "0"),
      new Nucleus.IniSaveInfo("ControllerNumber", "Controller3", "0"),
      new Nucleus.IniSaveInfo("ControllerNumber", "Controller4", "0")
    ]);
  }
};