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
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
NOTE: since this a code edit that affects the AI as a whole, you want to correct the vanilla necromages' AIP8 as well !