tomsoftware / Settlers.ts

A Web Settlers 4 Clone/Remake in TypeScript
https://settlers.hmilch.net/
MIT License
33 stars 13 forks source link

Possible to write maps? #5

Closed domhel closed 2 years ago

domhel commented 2 years ago

Hi, cool project.

I see that you can read and display .map files. Do you think it's possible to write .map files so we can create maps programmatically? Or do you not actually read .map files and just display what the graphics engine spits out?

Thanks in advance

Platin21 commented 2 years ago

It’s an re of the map format so it is reading them. Writing is something one might be able to derive from the reading code.

tomsoftware commented 2 years ago

Hello Dippa

Yes, it would be possible to change the map data, but at the moment it is not tested yet. There are two things you have to do (after changing the data in the map)

By the way: there are other tools to modify a .map file - they use a modification of the original editor.exe so that it can access the .map files as well (https://s4.muffinmar.io/downloads/)

p.s. What is the purpose of your question? How would you create the map or are you thinking of a converter? A map file editor is not in my scope at the moment, but if you try I would support you!

Platin21 commented 2 years ago

I suspect this would allow to make more interesting single player maps and also stuff for multiplayer which is less predictable? Maybe even something the current map gen can even do.

Last time when I tried to get the bit writter ported I got biten by the bit reader. Maybe I give it another try soon'ish..

domhel commented 2 years ago

p.s. What is the purpose of your question? How would you create the map or are you thinking of a converter? A map file editor is not in my scope at the moment, but if you try I would support you!

Thanks a lot. 3 years ago I was working on a little map generator that would generate maps to perfectly suit the AI, so they can expand as fast as they can. My only solution to convert the generated map to an actual Settlers map was to automate the map editor. I wrote a script to move the mouse around, read the current mouse coordinates and place grass. It worked, but it was extremely slow because of the bad mouse dragging behavior of the map editor. I actually was in contact with MuffinMario but only asked about map editor automation, as I searched online for reading Settlers map files and didn't find anything. but he couldn't help me either.

Now, maybe MuffinMario can give me a code snippet or I can use your suggestion, thanks for that.

My ultimate goal is to write a map generator with perfect conditions for AI, which might even make a 1v1 hard. The other idea I had to make AI better is to write a Lua script that fully controls the ai, with placing buildings, spawning troops etc.

tomsoftware commented 2 years ago

Cool, I didn't know there are so many idears and people who crafting Siedler stuff :-)

So, I think it is quiet easy to replace the map-ground and hight of a existing map with this/my tool Just edit every 4th byte in the container with ID13 - see: grafik

Objects and Building are harder to edit but the are quiet the same as in Siedler3 - you can see my code in the https://github.com/jsettlers/settlers-remake/tree/88ba0d98fee47c92aa82f763698cdbc2b4899485/jsettlers.logic/src/main/java/jsettlers/logic/map/loading/original/