Skip to content
This repository has been archived by the owner on Dec 21, 2022. It is now read-only.

Commit

Permalink
fix after latest blizzard patch
Browse files Browse the repository at this point in the history
  • Loading branch information
joffreybesos committed Sep 22, 2022
1 parent 64bb56f commit e5b6e0b
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 66 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ currentmap.png
/src/mapconfig.ini
/src/GameSessionLog.csv
/src/d2r-map3.ahk
/src/*.wav
/src/*.wav
/src/game/
/src/d2-mapgenerator.exe
/src/mapgen/
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

All notable changes to this project will be documented in this file.

## [3.0.1] - 2022-09-23 - Fix after latest patch

- Seed decryption has been reimplemented
- Made some fixes to item stats

## [3.0.0] - 2022-09-08 - Major rework

- Maps no longer have to load when going from one walkable area to another!
Expand Down
Binary file added src/SeedGenerator.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion src/d2r-map.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Menu, Tray, Add, Reload, Reload
Menu, Tray, Add
Menu, Tray, Add, Exit, ExitMH

global version := "3.0.0"
global version := "3.0.1"

WriteLog("*******************************************************************")
WriteLog("* Map overlay started https://github.com/joffreybesos/d2r-mapview *")
Expand Down
1 change: 1 addition & 0 deletions src/init/readSettings.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ readSettings(settingsFile, ByRef settings) {
FileInstall, exocetblizzardot-medium.otf, exocetblizzardot-medium.otf , 1
FileInstall, formal436bt-regular.otf, formal436bt-regular.otf , 1
FileInstall, settings.ini, settings.ini, 0
FileInstall, SeedGenerator.dll, SeedGenerator.dll, 1

; these are the default values
settings := []
Expand Down
29 changes: 23 additions & 6 deletions src/memory/readGameMemory.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
#Include %A_ScriptDir%\memory\scanForPlayer.ahk


; global lastdwInitSeedHash1
; global lastdwInitSeedHash2
; global lastdwEndSeedHash1
global lastdwInitSeedHash1
global lastdwInitSeedHash2
global lastdwEndSeedHash1
global xorkey
global playerLevel
global experience
Expand Down Expand Up @@ -38,16 +38,25 @@ readGameMemory(ByRef d2rprocess, ByRef settings, ByRef gameMemoryData) {
; get playername
, playerNameAddress := d2rprocess.read(playerUnit + 0x10, "Int64")
, playerName := d2rprocess.readString(playerNameAddress, length := 0)


; get the map seed
, actAddress := d2rprocess.read(playerUnit + 0x20, "Int64")
, actMiscAddress := d2rprocess.read(actAddress + 0x78, "Int64") ;0x0000023a64ed4780 ;2449824630656
, mapSeed := d2rprocess.read(actMiscAddress + 0x840, "UInt")

dwInitSeedHash1 := d2rprocess.read(actMiscAddress + 0x840, "UInt")
dwInitSeedHash2 := d2rprocess.read(actMiscAddress + 0x844, "UInt")
dwEndSeedHash1 := d2rprocess.read(actMiscAddress + 0x868, "UInt")

if (dwInitSeedHash1 != lastdwInitSeedHash1 or dwInitSeedHash2 != lastdwInitSeedHash2 or mapSeed == 0) {
mapSeed := calculateMapSeed(dwInitSeedHash1, dwInitSeedHash2, dwEndSeedHash1)
lastdwInitSeedHash1 := dwInitSeedHash1
lastdwInitSeedHash2 := dwInitSeedHash2
}
;mapSeed := d2rprocess.read(actMiscAddress + 0x840, "UInt")


; get the difficulty
, aActUnk2 := d2rprocess.read(actAddress + 0x78, "Int64")
aActUnk2 := d2rprocess.read(actAddress + 0x78, "Int64")
, difficulty := d2rprocess.read(aActUnk2 + 0x830, "UShort")

if (Mod(ticktock, 6)) {
Expand Down Expand Up @@ -171,3 +180,11 @@ readGameMemory(ByRef d2rprocess, ByRef settings, ByRef gameMemoryData) {
;OutputDebug, % ElapsedTime "`n"
;ToolTip % "`n`n`n`n" ElapsedTime
}


calculateMapSeed(InitSeedHash1, InitSeedHash2, EndSeedHash1) {
WriteLog("Calculating new map seed from " InitSeedHash1 " " InitSeedHash2 " " EndSeedHash1)
mapSeed := DllCall("SeedGenerator.dll\GetSeed", "UInt", InitSeedHash1, "UInt", InitSeedHash2, "UInt", EndSeedHash1, "UInt", "0", "UInt")
WriteLog("Found mapSeed " mapSeed)
return mapSeed
}
18 changes: 13 additions & 5 deletions src/memory/readItems.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,20 @@ ReadItems(ByRef d2rprocess, startingOffset, ByRef items) {
, itemx := NumGet(&pPath , 0x10, "UShort")
, itemy := NumGet(&pPath , 0x14, "UShort")
, pStatsListExPtr := NumGet(&itemStructData , 0x88, "Int64")
d2rprocess.readRaw(pStatsListExPtr, pStatsListEx, 144)
d2rprocess.readRaw(pStatsListExPtr, pStatsListEx, 180)
, statPtr := NumGet(&pStatsListEx , 0x30, "Int64")
, statCount := NumGet(&pStatsListEx , 0x38, "Int64")
, statExPtr := NumGet(&pStatsListEx , 0x80, "Int64")
, statExCount := NumGet(&pStatsListEx , 0x88, "Int64")
, item := new GameItem(txtFileNo, itemQuality, uniqueOrSetId)
, statCount := NumGet(&pStatsListEx , 0x38, "UInt")
, statExPtr := NumGet(&pStatsListEx , 0x88, "Int64")
, statExCount := NumGet(&pStatsListEx , 0x90, "UInt")

; SetFormat, Integer, Hex
; OutputDebug, % "UD "
; Loop, 180
; {
; OutputDebug, % NumGet(&pStatsListEx, A_Index-1, "UChar") " "
; }

item := new GameItem(txtFileNo, itemQuality, uniqueOrSetId)
, item.name := name
, item.itemLoc := itemLoc
, item.x := itemx
Expand Down
1 change: 0 additions & 1 deletion src/settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@
; Pressing Ctrl+O in the game will bring up a settings UI

[Settings]

108 changes: 56 additions & 52 deletions src/types/Stats.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -5,62 +5,66 @@ loadStats(ByRef statCount, ByRef statPtr, ByRef statExCount, ByRef statExPtr) {
d2rprocess.readRaw(statPtr, statBuffer, statCount*10)
statArray := []
skillsfound := 0
Loop, %statCount%
{
offset := (A_Index -1) * 8
, statLayer := NumGet(&statBuffer, offset, Type := "Short")
, statEnum := NumGet(&statBuffer, offset + 0x2, Type := "UShort")
, statValue := NumGet(&statBuffer , offset + 0x4, Type := "Int")
switch (statEnum) {
case 6: statValue := statValue >> 8 ; life
case 7: statValue := statValue >> 8 ; maxlife
case 8: statValue := statValue >> 8 ; mana
case 9: statValue := statValue >> 8 ; maxmana
case 10: statValue := statValue >> 8 ; stamina
case 11: statValue := statValue >> 8 ; maxstamina
case 216: statValue := statValue >> 8 ; item_hp_perlevel
case 217: statValue := statValue >> 8 ; item_mana_perlevel
case 56: statValue := statValue / 25 ; cold length, divided by num frames
case 59: statValue := statValue / 25 ; poison length
}
statName := getStatName(statEnum)
if (statEnum == 107) {
skillsfound++
statName := statName . skillsfound

if (statCount < 20) {
Loop, %statCount%
{
offset := (A_Index -1) * 8
, statLayer := NumGet(&statBuffer, offset, Type := "Short")
, statEnum := NumGet(&statBuffer, offset + 0x2, Type := "UShort")
, statValue := NumGet(&statBuffer , offset + 0x4, Type := "Int")
switch (statEnum) {
case 6: statValue := statValue >> 8 ; life
case 7: statValue := statValue >> 8 ; maxlife
case 8: statValue := statValue >> 8 ; mana
case 9: statValue := statValue >> 8 ; maxmana
case 10: statValue := statValue >> 8 ; stamina
case 11: statValue := statValue >> 8 ; maxstamina
case 216: statValue := statValue >> 8 ; item_hp_perlevel
case 217: statValue := statValue >> 8 ; item_mana_perlevel
case 56: statValue := statValue / 25 ; cold length, divided by num frames
case 59: statValue := statValue / 25 ; poison length
}
statName := getStatName(statEnum)
if (statEnum == 107) {
skillsfound++
statName := statName . skillsfound

}
;OutputDebug, % statName " " statEnum " " statLayer " " statValue "`n"
statArray[statName] := { "statLayer": statLayer, "statValue": statValue }
}
;OutputDebug, % statName " " statEnum " " statLayer " " statValue "`n"
statArray[statName] := { "statLayer": statLayer, "statValue": statValue }
}
statExCount := statExCount
d2rprocess.readRaw(statExPtr, statBuffer, statExCount*10)
Loop, %statExCount%
{
offset := (A_Index -1) * 8
, statLayer := NumGet(&statBuffer, offset, Type := "Short")
, statEnum := NumGet(&statBuffer, offset + 0x2, Type := "UShort")
, statValue := NumGet(&statBuffer , offset + 0x4, Type := "Int")
switch (statEnum) {
case 6: statValue := statValue >> 8 ; life
case 7: statValue := statValue >> 8 ; maxlife
case 8: statValue := statValue >> 8 ; mana
case 9: statValue := statValue >> 8 ; maxmana
case 10: statValue := statValue >> 8 ; stamina
case 11: statValue := statValue >> 8 ; maxstamina
case 216: statValue := statValue >> 8 ; item_hp_perlevel
case 217: statValue := statValue >> 8 ; item_mana_perlevel
case 56: statValue := Round(statValue / 25, 0) ; cold length, divided by num frames
case 59: statValue := Round(statValue / 25, 0) ; poison length
}
statName := getStatName(statEnum)
if (statEnum == 107) {
skillsfound++
statName := statName . skillsfound

if (statExCount < 20) {
d2rprocess.readRaw(statExPtr, statBuffer, statExCount*10)
Loop, %statExCount%
{
offset := (A_Index -1) * 8
, statLayer := NumGet(&statBuffer, offset, Type := "Short")
, statEnum := NumGet(&statBuffer, offset + 0x2, Type := "UShort")
, statValue := NumGet(&statBuffer , offset + 0x4, Type := "Int")
switch (statEnum) {
case 6: statValue := statValue >> 8 ; life
case 7: statValue := statValue >> 8 ; maxlife
case 8: statValue := statValue >> 8 ; mana
case 9: statValue := statValue >> 8 ; maxmana
case 10: statValue := statValue >> 8 ; stamina
case 11: statValue := statValue >> 8 ; maxstamina
case 216: statValue := statValue >> 8 ; item_hp_perlevel
case 217: statValue := statValue >> 8 ; item_mana_perlevel
case 56: statValue := Round(statValue / 25, 0) ; cold length, divided by num frames
case 59: statValue := Round(statValue / 25, 0) ; poison length
}
statName := getStatName(statEnum)
if (statEnum == 107) {
skillsfound++
statName := statName . skillsfound

}
;OutputDebug, % statName " " statEnum " " statLayer " " statValue "`n"
statOrder := getStatSortPriority(statName) ;"_" statName
statArray[statName] := { "statLayer": statLayer, "statValue": statValue, "statOrder": statOrder }
}
;OutputDebug, % statName " " statEnum " " statLayer " " statValue "`n"
statOrder := getStatSortPriority(statName) ;"_" statName
statArray[statName] := { "statLayer": statLayer, "statValue": statValue, "statOrder": statOrder }
}

; turn list of stats into readable format
Expand Down

0 comments on commit e5b6e0b

Please sign in to comment.