The whole eth bonus % section as far as I can see is the following
Code: Select all
D2Common:
---------------------------------------------------
000558D0 56 PUSH ESI
000558D1 8B7424 08 MOV ESI,DWORD PTR SS:[ESP+8]
000558D5 85F6 TEST ESI,ESI
000558D7 75 1E JNZ SHORT 000558F7
000558D9 68 06070000 PUSH 706
000558DE 68 D439DE6F PUSH 6FDE39D4
000558E3 68 5831DE6F PUSH 6FDE3158
000558E8 E8 65EA0200 CALL 00084352
000558ED 83C4 0C ADD ESP,0C
000558F0 6A FF PUSH -1
000558F2 E8 78EB0200 CALL 0008446F
000558F7 6A 01 PUSH 1
000558F9 68 00004000 PUSH 400000
000558FE 56 PUSH ESI
000558FF E8 7C2E0000 CALL 00058780
00055904 6A 2D PUSH 2D
00055906 56 PUSH ESI
00055907 E8 D4830000 CALL 0005DCE0
0005590C 6A 00 PUSH 0
0005590E 6A 00 PUSH 0
00055910 85C0 TEST EAX,EAX
00055912 0F84 BA000000 JE 000559D2
00055918 6A 15 PUSH 15 ; min dmg stat
0005591A 56 PUSH ESI
0005591B E8 10220200 CALL 00077B30
00055920 8D0440 LEA EAX,DWORD PTR DS:[EAX+EAX*2] ; calc to return eth bonus (50% +(50%*2))
00055923 99 CDQ
00055924 2BC2 SUB EAX,EDX
00055926 D1F8 SAR EAX,1 ; divide by 2, 1 time for 50%
00055928 50 PUSH EAX
00055929 6A 15 PUSH 15 ; min dmg stat
0005592B 56 PUSH ESI
0005592C E8 7F210200 CALL 00077AB0
00055931 6A 00 PUSH 0
00055933 6A 00 PUSH 0
00055935 6A 16 PUSH 16 ; max dmg stat
00055937 56 PUSH ESI
00055938 E8 F3210200 CALL 00077B30
0005593D 8D0440 LEA EAX,DWORD PTR DS:[EAX+EAX*2] ; calc to return eth bonus (50% +(50%*2))
00055940 99 CDQ
00055941 2BC2 SUB EAX,EDX
00055943 D1F8 SAR EAX,1 ; divide by 2, 1 time for 50%,
00055945 50 PUSH EAX
00055946 6A 16 PUSH 16 ; max dmg stat
00055948 56 PUSH ESI
00055949 E8 62210200 CALL 00077AB0
0005594E 6A 00 PUSH 0
00055950 6A 00 PUSH 0
00055952 6A 17 PUSH 17 ; secondary min dmg stat
00055954 56 PUSH ESI
00055955 E8 D6210200 CALL 00077B30
0005595A 8D0440 LEA EAX,DWORD PTR DS:[EAX+EAX*2] ; calc to return eth bonus (50% +(50%*2))
0005595D 99 CDQ
0005595E 2BC2 SUB EAX,EDX
00055960 D1F8 SAR EAX,1 ; divide by 2, 1 time for 50%,
00055962 50 PUSH EAX
00055963 6A 17 PUSH 17 ; secondary min dmg stat
00055965 56 PUSH ESI
00055966 E8 45210200 CALL 00077AB0
0005596B 6A 00 PUSH 0
0005596D 6A 00 PUSH 0
0005596F 6A 18 PUSH 18 ; secondary max dmg
00055971 56 PUSH ESI
00055972 E8 B9210200 CALL 00077B30
00055977 8D0440 LEA EAX,DWORD PTR DS:[EAX+EAX*2] ; calc to return eth bonus (50% +(50%*2))
0005597A 99 CDQ
0005597B 2BC2 SUB EAX,EDX
0005597D D1F8 SAR EAX,1 ; divide by 2, 1 time for 50%,
0005597F 50 PUSH EAX
00055980 6A 18 PUSH 18 ; Secondary max dmg stat
00055982 56 PUSH ESI
00055983 E8 28210200 CALL 00077AB0
00055988 6A 00 PUSH 0
0005598A 6A 00 PUSH 0
0005598C 68 9F000000 PUSH 9F ; throw min dmg stat
00055991 56 PUSH ESI
00055992 E8 99210200 CALL 00077B30
00055997 8D0440 LEA EAX,DWORD PTR DS:[EAX+EAX*2] ; calc to return eth bonus (50% +(50%*2))
0005599A 99 CDQ
0005599B 2BC2 SUB EAX,EDX
0005599D D1F8 SAR EAX,1 ; divide by 2, 1 time for 50%,
0005599F 50 PUSH EAX
000559A0 68 9F000000 PUSH 9F ; throw min dmg stat
000559A5 56 PUSH ESI
000559A6 E8 05210200 CALL 00077AB0
000559AB 6A 00 PUSH 0
000559AD 6A 00 PUSH 0
000559AF 68 A0000000 PUSH 0A0 ; throw max dmg stat
000559B4 56 PUSH ESI
000559B5 E8 76210200 CALL 00077B30
000559BA 8D0440 LEA EAX,DWORD PTR DS:[EAX+EAX*2] ; calc to return eth bonus (50% +(50%*2))
000559BD 99 CDQ
000559BE 2BC2 SUB EAX,EDX
000559C0 D1F8 SAR EAX,1 ; divide by 2, 1 time for 50%,
000559C2 50 PUSH EAX
000559C3 68 A0000000 PUSH 0A0 ; throw max dmg stat
000559C8 56 PUSH ESI
000559C9 E8 E2200200 CALL 00077AB0
000559CE 5E POP ESI
000559CF C2 0400 RETN 4
000559D2 6A 1F PUSH 1F ; AC stat
000559D4 56 PUSH ESI
000559D5 E8 56210200 CALL 00077B30
000559DA 8D0440 LEA EAX,DWORD PTR DS:[EAX+EAX*2] ; calc to return eth bonus (50% +(50%*2))
000559DD 99 CDQ
000559DE 2BC2 SUB EAX,EDX
000559E0 D1F8 SAR EAX,1 ; divide by 2, 1 time for 50%,
000559E2 50 PUSH EAX
000559E3 6A 1F PUSH 1F ; AC stat
000559E5 56 PUSH ESI
000559E6 E8 C5200200 CALL 00077AB0
000559EB 5E POP ESI
000559EC C2 0400 RETN 4
000559EF 90 NOP
As a test I tried the following for the AC stat to get 125% bonus as there is a spare byte to play with at the bottom.
Changing
Code: Select all
SAR EAX,1
Code: Select all
SAR EAX,2
to divide by 2 twice (25% of EAX)
then rewriting the follow up code to RETN 4.
I then change
Code: Select all
LEA EAX,DWORD PTR DS:[EAX+EAX*2]
Code: Select all
LEA EAX,DWORD PTR DS:[EAX+EAX*4]
Testing in game shows this works
The problem I have is I need to get around a 1/3 bonus so I would want to do something similar to this:
Code: Select all
LEA EAX,DWORD PTR DS:[EAX+EDI*4] ; value in EAX +(EDI*4) (3/8 of base)+(1/4*4) = 1+(3/8)
CDQ
SUB EAX,EDX
SAR EAX,2 ; divide base value of stat by 2, twice (1/4)
MOV EAX,EDI ; copy 1/4 of stat into EDI (EDI = 1/4) ; EDI simply as an example. I'd have to use an unused register
SAR EAX,1 ; divide 1/4 of stat by 2 one time (EAX = 1/8)
ADD EAX,EDI ; add EDI (1/4) to EAX (1/8). EAX = 1/8+1/4 (3/8)
If we forget about the above code for now and any problems it may contain (It's mostly theory of how to reach roughly 133%). I have a more pressing issue.
I tried simply jumping from the AC section too, rewriting the code and jumping back, but again I crash when spawning an eth item.
Original with Jump for AC bonus only:
Code: Select all
000559CF C2 0400 RETN 4 ; End of previous function block for weapons
000559D2 6A 1F PUSH 1F ; AC stat (I change this to JMP 000XXXXX)
000559D4 56 PUSH ESI
000559D5 E8 56210200 CALL 00077B30
000559DA 8D0440 LEA EAX,DWORD PTR DS:[EAX+EAX*2] ; calc to return eth bonus (50% +(50%*2))
000559DD 99 CDQ
000559DE 2BC2 SUB EAX,EDX
000559E0 D1F8 SAR EAX,1 ; divide by 2, 1 time for 50%,
000559E2 50 PUSH EAX
000559E3 6A 1F PUSH 1F ; AC stat
000559E5 56 PUSH ESI
000559E6 E8 C5200200 CALL 00077AB0
000559EB 5E POP ESI
000559EC C2 0400 RETN 4 ; I jump back here from the end of the new function location
Code: Select all
000XXXXX 6A 1F PUSH 1F ; AC stat < The jump from the original leads here
000XXXXX 56 PUSH ESI
000XXXXX E8 56210200 CALL 00077B30
000XXXXX 8D0440 LEA EAX,DWORD PTR DS:[EAX+EAX*2] ; calc to return eth bonus (50% +(50%*2))
000XXXXX 99 CDQ
000XXXXX 2BC2 SUB EAX,EDX
000XXXXX D1F8 SAR EAX,1 ; divide by 2, 1 time for 50%,
000XXXXX 50 PUSH EAX
000XXXXX 6A 1F PUSH 1F ; AC stat
000XXXXX 56 PUSH ESI
000XXXXX E8 C5200200 CALL 00077AB0
000XXXXX 5E POP ESI
000XXXXX C2 0400 RETN 4 ; Here I jump back to the end of the original code block, so JMP 000559EC
Any idea what is going wrong with jumping out for more space, rewriting the code then jumping back in this instance?
I've used this method many times when I need to edit something but require more space.
Any help is hugely appreciated, as I'm finding myself thinking about wtf is going on all the time, even out with the dog or going to the shop etc.