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

Contagion · handler “Contagion”

Version 3

Release notes

more UI options fixes and updated to work on latest.

Released
Size
2.8 KB
Downloads
517
Check
Verified
SHA-256
5621a835fe3ba126caddee513be1d70c623176c70df2645800cfc36aba7d8b25
Download v3 (.nc)All versions

Files 1

PathSize
handler.js14 KB

handler.js

Plain text
Hub.Handler.Version = 3; // Released at https://hub.splitscreen.me/ on Sat Aug 01 2020 22:40:05 GMT+0000 (UTC).
Hub.Handler.Id = "eLNoCHEyD2aPnhcoM";
Hub.Maintainer.Name = "Talos91";
Hub.Maintainer.Id = "eeL7HAz8zJovChWw4";

var answers1 = ["Both instances", "Only in first instance", "No"];
var answers2 = ["Vertical", "Horizontal"];
var answers3 = ["No", "Yes"];
Game.AddOption("Are you going to use the game native splitscreen?", "Max two horizontal instances with two controllers each (no keyboard).", "Split", answers1);
Game.AddOption("If you use the native splitscreen, choose a split mode.", "", "Mode", answers2);
Game.AddOption("Will you use more than 4 xinput gamepads?", "Only works with 1 player per instance.", "Reroute", answers3);

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 = true;
Game.HookFocus = false;
Game.FakeFocus = true;
Game.XInputPlusDll = ["xinput1_3.dll"];
Game.Hook.CustomDllEnabled = false;
Game.PromptBetweenInstances = true;
Game.PauseBetweenStarts = 30;
Game.Description =
  "CREATE a LAN server in the first instance and start the next instances until you are in gameplay, they will join automatically. If you select to use the game native splitscreen in the Player Options UI you can play with 4 or 3 players in only two instances of the game for better performance, the first two gamepads will control the first instance and the other two gamepads the second, if you want to have only one player per instance select to not use it in the UI. 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 in native split.). Alt+tab on keyboard instance to make it work. Reduce graphic settings in your main game to improve performance and load times. 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.tx

  if (Player.Owner.IsDualHorizontal()) {
    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);
  }
  if (Player.Owner.IsDualVertical()) {
    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 = ['5|		"aspect"				"16 by 9"', '13|		"aspect"				"8 by 9"', '21|		"aspect"				"16 by 9"'];
    Context.ReplaceLinesInTextFile(txtPath, dict);
  } else {
  }

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

  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 --controller_mode" + " -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 in 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;

    if (Context.PlayerID == 0) {
      if (mode == "Horizontal") {
        var Args = (Context.Args =
          "-steam -nointro -novid -sw --controller_mode " +
          " -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 --controller_mode " +
          " -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;

    if (Context.PlayerID == 0) {
      if (mode == "Horizontal") {
        var Args = (Context.Args =
          "-steam -nointro -novid -sw --controller_mode" + " -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 --controller_mode" + " -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 --controller_mode" +
          " -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 --controller_mode" +
          " -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 uses keyboard (not supported in 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")
    ]);
  }
  if (reroute == "No") {
    //You can use only ONE XboxOne controller and you can't use the keyboard at the same time. You must click/alt+tab on the corresponding instance to make it work. Alternatively you can try fix the problem by doing this http://www.snes9x.com/phpbb3/viewtopic.php?t=27510 or try Xoutput.

    Game.Hook.XInputReroute = false;
  }

  if (reroute == "Yes") {
  }
};