Dungeons & Dragons: Dragonshard

From LANCommander
Revision as of 02:09, 6 January 2024 by DoctorDalek (talk | contribs) (Created new page for Dungeons & Dragons: Dragonshard)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Developers
Liquid Entertainment
Publishers
Atari, Inc.
Release Date
Windows: September 21, 2005
Genres
StrategyRole-playing (RPG)
View at PCGamingWiki

Actions

Name Path Arguments Working Directory Primary
Play {InstallDir}\Dragonshard.exe True

Install Script

This script requires admin access to function properly

# Bounds are accessible by $Display.Bounds.Width and $Display.Bounds.Height
$Display = Get-PrimaryDisplay

Write-ReplaceContentInFile -Pattern '^video_resolutionX "(.+)"' -Substitution "video_resolutionX ""$($Display.Bounds.Width)""" -FilePath "$InstallDirectory\Dragonshard\Profiles\test.pro"
Write-ReplaceContentInFile -Pattern '^video_resolutionY "(.+)"' -Substitution "video_resolutionY ""$($Display.Bounds.Height)""" -FilePath "$InstallDirectory\Dragonshard\Profiles\test.pro"

Write-ReplaceContentInFile -Pattern '^Width(.+)' -Substitution "Width = $($Display.Bounds.Width)" -FilePath "$InstallDirectory\DND.ini"
Write-ReplaceContentInFile -Pattern '^Height(.+)' -Substitution "Height = $($Display.Bounds.Height)" -FilePath "$InstallDirectory\DND.ini"

New-Item -Path "registry::\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Liquid Entertainment"
New-Item -Path "registry::\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Liquid Entertainment\Dragonshard"
New-ItemProperty -Path "registry::\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Liquid Entertainment\Dragonshard" -Name "Program" -Value "Dragonshard.exe" -Force
New-ItemProperty -Path "registry::\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Liquid Entertainment\Dragonshard" -Name "Install Path" -Value "$InstallDirectory" -Force
New-ItemProperty -Path "registry::\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Liquid Entertainment\Dragonshard" -Name "CD Key" -Value "JDZJ-QD6B-437T-WBDY" -Force

# cmd /c mkdir '%userprofile%\Documents\My Games'
# cmd /c mkdir '%userprofile%\Documents\My Games\Dragonshard'
# cmd /c mklink /j '%userprofile%\Documents\My Games\Dragonshard' '$InstallDiretory\Dragonshard'
# 
# $filePath = "$InstallDiretory\DNDini"
# 
# # Get the screen resolution
# Add-Type -AssemblyName System.Windows.Forms
# $screen = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Size
# $width = $screen.Width
# $height= $screen.Height
# 
# # Read the content of the file
# $content = Get-Content -Path $filePath
# 
# # Loop through each line in the file
# for ($i = 0; $i -lt $content.Count; $i++) {
#     $line = $content[$i]
# 
#     # Check if the line contains "Resolution"
#     if ($line -like '*Width*') {
#     $line
#         # Replace the line with the updated width
#         $content[$i] = "Width             =$width"
#         
#     }
#     if ($line -like '*Height*') {
#     $line
#         # Replace the line with the updated width
#         $content[$i] = "Height             =$height"
#         
#     }
#    
#   }
# 
# # Save the updated content back to the file
# $content | Set-Content -Path $filePath
# 
# $filePath = "$env:USERPROFILE\Documents\My Games\Dragonshard\Profiles\test.pro"
# # Get the screen resolution
# Add-Type -AssemblyName System.Windows.Forms
# $screen = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Size
# $width = $screen.Width
# $height= $screen.Height
# 
# # Read the content of the file
# $content = Get-Content -Path $filePath
# 
# # Loop through each line in the file
# for ($i = 0; $i -lt $content.Count; $i++) {
#     $line = $content[$i]
# 
#     # Check if the line contains "Resolution"
#     if ($line -like '*video_resolutionX*') {
#     $line
#         # Replace the line with the updated width
#         $content[$i] = "video_resolutionX ""$Width"""
#         
#     }
#     # Check if the line contains "Resolution"
#     if ($line -like '*video_resolutionY*') {
#     $line
#         # Replace the line with the updated width
#         $content[$i] = "video_resolutionY ""$Height"""
#         
#     }
#   }
# 
# # Save the updated content back to the file
# $content | Set-Content -Path $filePath
#

Uninstall Script

This script requires admin access to function properly

$Documents = [Environment]::GetFolderPath("MyDocuments")

Remove-Item -Path "$Documents\My Games\Dragonshard" -Force -Recurse
Remove-Item -Path "registry::\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Liquid Entertainment" -Force -Recurse

Name Change Script

$Documents = [Environment]::GetFolderPath("MyDocuments")
$NewPlayerAlias = $NewPlayerAlias.Split([IO.Path]::GetInvalidFileNameChars()) -join '_'
$OldPlayerAlias = $NewPlayerAlias.Split([IO.Path]::GetInvalidFileNameChars()) -join '_'
$Display = Get-PrimaryDisplay
$Guid = [Guid]::NewGuid()

# Trim a string down to a specified amount of characters
if ($NewPlayerAlias.Length -gt 20) {
    $NewPlayerAlias = $NewPlayerAlias.Substring(0, 20);
}

if ($OldPlayerAlias.Length -gt 20) {
    $OldPlayerAlias = $OldPlayerAlias.Substring(0, 20);
}

if (Test-Path "$Documents\My Games\Dragonshard\Profiles\$OldPlayerAlias.pro") {
    Move-Item "$Documents\My Games\Dragonshard\Profiles\$OldPlayerAlias.pro" "$Documents\My Games\Dragonshard\Profiles\$NewPlayerAlias.pro"
} else {
    New-Item -ItemType Directory -Path "$Documents\My Games"
    New-Item -ItemType Directory -Path "$Documents\My Games\Dragonshard"
    New-Item -ItemType Directory -Path "$Documents\My Games\Dragonshard\Profiles"
    Copy-Item -Path "$InstallDirectory\Dragonshard\Profiles\test.pro" -Destination "$Documents\My Games\Dragonshard\Profiles\$NewPlayerAlias.pro"
}

# Use regex to replace text within a file. Quotes are escaped by double quoting ("")
Write-ReplaceContentInFile -Pattern '^player_name "(.+)"' -Substitution "player_name ""$NewPlayerAlias""" -FilePath "$Documents\My Games\Dragonshard\Profiles\$NewPlayerAlias.pro"
Write-ReplaceContentInFile -Pattern '^player_filename "(.+)"' -Substitution "player_filename ""$NewPlayerAlias""" -FilePath "$Documents\My Games\Dragonshard\Profiles\$NewPlayerAlias.pro"
Write-ReplaceContentInFile -Pattern '^guid "(.+)"' -Substitution "guid ""{$($Guid.ToString())}""" -FilePath "$Documents\My Games\Dragonshard\Profiles\$NewPlayerAlias.pro"

# The profiles.dat file selects the last used profile. It's a binary file that starts with a 5 byte header with offset 0x01 describing the length of the name based on character count.
# The profile name itself is UTF16 encoded and is suffixed by two bytes of 0x00, probably to denote end-of-file.
$Header = @([byte] 0x00, 0x15, 0x00, 0x00, 0x00)
$NameBytes = ConvertTo-StringBytes -Input "$NewPlayerAlias" -Utf16 1 -MaxLength 21 -MinLength 21
$NameBytes = $Header + $NameBytes

[IO.File]::WriteAllBytes("$Documents\My Games\Dragonshard\Profiles\profiles.dat", $NameBytes)

#$filePath = "$env:USERPROFILE\Documents\My Games\Dragonshard\Profiles\test.pro"
## Get the screen resolution
#Add-Type -AssemblyName System.Windows.Forms
#$screen = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds.Size
#$width = $screen.Width
#$height= $screen.Height
#
## Read the content of the file
#$content = Get-Content -Path $filePath
#
## Loop through each line in the file
#for ($i = 0; $i -lt $content.Count; $i++) {
#    $line = $content[$i]
#
#    # Check if the line contains "player_name"
#    if ($line -like '*player_name*') {
#    $line
#        # Replace the line with the updated width
#        $content[$i] = "player_name ""$NewPlayerAlias"""
#        
#    }
#    # Check if the line contains "player_filename"
#    if ($line -like '*player_filename*') {
#    $line
#        # Replace the line with the updated width
#        $content[$i] = "player_filename ""$NewPlayerAlias"""
#        
#    }
#  }
#
## Save the updated content back to the file
#$content | Set-Content -Path $filePath
#