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 3.5 - WoG and Beyond > Thread: How to edit HotA?
Thread: How to edit HotA? This Popular Thread is 118 pages long: 1 ... 6 7 8 9 10 ... 20 30 40 50 60 70 80 90 100 110 118 · «PREV / NEXT»
OxFEA
OxFEA


Promising
Famous Hero
feanor on DF2.ru
posted October 11, 2016 08:45 AM

Movement.txt

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


Legendary Hero
Heroes is love, Heroes is life
posted October 11, 2016 09:38 AM

Thank you.

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


Hired Hero
posted October 11, 2016 10:02 AM
Edited by tax_375 at 10:33, 11 Oct 2016.

Since I was unable to send you a PM. OxFEA do you know how to change back Ranloo to Galthran in Hota? As I examined in the hota.exe file Galthran bytes are unchanged compared to H3 Complete.exe so this trigger has to be somewhere else? This questions is still a blind spot

Sorry for asking this again and again I just don't want to give up hope, and also all other questions I had, are already answered.

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


Promising
Famous Hero
feanor on DF2.ru
posted October 11, 2016 05:46 PM

Most simple way, I think, find Ranloo data at Hota.dat and replace them with Galthran's. And portait, of course.
No, I don't know where are they exactly and don't plan to search.

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


Hired Hero
posted October 11, 2016 06:42 PM
Edited by tax_375 at 18:44, 11 Oct 2016.

Thank you for the info! Good Idea.

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

Hero of Order
Part of the furniture
posted October 14, 2016 09:40 PM
Edited by Maurice at 01:33, 15 Oct 2016.

Having fun with exploring the H3Hota.exe with a decompilation as well as a disassembly . Already learned a few nice things about how the game works. Currently mostly interested in how it handles spell casting, most notably how the game determines how much damage to deal, based on Spell Power, or how the numbers from the various experise levels affect it.

For instance, I've found the code that handles the Acid Breath secondary attack. The H3 website here says that there's a 30% chance, but it's actually only 20% chance to trigger - and besides, the Dragons' extra Acid damage actually need to do at least 2 points of damage for it to trigger, too.

The game first randomizes a number between 1 and 100 and compares it to 20. If the value is below this, the extra Acid damage will trigger. The game will then determine a random damage amount between the minimum damage and maximum damage of the Dragon (which is always 50, the Rust Dragon doesn't have a damage range - but keep in mind that if you edit or somehow manipulate the damage of the Rust Dragon, you'll also change the damage amount of the possible extra Acid damage) and multiply this random value with the number of Dragons in the stack. By changing the base damage of the Rust Dragon, you also affect the Acid Breath damage; it needs to do at least 2 damage to be applied.

For people feeling like playing around with the random chance on this one:
0x000411CEh is 64, this is the upper bound it uses for the randomizer
0x000411D3h is 01, this is the lower bound it uses for the randomizer
0x000411DEh is 14, this is the value it compares the random value against, to see if it should trigger
Note that these are HEX values; in DEC, they're 100, 1 and 20 respectively.

Similar entries exist in the same subroutine for the Vampire Lord Life Drain, the Mighty Gorgon Death Stare, the Thunderbird Lightning Bolt (which differs from the standard Lightning Bolt, by the way) and the Serpent and Dragon Fly's Dispel Beneficial Spells and Weakness. These are creatures that have a post-melee-attack Spell cast ability. I yet have to find the subroutine for the other creatures that have a spell-like effect, like the Stone Gaze and Paralysing/Rooting abilities.

The randomizer works interesting too. Basically, it takes two parameters as lower and upper bound, between which it will find a value. If the lower bound is higher than the upper bound, the returned value is the lower bound. If the lower bound and upper bound are identical, the upper bound is the returned value. The interesting case is of course the one where the lower bound is below the upper bound; in that case:
result = lower bound + rand() MOD (upper bound - lower bound + 1)
The function rand() is a random value derived from a number of system parameters at the time of calling (and I admit I couldn't quite follow the build-up as a result), which is then divided by the (upper bound - lower bound + 1) value, of which the remainder is then taken to be added to the lower bound as result of the random determination.

Update: The Eagle Eye skill simply makes no sense in how they set that one up. Rather than using a straight multiplier in integer format, they are actually messing around with floating point values.

The subroutine that determines the Eagle Eye skill power (and thereby chance to learn a spell) first gets the skill multiplier from the Hero, based on his skill level with Eagle Eye. The 40%/50%/60% are floating point values, stored at address 0x0023EA2Ch and onward, as detailed on the opening page. Anyway, the subroutine then checks to see if the Hero is specialised in Eagle Eye. If so, it updates the Eagle Eye power as follows:
Eagle Eye Power = (Hero Level * 0.05000000074505806 + 1.0) * Eagle Eye Power

Then it checks to see if the Hero has any Eagle Eye enhancing Artifacts equipped. The code here actually checks all 19 Paper Doll slots where the Hero can have an Artifact equipped, even slots that aren't applicable for such an Artifact, like the War Machine slots. It loops through them 3 times, once for each of the 3 possible Artifacts with an Eagle Eye skill bonus.

It performs the following summations if it finds any:
Eagle Eye Power = Eagle Eye Power + 0.05000000074505806 for the Bird of Perception
Eagle Eye Power = Eagle Eye Power + 0.1000000014901161 for the Stoic Watchman
Eagle Eye Power = Eagle Eye Power + 0.1500000059604645 for the Emblem of Cognizance

If the total Eagle Eye Power is larger than 1, it gets rounded down a very slight bit (for instance, 1.15 is reduced to 1.149999855...).

It's then multiplied with a Floating Point representation of the number 100, before finally being converted into an integer.

Then the game determines a random number between 1 and 100 and compares it to that integer.

I fail to see the difference in outcome if you'd simply take Level * 5 and add 5 for the Bird, 10 for the Watchman and 15 for the Emblem, topping it off at 100 if it exceeds that value. Much less convoluted, if you'd ask me.

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


Hired Hero
posted October 15, 2016 02:04 PM

Just wow, awesome exploration!

But tell me pls what knowledge is necessary to understand for example this code? Some programming skills?

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


Promising
Famous Hero
feanor on DF2.ru
posted October 15, 2016 02:11 PM

Maurice said:

I fail to see the difference in outcome if you'd simply take Level * 5 and add 5 for the Bird, 10 for the Watchman and 15 for the Emblem, topping it off at 100 if it exceeds that value. Much less convoluted, if you'd ask me.


Less transparency of the source code.
Developers didn't care about diassembly/decompilation readabilty usually)

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

Hero of Order
Part of the furniture
posted October 15, 2016 02:57 PM
Edited by Maurice at 22:33, 15 Oct 2016.

OxFEA said:
Less transparency of the source code.
Developers didn't care about diassembly/decompilation readabilty usually)


Heh, true. After turning off my PC last night, it dawned on me that the numbers I am seeing (like 0.05000000074505806) are actually the result of the floating point number 0.05 getting compiled, then assembled, then disassembled and finally decompiled again. Each step introduces an approximation, but the end result is somewhat off from what it started out as.

Also, I realised based on this code:

 if ( v15 > 1.0 )
   LODWORD(v15) = 1065353216;

that the variable v15 is actually a 32-bit floating point number, instead of 64-bit, which I originally assumed. After all, the LODWORD seemed to imply there's a HIDWORD part too, but there isn't. Inserting 1065353216 into a 32-bit floating point converter yields the value 1.0. As such, the value gets capped at 1.0 and not rounded down slightly as would be the case for a 64-bit floating point number.

Update: Faerie Dragons!

From address 0x0023B850h through to 0x0023B897h is the following byte string:
10 00 00 00 16 00 00 00 11 00 00 00 16 00 00 00 15 00 00 00 15 00 00 00 0F 00 00 00 0A 00 00 00 14 00 00 00 0A 00 00 00 13 00 00 00 05 00 00 00 17 00 00 00 05 00 00 00 16 00 00 00 05 00 00 00 FF FF FF FF 00 00 00 00

Separating these into sets of 8 bytes each, they tell the game which spells the Faerie Dragons can cast and what the chances are for each of them:
10 00 00 00 16 00 00 00
11 00 00 00 16 00 00 00
15 00 00 00 15 00 00 00
0F 00 00 00 0A 00 00 00
14 00 00 00 0A 00 00 00
13 00 00 00 05 00 00 00
17 00 00 00 05 00 00 00
16 00 00 00 05 00 00 00
FF FF FF FF 00 00 00 00

The first number in this column is the Spell ID of the spell they can cast. The second number is the chance it will cast that spell. Translating the HEX values to decimals and translating the spell ID's to spells, we get the following list:

Ice Bolt - 22% chance
Lightning Bolt - 22% chance
Fireball - 21 % chance
Magic Arrow - 10% chance
Frost Ring - 10% chance
Chain Lightning - 5% chance
Meteor Shower - 5% chance
Inferno - 5% chance

What the game does is that it determines a random value based on system parameters. The random value is divided by the total sum of the chances (which is 100; they're essentially weights instead of percentages) and the MOD value is taken as the pointer to the specific spell, as it falls somewhere in the range 0 - 99.

The final entry of FF FF FF FF 00 00 00 00 is essentially a stopper for the loop that adds all the chances together. As soon as it encounters a spell ID value smaller than zero, it stops - and FF FF FF FF just happens to be the representation of -1.

Update 2:
0x001A01DEh has the value 03. It's the skill level to use for spells when the fight takes place on Magic Plains (0 = Unskilled, 1 = Basic, 2 = Advanced, 3 = Expert).

Angelic Alliance spell cast
0x00064FD8 and 0x00064FEFh: holds the value 30h, which is 48, the spell ID for Prayer. The first address checks to see if the effect is already present, the second is part of the string that auto-casts it because the Hero wields the Angelic Alliance.
0x00064FE5h: value 0Ah, or 10; it's the Spell Power with with Prayer is cast (the only influence of Spell Power is the duration of the Prayer spell).
0x00064FE7h: value 03h, or 3; it's the level with which the spell is cast (3 is Expert).

Armor of the Damned spells cast
0x00065019h and 0x00065030h: holds the value 36h, which is 54, the spell ID for Slow. Like with Prayer above.
0x00065026h: holds the value 32h, which is 50, the Spell Power with which it is cast.
0x00065028h: holds the value 03h, or 3: it's the level with which the spell is cast.

0x00065046h and 0x0006505Dh: holds the value 2Ah, which is 42, the spell ID for Curse. Like with Prayer above.
0x00065053h: holds the value 32h, which is 50, the Spell Power with which it is cast.
0x00065055h: holds the value 03h, or 3: it's the level with which the spell is cast.

0x00065073h and 0x0006508Ah: holds the value 2Dh, which is 45, the spell ID for Weakness. Like with Prayer above.
0x00065080h: holds the value 32h, which is 50, the Spell Power with which it is cast.
0x00065082h: holds the value 03h, or 3: it's the level with which the spell is cast.

0x000650A0h and 0x000650B7h: holds the value 2Dh, which is 45, the spell ID for Misfortune. Like with Prayer above.
0x000650ADh: holds the value 32h, which is 50, the Spell Power with which it is cast.
0x000650AFh: holds the value 03h, or 3: it's the level with which the spell is cast.

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

Hero of Order
Part of the furniture
posted October 16, 2016 01:51 AM
Edited by Maurice at 15:11, 16 Oct 2016.

Making a separate post about this one, as it's somewhat elaborate, but very informative if I say so. I've mapped out the subroutine that handles the offering of new skills as Heroes level up.

Basically, it steps through a few logical considerations.

First it checks to see if the Hero has an existing skill to be upgraded. If so, this will be offered as first skill. If not, it will offer a new skill to add to the Hero's repertoire.

Then it checks to see if the Hero can be offered a new skill (excluding one that was possibly found during the first check). If so, this new skill will be offered as second skill. If not, it will offer to upgrade an existing skill.

If no valid skills can be found at any of those steps, that choice won't be offered to the player.

To determine which skill it is going to offer, it makes a number of considerations. The first one is whether or not the Hero has to be offered the Wisdom skill - either as new skill or as upgrade. The game keeps track of the moment it last offered the Wisdom skill to each Hero and will compare this to the current level of the Hero. To make that comparison, it uses these values:
Might Heroes: Wisdom level gap = 6
Magic Heroes: Wisdom level gap = 3
Two notes
Note 1: Elementalists, the Magic Heroes of Conflux, fall in the Might Hero category; not sure if this was intended, or simply an oversight when they added the Conflux Magic class to the game.
Note 2: All Magic Heroes start with Wisdom, except for Necromancers.

If the previous level Wisdom was offered plus the level gap is equal to the Hero's current level, while Wisdom isn't capped at maximum level and not all 8 Skill slots have been occupied, Wisdom will be offered to the Hero. If the Hero doesn't yet have Wisdom, while he also has an existing skill he can upgrade, Wisdom will be offered in the second Skill slot. Otherwise, it will appear in the first Skill slot.

Something similar applies to Magic School Skills: Fire Magic, Air Magic, Water Magic and Earth Magic. Like with Wisdom, the game keeps track of when it last offered a Magic School to acquire or upgrade. Like with Wisdom, the Magic Schools also have a gap:
Might Heroes: Magic School level gap = 4
Magic Heroes: Magic School level gap = 3
Note: the same issue for Elementalists as with the Wisdom skill also applies here: they follow the Might Hero gap.

Because there are four Magic Schools as opposed to just one Wisdom Skill, the game determines which Magic School to offer as well. It only considers Magic Schools that haven't yet been maxed at Expert. If the Hero can upgrade one or more Magic Schools, only those will be considered. The game will randomly pick one of the available ones for upgrade and offer it, with equal chance across those Schools. This upgrade will then appear as the first Skill to upgrade.

If the Hero has no Magic Schools to upgrade but still Skill slots available, the game will consider the Magic Schools the Hero doesn't yet have and add up the chances for each of those, derived from the HCTRAITS.TXT file. It will then randomly pick one of those, based on those weights, and offer it as a new skill. If the Hero also has another skill to upgrade, or gets the choice to take Wisdom as a new Skill, the Magic School will be offered as the second Skill; otherwise, it appears as a new skill in the first Skill slot.

Table derived from the HCTRAITS.TXT file as it exists in the Heroes3 Complete installation that I have:


Class        Fire Air Water Earth
Knight        1    3    4    2
Cleric        2    4    4    3
Ranger        0    1    3    3
Druid         1    2    4    4
Alchemist     1    4    2    3
Wizard        2    6    3    3
Demoniac      4    2    1    3
Heretic       5    3    2    4
Death Knight  1    2    3    4
Necromancer   2    3    3    8
Overlord      2    1    0    3
Warlock       5    2    2    5
Barbarian     2    3    0    3
Battle Mage   3    3    3    3
Beastmaster   0    1    2    3
Witch         3    3    3    3
Planeswalker  3    2    2    3
Elementalist  6    6    6    6


After determining whether or not the game has to forcibly offer the Wisdom Skill and/or one of the four Magic School Skills, it will consider the available set of Skills to offer (note that this set includes Wisdom and the four Magic Schools as well). It will simply sum across all the available Skill weights from the HCTRAITS.TXT file, based on the class of the Hero getting its level-up, excluding skills that are forbidden on the map*. This is done both when offering a new Skill (adding up the weights of available but not yet acquired Skills) as well as when upgrading an existing Skill (adding up the weights of acquired Skills that haven't yet been maximised).

* = during the "Birth of a Barbarian" campaign from Shadow of Death, the game features Yog who has discarded all Magic. Throughout that campaign, all Magic Skills are unavailable to Yog (and only Yog, other Heroes aren't affected): Wisdom, Intelligence, Mysticism, the four Magic Schools, Sorcery, Scholar, Eagle Eye and Necromancy.

If the Hero somehow ends up with a Skill for which the chances to acquire them through a natural level up (like Necromancy being offered in a Witch Hut to a non-Necropolis Hero), the odds to get those as an upgrade are considered with a weight of 1. They will not appear as a new offer, of course.

Interesting addresses and their values
0x000DAFE6h: 01h, refers to the Cleric class
0x000DAFEBh: 03h, refers to the Druid class
0x000DAFF0h: 05h, refers to the Wizard class
0x000DAFF5h: 07h, refers to the Heretic class
0x000DAFFAh: 09h, refers to the Necromancer class
0x000DAFFFh: 0Bh, refers to the Warlock class
0x000DB004h: 0Dh, refers to the Battle Mage class
0x000DB009h: 0Eh, refers to the Witch class
These values are used to determine whether to use the gap values for a Might Hero or a Magic Hero. If the Hero in question has one of the classes in the above list, it will use the Magic gap values; all other Heroes will use the Might gap values. By changing these values, you can manipulate which classes use which set of gap values.

0x000DB00Dh: 06h, the gap value for the Wisdom skill of Might Hero classes
0x000DB012h: 04h, the gap value for the Magic School skills of Might Hero classes
0x000DB019h: 03h, the gap value for both the Wisdom and the Magic Schools of Magic Hero classes
Unfortunately, due to the way the assembly code works, the gap value for Magic Heroes isn't split in two separate values. After assigning the Wisdom gap value, the Magic School gap value is simply copied from that one. By manipulating these values, you can determine how fast the game will resort to a mandatory skill offer for two sets of classes.

0x000DB034h: D0h, is 208 in decimals. It's a pointer to the byte string of skills the Hero has. It starts at byte 201 in the Hero array, making 208 the 8th entry; with skill ID's starting at 0, the 8th entry is skill ID 7, which is Wisdom. This value is used to check and see if the Hero has the Wisdom skill and if so, what the Skill level is. By changing this value, you can have the game check for another Skill instead. You should make sure that when you do, you also change the following two entries:
0x000DB046h: 07h, a direct Skill ID, which is Wisdom. This value is used to determine if the first skill being offered is already the Wisdom skill.
0x000DB04Eh: 07h, direct reference to the Skill ID for Wisdom. This value is used to check if the skill is actually forbidden on the map at large.
0x000DB056h: 07h, again a direct reference to the skill ID for Wisdom. This value is returned as the mandatory offer on level up, if all conditions apply.

By changing the values at the above addresses to another Skill ID reference, you can have the game treat another skill as a mandatory one, instead of Wisdom.

Like with Wisdom, the game also has references to the Magic Schools when it considers mandatory skill offers.
0x000DB074h: 0Eh, a reference to the Skill ID for Fire Magic
0x000DB07Dh: 0Fh, a reference to the skill ID for Air Magic
0x000DB086h: 10h, a reference to the skill ID for Water Magic
0x000DB08Fh: 11h, a reference to the skill ID for Earth Magic
The game uses these values to check if any of these 4 are already being offered as a new skill or skill to upgrade in the other skill offer slot. If so, it will skip offering it as a mandatory skill offer in the second skill slot (note that they can still appear as a new skill or upgrade skill as a non-mandatory offer). By manipulating these values, you can have the game consider other Skills as potential mandatory ones. You should then also look at the next section and change the data string it points to, accordingly:

0x000DB099h to 0x000DB09Bh: BC 9C 67. Rewriting it by mirroring the bytes, one gets 679CBCh. This is a reference to the address 279CBCh, which holds 16 bytes in total: 0E 00 00 00 0F 00 00 00 10 00 00 00 11 00 00 00. The non-zero bytes are direct references to spell ID's, as is obvious by checking the values in the table above. If the game finds it has to make a mandatory offer of a Magic School Skill, it will use this data entry to check which Skills it has to look up in the HCTRAITS.TXT file for the Hero in question. It will sum the weights for the Skills in question if it is a new Skill being offered and randomly pick one of those based on their individual weights. For determining which Skill to offer if an upgrade to an existing one is available, it considers each viable Skill with a weight of 1.

0x000DB178h: 01h
0x000DB1D7h: 01h
The weight the game has to use for Skills of the Hero that the Hero has no chance of getting through natural level-ups, but the Hero still has anyway (like Necromancy for non-Necropolis Heroes, who got it through Witch Huts or similar). The first of these two is used to determine the maximum number to use in the randomizer, while it adds the weights for all viable Skills. The second is used to determine which Skill the random number is actually pointing at. Note that if the values at these addresses aren't identical, it can give weird results on level up and maybe even crash the game! By manipulating these two values, you can change the weight with which the game considers "forbidden" Skills that the Hero somehow has. Note that the game will still skip Skills that are forbidden across the map.

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


Promising
Famous Hero
feanor on DF2.ru
posted October 16, 2016 03:38 PM

Maurice said:

Note 1: Elementalists, the Magic Heroes of Conflux, fall in the Might Hero category; not sure if this was intended, or simply an oversight when they added the Conflux Magic class to the game.

<...>

Interesting addresses and their values
0x000DAFE6h: 01h, refers to the Cleric class
0x000DAFEBh: 03h, refers to the Druid class
0x000DAFF0h: 05h, refers to the Wizard class
0x000DAFF5h: 07h, refers to the Heretic class
0x000DAFFAh: 09h, refers to the Necromancer class
0x000DAFFFh: 0Bh, refers to the Warlock class
0x000DB004h: 0Dh, refers to the Battle Mage class
0x000DB009h: 0Eh, refers to the Witch class
These values are used to determine whether to use the gap values for a Might Hero or a Magic Hero. If the Hero in question has one of the classes in the above list, it will use the Magic gap values; all other Heroes will use the Might gap values. By changing these values, you can manipulate which classes use which set of gap values.

If we say about HotA then bug with Elementalists was fixed (also for Navigator's purposes, yes). At the game start hook with additional check will be placed at mem:004DAFE4.

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

Hero of Order
Part of the furniture
posted October 16, 2016 04:47 PM
Edited by Maurice at 18:10, 16 Oct 2016.

OxFEA said:
If we say about HotA then bug with Elementalists was fixed (also for Navigator's purposes, yes). At the game start hook with additional check will be placed at mem:004DAFE4.


That's good to know! I haven't yet explored the HotA hook, though, so thanks for that pointer . Even though I am currently exploring the H3HotA.exe, I am still rummaging through the H3 SoD section, so whatever HotA then changes to that is something I haven't explored yet.

And by the way, if I haven't said so already, thanks for providing the download of the Hex Rays decompiled Heroes 3 exe. It's been a tremendous help for me to understand just how the game works. The translated variables and data structures within that decompilation enhance that even further. I did see some sections weren't properly decompiled, unfortunately. Next to that, I am running IDA Pro 5.0, the freeware version, which had very little problems disassembling the H3HotA.exe file, but it fails to properly recognize jump tables, messing up the function buildup . Still, I think I got it mostly cleaned up by manually telling IDA to build the missing functions. Comparing the disassembled code with the decompiled code has allowed me to trace stuff pretty nice .

That being said, a bit more info:

0x00047CE1h: 06h, the Spell Power with which Master Genies cast their Spells.
0x00047CE3h: 02h, the School Skill Level with which they cast it (02 is Advanced Level).
The game checks the target for the Master Genie's spell, then loops through all Combat Spells and picks one spell at random (all at a weight of 1) out of the spells available to be cast on that target.

0x00047F66h: 03h, the Spell Power with which Enchanters cast their Spells.
0x00047F68h: 03h, the School Skill Level with which they cast it (03 is Expert Level).

Like with the Faerie Dragons, Enchanters also have a data range within the .exe which determines which spells they can cast and at what weight for each. Starting from address 0x002608B8h, the following byte string exists:
35 00 00 00 0F 00 00 00 1C 00 00 00 0A 00 00 00 36 00 00 00 0A 00 00 00 2E 00 00 00 0F 00 00 00 2B 00 00 00 05 00 00 00 29 00 00 00 0F 00 00 00 25 00 00 00 0A 00 00 00 2D 00 00 00 04 00 00 00 FF FF FF FF

Separating them, we get:
35 00 00 00 0F 00 00 00
1C 00 00 00 0A 00 00 00
36 00 00 00 0A 00 00 00
2E 00 00 00 0F 00 00 00
2B 00 00 00 05 00 00 00
29 00 00 00 0F 00 00 00
25 00 00 00 0A 00 00 00
2D 00 00 00 04 00 00 00
FF FF FF FF

The FF FF FF FF entry acts as a stopper when the game is adding the various weights together. The total weight sum is 84 in this case, which means that the chances for each Spell aren't the values as listed above, but rather as (Spell weight)*100/84. Translating the above spell ID's and calculating the chances, we get:
Haste: 17.86% chance
Air Shield: 11.90% chance
Slow: 11.90% chance
Stone Skin: 17.86% chance
Bloodlust: 5.95% chance
Bless: 17.86% chance
Cure: 11.90% chance
Weakness: 4.76% chance
By manipulating the Spell ID's and the weights, you can change what the Enchanters are casting.

Update:
Some more spell casting info on creatures.

Faerie Dragons
Spell Power is 5 * the number of Dragons in the stack. Unfortunately, the number '5' isn't embedded as a value, but rather handled through an OPCODE. At address 0x00048370h - 0x00048372h, you'll find the OPCODE 8D 04 80. This tells the CPU to fill the register EAX with the value [ EAX + EAX * 4 ], essentially multiplying the value in the register by 5. As the multiplier of 4 is implicit through the OPCODE, it can't be manipulated straight away. However, two other options exist: 8D0440 and 8D04C0. The first OPCODE does [ EAX + EAX * 2 ], essentially multiplying stack size by 3. The second does [ EAX + EAX * 8 ], essentially multiplying stack size by 9.
0x00048375h: 02h, the School Skill at which the spell is cast; 2 is Advanced Skill.

The four upgraded Elementals can cast the Protection spell belonging to their Element. They have a Spell Power and School Level defined as well.

Storm Elementals:
0x00048388h: 06h is the Spell Power
0x0004838Ah: 02h is the Spell School Level
0x00048391h: 1Eh is the ID for the spell in question. Value 1Eh is 30, the ID for Protection from Air.

Ice Elementals:
0x00048398h: 06h is the Spell Power
0x0004839Ah: 02h is the Spell School Level
0x000483A1h: 20h is the ID for the spell in question. Value 20h is 32, the ID for Protection from Water.

Energy Elementals:
0x000483A8h: 06h is the Spell Power
0x000483AAh: 02h is the Spell School Level
0x000483B1h: 1Fh is the ID for the spell in question. Value 1Fh is 31, the ID for Protection from Fire.

Magma Elementals:
0x000483B8h: 06h is the Spell Power
0x000483BAh: 02h is the Spell School Level
0x000483C1h: 21h is the ID for the spell in question. Value 21h is 33, the ID for Protection from Earth.

Something similar exists for Ogre Mages:
0x000483C8h: 06h is the Spell Power
0x000483CAh: 02h is the Spell School Level
0x000483D1h: 2Bh is the ID for the spell in question. Value 2Bh is 43, the ID for Bloodlust.

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


Legendary Hero
Heroes is love, Heroes is life
posted October 19, 2016 09:19 AM

So I was thinking about hero specialities and one them most in need of change is Melodia with luck AND fortune, so I managed to change Fortune to Precision, probably won't be precision permanently, but just as a test.
I also know where to change the text of the speciality, the only thing missing is the icon for the speciality on the hero interface, does anyone know where to change those?

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

Hero of Order
Part of the furniture
posted October 19, 2016 06:25 PM
Edited by Maurice at 18:41, 19 Oct 2016.

phoenix4ever said:
I also know where to change the text of the speciality, the only thing missing is the icon for the speciality on the hero interface, does anyone know where to change those?


That's hard-coded in the .exe file. Change the following:

0x2788ACh: 33h -> 2Ch

Spell 33h (51) is the Fortune Spell. Spell 2Ch (44) is the Precision Spell. Note that this only changes the specialty for Melodia, no other Heroes.

Edit: I just tried to verify this ingame myself, but the change didn't take hold, at least not for the icon ... I think it did change the specialty though, for all purposes ingame.

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


Legendary Hero
Heroes is love, Heroes is life
posted October 19, 2016 09:04 PM

Thanks Maurice, but as I said above I did manage to change her speciality, the only thing missing is the icon. I guess I don't need to change it, but it would be nice if I could.

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


Promising
Famous Hero
feanor on DF2.ru
posted October 20, 2016 09:01 AM
Edited by OxFEA at 09:26, 20 Oct 2016.

Quote:
the only thing missing is the icon.

UN**.def
Why not to review all the defs and txts in lod once?

Maurice said:
That's good to know! I haven't yet explored the HotA hook, though, so thanks for that pointer . Even though I am currently exploring the H3HotA.exe, I am still rummaging through the H3 SoD section, so whatever HotA then changes to that is something I haven't explored yet.

And by the way, if I haven't said so already, thanks for providing the download of the Hex Rays decompiled Heroes 3 exe. It's been a tremendous help for me to understand just how the game works. The translated variables and data structures within that decompilation enhance that even further. I did see some sections weren't properly decompiled, unfortunately. Next to that, I am running IDA Pro 5.0, the freeware version, which had very little problems disassembling the H3HotA.exe file, but it fails to properly recognize jump tables, messing up the function buildup . Still, I think I got it mostly cleaned up by manually telling IDA to build the missing functions. Comparing the disassembled code with the decompiled code has allowed me to trace stuff pretty nice .


I'm using OllyDbg for disassembling.
IDA is so huge, and most of its functions aren't necessary for Heroes' modding. And runtime debugging (that is totally necessary when we speak about self-modifying code, like in WoG or HotA) in IDA isn't very impressive, I think.

Last available IDA+Hex-rays (6.4, afaik) has no problems with jump tables, but it has no progress in decomping lost for "stack frame" or "overlapping variables" , alas.

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

Hero of Order
Part of the furniture
posted October 20, 2016 10:44 AM

phoenix4ever said:
Thanks Maurice, but as I said above I did manage to change her speciality, the only thing missing is the icon. I guess I don't need to change it, but it would be nice if I could.


Yeah, I realised later that you already did what I did ... I wasn't the sharpest tool in the shed last night, so to speak .

OxFEA said:
Quote:
the only thing missing is the icon.

UN**.def
Why not to review all the defs and txts in lod once?


You mean to say that the icon used for the Hero specialisation is actually defined per Hero, instead of being a reference to the .def belonging to the specialty in question? As it is, the exe table has both the type and ID for the specialty for each Hero.

0xFEA said:
Last available IDA+Hex-rays (6.4, afaik) has no problems with jump tables, but it has no progress in decomping lost for "stack frame" or "overlapping variables" , alas.



I started using IDA last year, while decompiling X-Com2: Terror From The Deep (I was mainly interested in the algorithm that built the various combat maps, as I wanted to change a few of those). Back then, IDA 6.* was not freeware, so I decided to use IDA 5 instead.
____________
The last Reasonable Steward of Good Game Design and a Responsible Hero of HC. - Verriker

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


Promising
Famous Hero
feanor on DF2.ru
posted October 20, 2016 12:28 PM

Maurice said:

You mean to say that the icon used for the Hero specialisation is actually defined per Hero, instead of being a reference to the .def belonging to the specialty in question? As it is, the exe table has both the type and ID for the specialty for each Hero.

Yes, one cadre - one hero.
Btw, WoG implements its own mechanic over it, for dynamic changes, but in HotA it's unchanged, afaik.

Maurice said:
Back then, IDA 6.* was not freeware, so I decided to use IDA 5 instead.

Oh, sorry.
I'm Russian, so never had such problems.

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


Legendary Hero
Heroes is love, Heroes is life
posted October 20, 2016 10:28 PM

Hi guys. I think I have located the icons for the heroes specialities, they are located in H3sprite.lod H3ab_spr.lod and HotA.lod the files are called UN32.def and UN44.def, I don't know what the difference is between the two files, they both seem to contain all heroes and HotA.lod also contains all Cove heroes specialities.
I don't know how to edit those files however...    

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


Promising
Famous Hero
feanor on DF2.ru
posted October 20, 2016 10:50 PM

phoenix4ever said:
I don't know what the difference is between the two files, they both seem to contain all heroes and HotA.lod also contains all Cove heroes specialities.

Size.
No, really.

44px def for hero screen, 32 - for kingdom overview

 Send Instant Message | Send E-Mail | View Profile | Quote Reply | Link
Jump To: Next Thread » This Popular Thread is 118 pages long: 1 ... 6 7 8 9 10 ... 20 30 40 50 60 70 80 90 100 110 118 · «PREV / NEXT»
Post New Poll    Post New Topic    Post New Reply

Page compiled in 0.1254 seconds