H4 Modding Compendium

Mods and development for mods.

Moderator: Moderators

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

H4 Modding Compendium

Postby Karmakeld » Jan 18 2019, 11:01

Seeing how the H4 modding community has succesfully managed to mod various parts of the game, within the last few years, and how many topics about modding has long been lacking and the few that exists are widely spread, I'll try to compile most of the knowledge here along with useful guides. I took the liberty of borrowing the line up from the 'H5 Modding for Dummies' topic.

**in progress**

Table of Contents

1 Introduction
1.1 What is a mod?
1.2 How do I install/uninstall a mod?
1.3 What programs do I need and where do I get them?
1.4 How do I make my own mod?
1.5 Game file extension overview.

2 Data Modding
2.1 Where is my Heroes4/data folder?
2.2 What files should I change?
2.3 How do I get the game to read my changed files?

3 Modifying Creatures
3.1 Where are the creature stats stored?
3.2 How do I change the creature's stats?
3.3 How do I change the creature's cost?
3.4 Other stuff you can change.

4 Adding Abilities/Spells to Creatures
4.1 How do I add abilities to creatures?
4.2 How do I add mana to creatures?
4.3 How do I add spells to creatures? *see Nimo modded creatures that can cast spells (have spell animations added)

5 Modifying Texts
5.1 How do I change the creature name?
5.2 How do I change the hero name?
5.3 How do I change the creature description?
5.4 How do I change the hero biography?
5.5 Other stuff you can change.

6 Animations
6.1 How do I make my own animation?

7 .Pack Files
7.1 How do I pack the modded files?
7.2 What should I post on the forums?

- Adding New/Modding Existing Objects
- Changing Layers (UI, Townscreens, Splashscreens, Artifacts, TownStructures, Creature Skins, Hero/Creature Portraits etc.)
- How to make Creature Heroes
- Understanding HexEditing/HexCode
- How to change/rearrange the UI
- DLL Extension(?!)

- H4R file content overview/quick review (Actor Sequence, Adv_Actor* [adventure avatar setup], Adv_Object, Animation, Battlefield_Preset_Map, Bitmap_Raw, Castle [combat screen, sets up combat objects], Combat Actor* [combat avatar setup], Combat Object, Game Maps, Layers, Sound, Table, Terrain).

*sources and original treads...
Researching how to add new objects: http://heroescommunity.com/viewthread.php3?TID=44045
H4 dll researching: http://heroescommunity.com/viewthread.php3?TID=45392
Researching how to make new spells + town buildings: http://heroescommunity.com/viewthread.php3?TID=45442
How to mod HOMMIV: http://heroescommunity.com/viewthread.php3?TID=39499
Add new heroes (location Addresses also posted): http://heroescommunity.com/viewthread.p ... genumber=2
Heroes 4 Modding Revisited: http://heroescommunity.com/viewthread.php3?TID=37350
Sharing something about Mod (modding tool in Chinese): http://heroescommunity.com/viewthread.php3?TID=44984
Is this possible (Adding Music): https://www.celestialheavens.com/forum/ ... 25#p326625
Research: Adding and Modifying creatures: http://heroescommunity.com/viewthread.php3?TID=44056
New hero skins: http://heroescommunity.com/viewthread.php3?TID=45209
Editing special terrains: http://heroescommunity.com/viewthread.php3?TID=44455
Editing Townscreens and building placement: http://heroescommunity.com/viewthread.p ... genumber=6
Creating H4L files with MH4_096/08: http://heroescommunity.com/viewthread.php3?TID=44642
Presenting... Hero Creatures! Vote!: http://heroescommunity.com/viewthread.php3?TID=42887
Full Hero Creatures and Heroes WITH DOWNLOAD: http://heroescommunity.com/viewthread.php3?TID=42915


*In Progress
Last edited by Karmakeld on Feb 18 2019, 20:57, edited 7 times in total.
I'm silent in seven languages - and I got all my familys fear.
Everytime you throw dirt, you loose a little ground

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

Re: H4 Modding Compendium

Postby Karmakeld » Jan 18 2019, 11:01

1 Introduction

1.1 What is a mod?
A mod is a file that changes the game. People make mods because they want to improve the game, add stuff to the game, or balance the game.

1.2 How do I install/uninstall a mod?
Depending on wheter the mod is a program (exe) or simply file(s), the Mod should either come with an Install file which can be extracted to your HoMM 4 folder (like the Equilibris Mod) or with separate files (eg. mod.h4r or mod.h4d) that needs to be placed in the Heroes of Might and Magic 4 Data folder (the path is likely similar to this: Programs > HoMM 4 > Data).
The game reads the files located in the Data folder, so if you modify any of the game files, be sure to place it in the Data folder afterwards.
If you want to 'toggle off' any customized data files, you don't need to delete it from you Data folder, simply renamed it or add an "_" to it's name and it's won't be read by the game - can be useful when testing.

1.3 What programs do I need and where do I get them?
Programs used to create mods are mentioned in BOLD in the guide below. Most should be fairly easy to find if you search for them.
Neo Hex Editor used both for making mods and modifying objects, images etc
Other useful programs (Extractor/Builder - mh4, Extractor - h4unpacker. These are useful for extracing and building game files).
Namerutan's ResourceHelper (Allows you to view most of the games image files, export/import images/animations to/from ora format and extract most game files - if you wanna change any kind of image or animation within the game, this tool is quite handy. Some features are unfinished, so expect that some degree of hex editing is often requited.)
iLiVeInAbOx05's ResourceEditor (Viewing, extracting, importing and editing H4 resource and def files - if you want to fool around with creating new/editing existing adventure map objects, this is the tool to get. Released february 2019, but some features are still to be added).'
There is a number of other tools, useful for modifying specific parts of the game, I'll cover them seperately in their appropiate topic.

1.4 How do I make my own mod?
This is explained by NimoStar in his post below.
Original tread: [TUT] Make and use unlimited independent mod

NimoStar wrote:I want to contribute to the community so that everyone knows how to make their own mods that do not overwrite any other mods or the original game. Specially as it is rather simple.

Note: This topic doesn't deal on the specifics of how to mod things in the game. This topic covers file types and their contents.

In a more particular way, this topic deals with the general ability to make mods separate from the original game and eachother, in the way they will not overwritte any other mod at all.

You can have unlimited different mods in a single installed Heroes 4 folder this way, and none will overwrite anything from the others or from the original game. You launch them separately from their executable files!

We will be using codes from Equilibris 3.51 as example (3.55 is almost the same, except it aditionally uses a campaign .dll and a separate text .h4r) - but new mods will NOT carry on the non-exe characteristics of equilibris (objects, etc.) unless you would specifically include them.

My tutorial is based on hex editing. I used Neo Hex Editor (it has a free version) for the demonstrations. it is good for this because it can search for ANSI characters in a file (plain text) and modify them directly. You don't need adress, just use the search function for the text indicated in the images (mind up/down search and type of characters, though).

Any hex editor will do if you know what you are doing. For programming editing, hiew32 is better because it can convert hexes into assembly code. Assembly editing is not used on this tutorial (it is hard enough even for programmers).


Now, let's make an overview of the file components of any generic independent mod:


1- .exe file : Pretty self-explanatory, this is the executable for the game. Give it any name you want, the code doesn't care. You can also change the icon to suit your tastes and image you like. I use a program called Resource Hacker, it's free IIRC. you can download icons from the internet and append them to the file. As for the contents, all of the engine and hardcoded features are originally here. It also includes skill menues (in equi) and cheats menues(useful for testing) which can be enabled. On my Greatest Mod the cheat menu is enabled (and modified) by default as of version 0.09.


2a- .h4r file (on /Data): Heroes IV resources, as its name implies, are stored here. All the tables, texts and graphics of your mod will be put inside this file. It has to be called by the .exe by name. Give it any four letter name, and then call for it Hex Editing your .exe file:

Note: NEVER write extra characters when hex editing. This means, if there was four spaces, write over them but no more and no less. Otherwise you will mess up all locations and thus destroy the file.

2b- secondary .h4r file (on /Data): These are marked in equi as new_mod.h4r, and by changing that name on the exe and on the further .h4r files, you change your mod moddability. They are basically a mod for your mod. You can combine .h4r mods (only two) this way without extracting and re-bundling. New_mod has priority over the main .h4r file.

3- .dll file : This file was introduced with Equilibris and it compliments/replaces some of the .exe functions. it is called on by the .exe too, so copy and rename your .dll file, and then change the call (only two characters here).


Optionally, you can add independent editor functionality to your mod...

4- Campaign Editor .exe : Sure, you have your mod, but if you included any extra objects, you will want them to be listed, right? So, create a copy of the Equilibris campaign editor and rename it to your liking. You will have to edit it to read your resources, so...

5- .aop files (/Data) : Inside the data folder like.h4r files, these are referenced by your campaign editor.exe to know which objects to display and how to arrange them in the menus. So rename the file before editing them for your mod. Also, rename the reference on the editor .exe file so it knows what to look for.

You can also change others like "expansions":


6- Maps: Maps are separate, but you can include them in a maps folder. Remember that you can't play maps incompatible with the mod you are running (also, as you may know, you cannot play maps with special/equilibris objects in default game. It works the same for different mods). You can make them compatible by the new_mod technique or by extracting and re-bundling.

7- Saves: You can include them just as maps can, and you can even hex edit the save files for weird effects if you know what do you. The maps there will not able to be edited, though.

* * *

And... that's pretty much it!

Fundamentally speaking, only the game .exe and .h4r differentiation are strictly neccesary. The rest are extra features.

With just those files you can make unlimited different modular mods!

How a mod folder could look before install. Just zip or rar it, and people should extract it over their main Heroes IV folder. If you did everything as instructed here, nothing will be overwritten.


Baronus wrote: Yes its necessary. I thinked about it but you overtake me. Good work.
If you want mod WoW HIV go to adress:
0x66f670 (+ 4**** for Ida, Hiew etc)
Game load files in order:
1.heroes4.h4r
2.storm.h4r
3.x2.h4r
4.text.h4r
5.updates.h4r
6.storm_override.h4r
7.storm_updates.h4r
8.x2_override.h4r
9.x2_updates.h4r
10.new.h4r
UFFF! Alot!
New is on the top and all in there is in game.
7,9,10 are not used and you can. You can rename too at it will be worked for your exe.
Last txt tables are in updates.h4r. So you must put your tables in updates or higher.

Note: the storm_updates.h4r file name is used for my Object Package


1.5 Game file extension overview
Inside the games main Resource file (heroes.h4r) the individual files have various extensions based on what kind of what file they. If you look at the files first name, it's rather easy to determine their extension. Note depending on the program used to extract, extension or filename may vary, see the image below. They're all the same file though.
The ".h4d" extension allows you to place the file directly in your Data folder and it can be read by the game, unpacked.
The ".obj" extension is required if you want to pack several files into a Resource (h4r) file.
If named .adv_object it needs to be changed to either .h4d or .obj.
If the file is unpacked into folders, in this case it is named 17.adv_object and it needs to be renamed to e.g. adv_object.Dunes.Snow.17.(xxx) in order to be read/packed. I'll also cover this later on..

(insert image "file extension")

Here's an overview of the games file extensions for understanding what the shortened extensions means.

Major File types:
H4R - Resource files (This is where all the minor game files are packed into and read from)
H4L - List/Log file (A text based file that allows you to either read extracted data or to list files to be packed into h4r format)
H4C - Game_maps (Campaign maps read by the map editor)
H4S - Save files (Any save game)
H4D - Data files (these consists of all the below mentioned type of files/formats)
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
Spr- Sprite files (actor_sequences, adv_actors)
Objects - Obj (adv_objects, combat_objects)
Ani - Animations
Raw - bitmap_raw (main menu is in this format)
Lay - Layers (UI, Portraits, Artifacts, Campaign Splashscreens and more)

(insert image "heroes4.h4r content overview)
Last edited by Karmakeld on Feb 18 2019, 21:28, edited 10 times in total.
I'm silent in seven languages - and I got all my familys fear.

Everytime you throw dirt, you loose a little ground

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

Re: H4 Modding Compendium

Postby Karmakeld » Jan 18 2019, 11:01

reserved
I'm silent in seven languages - and I got all my familys fear.

Everytime you throw dirt, you loose a little ground

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

Re: H4 Modding Compendium

Postby Karmakeld » Jan 18 2019, 11:01

reserved
I'm silent in seven languages - and I got all my familys fear.

Everytime you throw dirt, you loose a little ground

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

Re: H4 Modding Compendium

Postby Karmakeld » Jan 18 2019, 11:01

reserved
I'm silent in seven languages - and I got all my familys fear.

Everytime you throw dirt, you loose a little ground

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

Re: H4 Modding Compendium

Postby Karmakeld » Jan 18 2019, 11:01

reserved
I'm silent in seven languages - and I got all my familys fear.

Everytime you throw dirt, you loose a little ground

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

Re: H4 Modding Compendium

Postby Karmakeld » Jan 18 2019, 11:01

reserved
I'm silent in seven languages - and I got all my familys fear.

Everytime you throw dirt, you loose a little ground

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

Re: H4 Modding Compendium

Postby Karmakeld » Jan 18 2019, 11:01

reserved
I'm silent in seven languages - and I got all my familys fear.

Everytime you throw dirt, you loose a little ground

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

Re: H4 Modding Compendium

Postby Karmakeld » Jan 18 2019, 11:01

reserved
I'm silent in seven languages - and I got all my familys fear.

Everytime you throw dirt, you loose a little ground

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

Re: H4 Modding Compendium

Postby Karmakeld » Jan 18 2019, 11:02

reserved
I'm silent in seven languages - and I got all my familys fear.

Everytime you throw dirt, you loose a little ground

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

Re: H4 Modding Compendium

Postby Karmakeld » Jan 18 2019, 11:02

reserved
I'm silent in seven languages - and I got all my familys fear.

Everytime you throw dirt, you loose a little ground

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

Re: H4 Modding Compendium

Postby Karmakeld » Jan 18 2019, 11:02

reserved
I'm silent in seven languages - and I got all my familys fear.

Everytime you throw dirt, you loose a little ground

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

Re: H4 Modding Compendium

Postby Karmakeld » Jan 18 2019, 11:02

reserved
I'm silent in seven languages - and I got all my familys fear.

Everytime you throw dirt, you loose a little ground

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

Re: H4 Modding Compendium

Postby Karmakeld » Jan 18 2019, 11:02

reserved
I'm silent in seven languages - and I got all my familys fear.

Everytime you throw dirt, you loose a little ground

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

Re: H4 Modding Compendium

Postby Karmakeld » Jan 18 2019, 11:02

reserved
I'm silent in seven languages - and I got all my familys fear.

Everytime you throw dirt, you loose a little ground

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

Re: H4 Modding Compendium

Postby Karmakeld » Jan 18 2019, 11:02

reserved
I'm silent in seven languages - and I got all my familys fear.

Everytime you throw dirt, you loose a little ground

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

Re: H4 Modding Compendium

Postby Karmakeld » Jan 18 2019, 11:02

reserved
I'm silent in seven languages - and I got all my familys fear.

Everytime you throw dirt, you loose a little ground

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

Re: H4 Modding Compendium

Postby Karmakeld » Jan 18 2019, 11:02

reserved
I'm silent in seven languages - and I got all my familys fear.

Everytime you throw dirt, you loose a little ground


Return to “Modcrafting Guild”

Who is online

Users browsing this forum: No registered users and 1 guest