Skip to content

Instantly share code, notes, and snippets.

@ebith
Last active February 7, 2024 23:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ebith/b3a61eff5cbb8e5eecdfa2d951e54717 to your computer and use it in GitHub Desktop.
Save ebith/b3a61eff5cbb8e5eecdfa2d951e54717 to your computer and use it in GitHub Desktop.
Script for edit equipment in Baldur's Gate 3 (https://ebith.hatenablog.jp/entry/2024/02/05/075512)
$bg3_path = "${env:ProgramFiles(x86)}\Steam\SteamApps\common\Baldurs Gate 3\Data\"
$z = "https://gist.github.com/ebith/b3a61eff5cbb8e5eecdfa2d951e54717/raw/Z.txt"
[void][System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms")
$dialog = New-Object System.Windows.Forms.OpenFileDialog
$dialog.Filter = "Divine.exe|Divine.exe"
$dialog.InitialDirectory = $(Get-Location)
if($dialog.ShowDialog() -ne [System.Windows.Forms.DialogResult]::OK){ exit }
$divine = $dialog.FileName
$processes = @()
Get-ChildItem $bg3_path | ForEach-Object {
if ($_.Name -match "^(Patch\d_Hotfix\d.pak|Gustav.pak)$") {
$dest = Join-Path -Path $(Get-Location) -ChildPath "unpacked" -AdditionalChildPath $_.BaseName
if ($(Get-ItemProperty $_.FullName).LastWriteTime -gt $(Get-ItemProperty $dest -ErrorAction SilentlyContinue).LastWriteTime) {
Remove-Item -Path $dest -Force -Recurse -ErrorAction SilentlyContinue
$processes += Start-Process -FilePath $divine -ArgumentList "-g bg3 -s `"$($_.FullName)`" -d `"$dest`" -a extract-package" -PassThru -NoNewWindow
}
}
}
$processes | ForEach-Object {
Wait-Process -Id $_.Id -ErrorAction SilentlyContinue
}
Remove-Item -Path source -Force -Recurse -ErrorAction SilentlyContinue
New-Item -Path source -ItemType Directory | Out-Null
Get-ChildItem ./unpacked | ForEach-Object {
$data = Join-Path -Path $_.FullName -ChildPath "Public\GustavDev\Stats\Generated\Data"
if (Test-Path $data) {
Copy-Item -Path $(Join-Path -Path $data -ChildPath "*") -Destination $(Join-Path -Path $(Get-Location) -ChildPath "source")
}
}
$data_path = Join-Path -Path $bg3_path -ChildPath "Public\GustavDev\Stats\Generated\Data"
New-Item -Path $data_path -ItemType Directory -ErrorAction SilentlyContinue | Out-Null
@("Armor.txt", "Weapon.txt") | ForEach-Object {
Copy-Item -Path $(Join-Path -Path $(Get-Location) -ChildPath "source" -AdditionalChildPath $_) -Destination $(Join-Path -Path $data_path -ChildPath $_)
}
$z_path = $(Join-Path -Path $data_path -ChildPath "Z.txt")
if (!(Test-Path $z_path)) {
Invoke-WebRequest -Uri $z -OutFile $z_path
}
new entry "Z_MistyStep"
type "SpellData"
data "SpellType" "Target"
using "Target_MistyStep"
data "Cooldown" "OncePerTurn"
data "UseCosts" "BonusActionPoint:1"
new entry "Z_Dagger_Passive"
type "PassiveData"
data "Boosts" "ReduceCriticalAttackThreshold(3);Advantage(AttackRoll);Advantage(AttackTarget);AbilityOverrideMinimum(Strength, 24)"
new entry "WPN_Dagger"
type "Weapon"
using "_BaseWeapon"
data "RootTemplate" "569b0f3d-abcd-4b01-aaf0-979091288163"
data "Damage Type" "Piercing"
data "Damage" "1d4"
data "ValueScale" "0.5"
data "Weight" "0.45"
data "Weapon Group" "SimpleMeleeWeapon"
data "Weapon Properties" "Finesse;Light;Thrown;Melee;Dippable"
data "Proficiency Group" "Daggers;SimpleWeapons"
data "BoostsOnEquipMainHand" "UnlockSpell(Target_PiercingThrust);UnlockSpell(Z_MistyStep)"
data "Rarity" "Legendary"
data "DefaultBoosts" "WeaponEnchantment(3);WeaponProperty(Magical);WeaponDamage(StrengthModifier, Piercing)"
data "PassivesOnEquip" "Z_Dagger_Passive"
new entry "MAG_PHB_CloakOfProtection_Cloak"
type "Armor"
using "_Back_Magic"
data "RootTemplate" "602f62dd-0fba-4438-ad68-b846f17ac538"
data "ValueLevel" "7"
data "Rarity" "Legendary"
data "Boosts" "AC(2);RollBonus(SavingThrow, 2)"
data "PassivesOnEquip" "MAG_PHB_OfRegeneration_Ring_Passive;MAG_PHB_Displacement_Cloak_Passive"
data "StatusOnEquip" "MAG_PHB_CLOAK_OF_DISPLACEMENT_TECHNICAL"
new entry "ARM_Amulet_Necklace_A_Bronze_Green"
type "Armor"
using "ARM_Amulet_Bronze"
data "RootTemplate" "8bba4a7c-a7df-4d1f-b202-286522a028fa"
data "StatusOnEquip" "MAG_CELESTIAL_HASTE"
@ebith
Copy link
Author

ebith commented Feb 4, 2024

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