The CorruptLancer's secret AI Param

Post here about all aspects of D2 mod making whether it's information, problems or whatever. Please specify whether your post is relating to Classic D2 or the Expansion.

Moderator: Nizari

Post Reply
User avatar
Senior Moderator
Champion of the Light
Posts: 462
Joined: Thu Mar 10, 2016 8:31 am


The CorruptLancer's secret AI Param

Post by Ogodei » Sun Apr 14, 2019 9:49 pm

Hey guys, how're you doing? :)

I was reading through the code that handles the Corrupt Lancer's AI and found out an interesting feature. Despite what MonAI.txt says the AIParam 8 can actually be used. This param handles the chances for the unit to use skill 3, so if you want to use this AI for a melee fighter you will be able to use up to three abilities =)

Here's the code I found:

Code: Select all

6FCD8755      66:83BF 74010 CMP WORD PTR DS:[EDI+174],0  // check if the skill3 is empty or null
6FCD875D      7C 5C         JL SHORT 6FCD87BB                       // if no skill3, then jump to AI_Attack (regular melee attack)
6FCD875F      8B46 20       MOV EAX,DWORD PTR DS:[ESI+20]
6FCD8762      BA C590C66A   MOV EDX,6AC690C5
6FCD8767      F7E2          MUL EDX
6FCD8769      8B4E 24       MOV ECX,DWORD PTR DS:[ESI+24]
6FCD876C      33ED          XOR EBP,EBP
6FCD876E      03C1          ADD EAX,ECX
6FCD8770      B9 64000000   MOV ECX,64
6FCD8775      13D5          ADC EDX,EBP
6FCD8777      8946 20       MOV DWORD PTR DS:[ESI+20],EAX
6FCD877A      8956 24       MOV DWORD PTR DS:[ESI+24],EDX
6FCD877D      33D2          XOR EDX,EDX
6FCD877F      F7F1          DIV ECX
6FCD8781      33C0          XOR EAX,EAX
6FCD8783      8A43 6D       MOV AL,BYTE PTR DS:[EBX+6D]                                 
6FCD8786      0FBF8C47 8000 MOVSX ECX,WORD PTR DS:[EAX*2+EDI+80]   // Check AIParam 8 vs a Random[100] roll
6FCD878E      3BD1          CMP EDX,ECX
6FCD8790      7D 29         JGE SHORT 6FCD87BB         // if Rand[100] is > than AIParam 8 then just use the melee attack
6FCD8792      0FBF87 740100 MOVSX EAX,WORD PTR DS:[EDI+174]   // else use skill 3 
6FCD8799      8B5424 20     MOV EDX,DWORD PTR SS:[ESP+20]
6FCD879D      8A8F 82010000 MOV CL,BYTE PTR DS:[EDI+182]
6FCD87A3      55            PUSH EBP
6FCD87A4      55            PUSH EBP
6FCD87A5      52            PUSH EDX
6FCD87A6      50            PUSH EAX
6FCD87A7      51            PUSH ECX
6FCD87A8      8BD6          MOV EDX,ESI
6FCD87AA      8BCB          MOV ECX,EBX
6FCD87B1      5F            POP EDI
6FCD87B2      5E            POP ESI
6FCD87B3      5D            POP EBP
6FCD87B4      5B            POP EBX
6FCD87B5      83C4 0C       ADD ESP,0C
6FCD87B8      C2 0400       RETN 4
Happy modding :)

Post Reply

Return to “General Mod Making”