Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How does the map part work? #430

Open
ffMathy opened this issue Feb 16, 2025 · 1 comment
Open

How does the map part work? #430

ffMathy opened this issue Feb 16, 2025 · 1 comment

Comments

@ffMathy
Copy link

ffMathy commented Feb 16, 2025

I'm not very familiar with C, which seems to be what the map part of this project is written in.

Does this inject itself into the memory of Diablo 2 somehow?

Can you explain a bit how it works in really high level terms?

I'm asking because I'd love to contribute, and also know your thoughts on what's holding back this from supporting D2R directly.

I know it says it supports D2R, but my understanding is that D2 1.13c is still needed?

@blacha
Copy link
Owner

blacha commented Feb 18, 2025

Hi @ffMathy, its been a while since I've played D2R so my knowledge may be slightly out of date.

A lot of tools interact directly with D2 / D2R eg reading / writing memory, generally these can be detected pretty easily and get your account banned, so I wanted to look for a way to get player and map data without interacting directly with the diablo2 process.

In the old days of diablo2 it was very easy to intercept game packets as they were not encrypted, so you could use a packet sniffer (even on a separate machine) to read game packets, with these packets you get a lot of information about the current state of the game, where the player is, where the monsters are and their stats. But the only information about the map you can sniff is the mapseed and difficulty.

So to make a fully external maphack the map needs to be generated given the seed and difficulty, since the map generation is very similar (exactly the same?) between versions of diablo2 we can use an older version of diablo2 to generate the map then export it into a file.

With the older diablo2 clients (<=1.13c), the initialization process is somewhat well documented with the old bots. Using WINEDEBUG=+snoop wine game.exe you can trace how diablo2 game starts up by calling different DLLs, loading MPQs then loading into a game world which triggers a map generation.

https://github.com/blacha/diablo2/blob/master/packages/map/README.md#fixing-offsets

The map generation library https://github.com/blacha/diablo2/blob/master/packages/map/map/d2_client.c#L112 a full diablo2 classic client is spun up and initialized, then a game world can be created and then dumped into a JSON file https://github.com/blacha/diablo2/blob/master/packages/map/map/d2_client.c#L446

when D2R first came out it encrypted the packets so it made it significantly harder to intercept them, but then it also had the map seed sitting in memory, Since I game under linux it was somewhat hard for me to find the exact location of the seed in memory consistently. I ended up dumping a copy of the game memory and using https://github.com/blacha/memoryscanner to look for known game structures which included the mapseed https://github.com/blacha/diablo2/blob/master/packages/memory/src/struts/d2r.act.ts#L9,

Some time later D2R updated and started hiding the seed in memory too which is about the time I stopped playing D2R.

TLDR: Getting map data from D2R is hard but the map generation is the same between versions so just grab the map seed from D2R and use a old client to generate the map.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants