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? (started by Baronus in January 2016)
How to edit HotA? This Popular Thread is 128 pages long: 1 2 3 4 5 ... 30 60 90 120 ... 124 125 126 127 128 · «PREV / NEXT»
BigPig2
BigPig2


Known Hero
posted October 26, 2026 09:13 PM

The short answer is I dont understand these data structures.

 View Profile
purerogue3
purerogue3


Famous Hero
posted October 26, 2026 09:25 PM

the number of registers is limited - how about just trying them all, then the stack

the first thing i see in CastSpell is
mov     eax, [ebp+spellID]

so 50 push eax at 1A874B

 View Profile
BigPig2
BigPig2


Known Hero
posted October 26, 2026 09:48 PM

My understanding of asm is pretty shallow so Im not going to go into what I imagine this is but I see references to [ebp + 8] when functions nearby fetch the spell ID. I have tried to push that instead (and removing an INC edx further down to make space for it, that INC just adds 1 to the monster level for the purposes of comparison so its easy to track the consequences of removing it) but the game crashes when I try to cast any of the spells routed to the case.

I have tried eax too but I feel the check gets skipped, same if I select a number higher than the highest spell ID.

 View Profile
purerogue3
purerogue3


Famous Hero
posted October 26, 2026 10:50 PM

Can we just add a new case to the jumptable and go to free space?

 View Profile
BigPig2
BigPig2


Known Hero
posted October 27, 2026 02:09 PM

You likely can if you have the free space for it somewhere but thats not necessarily easier. And this switch case is very close to what were trying to achieve, its a bit of a shame not to explore this possibility first.

 View Profile
DarkAtom
DarkAtom


Known Hero
posted October 28, 2026 12:31 PM
Edited by DarkAtom at 12:45, 28 Oct 2026.

@BigPig2

From my understanding of your post, you replaced push 0x41 (6A 41) with push dword [ebp + 8] (FF 75 08) and shifted everything after it by one byte up until inc edx which you removed. Have you also adjusted the relative call offset? That might be the cause of the crash.

A cleaner way to do it, IMO, is to take advantage of the compiler inefficiency and replace mov ecx, [esi + 0x53C0] ; push ecx (8B 8E C0 53 00 00 ; 51) with push dword [esi + 0x53C0] (FF B6 C0 53 00 00) thus saving the byte you need without sacrificing inc edx and without moving any call instruction. Note that ecx is loaded immediately after (mov ecx, [ebp - 4]) so there is no need to preserve the value. It is purely a missed optimization on the compiler's part.

 View Profile
BigPig2
BigPig2


Known Hero
posted October 28, 2026 12:51 PM
Edited by BigPig2 at 14:28, 28 Oct 2026.

I have not adjusted the call offset, thanks for the tip! I will also have a look at your other suggestion as well and will report how it went.

update: The game doesnt crash but it appears to still be using water magic.

edit: to be clear, I edited 1A8740-B, changing:

8B 8E C0 53 00 00 51 8B 4D FC 6A 41 ->
FF B6 C0 53 00 00 8B 4D FC ff 75 08

 View Profile
DarkAtom
DarkAtom


Known Hero
posted October 28, 2026 02:46 PM

You mean the game uses the hero's mastery in Water Magic to determine the max level of creatures you can cast Blind/Berserk on?

 View Profile
BigPig2
BigPig2


Known Hero
posted October 28, 2026 03:00 PM

Yes. What I am trying to achieve is for this case to use current spell ID to check mastery (school of magic skill level) and Clone's SPtraits values to determine eligible target levels. I had assumed the push 41h instruction is where the get_spell_level function gets the spell ID from..

 View Profile
DarkAtom
DarkAtom


Known Hero
posted October 28, 2026 03:29 PM
Edited by DarkAtom at 15:32, 28 Oct 2026.

Can't reproduce, I tried in both SoD and HotA 1.8.1 and it's linked to Fire Magic for me (at least for Blind). Maybe you have Blind marked as a Water spell?

In both cases, the only patches I applied were:

1A8740: 8B 8E -> FF B6
1A8746: 51 8B 4D FC 6A 41 -> 8B 4D FC FF 75 08
1A8940: 06 -> 05

 View Profile
BigPig2
BigPig2


Known Hero
posted October 28, 2026 03:33 PM
Edited by BigPig2 at 15:55, 28 Oct 2026.

My bad! It does work! I had Clone attributes adjusted from testing without the INC before.. Thank you for your help!

edit: And if Im not wrong (I might though), Hypnotizes case can be opened up to use by other spells by editing:

1A8673-E:

(edit2 to clean up incorrect source)

8B 96 C0 53 00 00 8B 5D FC 52 6A 3C ->
8B 5D FC FF B6 C0 53 00 00 FF 75 08

which changes:

mov    edx,DWORD PTR [esi+0x53c0]
mov    ebx,DWORD PTR [ebp-0x4]
push   edx
push   0x3c

into:

mov    ebx,DWORD PTR [ebp-0x4]
push   DWORD PTR [esi+0x53c0]
push   DWORD PTR [ebp+8]

I believe edx gets overwritten before any instruction attempts to read from it?

 View Profile
DarkAtom
DarkAtom


Known Hero
posted October 28, 2026 04:00 PM

Should be, because get_spell_level (0x4E52F0) is thiscall (and thus edx is caller-saved).

 View Profile
purerogue3
purerogue3


Famous Hero
posted October 28, 2026 04:14 PM

my hero with bas fire magic only, berserk

only 06->05: uses non water
rest of: uses base water

 View Profile
BigPig2
BigPig2


Known Hero
posted October 28, 2026 04:18 PM

Thats a bit cryptic.. you mean you have a hero with only fire magic skill at basic level and if you only edit the switch value your berserk has the power of unskilled clone and if you apply the patch above it has the power of basic clone? That would be what we are aiming for, I believe?

 View Profile
purerogue3
purerogue3


Famous Hero
posted October 28, 2026 04:21 PM

Yes, except we want it to check for fire magic skill, not water right?

 View Profile
BigPig2
BigPig2


Known Hero
posted October 28, 2026 04:25 PM

Yes, and isnt that what you are describing you experience after applying the patch above? The first one, the one I posted further down is for using Hypnotize's case 04.

 View Profile
purerogue3
purerogue3


Famous Hero
posted October 28, 2026 04:28 PM

it checks water, but berserk/blind are fire spells?
why do we want it to check water?

 View Profile
BigPig2
BigPig2


Known Hero
posted October 28, 2026 04:30 PM

Im not sure I understand, does the hero you are testing have water magic or only basic level fire magic?

 View Profile
purerogue3
purerogue3


Famous Hero
posted October 28, 2026 04:32 PM

only bas fire, no water magic

i think the school magic is loaded somewhere before this function, which seems to only check level .. but we are in the wrong school

 View Profile
BigPig2
BigPig2


Known Hero
posted October 28, 2026 04:37 PM
Edited by BigPig2 at 16:40, 28 Oct 2026.

Hold on, your hero doesnt have water magic, only basic fire magic. And your berserk spell does the check as if for basic water magic, a skill your hero doesnt have?

edit:

Does your Clone differentiate between no skill and basic skill? It doesnt by default. It might be better to check with advanced Fire magic or set different values to Clone on no skill vs basic.

 View Profile
Jump To: « Prev Thread . . . Next Thread » This Popular Thread is 128 pages long: 1 2 3 4 5 ... 30 60 90 120 ... 124 125 126 127 128 · «PREV / NEXT»
Post New Poll   Post New Topic   Post New Reply

Page compiled in 0.0890 seconds