Skip to content

Instantly share code, notes, and snippets.

@axxag
Last active April 25, 2022 11:16
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save axxag/5b8ddeecc15bf7b16652860779ff8120 to your computer and use it in GitHub Desktop.
Save axxag/5b8ddeecc15bf7b16652860779ff8120 to your computer and use it in GitHub Desktop.
Borderlands3-Epic-NucleusCoop
Game.DirSymlinkExclusions = ["OakGame\\Binaries\\Win64"];
Game.GameName = "Borderlands 3";
Game.HandlerInterval = 100;
Game.SymlinkExe = false;
Game.SymlinkGame = true;
Game.SymlinkFolders = true;
Game.ExecutableName = "Borderlands3.exe";
Game.GUID = "Borderlands 3";
Game.MaxPlayers = 4;
Game.MaxPlayersOneMonitor = 4;
Game.BinariesFolder = "OakGame\\Binaries\\Win64";
Game.NeedsSteamEmulation = false;
Game.UseGoldberg = false;
Game.LauncherTitle = "splashscreen";
Game.Hook.ForceFocus = true;
Game.Hook.ForceFocusWindowName = "Borderlands® 3";
Game.Hook.DInputEnabled = false;
Game.Hook.XInputEnabled = true;
Game.Hook.XInputReroute = false;
Game.Hook.CustomDllEnabled = false;
Game.XInputPlusDll = ["xinput1_3.dll"];
Game.SetWindowHook = true;
Game.ResetWindows = true;
Game.PauseBetweenStarts = 30;
Game.KeepSymLinkOnExit = false;
Game.FakeFocus = true;
Game.FakeFocusSendActivate = false;
Game.HookFocus = true;
Game.ResetWindows = true;
Game.PromptBetweenInstances = false;
Game.UserProfileConfigPath =
"Documents\\My Games\\Borderlands 3\\Saved\\Config\\WindowsNoEditor";
Game.UserProfileSavePath =
"Documents\\My Games\\Borderlands 3\\Saved\\SaveGames";
Game.Description = "Only works with the Epic Games version";
Game.SupportsMultipleKeyboardsAndMice = true;
Game.HookSetCursorPos = true;
Game.HookGetCursorPos = true;
Game.HookGetKeyState = true;
Game.HookGetAsyncKeyState = true;
Game.HookGetKeyboardState = true;
Game.HookFilterRawInput = true;
Game.HookFilterMouseMessages = false;
Game.HookUseLegacyInput = false;
Game.HookDontUpdateLegacyInMouseMsg = false;
Game.HookMouseVisibility = false;
Game.SendNormalMouseInput = true;
Game.SendNormalKeyboardInput = true;
Game.SendScrollWheel = true;
Game.ForwardRawKeyboardInput = false;
Game.ForwardRawMouseInput = false;
Game.HookReRegisterRawInput = true;
Game.HookReRegisterRawInputMouse = true;
Game.HookReRegisterRawInputKeyboard = true;
Game.DrawFakeMouseCursor = false;
Game.LockInputAtStart = false;
Game.LockInputToggleKey = 0x23;
Game.Play = function() {
var EpicArgs = 'PREFLIGHT_SCRIPT_WILL_REPLACE';
var GameArgs =
" -windowed -AlwaysFocus -nosplash" + Context.IsKeyboardPlayer
? " -NoController"
: "";
var Args = GameArgs + EpicArgs;
Context.StartArguments = Args;
var savePath =
Context.EnvironmentPlayer +
Context.UserProfileConfigPath +
"\\GameUserSettings.ini";
Context.ModifySaveFile(savePath, savePath, Nucleus.SaveType.INI, [
new Nucleus.IniSaveInfo(
"/Script/OakGame.OakGameUserSettings",
"FullscreenMode",
"2"
),
new Nucleus.IniSaveInfo(
"/Script/OakGame.OakGameUserSettings",
"ResolutionSizeX",
Context.Width
),
new Nucleus.IniSaveInfo(
"/Script/OakGame.OakGameUserSettings",
"ResolutionSizeY",
Context.Height
)
]);
};
$NC_SCRIPT_PATH = ".\Borderlands3.js"
$NC_SCRIPT_REPLACE_STRING = "PREFLIGHT_SCRIPT_WILL_REPLACE"
$EPIC_LOG_PATH = "$env:USERPROFILE\AppData\Local\EpicGamesLauncher\Saved\Logs\EpicGamesLauncher.log"
try {
Write-Host Checking if NC Script file needs launch args
$containsString = Select-String -Path $NC_SCRIPT_PATH -Pattern $NC_SCRIPT_REPLACE_STRING
If ($null -eq $containsString) {
Write-Host "Launch args already added! Skipping..."
exit
}
}
catch {
Write-Error "Unable to open nucleus script file. Quitting..." -ErrorAction Stop
}
try {
Write-Host Checking if epic logs already contain launch args
$Launch_Info = Get-Content $env:USERPROFILE\AppData\Local\EpicGamesLauncher\Saved\Logs\EpicGamesLauncher.log | `
Where-Object { $_ -like '*FCommunityPortalLaunchAppTask: Launching app*Borderlands3.exe*' } | `
Select-Object -First 1
}
catch {
# Cant find args yet
}
if ($null -eq $Launch_Info) {
# Start an instance of Borderlands 3 using the Epic Launcher
try {
Write-Host Args not found yet. Starting Borderlands 3 using Epic Launcher
Start-Process -FilePath "com.epicgames.launcher://apps/Catnip?action=launch&silent=true"
}
catch {
Write-Error "Unable to launch Borderlands 3 using Epic Launcher. Quitting..." -ErrorAction Stop
}
# Get args needed to launch BL3 offline
try {
# Search through Epic Launcher logs to find the launch parameters for Borderlands 3.
Write-Host Finding offline launch arguments
while (($null -eq $Launch_Info ) -or ($null -eq $bl3_process)) {
Start-Sleep -s 1
$bl3_process = Get-Process -name Borderlands3 -ErrorAction SilentlyContinue
$Launch_Info = Get-Content $EPIC_LOG_PATH | `
Where-Object { $_ -like '*FCommunityPortalLaunchAppTask: Launching app*Borderlands3.exe*' } | `
Select-Object -First 1
}
Start-Sleep -s 15
Write-Host Killing Borderlands3
Stop-Process $bl3_process.Id
}
catch {
Write-Error "Unable to get offline args for Borderlands 3. Quitting..." -ErrorAction Stop
}
}
try {
Write-Host Parsing launch args
# Reformat it, split out the binary/args
$null, $bl3_bin = $Launch_Info -split "Launching app "
$bl3_bin = $bl3_bin -replace "'", ""
$bl3_bin, $bl3_arg = $bl3_bin -split "with commandline "
$bl3_bin = $bl3_bin -replace "Borderlands3.exe", "OakGame/Binaries/Win64/Borderlands3.exe"
# Sanity check- make sure binary exists
$null = Test-Path -Path $bl3_bin -ErrorAction stop
Write-Host Found Borderlands 3 args
Write-Host Writing launch args to script
(Get-Content -Path $NC_SCRIPT_PATH) -replace $NC_SCRIPT_REPLACE_STRING, $bl3_arg | Set-Content -Path $NC_SCRIPT_PATH
}
catch {
Write-Error "Unable to write launch args to NC script. Quitting..." -ErrorAction Stop
}
Write-Host All done!
@slumlorddaddy
Copy link

So I stick the preflight and .js file in my nucleus coop scripts. I run the .ps1 file with powershell. Then I try to run the game and just get a "sorry, something went wrong" error from BL3 and it doesn't startup.

@Snailedlt
Copy link

Hi, how would you like to join the developer discord? Would be awesome to have this script downloadable through the app

@killerman18
Copy link

killerman18 commented Aug 2, 2020

I joinded discord ! Im trying to run prefligth with powershell (i copied paste the script and pressed enter) and then i have a red msg looking like this :
image
Eddit : i managed that the game appear in the nucleus coop app not sure how but it tells that i need to start the game with the epic game lancher.
Edit : i think it did work for prefligth (i rigth clicked instead ) and it does not appear in red. tho it didnt change the error msg to use Epic Launcher

Do i have to run the js. in powershell 2 ? if yes i tried and it give a lot or Error msg. not sure how to do this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment