Warzone2100 / warzone2100

Command the forces of The Project in a battle to rebuild the world after mankind has been nearly destroyed by nuclear missiles. A 100% free and open source real-time strategy game for Windows, macOS, Linux, BSD+
https://wz2100.net
GNU General Public License v2.0
3.2k stars 531 forks source link

Documentation for procedurally generated maps #1734

Open adolfintel opened 3 years ago

adolfintel commented 3 years ago

I've been playing around with the code of 6c-Entropy and was finally able to create my own simple procedurally generated map that wouldn't crash the game. I was wondering if there is some documentation on creating these maps, I kinda feel like I'm reverse engineering the existing maps here to learn what I'm supposed to do.

past-due commented 3 years ago

At the moment the only documentation is the example maps and the comments in https://github.com/Warzone2100/warzone2100/blob/master/src/quickjs_backend.cpp#L2614-L2626

I completely agree that this should be improved (PRs gladly accepted!)

However, if you found ways to crash the game, please open Issues with example scripts attached so we can fix those (if you still have the scripts or remember what you did).

adolfintel commented 3 years ago

The crashing was caused by the wz file not being properly made, like a missing .gam file, nothing major. I'm more worried about #1646 because it's a game breaking bug if players get put in the wrong location, and I can replicate this consistently.

adolfintel commented 3 years ago

I'll write some documentation about this in the next few days. Is markdown okay for this?

past-due commented 3 years ago

If it's largely documentation for the handful of APIs available to map scripts, (like gameRand, log, setMapData), then it can be added directly to quickjs_backend.cpp (see the lines that start with //MAP--). We can then auto-extract it to a markdown file, like the rest of the JS APIs, as part of the CI / build process.

You can add general info above those functions - again prepended with //MAP-- - and that'll appear first in the auto-generated doc file.

adolfintel commented 3 years ago

@past-due I was thinking of having something more like a guide. I made a basic template that I use to play around with procedural maps, with functions like setHeightAt, setTextureAt, tileToWorldCoordinates, etc. and I want to use that as a starting point to explain how to make these maps.

If you prefer just some documentation on the APIs, I can do that too, I just need to figure out that auto documentation system.

past-due commented 3 years ago

@adolfintel Ah, yes, for a detailed guide a markdown file would be the best bet. 👍

adolfintel commented 3 years ago

Let's do the API documentation first, since they're missing, then I'll try to make a guide+template thing.