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 > Heroes 4 - Lands of Axeoth > Thread: Mod for adding new creatures, abilities, projectiles and spells
Thread: Mod for adding new creatures, abilities, projectiles and spells This thread is 3 pages long: 1 2 3 · NEXT»
H4Zer0
H4Zer0

Tavern Dweller
posted June 26, 2022 11:00 AM

Mod for adding new creatures, abilities, projectiles and spells

Hi everyone,

I've been working since last year on a mod to balance some buildings and creatures stats mostly to play with a friend that I've also played a lot of H3 in the past.
At the beginning of this year I wanted to see if I can add new creatures and then I actually succeded and in the past few months I've also managed to add new creature abilities,
new ranged projectiles and new spells.

The reason I'm making this post is to share all this information I've discovered (mostly through reverse engineering the exe) on making this mod, which I've named for now "Equilibris++" since
it's based on the Equilibris 3.55 mod, and I'm not planning on releasing it on Mod DB or other sites, at least not in the near future, since there are still many things to do anyway.

Here are the mod files archive, it also includes the HD Mod by Verok:
[url]https://www.mediafire.com/file/pv4798sfwuonypm/eq_patch.zip/file[/url]

You just need to extract and copy the contents of the "eq_patch" folder to an installed version of HoMM 4 Complete.
As always recommended, you should make a backup copy of your files or just create a new folder with a fresh installation of the game just for this mod.

To test the mod and see all the new creatures you can just load the "new_creatures_test" save file from the "games" folder.
Here is an image of the battle with the 7 new creatures that I've added so far:


They are from left to right: Diamond Golem, Lich, Magog, Pit Fiend, Manticore, Rust Dragon and Cleric. Currently they can only appear in the map random neutral stacks of their level.
The same with their dwellings, they can only appear in the random adventure map dwellings of their level.
For now I didn't had time to also have a look and reverse engineer the campaign editor in order to add them there so you can manually add them in a map.
You can also replace the ones from the towns if you want to play with them some more.
The only issue I've found so far is that the game sometimes crashes after a battle where the Manticore's Paralyzing Venom ability activates at least once,
but I'm still investigating this issue.
Well there is still another issue with the combat AI unable to cast Fire Ring or Frost Ring without crashing the game after the battle,
which I've tried to fix but it still has some problems so I've disabled it for now.

The new ranged projectiles are just a simple green mage missile for the Lich and a purple firebolt missile for the Cleric.

The new abilities and spells are found in the changelog text file which you can find in the main "eq_patch" folder. There are also many other changes to try to balance some things.
I'm still a fairly new H4 player (especially compared to H3) so many balance decisions might not be very good but I'm still learning and always welcome everyone's feedback and suggestions .

Here is an archive of my H4 modding folder, which contains all the code, resources, tools etc. that I've used for this mod:
[url]https://www.mediafire.com/file/s1dcmyzqul0hi10/h4_modding.zip/file[/url]

The code is located in the "h4ms" folder, it's a solution file which you can open with the Visual Studio 2019 Community editor which is free.
It is based on RoseKavalier's very nice H4 Modding System H4API (which is also based on his H3API that I've also used to make some plugins for H3 in the past) from here:
[url]https://github.com/RoseKavalier/H4MS[/url]

When you build the solution it creates the "h4ms.dll" file in the "Release" folder, which injects all the necessary code in the main exe file, similar with the "h4.dll" of Equilibris.

The code is written in C++ and currently is not very well organized but I can help and guide anyone who wants to modify it and add more creatures, spells etc.
The main points of interests are in the "H4Constants", "NewCreatures", "NewCreaturesAbilities", "NewMissiles" and "NewSpells" .hpp files.

You can also find all my IDA databases that I've used for reverse engineering and finding all this information in the "ida_dbs" folder.

My next priority is to reverse engineer the "c_e_mod.exe" file in order to be able to add all the new creatures and their adventure dwellings manually from the editor.

In the future I also want to reverse engineer and try to improve the adventure map AI and also the combat AI a little
and maybe also try to implement simultaneous turns after I learn some more about networking.

This was all possible because of all the great information about modding and the game shared here on this forum by all of you nice guys.
Many thanks to Equilibris team, RoseKavalier, NimoStar, iliveinabox05, karmakeld, Baronus, mirage, brink99, WhiteRider and many others!

Thank you all for your love for this wonderful game!

____________

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


Admirable
Supreme Hero
posted June 26, 2022 05:36 PM

Hey H4Zer0,

Good job on making something out of h4ms - I'm glad it has served as a decent base for something to build on top of to finally add some modability to homm4!

I don't have that much free time on my hands to work on h4 specifically but I'd be happy to offer what help I can if you wish. Feel free to get in touch by PM or through my email which is available a bit all over the place.


____________
My Let's Plays: Metataxer's Revenge - The Empire of The World 2

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


Known Hero
posted June 26, 2022 05:55 PM

@H4Zer0

Always happy to see that someone is modding H4. This game needs more love. A bit disappointment that they are not new models created from scratch, but still better then nothing.

Have you hexedit in equilibris? I can't find the offsets of the orc and Frenzied gnasher i like to change thier skills.

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


Honorable
Legendary Hero
Modding the Unmoddable
posted June 26, 2022 07:31 PM
Edited by NimoStar at 19:33, 26 Jun 2022.

Extremely interesting coding exercise and game logic extension Very impressive!

So, this uses Equilibris dll and the RoseKavalier plugin at the same time? Isn't that unstable? I thought that the plugin self-disabled with Equi system.

I see that you have done h4r files in a modular way

***

My only negative comment so ar is that those new creatures are recolored in the terrible wog manner. Ah well, as many wkis say, "programmer art"...
____________
Never changing = never improving

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


Promising
Legendary Hero
posted June 26, 2022 08:05 PM

Lol! Shock! Go ahead! You have a big potential! Im really delighted! That's why I wrote Hex addresses years ago so that there would be more mods for poor H4! Today I see great results! Don't worry about recolored units! H3 was like that at the beginning of moding. Great!

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


Honorable
Legendary Hero
Modding the Unmoddable
posted June 26, 2022 08:36 PM
Edited by NimoStar at 21:12, 26 Jun 2022.

Well, WoG "started" like that... and the recolored creatures never ever got replaced.

***

What worries me is that everything is "Baked in" here, so a lot is obscured in a way. RoseKavalier had argued against this kind of hex DLL modding. Ironic that his work would be used this way.

There is even no trace of the configurable .json we had on the other plugin

In NewCreatureAbilities.h we have this:

Quote:
int __stdcall addCreaturesAbilitiesWithoutIcon(LoHook* h, HookContext* c)
{
   addCreatureAbility(eCreatures::LICH, eCreatureAbilities::AREA_ATTACK);
   addCreatureAbility(eCreatures::MAGOG, eCreatureAbilities::FIRE_ATTACK);
   addCreatureAbility(eCreatures::MAGOG, eCreatureAbilities::AREA_ATTACK);

   return EXEC_DEFAULT;
}


Say, if I were to add abilities for default creatures that come with the game this way, would that work?

Adding abilities without adding icons is something I didn't think about before, and can possibly be used to have more than 4 abilities per creature without GUI crash.

____


Also as for adding new dwellings to the H4 map editor, no reverse engineering would be needed as long as the new creatures simply have an hex code. Just enter palette editor and add them, no?

For example, Megadragon, Mermaid dwelling could be added, and it's just changing the recruited creature hex in the object.

If new creatures lack an hex code that would certainly be a problem.
____________
Never changing = never improving

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


Adventuring Hero
posted June 26, 2022 08:50 PM
Edited by Assryn at 20:51, 26 Jun 2022.

@H4Zer0

That's insane !! Well done !
All the potential this could unlock for breathing new life into H4 is crazy !

I for one really like to colorations on the Diamond Golem, Lich and Cleric, I think they look very clean and neat, very harmoniously done !! Can't wait to see more of your work !

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


Hired Hero
posted June 26, 2022 09:05 PM
Edited by BrucknerHun at 21:06, 26 Jun 2022.

Wow !

This is amazing! Can't wait to try it out!

Soo nice, that are still some people playing and actually care for this game!

Keep it up the good work bro!

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


Promising
Legendary Hero
posted June 26, 2022 10:41 PM

Yes. There are some filters for unskilled graphics. Not only recolorize. Change width height, pixelize, blurry, unsharp mask etc.
Give completly new models is hard work. But it may happen if we see possibilities to add new creatures. I need for my mod all number!

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


Responsible
Famous Hero
posted June 26, 2022 10:58 PM

baronus said:
Give completly new models is hard work. But it may happen if we see possibilities to add new creatures. I need for my mod all number!


We already have quite a few new models, they just haven't been unveiled yet. With h4zero's work here, the possibilities are huge. Instead of reskins, well, totally new stuff

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


Promising
Legendary Hero
posted June 26, 2022 11:35 PM

Great! We need a models bank!  Completly new creatures is better solution than recoloring! With this engine we have new era of Heroes IV! Very good day we have today! )))

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

Tavern Dweller
posted June 27, 2022 12:37 AM

@RoseKavalier

Thanks a lot for your help, I really appreciate it!

I'm also a little busy right now but when I have any question I'll get in touch with you
____________

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

Tavern Dweller
posted June 27, 2022 12:39 AM
Edited by H4Zer0 at 01:06, 27 Jun 2022.

@szaman

Thanks, yes it's very hard to create new models from scratch but I want to try to make a few 3D models in Blender in the future
and then try to automate the process of exporting all the hundreds of animation frames and shadows for their actor_sequence images.

I've used the Equilibris 3.55 h4mod.exe file, there the Orc offset is at 0x32D and the Frenzied Gnasher one is at 0x36F.
You can use a hex editor like HxD and you can find a list of all the abilities codes here:
[url]http://heroescommunity.com/viewthread.php3?TID=37350[/url]

If I try to post again I'm getting this warning:

"WARNING! You are posting a third reply in a row. If you submit, your post count will decrease.
We suggest editing your last reply instead of posting this reply and losing rank points."

So I'll just edit my last reply.


@baronus, @Assryn, @BrucknerHun

Thank you for your kind words, I will do my best


@NimoStar

Thank you! You are right about the recoloring, I'm not very good at it and only learned how to use Photoshop a few months ago
Hopefully we can add new quality models in the near future.

NimoStar said:
So, this uses Equilibris dll and the RoseKavalier plugin at the same time? Isn't that unstable? I thought that the plugin self-disabled with Equi system.


Well I've made a little hack where I've inserted this code in the exe to load the h4ms.dll right at the start of the entry point function and it executes after the Equi h4.dll.
Here is a screenshot of the disassembled code in IDA:


As long as you don't overwrite their code, or do it in a way that doesn't generate conflicts, it won't be a problem.

NimoStar said:
I see that you have done h4r files in a modular way


Yes, I wanted to make them load separately in this modular way in order to have them better separated and organized.
You can find the code in the "loadAllModFilesFromData" function, I just load all files from the "data" folder that end with "_mod.h4r".

NimoStar said:
What worries me is that everything is "Baked in" here, so a lot is obscured in a way.


I think you're referring here to this type of code:

Quote:
_PI->WriteByte(0x658233, total_creatures_nr);
_PI->WriteDword(0x65823A, (UINT)creatures_ids_and_keywords_array);


Unfortunately, at least for now, this is the best way that I've found how to make the necessary changes to the exe.
You also need the annotated IDA db file "h4mod.idb" to really understand the Assembly code and all the reverse engineered info of the game functions etc.
I will make a post about this with more details in a few days.

NimoStar said:
Say, if I were to add abilities for default creatures that come with the game this way, would that work?


Yes, I think in theory you can add almost all abilities to a single creature. For example:

Quote:
int __stdcall addCreaturesAbilitiesWithoutIcon(LoHook* h, HookContext* c)
{
   addCreatureAbility(eCreatures::LICH, eCreatureAbilities::AREA_ATTACK);
   addCreatureAbility(eCreatures::MAGOG, eCreatureAbilities::FIRE_ATTACK);
   addCreatureAbility(eCreatures::MAGOG, eCreatureAbilities::AREA_ATTACK);

   addCreatureAbility(eCreatures::HALFLING, eCreatureAbilities::LONG_RANGE);
   addCreatureAbility(eCreatures::HALFLING, eCreatureAbilities::SHOOTS_TWICE);
   addCreatureAbility(eCreatures::HALFLING, eCreatureAbilities::FLYING);
   addCreatureAbility(eCreatures::HALFLING, eCreatureAbilities:EVOURING);
   addCreatureAbility(eCreatures::HALFLING, eCreatureAbilities::FEAR);
   addCreatureAbility(eCreatures::HALFLING, eCreatureAbilities:OISON_ABILITY);
   addCreatureAbility(eCreatures::HALFLING, eCreatureAbilities::STONE_GAZE_ABILITY);

   return EXEC_DEFAULT;
}


I've tested it and all these extra abilities will work, except for the Devouring and Fear ones, because they are conditioned to only work in melee.
Of course they can also be made to work for ranged creatures but I think they are fine like this.

You can play with this by opening the "h4ms.sln" file with Visual Studio 2019 Community and after changing the code you just need to build the solution with F7.
Then you can copy the "h4ms.dll" generated file from the "Release" folder to replace the one from the main game folder.
Just make sure you select the "Release" and "x86" configuration options from the top left corner which I've highlighted in the red rectangle here:


NimoStar said:
Also as for adding new dwellings to the H4 map editor, no reverse engineering would be needed as long as the new creatures simply have an hex code. Just enter palette editor and add them, no?


I don't know if that's enough, I haven't really used the map editor that much.
The new creatures have increasing hex codes right after the Megadragon, you can find them in the "enum eCreatures" list in the "H4Constants.hpp" file.
____________

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


Responsible
Supreme Hero
posted June 27, 2022 02:42 PM

You don't have to load patcher_x86.dll, h4ms.dll will load it automatically.

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


Promising
Known Hero
posted June 27, 2022 05:14 PM

great news, I'll be watching the progress!

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


Honorable
Legendary Hero
Modding the Unmoddable
posted June 27, 2022 06:48 PM

Quote:
I've tested it and all these extra abilities will work, except for the Devouring and Fear ones, because they are conditioned to only work in melee.
Of course they can also be made to work for ranged creatures but I think they are fine like this.

You can play with this by opening the "h4ms.sln" file with Visual Studio 2019 Community and after changing the code you just need to build the solution with F7.
Then you can copy the "h4ms.dll" generated file from the "Release" folder to replace the one from the main game folder.
Just make sure you select the "Release" and "x86" configuration options from the top left corner which I've highlighted in the red rectangle here:


So, this will recognize the names of previous creatures just like the Creature Ability plugin did, right?

Can't I change the .h files with just a text editor? Abnd just use Visual Studio for generating the dll.

That part is unclear to me. I haven't got experience with visual studio yet.
____________
Never changing = never improving

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


Promising
Legendary Hero
posted June 27, 2022 07:12 PM

You must use editors with specjal pluggins. It must look as you see. Notepad +++ has it.

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


Honorable
Legendary Hero
Modding the Unmoddable
posted June 27, 2022 09:58 PM

I was speaking of Notapad++

I do have syntax highlighting, that's the editor I always use (even for just writing text)


____________
Never changing = never improving

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

Tavern Dweller
posted June 27, 2022 11:14 PM

AlexSpl said:
You don't have to load patcher_x86.dll, h4ms.dll will load it automatically.


Oh ok, thanks.

It didn't work for me without loading it separately but maybe I did something wrong when compiling my modified version of h4ms.dll.

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


Responsible
Famous Hero
posted June 27, 2022 11:26 PM

H4Zer0 said:
AlexSpl said:
You don't have to load patcher_x86.dll, h4ms.dll will load it automatically.


Oh ok, thanks.

It didn't work for me without loading it separately but maybe I did something wrong when compiling my modified version of h4ms.dll.


Check your pm's man

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

Page compiled in 0.1008 seconds