|
|
BigPig2

 
  
Known Hero
|
posted October 26, 2026 09:13 PM |
|
|
|
The short answer is I dont understand these data structures.
|
|
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
|
|
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.
|
|
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?
|
|
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.
|
|
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.
|
|
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
|
|
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?
|
|
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..
|
|
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
|
|
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?
|
|
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).
|
|
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
|
|
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?
|
|
purerogue3

 
   
Famous Hero
|
posted October 28, 2026 04:21 PM |
|
|
Yes, except we want it to check for fire magic skill, not water right?
|
|
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.
|
|
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?
|
|
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?
|
|
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
|
|
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.
|
|
|
|