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: Might spells are semi-implemented in-game!
Thread: Might spells are semi-implemented in-game!
NimoStar
NimoStar


Honorable
Legendary Hero
Modding the Unmoddable
posted May 03, 2022 09:55 AM
Edited by NimoStar at 11:38, 03 May 2022.

Might spells are semi-implemented in-game!

If you equip a parchment with a level 3 "Might" spell, the game tells you you need Expert Offense to cast it!

Steps to reproduce:
* Open spell table
* Change a spell school to "Might"
* Pack text into read h4r
* Make map
* Add spell to parchment
* Put parchment in map
* Save map
* Enter game
* Pick up parchment
* Equip to hero:



And if your hero DOES have expert offense, even this happens:

So it's not interface-text only. You can actually make your hero learn Might spells with Offense skill, and so far as that, it works.

Even, you could see this in conservatories, which was an early clue:


Now, if you set this spell into a scroll, or learn it via having the prerequisites...
...when opening the spellbook to see it...
...your game will crash.

BUT!


While there is real chances this still won't work no matter what without hex changes to game logic, there is still *a chance*

The crash might (pun unintended) be because there just isn't a Might spell icon set.

Creating the icon sets could give this a chance...

PS: Sadly, even generating a Might spells iconset doesn't make this *not* crash. But it's still just an icon problem. If we could force the game to read layers.icons.spells.might.52 , this would work. But I don't know where such UI instructions are, searching for lasers.icons.spells in main exe yields no results (either unicode or ANSI)

Anyways, very curious that this was programmed anyways. And almost like the H5 "blood magic".

Some hacker expert could make this functional if they just find the icon call logic, I bet...

This is actually the most radical possibility for H4 modding thus far, even bigger than edited "new" mass spells I implemented and bigger yet than the creature plugin made with my proposal before.

Over 20 years later this game still has secrets. Makes one wonder what we would have now if people modded H4 instead, or in addition to,  H3... it seems quite interesting.
____________
Never changing = never improving

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


Honorable
Legendary Hero
Modding the Unmoddable
posted May 03, 2022 10:16 AM
Edited by NimoStar at 11:42, 03 May 2022.

Also, I haven't actually tested this yet, but since the only missing thing seems to be reading icons, I find it quite likely that AI-controlled heroes and creatures CAN and WILL use Might spells.

**************

Also, if you switch the spell to level 6, then this happens:

Meaning level 10 spells will be Grandmaster Defense required.

If it's level 11, you need Basic Leadership. I think leadership (might spell levels 11-15) would be the more balanced to implement the might "spells", since Defense and Offense are already really strong -only leadership is kind of weak. But if we want to keep the spells in the standard levels (1-5), they will have to be Offense.

I wonder how this works with regular spells. Would you be able to create a level 20 Chaos Magic spell that requires Grandmaster Sorcery to cast? Or was this exclusively created for Might, seeing as Tactics, the main skill, doesn't count unlike in the magic ones? Will keep investigating...

PD: It seems indeed it was intended just for Might spells. A level 6 Chaos spell just requires basic Nature magic, so it loops within the "Normal" schools, which could make shenanigans (a level 10 Chaos spell will require grandmaster Nature) that "enrich" gameplay (since the spell is still trated as Chaos, for example, for purposes of Ward and % power enhancement) but is otherwise just confusing.


***********

I did find something to edit in the interface though it probably doesn't replace the icon problem,

it would be anyways nice to complete it in order to discard that as a future needed factor:



Sadly, TextEdit can't edit correctly table.interface and IliveInaABox text editor function can't add the required two new lines...


____________
Never changing = never improving

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


Responsible
Supreme Hero
posted May 04, 2022 05:41 PM
Edited by AlexSpl at 17:42, 04 May 2022.

Nice findings! I even want to help you with this problem. Alas, I haven't played H4 enough to call myself competent. Actually, I played only 4 original campaigns. And, you know, to effectively read the code you must be familiar with the game mechanics. Do IDA bases for H4 exist? How, for example, the Equilibris team modifies the game without one?

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


Honorable
Legendary Hero
Modding the Unmoddable
posted May 04, 2022 05:54 PM
Edited by NimoStar at 18:01, 04 May 2022.

THere are known

hex locations

, I don't know if you mean that for "IDA bases"

If you mean full decompiled executable code, one would have to ask Equilibris team. What I have seen, at least up to version 3.55, is that they use pure hex edit - including having their own "dll plugin" which is done entirely in assembly.

* * *

More tests with the Might spell uncovered more problems sadly. For example, the Might spells apparently interfere with artifacts that give spells from all schools - such as Apprentice's Handbook - and generate game crashes. This may be simply because the artifact lists the valid schools and lacks an entry. Generally, we will need more game logic edits than just reading icons - But with a concerted effort, it is achievable.

* * *

For non-equilibris, we have rosekavalier's plugin system, which is here:

H4MS

In theory it can modify arbitary game code, but thus far we only got the creature ability editor. The code seems to not have been understood by other modders, and I am not a programmer myself to write more plugins. I identified a piece of code in the EXE which I would like to extend via plugins (the mass spells), but from there no idea how to hook that into the C++ system. There has been a fork but only as technicality because nothing was actually changed.

Other than that we don't have something like H3 HD widely used plugin loader. Only a single system with a single plugin (sadly the creature plugin doesn't allow the technically perfectly working more than 4 abilities, just because some game screens UI can't display a fifth+ ability icon), or the mess of unreadable machine code that is Equilibris.
____________
Never changing = never improving

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


Responsible
Supreme Hero
posted May 04, 2022 06:10 PM
Edited by AlexSpl at 18:13, 04 May 2022.

Well, you can modify the entry point function of the executable to load plugins. And then use my universal loader. The main problem, as I understand, you haven't an IDA base with decompiled classes, which is a big problem. But, in theory, there is no difference between writing plugins for H3 and H4. I even wrote several plugins for H1 & H2. Basically, you can modify any x86 code with baratorch's patcher. All you need is to decomplie, at least, basic classes of H4, such as hero, town, army, etc. I wonder, why haven't it been already done. Lack of dedication/knowledge? Yes, it's hard to start from scratch. But, step by step, you will eventually write a readable code.

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


Responsible
Supreme Hero
posted May 04, 2022 06:22 PM
Edited by AlexSpl at 18:51, 04 May 2022.

RoseKavalier, btw, did a great job. If you can't modify the game with his API, then you have to start learning. Because the next level is only to have the source code or, at least, the dump we have for H3.

Basically, you need a decompiler. Alas, for free you can acquire only a disassembler (see free versions of IDA). Actually, a disassembler is enough to patch a game, but you must be a pro in Assembler. Having a decompiler (see, for example, free Ghidra) all you need to know is C++ which is much simpler and convenient language than Assembler. What to do next? Find classes' constructors/desctructors to determine their sizes. Search in the code what stands for what. Here breakpoints are your main helpers, but some basic stuff can be done even without them. Then the mess of offsets and calls, a decompiler provided you with, will gradually become more and more readable. Seems hard? But you have to start from something

Just look at this function which was "beautified" by decompiling the main classes (btw, it's the code of Heroes 1, no one has an IDA base for it):

void __thiscall AI_considerCreatures(void *this, TTown *town, TAIAction *action, float *value)
{
 char v5[4]; // [esp+8h] [ebp-30h] BYREF
 int canBuy; // [esp+Ch] [ebp-2Ch]
 float BuyingRV; // [esp+10h] [ebp-28h]
 float max_value; // [esp+14h] [ebp-24h]
 eCreatures creature_id; // [esp+18h] [ebp-20h]
 float value_of_buying; // [esp+1Ch] [ebp-1Ch] BYREF
 int i; // [esp+20h] [ebp-18h]
 int creatures_to_buy; // [esp+24h] [ebp-14h]
 int iTier; // [esp+28h] [ebp-10h]
 int tier; // [esp+2Ch] [ebp-Ch]
 int num; // [esp+30h] [ebp-8h]
 float result; // [esp+34h] [ebp-4h]

 tier = -1;
 num = 0;
 result = -99.0;
 max_value = -99.0;
 for ( iTier = 0; iTier < 6; ++iTier )
 {
   creature_id = dbTownCreaturesId[town->type][iTier];
   if ( ((1 << (iTier + 7)) & town->buildings) != 0 && town->numCreatures[iTier] > 0 )
   {
     canBuy = 0;
     for ( j = 0; j < 5; ++j )
     {
       if ( town->garrison.id[j] == -1 || town->garrison.id[j] == creature_id )
         canBuy = 1;
     }
     if ( canBuy )
     {
       creatures_to_buy = AI_getCreaturesNumberToBuyInTown(town, iTier);
       if ( creatures_to_buy > 0 )
       {
         AI_get_value_of_buying_creatures(this, town, creature_id, v5, creatures_to_buy, &value_of_buying);
         BuyingRV = (RandInt(1, 10) + 90) * value_of_buying / 100.0;
         if ( BuyingRV > max_value )
         {
           tier = iTier;
           result = value_of_buying;
           max_value = BuyingRV;
           num = creatures_to_buy;
         }
       }
     }
   }
 }
 action->town = town;
 action->type = 2;
 action->id = tier;
 action->num = num;
 *value = result;
}


Even without any knowledge of C++ you can read it. This is how the H4 functions would look like after you've done with basic classes.

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


Honorable
Legendary Hero
Modding the Unmoddable
posted May 04, 2022 06:34 PM
Edited by NimoStar at 18:35, 04 May 2022.

You just learned of the API right now since you were asking... by the way, parts of this API were lifted directly from H3 API, just a "barebones version" according to RoseKavalier itself. So H4 API we have is mostly just a stripped down version of H3 API.

Anyways, my focus is on the designs points of the game. I can't do everything from scratch myself. I have already helped with lots of things like deciphering file formats for adventure objects and sprite lists and the import of new graphics, not to mention the hex edit of several locations in the exe. I have no experience in decompiling nor formal programming training.

What would be more efficient, that I acquire years of experience in decompiling code to have the H4 bases, or that someone that already has this experience to do it? Clearly it is more expedient and efficient that a competent programmer/hacker undertakes such a complex task instead of a total amateur... reverse engineering executables is no children's play.
____________
Never changing = never improving

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


Responsible
Supreme Hero
posted May 04, 2022 07:02 PM
Edited by AlexSpl at 19:07, 04 May 2022.

Yeah, I understand your concerns. I created my first IDA base back in 2007, I guess Of course, I was just a clueless man with computer science background, still I couldn't do much with it

The problem with H4 is in its fan-base. H3 is way more popular, thus we have more skilled people.

But, if it's an option for you personally and all H4 players, you might pay money for decompiling the code of H4. Even to the professional programmers (believe me, there are plenty of them which don't know anything of the game, but can be more effective than us, enthusiasts). I don't see any crime in that.

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Jump To: « Prev Thread . . . Next Thread »
Post New Poll    Post New Topic    Post New Reply

Page compiled in 0.0540 seconds