[1.10f] Softcoding NecroPet's skill usage

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

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

Hand-picked

[1.10f] Softcoding NecroPet's skill usage

Post by Ogodei » Fri Jan 12, 2024 1:50 pm

Hey everyone :)

Today's chat on Discord with TrueMage prompted me to investigate the NecroPet's AI and I've found out that with just a few modified lines we can get any minion whose AI is NecroPet to adopt the Necromages' behavior, which essentially fires the skill stated in the 'Skill1' field of the unit's MonStats record.

I took a look at the very beginning of the NecroPet AI and found this :

Code: Select all

6FCE297A  | 8B4D 14               mov ecx,dword ptr ss:[ebp+14]      // pAiGeneral->dwParam[0]                                                                                              
6FCE297D  | 85C9                  test ecx,ecx     // if pAIGeneral->dwParam[0] == jump to melee routine call                                                                                                           
6FCE297F  | 0F84 FE010000        je d2game.6FCE2B83   


What prevents NecroPet from using Skill1 is the fact that the only case in the vanilla code where pAIGeneral->dwParam[0] is handled for this AI resides SrvDoFunc 31 (Raise Skeleton \ Skeletal Mage) and only if the unit's hcidx matches the hardcoded ID of the skeleton mage.

What we are doing now is a simple change in the AI itself that will make the unit ignore dwParam[0]'s settings and instead look at Monstats' AIP8 (not difficulty dependant, just the first of the AIP8 columns).

We will start by changing the aforementioned code to the following

Code: Select all

6FCE297A | E9 F4450400       jmp d2game.6FD26F73      // jump to custom space
6FCE297F | 90                nop
6FCE2980 | 90                nop
6FCE2981 | 90                nop
6FCE2982  | 90               nop
6FCE2983  | 90               nop
6FCE2984  | 90               nop
and in our custom space we'll write:

Code: Select all

6FD26F73  | 36:8B48 1C                 mov ecx,dword ptr ss:[eax+1C]  // pAiTick->pMonStats.txt                                                                                                 
6FD26F77  | 66:83B9 80000000 00        cmp word ptr ds:[ecx+80],0 // if pMonStats.txt->wAIP[8] > 0 then 'use skill1' routine, else melee routine
6FD26F7F  | 0F8E FEBBFBFF              jle d2game.6FCE2B83
6FD26F85   | E9 FBB9FBFF               jmp d2game.6FCE2985   
After this tiny code edit is made, all you need to do is to assign a valid Skill1\mode\level in your minion's Monstats record and set its AIP8 to anything greater than 0 and the trick is done.

NOTE: since this a code edit that affects the AI as a whole, you want to correct the vanilla necromages' AIP8 as well !
Last edited by Ogodei on Fri Jan 12, 2024 2:37 pm, edited 1 time in total.
Reason: fixing code format

User avatar
TrueMage
Hosted Forum Moderator
Principality
Posts: 2072
Joined: Thu Jun 24, 2004 7:58 am
Location: Elemental Conflux
Russia

Re: [1.10f] Softcoding NecroPet's skill usage

Post by TrueMage » Fri Jan 12, 2024 2:25 pm

Amazing! Thank you very much! :)

Return to “Code Editing”