Heroes 4 Map Generator / Utility

The old Heroes games developed by New World Computing. Please specify which game you are referring to in your post.

Moderator: Moderators

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 565
Joined: 21 Jul 2014

Heroes 4 Map Generator / Utility

Postby iLiVeInAbOx05 » Jan 22 2016, 4:20

To download the H4MG (Heroes 4 Map Generator), please visit this page on CH.

For documenation on reading .h4c files, see the following link

Current Features:
  • Create, open, and edit .h4c (Heroes 4) map files.
  • Paint terrain as you can in the H4 editor, but with significantly larger brushes and different shapes (circle and square so far). The utility here is to be able to quickly and efficiently paint an entire map. It makes level design, as far as terrain, fast and easy.
  • Paint "void" terrain. This is the completely black terrain that gets painted when using the rock or cave tool in the H4 editor. In the H4MG, you can paint that type of terrain without the rock or terrain boundaries, and on any elevation. Just make sure you place all of your objects first, since we can't yet place objects with the H4MG.
  • Gives quick and easy access to all map events and all objects which can contain events. Some fields on the events and objects are editable and some remain to be implemented. Most script types can be edited.
  • Copy / paste events between maps or objects.
  • Copy / paste scripts between events.
  • Save / load events to / from file. Rather than have to open a map with the scripts you want to copy, you can create an event group, copy the scripts to the event group, and save that to file. All event groups are loaded when the H4MG is started and the events can be copied / pasted to any map.
  • Save / load quest huts, gates, and guards to / from file. Have a cool item shop or quest hut? You can save the scripting to file, and load it to any quest hut type.
  • Viewing scripts in an event has been overhauled. Now scripts are in a Tree View, so you can navigate to any script you want, regardless of whether it is nested inside another script (such as inside a conditional script). You can create a new script at any level, and you can even drag and drop scripts to new locations, which can be extremely useful.
  • Easily navigate to custom triggered events from a script which calls said event. For example, if I have a script which calls a Custom Event "Blah_1", then I can edit the "Trigger Custom Event" script, and there is now a button to open the custom event. This is especially helpful for getting to custom events on objects which can be spread out around a map.
  • Area selection tool with advanced options such as copy / paste or move. Copy a part of the map, and paste it either in the same map, or on another.
  • AI difficulty adjustments, using scripts, based on this forum topic.

Planned Features:
  1. Renaming feature for variables and triggerable events.
  2. Elevation features such as cliffs and plateaus.
  3. Zoom in / out (right now you see the entire map).
  4. Change map size without having to create a new map.
  5. Random map generation.
  6. Advanced scripting system.
  7. Convert H2 / H3 maps to an H4 map.
  8. Convert picture to map. (This is being worked on by others, thus the low priority).

Examples of the following can be found on the pages listed:
  • Copying / pasting events: page 4
  • Example of void terrain: page 7
  • Above / below ground and grid: page 7
  • Painting terrain: page 8
  • Initial objects with events viewing: page 8
  • Copying / pasting events between heroes and armies: page 8
  • Event groups: page 9
  • Saving / loading quest huts: page 9
  • Script tree view: page 10
  • View a custom event from a separate event: page 11
  • Copying / pasting scripts between events: page 11
  • Dragging and dropping scripts: page 12
  • Initial area selection tool: page 12
  • Copy and paste a portion of a map to another map: video
Last edited by iLiVeInAbOx05 on Oct 14 2016, 15:45, edited 17 times in total.

User avatar
Baronus
Assassin
Assassin
Posts: 288
Joined: 06 Jun 2015

Re: Reading Heroes4 (.h4c) map files

Postby Baronus » Jan 22 2016, 9:32

There are two vieves hex and txt which we can read. I dont know about another.
See H4Util scripts. There are resource codes like units, objects etc.

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 565
Joined: 21 Jul 2014

Re: Reading Heroes4 (.h4c) map files

Postby iLiVeInAbOx05 » Jan 22 2016, 16:49

Baronus, thank you for your reply.

What is "vieves" ? Pieces perhaps? Do you mean that once I get into the .gz file, which has some readable and some not, that the unreadable part is hexadecimal?

I looked in all of the H4Util stuff. Unfortunately, I don't think the codes for units and objects will help me (there weren't many codes in any case). I'm more interested in being able to parse the map grid so that I can place objects.

I think the only thing from H4Util that I would find useful would be the source code so that I can see what they do to access the map grid. Codes for the different objects I can probably figure out for myself (but I might not need to since I can get a partially readable file from the .h4c file).

User avatar
Baronus
Assassin
Assassin
Posts: 288
Joined: 06 Jun 2015

Re: Reading Heroes4 (.h4c) map files

Postby Baronus » Jan 22 2016, 17:32

In hexd editor I have hex view and txt view. And coded view absolutly unreadable.
In unziped file you can read campaign txt. And in hd editor map code I think. But I cant pack this file to map format. Im not a programist. You can see Equlibris c. editor. They added some things. Maybe it will be useful?
I saw H4util scripts and there are list of resources. So I tell it.

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 565
Joined: 21 Jul 2014

Re: Reading Heroes4 (.h4c) map files

Postby iLiVeInAbOx05 » Jan 22 2016, 19:26

Hi Baronus. Which hex editor are you using? When you say unzipped file (and I assume you mean the unzipped .h4c file), what did you use to unzip it?

I'm not sure how to look in the Equilibris editor to see what they changed, but if I could look in the editor itself to see what it's doing, that would probably be extremely helpful :D

When I get home, I'll try to read the portions of the file that aren't readable as hex and see what that gets me. Thanks for the help, any suggestions are very much appreciated.

User avatar
Baronus
Assassin
Assassin
Posts: 288
Joined: 06 Jun 2015

Re: Reading Heroes4 (.h4c) map files

Postby Baronus » Jan 22 2016, 21:25

Im using:
hiev32 demo
frhed
fileinsight
textedit
mobile hexeditor
Ida Pro decompiler but is to difficult for me.
I unziped h3c. But i think that h4c is the same.
7zip
Izarc
Unrar
and other simple free programs.
But then I cant pack to h3c. Of course its new archive. Orginal h3c is ok.
PS. What abuot looking to df2 and h4d files ,,layers". It is posible doing program to conversion?
1 Resedit 2 can do bmp screenshot from campaign pictures.
2 MH4 can exctract the same screenshoot as h4d.
3 Comparing two files.
4 Building program to convert bmp to h4d?
Then we will adding our screens to campaigns?
Who knows?

User avatar
Karmakeld
CH Staff
CH Staff
Posts: 1092
Joined: 12 Nov 2011

Re: Reading Heroes4 (.h4c) map files

Postby Karmakeld » Jan 23 2016, 0:16

Now all this posting, Really Makes me wanna Guess what you're up to, iLiVe..
I'm silent in seven languages - and I got all my familys fear.
Everytime you throw dirt, you loose a little ground

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 565
Joined: 21 Jul 2014

Re: Reading Heroes4 (.h4c) map files

Postby iLiVeInAbOx05 » Jan 23 2016, 6:12

It appears that the .h4c map files are .gz files (1 for each map in the campaign) that are prepended with "h4campaign" and any campaign info.

I was able to get my java program to read a .h4c file and print out the same hex values that a hex editor showed, so that's good news :D My next step will be to try stripping out the campaign info so that I have a pure .gz file, and then use java's g unzip utility on it. If that decides to play nice, then I can start trying to get a grip on how the map grid is represented.

I think I see where it starts, but I think it might make things easier if I used an empty map :D

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 565
Joined: 21 Jul 2014

Re: Reading Heroes4 (.h4c) map files

Postby iLiVeInAbOx05 » Jan 23 2016, 15:12

Karmakeld wrote:Now all this posting, Really Makes me wanna Guess what you're up to, iLiVe..

;)

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 565
Joined: 21 Jul 2014

Re: Reading Heroes4 (.h4c) map files

Postby iLiVeInAbOx05 » Jan 24 2016, 7:42

Stripping the header out was pretty simple.. until I realized I needed to be operating on the underlying byte array.. rather than converting the byte array to a hex string and operating on that.

After much struggle, I was able to strip out the header and isolate the .gz file, and used java's gUnzip utility to unzip it. My newly created unzipped file matches the unedited one in the .h4c file.

My next step is to package it back into a .h4c file, and try to open it with the editor / Heroes 4, but my head hurts now, so I'm going to call it a night :D

Edit: I realized how close I was to that next step, so I went ahead and kept going. I was able to take the header and body byte arrays (body array before unzipping it, so I still have to try rezipping it and then using that) and create a new .h4c file, which I was able to open in the editor! Exciting :D

User avatar
Karmakeld
CH Staff
CH Staff
Posts: 1092
Joined: 12 Nov 2011

Re: Reading Heroes4 (.h4c) map files

Postby Karmakeld » Jan 24 2016, 16:08

So in English, this means something like - it looks (very) promising :) or..?
I'm silent in seven languages - and I got all my familys fear.

Everytime you throw dirt, you loose a little ground

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 565
Joined: 21 Jul 2014

Re: Reading Heroes4 (.h4c) map files

Postby iLiVeInAbOx05 » Jan 24 2016, 17:57

Things are looking very promising :D

Now that I can get to the unzipped version of the map data, I can work on determining the grid layout (meaning do they start with 0,0, or from one of the corners?). I can definitely see the grid in the file, so I should be able to figure that out relatively easy. I can just place different objects on a map, and then read then look at the file with my hex editor to see where they show up :D

I also need to try to see if I can change an object already in the map (pretty sure I can do this, but I just need to actually do it).

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 565
Joined: 21 Jul 2014

Re: Reading Heroes4 (.h4c) map files

Postby iLiVeInAbOx05 » Jan 25 2016, 2:22

Hmm, so it seems that, at least for objects, there isn't actually a grid. The row and column are specified as fields near the beginning of the object's entry in the file.

The codes and locations for the terrain seem like they're going to be a bit more difficult to find the pattern for.

User avatar
Baronus
Assassin
Assassin
Posts: 288
Joined: 06 Jun 2015

Re: Reading Heroes4 (.h4c) map files

Postby Baronus » Jan 26 2016, 11:44

I found brushes:
http://www.celestialheavens.com/heroes- ... ns/brushes
In polish (see down):
PĘDZLE PRZESZKÓD
http://web.archive.org/web/200402131013 ... wnload.htm

There are mayby cods for all obiects. You can do our own brush.

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 565
Joined: 21 Jul 2014

Re: Reading Heroes4 (.h4c) map files

Postby iLiVeInAbOx05 » Jan 26 2016, 16:16

Brushes is definitely a feature I'd like to add to what I'm planning to make :D Might not work as well as the actual editor, but should have more options :D

I just need to finish figuring out / documenting how to read and parse .h4c files. Once I get to that point, I'll start a new thread for this project.

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 565
Joined: 21 Jul 2014

Re: Reading Heroes4 (.h4c) map files

Postby iLiVeInAbOx05 » Feb 2 2016, 17:19

Small update: I'm currently going through different .h4c files with a hex editor to find hex code patterns that I'll need to match when parsing / creating .h4c files. The events, at least Timed Events (haven't gotten far enough to check the others), seem to all start with the same hex code, so that should make copying / pasting scripts between maps pretty straightforward.

Yes, I'm aware that H4Util does this, if you take enough time and effort to really figure it out, but I'm going to try to make it so there is zero time and effort required to figure out how to do it, and with a nice GUI.

User avatar
Baronus
Assassin
Assassin
Posts: 288
Joined: 06 Jun 2015

Re: Reading Heroes4 (.h4c) map files

Postby Baronus » Feb 2 2016, 18:41

I think that adding to HIVUtil Equilibris objects is important thing. We dont have Eq random map generator.

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 565
Joined: 21 Jul 2014

Re: Reading Heroes4 (.h4c) map files

Postby iLiVeInAbOx05 » Feb 2 2016, 19:15

Well, we don't have any reasonable random map generator at the moment, let alone one that also makes use of Equilibris objects ;)

I thought there weren't that many Equilibris objects anyway? Maybe I missed some of them when looking through the Equi map editor?

User avatar
Karmakeld
CH Staff
CH Staff
Posts: 1092
Joined: 12 Nov 2011

Re: Reading Heroes4 (.h4c) map files

Postby Karmakeld » Feb 2 2016, 22:28

I believe there's 3 artifacts and the new wall. And partially the wagon quest hut. Don't recall more than that.
I'm silent in seven languages - and I got all my familys fear.

Everytime you throw dirt, you loose a little ground

User avatar
iLiVeInAbOx05
Equilibris Team
Equilibris Team
Posts: 565
Joined: 21 Jul 2014

Re: Reading Heroes4 (.h4c) map files

Postby iLiVeInAbOx05 » Feb 3 2016, 19:10

Okay, so not that many. Shouldn't be that difficult to include them when I get to that point, but it's still a long ways off :D

I've got most of the relevant codes for timed, triggered, and placed events for the map itself. Now looking at start / end points for landscape objects again. Starting to become more familiar with them, and should be ready to start creating some class definitions to hold the data :D


Return to “Heroes I-IV”

Who is online

Users browsing this forum: Google [Bot] and 7 guests