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: All creatures four+ abilities close & files (DLL help needed)
Thread: All creatures four+ abilities close & files (DLL help needed) This thread is 2 pages long: 1 2 · NEXT»
NimoStar
NimoStar


Responsible
Legendary Hero
Modding the Unmoddable
posted December 11, 2019 03:00 PM bonus applied by Galaad on 23 Dec 2019.
Edited by Galaad at 17:46, 23 Dec 2019.

All creatures four+ abilities close & files (DLL help needed)

So, I came back again to look at the problem of adding extra abilities to all creatures and not merely replacing. All I need is for someone to include the hex code I made into the .dll, then everyone could use it.

Creature structure in ability list:

[potential push ability 1, two bytes] (6a ...)
[potential push ability 2, two bytes if present] (6a ...)
[potential push ability 3, two bytes if present] (6a ...)
[potential push ability 4, two bytes if present] (6a ...)
[CREATURE NUMBER, two bytes] (6a ...)
[Unknown variable value, two bytes] (b9 ...)
[Unknown sequential value, one byte] (19 to 1f progressing one every 8-12 creatures)
[always "ab", one byte]
[always "00", one byte]
[always "e8", one byte] (three total consecutive fixed values)
[Unknown variable value, one byte]
[Variable lenght of number of abilities, one byte] (from 04 for one ability up to 0b or 09 for four; though some two ability expansion creatures have 03 as well)
[End of creature signature, two bytes] (00 00)

A four ability creature has thus 20 bytes of information about it on this list, a one ability creature has 14 bytes.
Two are always unknown variables that don't seem to me to have any logical order.

No creature has less than 1 ability in the base game, there aren't zero ability creatures (though many abilities do nothing, such as "toughness", the only zombie ability)

There is an extra "c3" byte at the very end of all creatures, the purpose of this is unknown but it may signal the end of the list.

incomplete gallery of code



- Creature ability list code is isolated by "90" null assembly instructions, meaning it could potentially be extended some right there. However for the extent of our modifications it is better to make it with the DLL (even if it has false positives as a "virus")



- Red 6a parts are added abilities, black 6a parts are previously existing abilities. You can see here than the more default abilities a creature had, the bigger its "ability signature" hex byte number.


- Ultimately I changed all signatures to 0b, the highest value, to ensure all four abilities are working for each creature. Maybe it can be upped even more to have more than 4 abilities (the map view of a creature shows up to five, but the combat view only shows 4. No existing creature has more than 4 in the game, meaning the last big-preview ability square on each creature is always vacant.)

- I think in theory this SHOULD work although I don't know what the rest of non-6a values mean.



Quote:
This includes:

- Creature list replacement.hex
: An hexadecimal assembly file for replacing all creatures with four moddable abilities

- Template for four ability creatures.hex
: Stages for an hexadecimal assembly file for replacing all creatures with four moddable abilities

- Fixed Greatest 355
: The last version of the greatest mod .exe file, compatible with equilibris 3.55 features  

- x4.dll
: the dll with some 3.55 modifications and my own.
This may be detected as a virus by some antivirus programs, since this is an .exe "hack". You should set the antivirus to ignore this and ignore its signature, since the mod won't run without the DLL and the detection is a false positive.


Here is code and DLL to download:
https://www.moddb.com/mods/greatest-mod/addons/exe-dll-pack-for-adding-four-abilities-to-creatures-etc

All that is needed to be done is to put my code as replacement of the existing creature code, and fill in my "ff" abilities with actual ones.
From here : http://heroescommunity.com/viewthread.php3?TID=37350
Also the location.
Creature ability list starts in 00654820  ( 00254820 in my editor since others like hiew add 00400000 for some reason)

They end in 00654ce6 (00254ce6) which is the extra "c3" byte at the end, before going back to 90909090 nulls.

That should be set as the start and end for DLL replacement, but I don't know how to do it exactly, my tries have failed before.
Also modern antivirus are marking equi .dll as a trojan.

Please, if you have DLL making capabilities (or know someone thatd oes to contact) take a look at this to add it to the provided equi .dll as it will benefit H4 modding as a whole greatly; most creatures only have one or two abilities, making everyone have four would be great for diversifying combat and expanding strategy and effects.

I am more than certain many H3 enthusiasts have the ability to make it true4. I already did the "heavy work" of painstakingly writing and replacing the hexes by hand for all 73 creatures. All that is needed is a few bytes of "jump" code or replacement, since all the body is already written and the locations known.
____________
Never changing = never improving

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


Admirable
Supreme Hero
posted December 11, 2019 08:36 PM

I had a very quick look at sub_654820. It looks like things are highly customizable. I highly recommend you use a debugger to help in your endeavors, you could clear up so much uncertainty in a cinch with one.


There are 4 different functions, which add 1-2-3-4 abilities to creatures, then pushing the creature's id.

The next instruction,
mov ECX, OFFSET ...
indicates that ECX is a class pointer and that the function calls are __thiscall type.
x86 Calling conventions
Each of these offsets represents some data structure that will be used elsewhere by the code for actual abilities.

Each of these data structures is 20 bytes large (just take 2 consecutive entries and subtract them).

Finally the next instruction is CALL function, which should be pretty self-explanatory.

Now the interesting part...
each of these functions is only creating a vector<int> listing these abilities... that's all, nothing more. [if you don't know, vectors are stretchable containers that can contain as little or as much data as you want]
Without having done any more, I think the creature id isn't even relevant, as it's only used to initiate the vector... but I could be wrong.

With this knowledge, you could test 40 abilities to a single creature. I don't have any interest in heroes4 to personally test this but I can give you a hand in setting up your project.

My rough Ollydbg notes from 3~4 mins of looking at the code. Note the base code offset 0x400000 if you decide to use a debugger.
Quote:
RVA,label,comment
00014670,Vector4_Insert_414670,
00118600,Vector4_Size_518600,
0011E470,Vector4_Copy_51E470,
0011EC40,Vector4_pushback_51EC40,
00254820,CreatureAbilities_654820,
00254F30,1_ability_654F30,
00255000,2_abilities_655000,
002551D0,3_abilities_6551D0,
002553B0,4_abilities_6553B0,
004D98A0,h4new_8D98A0,
004DBD90,h4delete_8DBD90,



Quote:

template<typename T>
struct h4vector
{
   char init; // useless in h3, probably here as well
   char alignment[3]; // so that vector size is 16 bytes
   T* begin;
   T* end;
   T* capacity;
};

struct h4creature_abilities
{
   h4vector<int> abilities;
   int creature_id;
};


____________
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
NimoStar
NimoStar


Responsible
Legendary Hero
Modding the Unmoddable
posted December 12, 2019 06:34 AM

well, I struggle to understand half of what you posted since I am not an assembly programmer, just a modder, but




So in this scheme for example, e8 is the CALL x86 instruction, cc 060000 is an offset where the function "one ability" is located? (in big endian notation i am assuming)

And as well, B9 is the MOV SCX x86 instruction, and 9C19AB00 is again the offset in big endian for some adress? (meaning, the fi

If so, what does this first MOV SCX adress do?

And, woudn't that mean that to use more than four abilities, another function would have to be programmed somewhaere else in the code? (since we only have up to four abilities function?

And, if you review my hex code, does that mean that, since offsets are relative, one would have to recalculate the offset for the "call 4 abilities" function each time, for each different creature? That would be harder than I thought...

Please correct me and/or clarify any of these statements/questions, thanks.
____________
Never changing = never improving

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


Admirable
Supreme Hero
posted December 12, 2019 02:49 PM

I'm going to answer your questions, but first:

With DLL, you don't need to worry about any of this crap. You're can write your modifications in a readable fashion (e.g. in a json file) and the dll handles all the rest directly. No offset calculations and more importantly, no 1-2-3-4 abilities limit. Want a creature with 15 abilities? DLL's gotcha covered. And I'm sorry to say this, but hex patches are close to useless in most cases. They're hard to write, hard to modify and hard to maintain, bad bad bad.

Re questions.
CALL instructions use relative addresses, based on where the call is written. In a function call to 0x123456, the offset will be different if called from 0x222222 or 0x333333, so it requires offset calculation every time. A debugger does this calculation for you so there's that.

ECX is the data structure required for each of the 4 ability functions, it's required to tell where the abilities and creature id should go due to function signature. Without it you'll get a crash.

Quote:
And, woudn't that mean that to use more than four abilities, another function would have to be programmed somewhaere else in the code? (since we only have up to four abilities function?
If you stick to hex edit, yes. With DLL you wouldn't even use any of these functions, just store whatever you want directly in the data structures.

I didn't review your hex code and won't, it's not useful for DLL.

What you actually want is
1- a list of all creature names, in plain English
2- a list of all creature abilities, in plain English
3- setup a json with all the creature names as objects, and then abilities as sub-objects (being present or no)

That's it...no more. You're done. Easy to modify, easy to customize.

Quote:

{
 "Creatures": [
   {
     "Creature0": [
       "Ability3",
       "Ability32",
       "Ability47",
       "Ability48",
       "Ability49",
       "Ability68"
     ]
   },
   {
     "Creature1": [
       "Ability1",
       "Ability11",
       "Ability55"
     ]
   },
   {
     "And so on": []
   }
 ]
}



____________
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
Jagulars
Jagulars

Tavern Dweller
posted December 13, 2019 11:44 AM
Edited by Jagulars at 11:46, 13 Dec 2019.

RoseKavalier said:
With DLL, you don't need to worry about any of this crap. You're can write your modifications in a readable fashion (e.g. in a json file) and the dll handles all the rest directly. No offset calculations and more importantly, no 1-2-3-4 abilities limit. Want a creature with 15 abilities? DLL's gotcha covered. And I'm sorry to say this, but hex patches are close to useless in most cases. They're hard to write, hard to modify and hard to maintain, bad bad bad.
That's harsh. I haven't seen you done anything for Heroes 4.

Not to say that what you say wouldn't be useful, but you're not training a pro wrestler.

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


Admirable
Supreme Hero
posted December 19, 2019 03:10 AM bonus applied by Galaad on 23 Dec 2019.
Edited by RoseKavalier at 03:53, 19 Dec 2019.

I made something.

Essentially, I recycled other projects to make this, plus some time to format creature names + abilities from existing documentation and write a few custom things for the abilities plugin.

...there may be mistakes in the default creature abilities as I don't know them!

Heroes 4 Modding System
Loads *.dll from /Plugins/ folder, nothing fancy.

H4.CreatureAbilities
Reads a json to let you customize creature abilities. Completely bypasses game code.

Download from here and follow indicated steps.

As I said previously, I know next to nothing about Heroes 4, the only thing I checked was that the creature ability plugin actually wrote the customized abilities as it should. I haven't made a creature with more abilities or a creature with fewer ... although that should be pretty easy to test for anyone who knows his way around H4.

Pretty much all details needed are on the repository.

Only tested on Windows10

EDIT
*Fixed Behemoth/Beholder switch-a-roo
*Was reminded there is a GL wrapper to play this windowed, subsequently I actually let the game launch.
Quote:
"Orc": [
       "Ranged",
       "Normal Melee",
       "Short Range",
       "Flying",
       "Rebirth",
       "Breath Attack",
       "Fire Resistance"
   ],



It looks funny, but it seems to work
____________
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
theunknown
theunknown


Known Hero
posted December 19, 2019 04:47 PM

The waspwort, water elemental, wolf and zombie abilities are mixed up between each other.

This is great, can't wait to try it out.

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


Responsible
Legendary Hero
Modding the Unmoddable
posted December 24, 2019 10:09 PM
Edited by NimoStar at 22:10, 24 Dec 2019.

very interesting. If only some code wizard would have been interested like this in H4 20 years ago when it came out like in H3 we might be more advanced now :V

But, better late than never, so thanks.

Though, the negative part is that it took someone insulting you to get it done, it should be the oppossite

And I do wonder if it works with equilibris/my mod since they already use an auxiliary DLL (which sadly is detected as a virus now)
____________
Never changing = never improving

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


Legendary Hero
posted December 31, 2019 10:59 PM

Great RoseCavalier! We are welcome you on Heroes 4 field! Very good game for holidays after work in HIII :0)))
Ive made it using jump function. In HIV you can easy rewrite all creature in empty space using ,link' = jump.
But I think that 4 abilities is enough. If we give more a lot of creatures will be similiar.
DLL gives a lot of another chances. How about eg. another specialty for each hero?

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


Admirable
Supreme Hero
posted January 03, 2020 12:18 AM

I'll take a look at the default creature skills that are swapped and update the repository afterwards.

I don't know how Equilibris handled their dll injection, it's possible it works as is as the exe patcher should be smart enough to just re-route. If it isn't so then I'd have to get an Equilibris exe and change some addresses to allow both.

I don't have any particular interest in reversing Heroes 4, as I understand there is already some information out there which could be put together in DLLs and distributed easily through H4MS the same way Creature Abilities were done.
____________
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
Baronus
Baronus


Legendary Hero
posted January 03, 2020 08:07 AM

I dont know what are you fellings for IV so I dont want engage you to project you dont enyoy. But if you like will be nice to repair something in this underdeveloped game.
What is possible using dll? I know is easiest add new thing than modify hardcodded one.
Eg. city development is failed. Fort-castle-citadel gives nothing. Will be good make it in HIII mode - additional unit growth.
+20% +50% +100%. Percent function growth is in game. Barbarians have special building which gives 50% units more. It can be maybe used to all towns.
After this patch we have better gameplay.

Not only equilibris use dll way to mod game. Our chinese mates are doing something like this:

dll tools

So maybe together can be done something faster and better.

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


Responsible
Legendary Hero
Modding the Unmoddable
posted January 08, 2020 07:03 PM

Equilibris DLL is not like your DLL plugin, theirs is in assembly as far as I could see, replacing part for part of the original code.

That is why my original comment was about making this in Assembly, which you said was "Useless for DLL", but Equi one is done that way and is a dll, thus my confusion (?)

Of course since it was done so many years ago and by "Hackers" more than programmers, it doesn0't follow "best coding practices" like yours

On the other side I have already fixed the abilities, minus some typos I don't know how to fix. I will try to upload the fix some time, for now my residence doesn't have wi-fi even.

The typos are for example, some abilities have the word resistAnce, and others say resistEnce. This would lend itself to confusion as people would type the wrong letter and it isn't consistent.
____________
Never changing = never improving

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


Admirable
Supreme Hero
posted January 09, 2020 02:21 AM

I have yet to look at Equi, is there any source/comments/proof that it's purely assembly? Not that's it impossible to do with Assembly (I did quite a bit of that myself in my early mods & you can see quite a bit within WoG sources & MoP), it's just very impractical and makes it difficult for other people to read, understand, modify and build upon.

Thanks for any fixes, I have not yet taken the time to review creature abilites; also all the text I have came from that modding thread. I'll gladly correct them, or you can send a pull request directly to the H4MS repository.

As I have already stated, I don't have that much interest in reversing the Heroes4 code, reversing takes the most time in modding of Heroes games, speaking proportionally.
However if you happen to have detailed information about what you'd like to modify (functions, ids, structures, ...) then it is quite simple to implement. If you ignore all the customization in the CreatureAbilities plugin, the actual implementation is from lines 276 - 304.
____________
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
Baronus
Baronus


Legendary Hero
posted January 09, 2020 08:18 AM

Very precious mod. Will be good ad all known things. And build global plugin.
1.Creatures town aligment.
2. Heroes skills
3. Necromancy skill.
4. Recall skill.
5. Town income.
6. Game level difficultly resources.
And have it in one place. Modding json is much easy and fast than serching in code.
If we will find something more we give it to actualisation.
Thanks for pluggin.

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


Responsible
Legendary Hero
Modding the Unmoddable
posted February 02, 2020 12:06 AM
Edited by NimoStar at 00:08, 02 Feb 2020.

Quote:
I have yet to look at Equi, is there any source/comments/proof that it's purely assembly? Not that's it impossible to do with Assembly (I did quite a bit of that myself in my early mods & you can see quite a bit within WoG sources & MoP), it's just very impractical and makes it difficult for other people to read, understand, modify and build upon.



Im pretty sure that itds pure assembly since

1- That's all we have been able to see, the dll files are just the same assembly parts as the .exe but replaced/extended

2- That's all the equi team talked aboout when they were here as modding method.

Take into account this was originally done up to only 2006?, coding practices woudn't be the same as now.

In H4 many things are hardcoded that woudn't today be (creature abilities being one themselves)


Reverse engineering only has to be done once though? While customizations can be done infinite times based on that single reversing, like ERA scripts and etc.
____________
Never changing = never improving

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


Admirable
Supreme Hero
posted February 04, 2020 02:03 PM

I'm not a programmer by trade but I think practices are more down to personal preferences.

I installed Equi and had a very quick look at the provided exe.
Done with LordPE to extend the exe room and seems indeed to be done through exe modifications mostly. There's also a reference to "h4.dll" which I guess is Tournament Edition. Must have been challenging to keep all that going without some excellent documentation somewhere...

Reversing indeed need only be done once, but it still needs to be done, which is time consuming. As I've said before, if you have more documented regions of the code like creature abilities, then it's simpler to make sense of it and make it customizable.
____________
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
NimoStar
NimoStar


Responsible
Legendary Hero
Modding the Unmoddable
posted February 15, 2020 03:25 AM

h4.dll is the default equi dll file, then there is another one for the campaign editor.

and it has been detected as virus lately so people have been thinking I am a hacker or scanner due to distributing my edited version which is necessary for my mod -_-

Anyways... we have certain other areas of the code mapped like default starting hero abilities. Most are in the thread "heroes 4 modding revisited" here, but they are not many compared the the Heroes 3 ones. http://heroescommunity.com/viewthread.php3?TID=37350

AFAIK we don't even know where creature spells are stored other than the ones added by equilibris... and those have important limits as I found out using them. (only 14/15 creatures and only three spells each so they don't bleed over to the next one)
____________
Never changing = never improving

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


Admirable
Supreme Hero
posted February 16, 2020 03:25 PM

So what would be the next thing to add here?
My time is limited lately so any direct information (addresses, formats, text lists, ...) you can link to will help contribute to new features for H4MS.
____________
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
Baronus
Baronus


Legendary Hero
posted February 16, 2020 09:15 PM
Edited by Baronus at 21:15, 16 Feb 2020.

Baronus

Unit town aligment of course. We have complete list. But beware must be correctly faction i txt table! Cannot be chaos unit in life town because its crash.
If it will be mod platform must have all we know because situation we have units ability in modedd dll but aligment must be corrected in exe... Its not good solution.
But you must like it! Nothing should be done if is no satisfaction! Its not exploit you! :0))) Dont think we are pressing you! No feel no work! :0))) I know how it is if someone ask you dont fell to do it but you ,must' do! You have made a lot in HIll! Its precious too!

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


Responsible
Legendary Hero
Modding the Unmoddable
posted February 18, 2020 01:16 PM

Translation:

If you put a "life" creature in the "order" town, for example, the game crashes.

I take it that Baronus proposes you can mix units as you wish regarless of alignement.

And/Or be able to edit what unit goes in what town in a text file.

I am not sure how needed would be the last thing... it is only a simple hex edit. The adressess are in the file I linked.
I changed all the alignments of creatures without problems in my mod.

The crash thing is true, but we don't know the binary adress to prevent the crash?

_________________________

My proposal would be to be able to edit the effects of skills

We know which skills exist with which codes. Each skill has a 1-byte code that identifies it and is listed.
However, we have two sets of skills which are identical in effects.

Medidation, Demonology, Pyronmancy etc... (Five magics) All do relatively the same:
Increase magic of that skill by 20% per level

Herbalism, etc... five magics all do exactly the same:
Increase mana points by 2 per day and 10 per level

These 10 skills make an important proportion of the total

If we could have a DLL to customize what each skill does (with our own scripts), we can do the most important thing:
Make the game less boring!

And as a dream, add your own skills... but I supposse this would be significantly harder.
____________
Never changing = never improving

 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 · NEXT»
Post New Poll    Post New Topic    Post New Reply

Page compiled in 0.1079 seconds