Skip to content

Instantly share code, notes, and snippets.

@richard087
Last active June 28, 2023 12:33
Show Gist options
  • Save richard087/10b66313844e73cdd346ff755ffab54f to your computer and use it in GitHub Desktop.
Save richard087/10b66313844e73cdd346ff755ffab54f to your computer and use it in GitHub Desktop.
USE AT OWN RISK! A collection of functions to make it easier to manage Cyberpunk 2077 mods. This is NOT a mod manager. You will need to understand how to use/manage Subversion to get any value from this.
# install SVN
# tested with Slik SVN 1.14.2 from https://sliksvn.com/download/
#CONFIGURATION
#where should Subversion store its data?
$svn_data = "D:\Temp\repo"
#where will your downloaded mod files be kept?
$dir_download = "$env:USERPROFILE\Downloads"
#where is Cyberpunk 2077 installed?
$cp_install = "C:\Program Files (x86)\GOG Galaxy\Games\Cyberpunk 2077"
Function Init-SvnRepo
{
param($svn_data, $cp_install)
$svn_working = "$cp_install\.."
$cp_repo = "$svn_data\cp2077"
New-Item -ItemType Directory -Path $svn_data
svnadmin create $cp_repo
svn mkdir -m "Create directory structure." file:///$cp_repo/trunk file:///$cp_repo/branches file:///$cp_repo/tags
svn checkout file:///$cp_repo/trunk $svn_working
svn add --force $cp_install/
# takes time for SVN fiddling about...
svn commit -m "initial import" $cp_install
# tag it before we make a mess of it
svn copy -m "Tag fresh install" file:///$cp_repo/trunk file:///$cp_repo/tags/basic-1.62-DLSS
#slow... really slow.
svn update $cp_install
}
Function Init-7z
{
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force -Scope CurrentUser
Set-PSRepository -Name 'PSGallery' -SourceLocation "https://www.powershellgallery.com/api/v2" -InstallationPolicy Trusted
Install-Module -Name 7Zip4PowerShell -Force -Scope CurrentUser
}
function New-TemporaryDirectory {
$parent = [System.IO.Path]::GetTempPath()
[string] $name = [System.Guid]::NewGuid()
New-Item -ItemType Directory -Path (Join-Path $parent $name)
}
Function Install-SimpleMod {
param([parameter(Mandatory)]$cp_install, [parameter(Mandatory)]$mod_name, [parameter(Mandatory)]$mod_version, [parameter(Mandatory)]$nexus_id, $name_prefix = '', $archive_extension = "zip", $cp_install_suffix = '')
$filePath = "$dir_download\$mod_name-$nexus_id-$($mod_version -replace '\.', '-')-*.$archive_extension"
$cp_target = $cp_install
if ($cp_install_suffix -ne '') {
$cp_target = "$cp_install\$cp_install_suffix"
}
if (Test-Path -Path $filePath)
{
$archive = (Get-ChildItem -Path $filePath | Select-Object -First 1)
if ($archive_extension -eq "7z") {
Expand-7Zip -ArchiveFileName $archive -TargetPath $cp_target
} else {
Expand-Archive -DestinationPath $cp_target -Path $archive
}
Commit-Changes -cp_install $cp_install -mod_name $mod_name -mod_version $mod_version -name_prefix $name_prefix
} else {
throw "Could not find an archive for version $mod_version of $mod_name. Searched at $filePath Download from https://www.nexusmods.com/cyberpunk2077/mods/$nexus_id"
}
}
Function Commit-Changes
{
param([parameter(Mandatory)]$cp_install, [parameter(Mandatory)]$mod_name, [parameter(Mandatory)]$mod_version, [parameter(Mandatory)]$name_prefix)
svn add --force $cp_install/
svn commit -m "Installed $name_prefix$mod_name v$mod_version" $cp_install
svn update $cp_install
}
Function Install-BrokenLionMod
{
param([parameter(Mandatory)]$cp_install, [parameter(Mandatory)]$mod_name, [parameter(Mandatory)]$mod_version, [parameter(Mandatory)]$nexus_id, $name_prefix = '', $archive_extension = "7z")
$filePath = "$dir_download\$mod_name-$nexus_id-$($mod_version -replace '\.', '-')-*.$archive_extension"
if (Test-Path -Path $filePath)
{
$archive = (Get-ChildItem -Path $filePath | Select-Object -First 1)
$tempDir = New-TemporaryDirectory
Expand-7Zip -ArchiveFileName $archive -TargetPath $tempDir
Copy-Item -Path "$tempDir\*\*" -Destination $cp_install -Recurse -Force
Remove-Item -Recurse $tempDir
Commit-Changes -cp_install $cp_install -mod_name $mod_name -mod_version $mod_version -name_prefix $name_prefix
} else {
throw "Could not find an archive for this mod. Searched at $filePath Download from https://www.nexusmods.com/cyberpunk2077/mods/$nexus_id"
}
}
# Tested with Game version 1.63_Hotfix (GoG)
Function auto-enemies
{
param($cp_install)
Install-SimpleMod -cp_install $cp_install -mod_name 'redscript' -nexus_id 1511 -mod_version "0.5.14"
# install special does not be complete until after game starts
Install-SimpleMod -cp_install $cp_install -mod_name 'RED4ext' -nexus_id 2380 -mod_version "1.15.0"
# START GAME REQUIRED!
# (should be captured in svn) creates a config file $cp_install\red4ext\config.ini
# (should be ignored in svn) creates a logging directory at $cp_install\red4ext\logs
# uninstall special(?)
# https://docs.red4ext.com/getting-started/uninstalling
# appears not to be relevant
# install special does not complete until after game starts
# Cyber Engine Tweaks
Install-SimpleMod -cp_install $cp_install -mod_name 'Game version 1.63 Steam' -nexus_id 107 -mod_version "1.25.1"
Install-SimpleMod -cp_install $cp_install -mod_name 'cybercmd' -nexus_id 5176 -mod_version "0.0.10"
# requires: Cyber Engine Tweaks
Install-SimpleMod -cp_install $cp_install -mod_name 'Native Settings UI 1.93' -nexus_id 3518 -mod_version "1.93"
# Requires:
# Cyber Engine Tweaks
Install-SimpleMod -cp_install $cp_install -mod_name 'AI Netrunners Enhanced' -nexus_id 2468 -mod_version "1.5.0"
# Requires:
# Cyber Engine Tweaks
# cybercmd (if using redmod)
# Native Settings UI
# redscript
#SDO
Install-SimpleMod -cp_install $cp_install -mod_name 'SDO - Scissors Difficulty Options' -nexus_id 4408 -mod_version "1.1"
# Requires:
# Cyber Engine Tweaks
# Native settings UI
Install-SimpleMod -cp_install $cp_install -mod_name 'ArchiveXL' -nexus_id 4198 -mod_version "1.4.8"
# requires: 1.9.0+ RED4ext
Install-SimpleMod -cp_install $cp_install -mod_name 'input_loader.zip' -nexus_id 4575 -mod_version "0.1.1"
# requires: 1.9.0+ RED4ext
Install-SimpleMod -cp_install $cp_install -mod_name 'Ranged Attack Speed Damage Fix' -nexus_id 4997 -mod_version "2.0"
# Requires:
# Cyber Engine Tweaks
# Time Dilation Overhaul
Install-SimpleMod -cp_install $cp_install -mod_name 'Time Dilation Overhaul' -nexus_id 4931 -mod_version "1.8.5"
# Requires:
# ArchiveXL (Latest version required)
# Cyber Engine Tweaks (Latest version required)
# Input Loader (Latest version required)
# Native Settings UI (Technically optional, but HIGHLY recommended)
# Ranged Attack Speed Damage Fix (Required for ranged weapons to work properly in time dilation)
# RED4ext (Latest version required)
Install-BrokenLionMod -cp_install $cp_install -mod_name 'Enemies of Night City' -nexus_id 8467 -mod_version "1.1" -archive_extension "zip"
# Requires:
# AI Netrunners enhanced (optional but recommended)
# Native settings UI
# SDO - Scissors Difficulty Options
# Time Dilation Overhaul
}
Function auto-amm
{
#Caused crashes
param($cp_install)
# install special does not complete until after game starts
Install-SimpleMod -cp_install $cp_install -mod_name 'CET 1.23.0' -nexus_id 107 -mod_version "1.23.0"
Install-SimpleMod -cp_install $cp_install -mod_name 'Appearance Menu Mod' -nexus_id 790 -mod_version "2.0.2"
# requires: CET 1.8.2+
}
# Once everything's setup and you understand what the script will do, uncomment the lines below and run the script.
# Init-SvnRepo -svn_data $svn_data -cp_install $cp_install
# auto-enemies -cp_install $cp_install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment