You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: D2Loader.ps1
+7-101Lines changed: 7 additions & 101 deletions
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,7 @@ Servers:
20
20
21
21
Changes since 1.9.0 (next version edits):
22
22
Added Token based authentication. There are some setup steps and drawbacks to using this method but this can help when Blizzard Auth servers don't respond to authentication when launching via parameters.
23
+
Added capability to configure accounts for Parameter based auth but being able to temporarily force Token authentication (useful for connecting to a region when it's auth is down such as Asia right now).
23
24
Added notification capability so if I notice one of the auth servers going down I can advise users directly.
24
25
Added a new version of the SetText source code to enable renaming D2r windows based on processID. This prevents issues for people who load an account from Battle.net in addition to using the script.
25
26
Changed Current and Next TZ source to D2Emu.com for faster and more accurate results (no more OCR delays or inaccuracies).
@@ -30,9 +31,6 @@ Fixed unhandled DClone errors for timeouts.
30
31
Fixed DClone alarm from alarming twice when detecting changes from 6/6 to 1/6 on some sources.
31
32
Minor tidy ups.
32
33
33
-
##########TEST IMMEDIATELY AFTER RELEASE, test if settextv2.bas is downloaded and extracted.
34
-
#do before release, delete all .zip files in other releases.
35
-
36
34
1.10.1+ to do list
37
35
To reduce lines, Tidy up all the import/export csv bits for stat updates into a function rather than copy paste the same commands throughout the script.
38
36
To reduce lines, add repeated commands into functions
@@ -42,7 +40,7 @@ Fix whatever I broke or poorly implemented in 1.10.0 :)
42
40
#>
43
41
44
42
param($AccountUsername,$PW,$Region,$All,$Batch,$ManualSettingSwitcher) #used to capture parameters sent to the script, if anyone even wants to do that.
if (-not ($Script:AccountOptionsCSV|Get-Member-Name "CustomLaunchArguments"-MemberType NoteProperty -ErrorAction SilentlyContinue)) {#For update 1.8.0. If CustomLaunchArguments column doesn't exist, add it
809
805
# Column does not exist, so add it to the CSV data
810
806
$Script:AccountOptionsCSV|ForEach-Object {
@@ -1126,6 +1122,9 @@ Function Inventory {#Info screen
1126
1122
write-host ("`"$Script:WorkingDirectory`""-replace"((.{1,52})(?:\\|\s|$)|(.{1,53}))","`n`$1").trim() #add two spaces before any line breaks for indenting. Add line break for paths that are longer than 53 characters.
if($Script:LatestVersionCheck-eq$null-or$Script:LatestVersionCheck.tostring() -lt (Get-Date).addhours(-2).ToString('yyyy.MM.dd HH:mm:ss')){ #check for updates. Don't check if this has been checked in the couple of hours.
if ($CheckForNextTZ-ne$False){ #Find Next TZ image and convert to Text.
1914
-
Write-Host" Finding Next TZ Name..."
1915
-
$NextTZProvider="thegodofpumpkin"
1916
-
$75988Pool=@(#choose from pool of various connection details for OCR.Space to reduce chances of the free limit being reached. Helps future proof script if it ever becomes popular.
1917
-
"75988770481418K",
1918
-
"75988177170718K",
1919
-
"75988024702278K",
1920
-
"75988372514768K",
1921
-
"75988875571688K",
1922
-
"75988639433138K",
1923
-
"75988074942078K",
1924
-
"75988074727148K",
1925
-
"75988080905848K",
1926
-
"75988156278288K"
1927
-
)
1928
-
$tokreg=$75988Pool|Get-Random
1929
-
$script:D2ROCRref=$Null
1930
-
for ($i=$tokreg.Length-1; $i-ge0; $i--) {
1931
-
$script:D2ROCRref+=$tokreg[$i]
1932
-
}
1933
-
$Script:OCRAttempts=0
1934
-
do { ## Try each OCR engine until success. I've noticed that OCR.Space engines sometimes go down causing the script not being able to detect current TZ. This gives it a bit more reliability, albeit at the cost of time for each additional attempt.
1935
-
$Script:OCRAttempts++
1936
-
$Engine= (2,1,3)[$Script:OCRAttempts-1] #try engines in order of the best quality: Engine 2, then 1 then 3.
param ($EngineNumber) #Run the scriptblock with $EngineNumber as a parameter. This way we can insert the variable $Engine into the scriptblock. It's not possible to insert this variable into the script block any other way.
} -TimeoutSeconds 13#allow up to 13 seconds per request. Standard requests are around 3 seconds but as it's a free service it can sometimes be slow. Most of the time when it takes longer than 10 seconds to retrieve OCR it fails. Default timeout from OCR.Space (when an engine is down) is actually 30 seconds before an error is thrown.
1941
-
if ($SuccessfulEngine-ne$null){
1942
-
$NextTZOCR=$NextTZOCR.replace(": :","::") # Prevents issues if OCR mistakenly reads "::" as ": :" eg: Next TerrorZone(s) : : Barracks / Jail 1 / Jail 2 / Jail 3
1943
-
if ($SuccessfulEngine-eq2){#For Engine 2
1944
-
$NextTZ= [regex]::Match($NextTZOCR.Replace("`n",""),"(?<=Next TerrorZone(?:\s)?(?:\(s\))?(?:\s)?(?:\.|::) ).*").Value #Regex for engine 2
1945
-
} Elseif ($SuccessfulEngine-eq1){#For Engine 1
1946
-
$NextTZ= ($NextTZOCR.trim() -split"`n")[-1].replace("Next TerrorZone(s)","").replace(".","").replace(":","").trim() #Regex for engine 1
1947
-
} Elseif ($SuccessfulEngine-eq3) {#For Engine 3
1948
-
$NextTZ=$nexttzocr-replace"\r?\n",""-replace"(?s).*Next TerrorZone\Ss\S\s",""#Regex for engine 3
1949
-
}
1950
-
}
1951
-
$Script:SuccessfulEngine=$Null
1952
-
if ($OCRSuccess-eq$False){
1953
-
$FailMessage="Was unable to pull next TZ details :("
1954
-
}
1955
-
if ($NextTZ-eq""){#if next tz variable is empty due to OCR not working.
1956
-
$FailMessage="OCR failure, couldn't read next TZ details :("
1957
-
$Script:OCRSuccess=$False
1958
-
if ($Script:OCRAttempts-ne3){
1959
-
Write-Host" First Crack failed, having attempt number" ($Script:OCRAttempts+1)
1960
-
$TryAgain=$True
1961
-
}
1962
-
Else {
1963
-
$TryAgain=$False
1964
-
}
1965
-
}
1966
-
} until ($true-eq$Script:OCRSuccess-or ($Script:OCRAttempts-eq3-and$OCRSuccess-eq$false-and$TryAgain-ne$true))
1967
-
}
1968
-
if ($Script:OCRSuccess-eq$False-or$CheckForNextTZ-eq$False){# Messages if things are unsuccessful pulling Next TZ
1969
-
Write-Host
1970
-
Write-Host" Current TZ is: "-nonewline;Write-Host ($CurrentTZ-replace"(.{1,58})(\s+|$)","`$1`n").trim() -ForegroundColor magenta #print next tz. The regex code helps format the string into an indented new line for longer TZ's.
0 commit comments