Giter VIP home page Giter VIP logo

d2-mapper's Introduction

d2-mapper

Diablo 2 maps are randomly generated based on a seed value and difficulty.
There is another project which uses Diablo 2 to generate JSON payloads describing the layout of these maps. This repo takes that data and creates PNGs and HTML pages showing maps visually.

Refer to this project for more info https://github.com/blacha/diablo2/tree/master/packages/map

This repo uses the above project as a backend server to generate data based on a given seed/difficulty. If you don't have that project setup to fetch JSON data, this repo comes with a few sample payloads you can try.

At the moment this project is setup to take one sample output src/public/data/26396577_Hell.json and generate images from it.

Examples

Durance of hate level 2

Durance of hate level 2

Arcane Sanctuary

Arcane Sancutuary

Setup backend

This repo does not include the backend server. Please refer to https://github.com/blacha/diablo2/tree/master/packages/map

However to get the above project working:

  • Install Diablo 2 LOD 1.14b
  • Install Project Diablo 2
  • Install docker
docker pull blacha/diablo2
docker run -it -v "/E/Games/Diablo II":/app/game docker.io/blacha/diablo2:latest /bin/bash
wine regedit /app/d2.install.reg
wine bin/d2-map.exe game --seed 10 --level 1 --difficulty 0

The last wine command tests that it's working

This command will run a REST API server on port 8899:

docker run -v "/E/Games/Diablo II":/app/game -p 8899:8899 docker.io/blacha/diablo2:latest

Install

npm install
npm build

Execute example

npm run generate

Seed value must be in hex

npm run generate <seed> <difficulty> <level>
npm run generate 26396577 2      # will generate ALL maps for seed 26396577 hell
npm run generate 26396577 1 74   # will generate mapId 74 for seed 26396577 nightmare (74 is arcane sanc)

This will generate HTML for every level in ./public/<seed>/<difficulty> folder. You can open these HTML pages in any browser.

npm run generate has a default seed value, but you can pass a seed value npm run generate <seed>

This repo has an already cached response for 26396577/Hell and 1294978398/Hell so you can run this without a backed for those 2 settings.

Usage

This is published as a package that can be used to generate images from raw JSON. It also has an API server, which is really used for demo purposes.

REST API

npm run serve will run an API server, where you could fetch images this way:

curl -L -X GET "localhost:3001/v1/map/278898225/1/5/image"
imageUrl = `http://localhost:3001/v1/map/${seedDecimal}/${selectedDifficulty}/${mapId}/image`;

Notes

  • Purple box for exits
  • Red dot for monsters
  • Yellow box for waypoint
  • Green box for quest items (altars etc)
  • Cyan box for chests

TODO

  • Special icons/markings for exits and special items to be improved (bosses, special chests etc)
  • Making the map isometric makes it hard to dynamically draw on maps
  • Will probably totally rewrite how maps are drawn

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.