Heroes of Might and Magic Community
visiting hero! Register | Today's Posts | Games | Search! | FAQ/Rules | AvatarList | MemberList | Profile


Age of Heroes Headlines:  
5 Oct 2016: Heroes VII development comes to an end.. - read more
6 Aug 2016: Troubled Heroes VII Expansion Release - read more
26 Apr 2016: Heroes VII XPack - Trial by Fire - Coming out in June! - read more
17 Apr 2016: Global Alternative Creatures MOD for H7 after 1.8 Patch! - read more
7 Mar 2016: Romero launches a Piano Sonata Album Kickstarter! - read more
19 Feb 2016: Heroes 5.5 RC6, Heroes VII patch 1.7 are out! - read more
13 Jan 2016: Horn of the Abyss 1.4 Available for Download! - read more
17 Dec 2015: Heroes 5.5 update, 1.6 out for H7 - read more
23 Nov 2015: H7 1.4 & 1.5 patches Released - read more
31 Oct 2015: First H7 patches are out, End of DoC development - read more
5 Oct 2016: Heroes VII development comes to an end.. - read more
[X] Remove Ads
LOGIN:     Username:     Password:         [ Register ]
HOMM1: info forum | HOMM2: info forum | HOMM3: info mods forum | HOMM4: info CTG forum | HOMM5: info mods forum | MMH6: wiki forum | MMH7: wiki forum
Heroes Community > Library of Enlightenment > Thread: Heroes 3 map file (.h3m) format
Thread: Heroes 3 map file (.h3m) format This thread is 2 pages long: 1 2 · «PREV
potmdehex
potmdehex


Known Hero
professional ERM™ scripter
posted October 05, 2015 05:12 AM
Edited by potmdehex at 05:40, 05 Oct 2015.

Swaggy said:

More specifically :
-source code of H3 editor (but I don't think anyone has it)


It's not public, and even Ubisoft have stated they have lost the source code for everything past RoE. What we do have in ways of official things, however, is a presentation by one of the authors of the original RMG. It contains a ton of information on how the original RMG works. This is a must read if you are going to make an RMG, even if you like me don't agree with all his ideas: link. On another note, I have re-implemented the map editor's obstacle tool here.

Swaggy said:

-surface pictures sprites/numbers (where can I find them, and how they are placed). I built test maps and found there are 78 sprites for normal terrain, but if someone already made this for other terrains, that would save me a lot of time !

I have reverse engineered all sprites, and then a few ones that exist but are never used (see this, which also shows one of several extensions I made for the map editor, to show/edit the tile information of the tile hovered over). I know how all of them are placed given their surroundings and have created a standalone engine for selecting the correct sprite given an entire map of terrain types as input, e.g the snow/dirt/etc type of each square, but not their sprite number which is the output.

To use this engine, you simply pass a 2D array of integers of values 0-9 for each tile on the map, where 0 is DIRT, 1 is SAND, 2 is GRASS etc like in the h3m format. It also works for roads and rivers in the same way. The header is here. Additionally you can check for the numbers in the respective files, for example: dirt. The engine does not use the CRT, so it can be compiled to a DLL of ~10KB without any dependencies usable in C/C++/Python/Lua/other languages able to call exported C functions.

As previously mentioned I wrote some RMG as creating a new RMG was my initial purpose of reverse engineering the H3M formats and stayed so until Ubisoft announced HD Edition. For this reason, I wrote a higher level C++ and even higher level Python library on top of my low level C library that deals with the h3m format. My idea was to move away entirely from templates and instead have Python modules generating maps. These modules would despite being very simple to write be much more powerful than templates, and could in addition to creating maps akin to what the standard RMG does create maps that deviate entirely from the standard concept (imagine singleplayer Zelda-style maps, multiplayer Capture the Artifact etc).

Here are some simple PoC modules I made: link. Additional screenshot. Summer 2014 before making h3mlib I initially had a library for handling .h3m in Python on top of which I had some slightly more advanced modules including one creating groves in a forest linked together by portals. Unfortunately the implementation made entirely in Python turned out to be too slow. Also, while VCMI didn't have any working RMG when I started making my modules I haven't been following it since, so that might also be a place to look.

My recent publication allowing embedding code into .h3m to create map specific mods able to change any part of the game is also something that opens a whole new world to the possibilites of RMG.

I have a lot more information and could talk about this for hours on end but this has already turned into a wall of text so I guess I'll end my initial response to your queries around here. I think it's cool that you have an interest in this. May I ask you what your skills are in terms of programming and reverse engineering? As a last note, you might want to check out this parsing code in addition to MapFormatH3M.cpp, it's written quite differently.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
zmudziak22
zmudziak22


Supreme Hero
Heroes 3 Fan
posted October 05, 2015 08:26 AM

Would be cool if all campaign only objectives(victory and lost conditions) could be used in Single player maps.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Swaggy
Swaggy


Hired Hero
posted October 06, 2015 08:49 PM
Edited by Swaggy at 20:50, 06 Oct 2015.

I know C language and programming in general, but I'm still a student so not much experience. However I think it's going quite well for the moment, I didn't struggle with reverse engineering thanks to the h3m_description.txt.

Almost everything you posted are things that help/will help me. But I didn't even finish terrain generation for now. Also I'm doing this because it's interesting and a great way for learning things, but I'll probably never finish this RMG myself, this was more "for fun".

I already wrote a code that builds proper header and generates a valid .h3m file (only grass on the map).

I'm on the terrain generation part. For now my goal is to generate a map with different terrain zones with correct surface pictures, and also with no "lonely" tiles. I reverse-engineered most of picture terrains myself by looking frequencies of numbers in some random maps generated. I created artificial maps with these numbers myself and now I think I know with which sort of tile they correspond. In fact this is exactly what your .dll does, so I don't know if I will continue this. (I think I will, just because I already started it and there's not much to do anymore).

Why did you not finish this RMG ? It seems you have already done a lot. The obstacle tool especially looked like the hardest part for me. Are your projects still active ? I'd enjoy to help you. I also have many of questions about objects.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Laser70
Laser70


Adventuring Hero
posted October 07, 2015 03:02 AM
Edited by Laser70 at 03:33, 07 Oct 2015.

Instead of creating a random map generator, I would highly suggest you create something similar. For example, a random placement tool:

If you place an object on the map, let's say a tavern. The random placement tool works like this:

You can mark several spots on the map, perhaps you click at 4 different positions, and the object will be placed at all those positions, but only one of those positions will be selected when the game runs. Every time you restart a new game on that same map, the tavern will be placed at any of the 4 blue spots you marked on the map, so that the map gets a "slight" change every time you play it, rather than creating a totally new random map every time, you create a high quality pre-determined randomization chosen carefully by the map designer in which position that randomization will occur.

You can play around all day with complete map randomization, but those kind of features will never be able to replace a high quality map designed by a human, that is why I would like to see someone make a randomization placement tool rather than a randomization map generator.

Wouldn't it be cool if when every time you replayed a map, absolutely every single object in the game, including cities had a slightly different position, but the terrain looked the same all the time.

Here is a different proposal:

When it comes to resources and gold, those kind of objects may be totally and randomly placed anywhere on the map, they don't need to occur at pre-chosen places, they can occur anywhere on the map, so I am for complete randomization on resources and gold.

When it comes to building type objects, they can occur at pre chosen randomization places by the map designer.

A suggestion how the random placement tool works: When you select an object on the map, blue spots will light up on all the places that object can occur on the map, when you deselect it and select a different object on the map, the same thing repeats, blue spots pop up where that object can occur, and the blue spots from the previous object disappears.

This however, create huge technical challenges because the validation process would have to be altered to detect problems with the positions, unless you would leave it up to the map designer and trust his competence in not creating those kind of problems. The different random positions for each object on the map would have to be numbered, so that each random place have an equal number to the random position a different object will be placed so they are compatible with one another without creating validation problems.

If object 1 has 4 possible positions on the map and object 2 also have 4 random positions, but object 1 is only compatible with object 2 if object 1 position 2 is chosen and object 2 position 3 is chosen, then position 2 and 3 of object 1 and object 2 is compatible. They would have to be numbered in the map editor, quite honestly, I wouldn't number them, I would restrict maximum number of random positions per object to 4 and instead of using numbers I would use colors to signal sequence, colors are easily to deal with because if you select two objects, you can see the color of their compatible "companion" object somewhere "in-range" in the current view on the map.

The alternative is to have 4 buttons on the toolbar and you can select the 4 different possible random variations of the map to view, similar to the underground/overground view. Also, it might just be that objects are compatible with multiples of a different object, so that the randomization can increase beyond 4, in such cases they all get the same colors (map designer selects colors manually using any of the 4 brushes on the toolbar) you can even make the colors have many different colors appearing in the same square on the grid, indicating dual compatibility (top left corner blue, top right corner green, bottom left and right some other colors)

When the map is finished by the map designer, you have a top quality map "pack" in a single map, which has infinitely more replay value than any other "static" map type.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
potmdehex
potmdehex


Known Hero
professional ERM™ scripter
posted October 07, 2015 10:29 AM
Edited by potmdehex at 10:43, 07 Oct 2015.

Swaggy said:

Why did you not finish this RMG ?

The tl;dr is as previously mentioned that HD Edition was announced while I was in the middle of reversing .h3m, leading to me changing the course of my project.

My new goal was to spend the ~1,5 months from the announcement until release fixing what I predicted would be the two major causes of complaints: lack of RMG and lack of AB/SoD maps. To fix the lack of RMG I decided to take another route than creating my own given the extreme time constraints and reverse engineered the one of H3 Complete.

There is a lot more to the story that I might share in a blog post at some point, but as can be seen in my video dating from the very same day HD Edition was released I made it in time (and implemented h3msnake while at it): video
Swaggy said:

The obstacle tool especially looked like the hardest part for me.


I don't know if you mean hardest part of map generation in general or hardest part of what I have done, but regardless I think it is one of the easiest parts of either. Even terrain sprite selection which you are doing now, while also being one of the easiest parts, is more complex considering all possible borders when terrains meet, three way intersections with dirt and sand etc.

Regardless, I implemented the obstacle tool not because I needed it for RMG, but because I needed it for map conversion. Why? Because AB and SoD contain several new generic impassable terrain objects that have to be replaced with RoE-compatible terrain objects or unintended gaps will be there in the converted map if they were simply removed.

My projects are still active as time allows and I would be glad to answer any questions you have. I believe I am the most knowledgeable person on the standard three .h3m formats in the world right now (AKA the person who has probably wasted more time than anyone else thought was worth on this) so hit me up. You can contact me easiest by Steam: profile

Laser70, you have some interesting ideas. However, for starters:
Laser70 said:

You can play around all day with complete map randomization, but those kind of features will never be able to replace a high quality map designed by a human


This is your opinion on a subjetive matter, far from a fact as you make it sound it is. RMG is extremely popular both with casual and competetive (certain templates) players. I have seen lots of RMG vs human-made map discussions on heroes forums. Usually both sides seem to think the other side consists entirely of ignorant fools. Regardless of who is "right" (if anyone can even be "right" on this in the first place) one thing to note here is that the community is split here and there is not a consensus, with RMG and custom made maps both being popular. If delving into which seems to be the most popular of the two, RMG actually seems to be leading both with the casual and competetive crowd.

Personally I like elements of human-made maps that are hard to randomly generate and therefor think your pseudo-RMG concept is a good idea. When I previously thought of this concept myself however, what I thought included neither necessarily integrating anything into the map editor for this purpose nor packing the result into a single map file. If taking that approach, it would be necessary to either make use of the code embed technique I have recently published since there is no way the game can load such maps by default, or create a mod altering .h3m loading code that has to be installed first in order to run the map.

Both approaches mentioned above to make the map run seem very unnecessarily complex for this purpose when compared to having a RMG program (integrated or not) which just outputs standard readily loadable .h3m:s each time it is run and lets the game load them as normal. The tavern in your example would be randomly placed according to whatever criteria was specified on each run.

Here is a note on this concept and some possible uses of it in my repo: link

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Laser70
Laser70


Adventuring Hero
posted October 07, 2015 05:08 PM
Edited by Laser70 at 17:47, 07 Oct 2015.

It wouldn't be easy to do don't get me wrong on that. A different idea that intrigue me is this, to create a super mini map editor where you can create many (I do mean quite a lot) of highly specialized sections that "fit" inside a big map just like a tile fit inside the surrounding tiles of a map.

And then you can begin to play around with randomizing those "sections" to fit to create larger maps. The good thing about this idea is that map desiger can themselves design high quality sections, and a random map generator like the one you suggested can randomize those larger sections to create maps. (Sections can contain terrain and objects, not just terrain) and once the sections begin to be well categorized, it's an easy task for a rmg to create huge maps based on the category of those sections on disk (downloadable whatnot)

The map designer can use the mini map editor to create very very nice sections, perhaps he chooses to create a section of size 6x6 tiles and save that section on the disk as category "tiny islands". He have to make it fit surrounded by other sections just like tiles fit with other tiles and when done the map random generator can do amazing things to create beautiful maps with those sections. Perfect combination of human work and random.

About your own project, the rmg, there is nothing wrong with that idea at all, it's actually something that many game studios already do and believe in, so it's not a bad idea at all. My own ideas are not supposed to replace that idea, so do continue with that idea of yours, my own ideas are ideas on the side of that that adds another twist to how it would be done.

After many months (perhaps years) of tweaking an rmg, it can actually produce very high quality maps, the things it can do most of all is to balance out a map much better than that of any of my own ideas, that is where your idea really shines, but it requires a lot of tweaking over a lot of time.

Don't underestimate the work that lays ahead of you, projects like these that seems can be done quite rapidly, very often consumes years of a person's life (always good to know you're on the right project)

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
potmdehex
potmdehex


Known Hero
professional ERM™ scripter
posted October 07, 2015 05:47 PM

About the sections you speak of: yes, absolutely agree and have thought about this exact thing before. What I envisioned was for example things like a vampire section with a bunch of Vampire/Vampire Lords and Estate Dwellings and possibly a Vial. Of course there are tons of possibilities.

One should of course however keep in mind that even here an RMG within RMG approach can be used where when the RMG has decided it is going to place a section, it randomly chooses one from available types which then has its objects (but not which object types appear - that's determined by the section type) randomly placed.

For the mini map editor idea you speak of, the easiest would probably be to simply use the standard map editor to create these sections as its easy to use and familiar and also easy enough to parse. It could possibly be modified to make it more "neat", e.g by allowing it to create maps of any custom size, but really it would not make much of a difference as e.g 6x6 maps sections could still simply be made by making a 6x6 island in the top left corner of the map instead which is just as easy to parse.

All in all, I agree with your main point that it would be very interesting to combine human-made maps and RMG and that there are many interesting ways to do so.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Swaggy
Swaggy


Hired Hero
posted October 11, 2015 02:36 PM

I sent you a friend request

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Jump To: « Prev Thread . . . Next Thread » This thread is 2 pages long: 1 2 · «PREV
Post New Poll    Post New Topic    Post New Reply

Page compiled in 0.0710 seconds