Putting the 'role' back in role-playing games since 2002.
Donate to Codex
Good Old Games
  • Welcome to rpgcodex.net, a site dedicated to discussing computer based role-playing games in a free and open fashion. We're less strict than other forums, but please refer to the rules.

    "This message is awaiting moderator approval": All new users must pass through our moderation queue before they will be able to post normally. Until your account has "passed" your posts will only be visible to yourself (and moderators) until they are approved. Give us a week to get around to approving / deleting / ignoring your mundane opinion on crap before hassling us about it. Once you have passed the moderation period (think of it as a test), you will be able to post normally, just like all the other retards.

Automapper for some RPGs

behold_a_man

Educated
Joined
Nov 26, 2022
Messages
217
So, I made a tool for automapping. I used it for the first two Might & Magic titles; I'm not sure whether it'll be useful for anything else (but I guess it might be). I don't want to brag about it in that thread anymore, so I'll dump everything about it here.
1) The repository is present at:
https://github.com/codexianbeholdaman/mapper
I left my maps to show how they can be created here:
https://github.com/codexianbeholdaman/maps_for_mapper
Example maps in the application look like
MM2_Castle%20Pinehurst%201.png

MM2_C2.png

MM2_Druids%20Cave.png

MM1_Cave_B3.png

Note that the application was never meant to be pretty. It has two parts:
1) mapper part: what you see above. You can create a map, then save it in a file (clicking the 'Save' button) and load it. It should work without any hassle. The available options are:
a) Scripts: allows automatically switching maps with 'y' presses (if an arrow lies on a correct field), traps (which you see in the last image), or movement through the edge of a map, moving to some other map.​
b) 'Shorthand' and 'General' sections' aims are to document a cell and set a visible description of it.​
c) The 'Images' section allows one to crudely insert an image for future reference.​
d) Borders and whether the cell is usable (white on pictures) or not (dark grey on the last map) can be set manually.​
e) One can also set the terrain types (they are not mutually exclusive).​
f) I added 'Ground Truth mode' to disallow changes made by arrow misclicks.​
g) The 'Order' part allows to order maps (by clicking the button 'Order'): first by the content of 'Order', second by the map name, both lexicographically.​
h) Fly moves an arrow to another map. If an arrow is not set (as in the images above), an arrow automatically points to the north.​
2) auto part: all it does is capturing a keystroke (which is impossible in a normal browser if the window is not in context) and sending mapped keystrokes to a browser. It should not work at all unless you have Linux - but it's around ~10 lines of code, and Windows should have even better tools (autohotkey) to make this work. It is a 'listener.py' file in a repo.

Note that maps are saved in the JSON format and are easily viewable.
I wanted to be able to do as much as possible without switching context between a game and a mapper and to document my playthroughs. Unlike some current tools for mapping, I don't access game files or their processes.
I described everything (or at least I think so) in detail in the README.md file. I might expand the application in some time; hopefully I won't have to brick existing saves. I think I will allow maps of different sizes (and configurations) and create automated tests first if I'm going to do something. I don't plan to merge 'auto' and 'mapper' parts anytime soon; for that, I would probably need to use something like NW.js, and on my system, Chromium is as fast as ketchup.

If you can't run the app or just want to spew out some vitriol towards this application, well, I guess this is the appropriate place to vent.
 

Catacombs

Arcane
Patron
Joined
Aug 10, 2017
Messages
6,107
You need to add in the documentation that people must install the pynput library. The listener script won't run properly without it.
 

behold_a_man

Educated
Joined
Nov 26, 2022
Messages
217
You need to add in the documentation that people must install the pynput library. The listener script won't run properly without it.
The list of dependencies is a little bit longer; you're right, I added a section about it. I don't expect many people to be able to run this part without any changes - it relies on using X.org for xdotool, so there are actually few Linux distributions that can run it out of the box. Tinkering should be easy (relying on changing two lines of code - from xdotool to ydotool - at least if Wayland is used instead of X.org), but I cannot reliably test it right now.

Also, if anyone manages to change listener.py (the auto part) to work on another system - or scrapes it and writes something new - I'd be grateful if you would show your tweaks.
 

behold_a_man

Educated
Joined
Nov 26, 2022
Messages
217
I added support for changing the map size and some minor teleporting utilities, mostly in order to simplify playing Clouds of Xeen. Maps here turned out to be mostly useless, except for large dungeons like this:
Golem%20Dungeon.png

The biggest advantage this mapper has over the internal one is the ability to see the entire map (it was easier to figure out what 'branches' on the southwestern side of the map mean, for example).
 

behold_a_man

Educated
Joined
Nov 26, 2022
Messages
217
I added some stuff for Pool of Radiance:
Valjevo.png

Slums.png

In particular, I added:
-> the configuration option to emulate the backward movement from this game.
-> the configuration option to define y coordinate as ascending or descending in the game.
-> the overhead exploration option along with a blobbery one: the overhead one allows to move through the world map in this game (arrows always change character's position rather than character's direction).

I didn't nail the pyramid movement and, in general, options when moving to another place (i.e., I can't make a choice to go to X or Y within the scripting framework of this mapper, I have to change maps manually - unless I use both arrows and 'y' key, which is infuriating and dirty). I might solve it later if I stumble upon this problem more often.
 

behold_a_man

Educated
Joined
Nov 26, 2022
Messages
217
To sum up the changes I made over the playthrough of the Curse of the Silver Blades:

1) In terms of functionality:
a) I added the rename button so that I don't have to change JSON manually like an animal. Note that the circumstances in which such change occurs are precarious, so the mechanics are a bit different than any standard mechanics for changing something related to the map (that is, you need to click the rename button to activate the input field, change the name, then click the rename button once again to save map data).
b) I added the Translate option for a map, allowing one to move the entire map someplace else (e.g., 3,1 moves the point y,x to y+3,x+1). Note that this operation does not change the map size; in other words, it can be destructive. This is convenient if I made an error when picking the initial field, for example.
translate_1.png

to
translate_2.png

c) I added the Default cut option, which cuts any padding from a map (that is, usable fields or fields with text deteremine the new coordinates of a map). This operation does change the map size. This is very useful for maps without given coordinates, a common occurrence in the world of Azure Bonds.
cut_1.png

to
cut_2.png

d) I changed the suffix of the file name created to '.json' - which is, well, logical given this is a json file rather than a regular .txt file.
Note that it is advised to save the map before using any of the "Transforms" options.

2) The maximal map size was dropped from the config; now the map is enlarged on the fly.

3) Performance-wise, now I lazily create teleport icons - it might not be obvious, but if you'll try to create a 100x100 map (like the glacier in the Silver Blades), you'll probably notice quite a significant speedup.

4) Infrastructure-wise, I added some automated tests (so the app should be less likely to break after my changes), started refactoring the entire code into something manageable in the long run (so now if any of you are going to view the code, it will take a little bit more time to suffer a debilitating stroke), and made minor changes to the execution: now, you have to run 'firefox neodist/index.html' instead; also, config is stored in 'neodist/config.js' and 'neodist/game_terrain.js'.

5) I don't know if anyone of you uses the app, but, if you do: what irks you the most? For me, it is probably
a) The configs and loading files and manually setting game configuration. The fact that I store configs in .js files loaded in HTML as a regular script might be the biggest factor in changing any part of this app's infrastructure. I don't think I can automatically read a file not provided by the user in any normal browser; I can ignore it, I can move to nw.js (and the users would need to install it, too - basically a browser allowing to write regular desktop applications with node libraries), or I can read the config file as provided by the user - which is even more frustrating from my perspective.
b) Having a separate listener.py; that theoretically can be solved by nw.js too. This would possibly allow Windows users to use the app without any tinkering.
In other words, I feel inclined to move the app to nw.js, even though it runs on Chromium and doesn't have typical browser amenities (zoom in/out, for example - I will have to implement it manually). Does anyone know better/simpler solution for the problems above?
 

behold_a_man

Educated
Joined
Nov 26, 2022
Messages
217
And now you should be able to run this app on Windows and Mac too - though not without some fighting.
I added a file named selen.py; it uses selenium to control the browser (spawned by running this file) with some custom configuration in a file you can override (the file in question? You guessed it, selen.py). Selenium is available for pretty much any operating system, and pynput can work on Mac, on Windows, or on Linuxes with X11 (not on Wayland). The only problem is configuring selenium; it requires geckodriver, which needs to be installed, and you'd need to provide a path to it (changing the variable GECKODRIVER_PATH within the file selen.py). It may have some weird issues depending on the system (like the one with the solution described here: https://stackoverflow.com/a/76852633 ). If you have a problem configuring it, try to run check_selenium.py (it's only 5 lines of code, a fragment of selen.py file, including one import) until it works (that is, opens the browser without exception), then reproduce those changes in selen.py.

Additionally:
1) I added the ability to script cyclical movement (in case you want to move to the other end of the map when you pass the edge of the map).
2) I added the Cell Killer button to purge all data from a single cell in a single operation (useful if I made a mistake during mapping - like when a map changes without the game indicating it, like in Zhentil Keep in Pools of Darkness).
3) I added the ability to customize the overlay of the map button; like
colors.png

I highlighted the spot, where the option to change color of the map button overlay appears.

The colors used by this option can be changed in neodist/game_terrain.js (as always).

I think I'll abandon the idea of a standalone nw.js app - I haven't seen any still maintained library working on Node.js giving me the same functionality as pynput (that is, properly intercepting keystrokes). There are a few things I'd love that aren't there yet and should be possible to deliver without changing the entire ecosystem, one of them is the UI that doesn't look like Yugoslavia in the 90s.
 

As an Amazon Associate, rpgcodex.net earns from qualifying purchases.
Back
Top Bottom