[1.10] Restoring Hireling Running animation

This forum is for discussions on how to edit what can not be edited through the txt files, needless to say this isn't about battle net hacking.

Moderators: Nefarius, Havvoric

Post Reply
User avatar
Ogodei
Senior Moderator
Angel
Posts: 516
Joined: Thu Mar 10, 2016 8:31 am
Italy

Hand-picked

[1.10] Restoring Hireling Running animation

Post by Ogodei » Sun Aug 21, 2016 6:42 pm

[ Edit \ Overhaul Nov 29 2023 ]

Hey there, it's been a while.

During a conversation on our discord server I thought that I could do this fix way better. The previous work was more like a guess work as I was completely new to code edit and also eager to share info, guides and useful features with the community.

So, here I am " fixing my fix " so to speak, in order for it to only affect the Hirelings (i.e units that use the 'hireable' AI).

Let's start:

Our work begins at D2Game.0xB414F: we are inside the Hireable's AI code, and there are two functions to notice :

Code: Select all

07F8414F  8B4C24 40        mov ecx,dword ptr ss:[esp+40]
07F84153  6A 64               push 64   ; 100 extra speed
07F84155  51                    push ecx
07F84156  33D2                xor edx,edx
07F84158  8BCE                mov ecx,esi ; monster
07F84169  E8 32C3FEFF     call d2game.7F704A0  ; call AI_SetSpeedEx
07F8415F  8BCF                mov ecx,edi
07F84161  8BD6                mov edx,esi
07F84163  8B4424 38        mov eax,dword ptr ss:[esp+38]
07F84167  53                    push ebx
07F84168  55                    push ebp
07F84169  E832C3FEFF     call d2game.7F704A0     -> hijack to D2Game.0xA04C0 (approach_RN)
07F8416E  85C0                test eax,eax
07F84170  0F85 6B040000 jne d2game.7F845E1
This makes me think that the original devs made a typo when writing this code, as they first give the pUnit a +100% extra speed, and then make it ''walk'' towards a set of x\y coordinates near its owner. We fix it very easily, by hijacking the call at 0xB4169 ( the one right after 'push ebp') so that it points to D2Game.0xA04C0 instead. The function we are pointing at is a vanilla one, and does exactly the same things as the one we're changing, with the big exception that it forces the RN mode on the pUnit while moving.


The second step is a bit more complex as we have to write a new custom function for our hireable. We are editing the basic leash where the pUnit is told to walk to a spot near its pOwner. We want a function that still does that but also checks the animation mode used by the pOwner unit ( in this case, pOwner is the player who owns the mercenary).

Code: Select all

07F84030   8B4424 34             mov eax,dword ptr ss:[esp+34]
07F84034   50                        push eax
07F84035   8BD6                    mov edx,esi
07F84037   53                        push ebx
07F84038   E8 63C4FEFF         call d2game.7F704A0    -> hijack to custom function ( in this example, it should be call d2game.7FC6EA6)
07F8403D   85C0                    test eax,eax
We need to hijack the call to d2game.7F704A0 to a custom space in our D2Game.dll where we will write our function :

Code: Select all

 - - - c u s t o m   f u n c t i o n - - -

07FC6EA6   8B4424 08              mov eax,dword ptr ss:[esp+8]        ; get Y coord;
07FC6EAA   6A 04                     push 4                                           ;
07FC6EAC   6A 01                     push 1                                           ;
07FC6EAE   50                          push eax                                      ; use Y coord as argument
07FC6EAF   8B4424 10              mov eax,dword ptr ss:[esp+10]     ; get X coord
07FC6EB3   50                         push eax                                       ; use X coord as argument
07FC6EB4   85ED                     test ebp,ebp                                 ; Is there any owner ? (pOwner gets stored in EBP in this AI, at this point)
07FC6EB6   74 10                    je d2game.7FC6EC8                       ; if it's not, just use WL
07FC6EB8   837D 00 00            cmp dword ptr ss:[ebp],0              ; is pOwner a player type unit?
07FC6EBC   75 0A                    jne d2game.7FC6EC8                     ; if it's not, just use WL
07FC6EBE   837D 10 03            cmp dword ptr ss:[ebp+10],3         ; is the pOwner using RN anim ?
07FC6EC2   75 04                    jne d2game.7FC6EC8                     ; if they're not, just use WL
07FC6EC4   6A 0F                    push F                                          ; use RN as argument
07FC6EC6   EB 02                    jmp d2game.7FC6ECA                   ; skip using WL
07FC6EC8   6A 02                    push 2                                         ; use WL as argument
07FC6ECA   6A 00                    push 0                                         ; pTarget = NULL ( not needed because the function already uses x\y coords )
07FC6ECC   E8 6F93FAFF         call d2game.7F70240                    ; call the standard AI_Approach function
07FC6ED1   C2 0800                ret 8                                            ; return to the vanilla code
07FC6ED4   90                        nop
Here is a video showing the result.



Happy modding :)

Hardwood
Posts: 3
Joined: Wed Mar 29, 2017 9:21 pm

Re: [1.10] Restoring Hireling Running animation

Post by Hardwood » Tue Jun 20, 2017 7:32 pm

Sorry for the necro, but would anyone know where to find this edit in 1.13d?

User avatar
Ogodei
Senior Moderator
Angel
Posts: 516
Joined: Thu Mar 10, 2016 8:31 am
Italy

Hand-picked

Re: [1.10] Restoring Hireling Running animation

Post by Ogodei » Thu Jun 29, 2017 10:11 am

Hey,

I'm modding 1.10, so I don't know the offsets for 1.13d, but I can give you a piece of advice.

-Open Diablo 2 and enter a game with a character whose mercenary is dead or not hired
-Attach Olly and go to D2Game
-Search for All commands -> Push 02
-Set a breakpoint on every Push 02, and then remove every command that gets breakpointed (because not related to your mercenary walking animation)
- Resurrect or hire your mercenary and have it follow you. This should be enough to find the correct command to edit

I hope this helped. Let me know!

ascar
Posts: 69
Joined: Mon Aug 02, 2021 6:40 pm
France

Re: [1.10] Restoring Hireling Running animation

Post by ascar » Mon May 02, 2022 1:08 am

Hello

I was modding the act 2 merc and i thought about this !
I knew that it required code editing of AI...

its not possible with soft?

I just managed to put the "helm" visual again (like in beta)

by the way, if you put "lit,med" in the visual equipment in monstats2.txt the game always select the "lit" one, is it normal? (its supposed to randomly chose between those 2..)
Its not changing with gear you put on merc, sadly^^

Thanks !

ascar
Posts: 69
Joined: Mon Aug 02, 2021 6:40 pm
France

Re: [1.10] Restoring Hireling Running animation

Post by ascar » Sat Jul 30, 2022 2:21 am

Ogodei wrote:
Thu Jun 29, 2017 10:11 am
Hey,

I'm modding 1.10, so I don't know the offsets for 1.13d, but I can give you a piece of advice.

-Open Diablo 2 and enter a game with a character whose mercenary is dead or not hired
-Attach Olly and go to D2Game
-Search for All commands -> Push 02
-Set a breakpoint on every Push 02, and then remove every command that gets breakpointed (because not related to your mercenary walking animation)
- Resurrect or hire your mercenary and have it follow you. This should be enough to find the correct command to edit

I hope this helped. Let me know!
Hello!

Im trying what you said, i put breakpoint for every push2 and i clicked on "debugg" ->"Run" (F9)

im not sure whats happening, i got everything red in comands game search except one line that is black. Is it that one? I didnt yet ressurect my Merc.

its the only line that is black : 004A427A : 6A 02 PUSH 2 Arg2 = 2

im trying to change it now




EDIT : Merc is still walking^^ :(

Victor katilis
Posts: 9
Joined: Sat Oct 25, 2014 11:06 am

Re: [1.10] Restoring Hireling Running animation

Post by Victor katilis » Thu Aug 18, 2022 3:30 pm

Ogodei wrote:
Thu Jun 29, 2017 10:11 am
Hey,

I'm modding 1.10, so I don't know the offsets for 1.13d, but I can give you a piece of advice.

-Open Diablo 2 and enter a game with a character whose mercenary is dead or not hired
-Attach Olly and go to D2Game
-Search for All commands -> Push 02
-Set a breakpoint on every Push 02, and then remove every command that gets breakpointed (because not related to your mercenary walking animation)
- Resurrect or hire your mercenary and have it follow you. This should be enough to find the correct command to edit

I hope this helped. Let me know!
Hy Ogodei, hope you're good!
One question - I get that you need to filter out all the push 02's - but what did you mean by "removing" commands?

User avatar
Ogodei
Senior Moderator
Angel
Posts: 516
Joined: Thu Mar 10, 2016 8:31 am
Italy

Hand-picked

Re: [1.10] Restoring Hireling Running animation

Post by Ogodei » Mon Aug 22, 2022 6:09 am

Hey :)

I'm good, thanks.

What I meant is that since there are many functions that use 'push 02' as one of their arguments, you're better off with removing every breakpoint that is unrelated to the mercenary walk animation.

What you should do is starting a game without a mercenary, set a breakpoint on all the push 02 lines, and then hire a mercenary.

After you've done this, one of the push 02 that will trigger will be the one related to their walk animation. Change it to 0F to have your mercenary run again.

Victor katilis
Posts: 9
Joined: Sat Oct 25, 2014 11:06 am

Re: [1.10] Restoring Hireling Running animation

Post by Victor katilis » Fri Aug 26, 2022 10:12 pm

Ogodei wrote:
Mon Aug 22, 2022 6:09 am
Hey :)

I'm good, thanks.

What I meant is that since there are many functions that use 'push 02' as one of their arguments, you're better off with removing every breakpoint that is unrelated to the mercenary walk animation.

What you should do is starting a game without a mercenary, set a breakpoint on all the push 02 lines, and then hire a mercenary.

After you've done this, one of the push 02 that will trigger will be the one related to their walk animation. Change it to 0F to have your mercenary run again.
Right, so I more or less understand the logic - last time I tried this, I did the following (1.14d and attaching to game.exe since they removed the dlls and crammed everything into the .exe - at least nothing I can see from what ollydbg shows me).
-Run a game without a merc.
-Attach ollydbg
-Set breakpoints on all the push 02's
-F9 it, keep F2ing/disabling the breakpoints until I get no breakpoints triggered anymore.
-Hire a merc.

However, from here on I get set back - no push 02 triggers upon the merc following me. Tried going through the breakpoints I disabled one by one, to no avail.

Not sure what to do next - have I missed anything?

Victor katilis
Posts: 9
Joined: Sat Oct 25, 2014 11:06 am

Re: [1.10] Restoring Hireling Running animation

Post by Victor katilis » Fri Aug 26, 2022 11:51 pm

Turns out I didn't select game.exe from executables.
Anyhow, as soon as it looks like I reach the leash range and the merc should start to follow me - I hit an unignorable exception and the only thing ollydbg can do is terminate. Scratching my head...

Victor katilis
Posts: 9
Joined: Sat Oct 25, 2014 11:06 am

Re: [1.10] Restoring Hireling Running animation

Post by Victor katilis » Fri Aug 26, 2022 11:51 pm

Turns out I didn't select game.exe from executables.
Anyhow, as soon as it looks like I reach the leash range and the merc should start to follow me - I hit an unignorable exception and the only thing ollydbg can do is terminate. Scratching my head...

ascar
Posts: 69
Joined: Mon Aug 02, 2021 6:40 pm
France

Re: [1.10] Restoring Hireling Running animation

Post by ascar » Mon Mar 06, 2023 6:48 pm

Victor katilis wrote:
Fri Aug 26, 2022 11:51 pm
Turns out I didn't select game.exe from executables.
Anyhow, as soon as it looks like I reach the leash range and the merc should start to follow me - I hit an unignorable exception and the only thing ollydbg can do is terminate. Scratching my head...
Hello

interresting, im looking for it too for 1.14d

undying_ex
Posts: 23
Joined: Mon Mar 30, 2015 7:09 pm
Location: Bulgaria
Bulgaria

Re: [1.10] Restoring Hireling Running animation

Post by undying_ex » Sun May 14, 2023 7:13 pm

ascar wrote:
Mon Mar 06, 2023 6:48 pm
Victor katilis wrote:
Fri Aug 26, 2022 11:51 pm
Turns out I didn't select game.exe from executables.
Anyhow, as soon as it looks like I reach the leash range and the merc should start to follow me - I hit an unignorable exception and the only thing ollydbg can do is terminate. Scratching my head...
Hello

interresting, im looking for it too for 1.14d
Try here for 1.14d
005DEE6C |. 6A 02 PUSH 2 ; |Arg2 = 00000002
https://ibb.co/2j2FCkN
"It's only cheating if you get caught"
~Al Bundy


Victor katilis
Posts: 9
Joined: Sat Oct 25, 2014 11:06 am

Re: [1.10] Restoring Hireling Running animation

Post by Victor katilis » Wed Nov 29, 2023 11:54 pm

undying_ex wrote:
Sun May 14, 2023 7:13 pm
ascar wrote:
Mon Mar 06, 2023 6:48 pm
Victor katilis wrote:
Fri Aug 26, 2022 11:51 pm
Turns out I didn't select game.exe from executables.
Anyhow, as soon as it looks like I reach the leash range and the merc should start to follow me - I hit an unignorable exception and the only thing ollydbg can do is terminate. Scratching my head...
Hello

interresting, im looking for it too for 1.14d
Try here for 1.14d
005DEE6C |. 6A 02 PUSH 2 ; |Arg2 = 00000002
https://ibb.co/2j2FCkN
Can't find this offset in my game.exe - mine has 001DEE60

/EDIT nevermind it WORKED!

undying_ex
Posts: 23
Joined: Mon Mar 30, 2015 7:09 pm
Location: Bulgaria
Bulgaria

Re: [1.10] Restoring Hireling Running animation

Post by undying_ex » Wed Jan 17, 2024 8:12 pm

Victor katilis wrote:
Wed Nov 29, 2023 11:54 pm
I did not specify that the address is related to the ollydbg program, because the same one was mentioned above in the comments.
"It's only cheating if you get caught"
~Al Bundy

Post Reply

Return to “Code Editing”