144 lines
4.6 KiB
PowerShell
144 lines
4.6 KiB
PowerShell
$ErrorActionPreference = 'Stop'
|
|
|
|
$apiUrl = 'https://api.github.com/repos/LukeYui/EldenRingSeamlessCoopRelease/releases/latest'
|
|
$scDownloadUrl = $null
|
|
$localPath = $null
|
|
|
|
$input = Read-Host "Do you want to use the official Github-Repository [d] to download the mod or use an already downloaded .zip? [l] [D/l]"
|
|
|
|
if ($input -match '^(l|local)$') {
|
|
Write-Host "Searching Downloads folder..."
|
|
|
|
$downloads = Join-Path $HOME 'Downloads'
|
|
|
|
$localPath = Get-ChildItem -Path $downloads -Filter 'Seamless*.zip' -File -ErrorAction SilentlyContinue |
|
|
Select-Object -First 1 -ExpandProperty FullName
|
|
|
|
if ($localPath -and (Test-Path $localPath)) {
|
|
Write-Host "File found at $localPath"
|
|
}
|
|
else {
|
|
Write-Host "File not found in $downloads"
|
|
|
|
$input = Read-Host "Please specify the path to your local .zip archive"
|
|
|
|
if ([string]::IsNullOrWhiteSpace($input) -or $input -eq 'null') {
|
|
throw "Empty path provided"
|
|
}
|
|
elseif (Test-Path $input -PathType Leaf) {
|
|
$localPath = $input
|
|
Write-Host "File found at $localPath"
|
|
}
|
|
elseif (Test-Path $input -PathType Container) {
|
|
$localPath = Get-ChildItem -Path $input -Filter 'Seamless*.zip' -File -Recurse -ErrorAction SilentlyContinue |
|
|
Select-Object -First 1 -ExpandProperty FullName
|
|
|
|
if ($localPath) {
|
|
Write-Host "File found at $localPath"
|
|
}
|
|
else {
|
|
throw "File not found at $input"
|
|
}
|
|
}
|
|
else {
|
|
throw "Invalid path provided"
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
$release = Invoke-RestMethod -Uri $apiUrl -Headers @{ 'User-Agent' = 'PowerShell' }
|
|
$scDownloadUrl = $release.assets[0].browser_download_url
|
|
}
|
|
|
|
function Get-EldenRingGameDir {
|
|
$steamPaths = @(
|
|
"$env:ProgramFiles(x86)\Steam\steamapps\common\Elden Ring\Game",
|
|
"$env:ProgramFiles\Steam\steamapps\common\Elden Ring\Game",
|
|
"$env:LOCALAPPDATA\Programs\Steam\steamapps\common\Elden Ring\Game"
|
|
)
|
|
|
|
foreach ($path in $steamPaths) {
|
|
if (Test-Path (Join-Path $path 'eldenring.exe')) {
|
|
$input = Read-Host "Is this your Elden Ring Game folder? $path [Y/n]"
|
|
|
|
if ($input -notmatch '^(n|no)$') {
|
|
return $path
|
|
}
|
|
}
|
|
}
|
|
|
|
$drives = Get-PSDrive -PSProvider FileSystem | Select-Object -ExpandProperty Root
|
|
|
|
foreach ($drive in $drives) {
|
|
Write-Host "Searching at $drive"
|
|
|
|
$hit = Get-ChildItem -Path $drive -Filter 'eldenring.exe' -Recurse -File -ErrorAction SilentlyContinue |
|
|
Where-Object { $_.FullName -match '\\Elden Ring\\Game\\eldenring\.exe$' } |
|
|
Select-Object -First 1
|
|
|
|
if ($hit) {
|
|
$input = Read-Host "Is this your Elden Ring Game folder? $($hit.DirectoryName) [Y/n]"
|
|
|
|
if ($input -notmatch '^(n|no)$') {
|
|
return $hit.DirectoryName
|
|
}
|
|
}
|
|
}
|
|
|
|
return $null
|
|
}
|
|
|
|
Write-Host "Searching for Elden Ring game folder"
|
|
|
|
$eldenringDir = Get-EldenRingGameDir
|
|
|
|
if (-not $eldenringDir) {
|
|
$eldenringDir = Read-Host "Please provide your Elden Ring Directory Path"
|
|
|
|
if (-not (Test-Path (Join-Path $eldenringDir 'eldenring.exe'))) {
|
|
throw "Incorrect Elden Ring directory. 'eldenring.exe' not found at provided path."
|
|
}
|
|
|
|
Write-Host "Correct Elden Ring directory"
|
|
}
|
|
|
|
$tempDir = Join-Path $PWD 'ersc-download'
|
|
New-Item -ItemType Directory -Path $tempDir -Force | Out-Null
|
|
|
|
$zipPath = Join-Path $tempDir 'ersc.zip'
|
|
|
|
if (-not $scDownloadUrl -and $localPath) {
|
|
Write-Host "Copying .zip"
|
|
Copy-Item $localPath $zipPath -Force
|
|
}
|
|
else {
|
|
Write-Host "Downloading Seamless Coop"
|
|
Write-Host "Download URL: $scDownloadUrl"
|
|
Invoke-WebRequest -Uri $scDownloadUrl -OutFile $zipPath
|
|
}
|
|
|
|
Write-Host "Extracting downloaded files"
|
|
Expand-Archive -Path $zipPath -DestinationPath $tempDir -Force
|
|
|
|
$seamlessDir = Join-Path $tempDir 'SeamlessCoop'
|
|
$launcherPath = Join-Path $eldenringDir 'ersc_launcher.exe'
|
|
|
|
if (Test-Path $launcherPath) {
|
|
$input = Read-Host "Override existing Seamless Coop settings? This resets your Seamless Coop settings, including multiplayer password [Y/n]"
|
|
|
|
if ($input -match '^(n|no)$') {
|
|
$settings = Join-Path $seamlessDir 'ersc_settings.ini'
|
|
|
|
if (Test-Path $settings) {
|
|
Remove-Item $settings -Force
|
|
}
|
|
}
|
|
}
|
|
|
|
Write-Host "Copying files to Elden Ring Game folder"
|
|
Copy-Item -Path (Join-Path $tempDir '*') -Destination $eldenringDir -Recurse -Force
|
|
|
|
Write-Host "Cleaning up"
|
|
Remove-Item $tempDir -Recurse -Force
|
|
|
|
Write-Host "Done. Launch ersc_launcher.exe from the Game folder." |