Making Missiles Effected by AR% granted by skills again

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

0
No votes
 
Total votes: 0

User avatar
Nefarius
Retired Admin
Cherub
Posts: 11607
Joined: Sat Jun 15, 2002 8:13 pm
Location: Where the blood forever rains
Contact:

Hand-picked

Making Missiles Effected by AR% granted by skills again

Post by Nefarius » Fri Mar 23, 2007 3:49 am

This will _not_ fix the bug that exists with monsters that I discussed elsewhere, they will still treat the AR% bonus as a +AR bonus.

First of all, two places need to be patched where Blizzard is using the wrong stat Id:

Code: Select all

6FCBD782   PUSH EAX
6FCBD783   PUSH 13
6FCBD785   PUSH EDI
6FCBD786   CALL <JMP.&D2Common.#10061>

Code: Select all

6FCAE949   6A 00            PUSH 0
6FCAE94B   52               PUSH EDX
6FCAE94C   6A 13            PUSH 13
6FCAE94E   53               PUSH EBX
6FCAE94F   E8 EABAF7FF      CALL <JMP.&D2Common.#10590>
Change 0x13 to 0x77 (if you wonder, snippet A gets the ar% bonus from the missile, and snippet B stores the ar% bonus on the missile after it is created), now this only fixes the wrong stat Id, we must also make D2 store the proper amount of AR% on the missile again.

To do this, we must nop the code below and change it to:

Code: Select all

0001111D   833E 01          CMP DWORD PTR DS:[ESI],1
00011120   75 1A            JNZ SHORT 0001113C
00011122   6A 00            PUSH 0
00011124   6A 13            PUSH 13
00011126   56               PUSH ESI
00011127   E8 C492FFFF      CALL 0000A3F0

Code: Select all

0001111D   FF7424 40        PUSH DWORD PTR SS:[ESP+40]
00011121   FF7424 40        PUSH DWORD PTR SS:[ESP+40]
00011125   56               PUSH ESI
00011126   E8 D5EEFEFF      CALL xxxxxxxx
0001112B   90               NOP
Note, that this example uses a custom lib, but you can do the same in free space, you'd jump there instead of calling though!

The custom code needed (in C++ using NefEx)

Code: Select all

int MISSILES_MissileARFix(D2UnitStrc *pAttacker, int skill, int sLvl) {

	if (pAttacker == NULL)
		return 0;

	SkillsTXTStrc *pSkill = COMMON_GetSkillRecord(skill);
	if (pSkill == NULL)
		return 0;

	if (pSkill->ToHitCalc != -1) {
		return Common10074(pAttacker,pSkill->ToHitCalc,skill,sLvl);
	}

	int th = pSkill->ToHit;
	int thl = pSkill->ToHitPerLvl;

	if ((th+thl) == 0)
		return 0;

	if (sLvl <= 1)
		return th;

	return (th + thl * (sLvl - 1));

}

All this code is in D2Game.dll (v1.11b) ---- another bug squished.
Thats gotta be 100:0 vs. Blizzard ;)
Last edited by Nefarius on Fri Mar 23, 2007 3:53 am, edited 1 time in total.
''(...) The game can basically be considered unhackable. '' - Blizzard Entertainment (30th May 2000)
Black Omen Productions | MetalStorm: Progress Report | Screenshots

User avatar
Jason Maher
Posts: 20
Joined: Tue Sep 25, 2007 7:26 am
Location: Brisbane, Australia

Re: Making Missiles Effected by AR% granted by skills again

Post by Jason Maher » Fri Oct 05, 2007 10:29 am

Sorry to bring up such an old thread, but I found it a little hard to follow exactly what is required for the second part of this fix. Namely, what is the instruction "CALL xxxxxxxxxx" going to achieve? Is this supposed to be replaced by whatever you name the custom library? i.e. CALL <JMP.&library.function> or CALL <JMP.&library.#<function number>>, presumably the number would be 1 or 00001 as there is only one function in the library.

You also mention the possibility of achieving the same functionality within the free space in D2Game.dll. Am I right in thinking this would be a royal pain in the behind, and this is why you've given us C++ code instead?

Jason
I burst my pimples at you and call you door opening request a silly thing.

User avatar
Necrolis
Senior Admin
Throne
Posts: 9125
Joined: Sat Mar 25, 2006 1:22 pm
Location: The Land of the Dead
Contact:
South Africa

Hand-picked

Post by Necrolis » Fri Oct 05, 2007 11:19 am

Its in C++ because thats what nef programming in. The func would be CALL libname.address(DWORD). You can compile the code in cpp then open it with a debugger to get the asm, though you'll need to mod it a bit....
Image
Netiquette, Do you USE it?!?! | Nefarius' Fixed TXT Files | Terms Of Service
Blackened | Day of Death | D2GFEx
"What was yours is mine. Your land, your people, and now your life." - Lim-Dul, the Necromancer
Judgement is Final, Death is Eternal

User avatar
Necrolis
Senior Admin
Throne
Posts: 9125
Joined: Sat Mar 25, 2006 1:22 pm
Location: The Land of the Dead
Contact:
South Africa

Hand-picked

Post by Necrolis » Sat Dec 15, 2007 10:13 am

we roll 1.10 style

Code: Select all

Main Tap in Func
6FD11578   833F 01          CMP DWORD PTR DS:[EDI],1
6FD1157B   75 1D            JNZ SHORT D2Game.6FD1159A
6FD1157D   6A 00            PUSH 0
6FD1157F   6A 13            PUSH 13
6FD11581   57               PUSH EDI
6FD11582   E8 0BA10000      CALL <JMP.&D2Common.#10519>
6FD11587   85C0             TEST EAX,EAX

First Wrong Stat ID
6FC5FCD0   50               PUSH EAX
6FC5FCD1   6A 13            PUSH 13
6FC5FCD3   57               PUSH EDI
6FC5FCD4   E8 B9B90B00      CALL <JMP.&D2Common.#10519>
6FC5FCD9   6A 01            PUSH 1
6FC5FCDB   50               PUSH EAX
6FC5FCDC   8BD6             MOV EDX,ESI
6FC5FCDE   8BCB             MOV ECX,EBX

Second Wrong Stat ID
6FC55B16   8B4F 48          MOV ECX,DWORD PTR DS:[EDI+48]
6FC55B19   6A 00            PUSH 0
6FC55B1B   51               PUSH ECX
6FC55B1C   6A 13            PUSH 13
6FC55B1E   56               PUSH ESI
6FC55B1F   E8 845D0C00      CALL <JMP.&D2Common.#10517>
6FC55B24   F707 00000100    TEST DWORD PTR DS:[EDI],10000
EDIT: *****Important*******
the stack is different so it needs a minor fix

Code: Select all

6FD11578    FF7424 3C       PUSH DWORD PTR SS:[ESP+3C]
6FD1157C    FF7424 3C       PUSH DWORD PTR SS:[ESP+3C]
6FD11580    57              PUSH EDI
6FD11581    E8 CAF54892     CALL Death.MissileAR
6FD11586    90              NOP
Secondly cause not all missile created are made by skills we need to fix the code a little bit, fix in red (and the fact 1.10 uses __stdcall)

Code: Select all

int __stdcall MissileARFix(Unit* pAttacker, int skill, int sLvl) 
{
[color=red]
   if (pAttacker == NULL || skill == 0 || sLvl == 0)
      return 0;
[/color]
   FileSkillsTable* pSkill = D2GetPointerSkill(pAttacker,skill)->skillTxt;
   if (pSkill == NULL)
      return 0;

   if (pSkill->ToHitBonusCalc != -1) 
   {
      return D2EvalSkillCalc(pAttacker,pSkill->ToHitBonusCalc,skill,sLvl);
   }

   int th = pSkill->ToHitBonus;
   int thl = pSkill->ToHitBonusPerLvl;

   if ((th+thl) == 0)
      return 0;

   if (sLvl <= 1)
      return th;

   return (th + thl * (sLvl - 1));
}
Last edited by Necrolis on Sat Dec 22, 2007 4:26 pm, edited 1 time in total.
Image
Netiquette, Do you USE it?!?! | Nefarius' Fixed TXT Files | Terms Of Service
Blackened | Day of Death | D2GFEx
"What was yours is mine. Your land, your people, and now your life." - Lim-Dul, the Necromancer
Judgement is Final, Death is Eternal

User avatar
thaison
Junior Member
Paladin
Posts: 108
Joined: Fri Apr 03, 2015 11:59 am
Location: Viet Nam
Vietnam

Re: Making Missiles Effected by AR% granted by skills again

Post by thaison » Mon Mar 23, 2020 1:20 am

[1.13c] - D2Game
- For who needs it

Code: Select all

0003EF62   50             PUSH EAX
0003EF63   6A 13          PUSH 13		//Change 0x13 to 0x77
0003EF65   57             PUSH EDI
0003EF66   E8 BFB4FCFF    CALL <JMP.&D2Common.#10973>

Code: Select all

0006FE69   6A 00            PUSH 0
0006FE6B   52               PUSH EDX
0006FE6C   6A 13            PUSH 13		//Change 0x13 to 0x77
0006FE6E   53               PUSH EBX
0006FE6F   E8 FEA5F9FF      CALL <JMP.&D2Common.#10887>

Code: Select all

000A29DD   833E 01          CMP DWORD PTR DS:[ESI],1
000A29E0   75 1A            JNZ SHORT 000A29FC
000A29E2   6A 00            PUSH 0
000A29E4   6A 13            PUSH 13
000A29E6   56               PUSH ESI
000A29E7   E8 3E7AF6FF      CALL <JMP.&D2Common.#10973>
000A29EC   85C0             TEST EAX,EAX
To

Code: Select all

000A29DD   FF7424 40        PUSH DWORD PTR SS:[ESP+40]
000A29E1   FF7424 40        PUSH DWORD PTR SS:[ESP+40]
000A29E5   56               PUSH ESI
000A29E6   E8 3F7AF6FF      CALL D2GAME_GetUnitStats_MissileARFix1
000A29EB   90               NOP
- Patch in C ++ for whoever needs it

Code: Select all

D2PTR(D2GAME, MissileARFix1_I, 0xA29EE)
NAKED void D2GAME_GetUnitStats_MissileARFix1_STUB()
{
	__asm
	{
		push[esp + 0x40]
		push[esp + 0x40]
		push esi
		call D2GAME_GetUnitStats_MissileARFix1
		test eax, eax
		jmp MissileARFix1_I
	}
}

Patch(JUMP, "D2Game.dll", 0xA29DD, (DWORD)D2GAME_GetUnitStats_MissileARFix1_STUB, 0xA29EE - 0xA29DD, "MissileARFix1");

Code: Select all

int __stdcall D2GAME_GetUnitStats_MissileARFix1(UnitAny* pAttacker, int skill, int sLvl)
{
	if (!pAttacker || skill <= 0 || sLvl <= 0)
		return 0;

	SkillsTxt* pSkill = TXT_GetSkillsRecord(skill);
	if (!pSkill) return 0;

	if (pSkill->dwToHitCalc != -1)
		return D2COMMON_EvalSkillCalc(pAttacker, pSkill->dwToHitCalc, skill, sLvl);

	int th = pSkill->dwToHit;
	int thl = pSkill->dwLevToHit;

	if (!(th + thl))
		return 0;

	if (sLvl <= 1)
		return th;

	return (th + thl * (sLvl - 1));
}

Post Reply

Return to “Code Editing”