Page 1 of 1

[1.13c] Force an item to appear in the gamble window every time

Posted: Tue Jul 23, 2019 8:40 pm
by keloman
Hello!

I am a newbie when it comes to code editing and I've been wondering how to force an item to appear in the gamble window.

For example, I want at least 1 jewel to appear every time in the gamble window. How can I force that (just like amulets and rings are forced to appear).

Thanks in advance!

EDIT: I've enabled jewels in gamble.txt already but I realize the chance for it to appear is very slim

Re: [1.13c] Force an item to appear in the gamble window every time

Posted: Tue Jul 23, 2019 9:18 pm
by devurandom
The way Rings/Amulets are forced in Gamble screen is done in the loop that generates gamble items.
2 globals store the (EDIT CORRECTION) item Record for rin and amu. you'd have to do it like its done there & also check the loop count, cause those are the first items that get created.

You can find that code loop by looking at the code edit for increasing the number of items on gamble screen.

a simpler way is just to add the item to gamble.txt, but it won't guarantee that the item will get spawn every time on gamble screen.

Re: [1.13c] Force an item to appear in the gamble window every time

Posted: Wed Jul 24, 2019 5:30 am
by keloman
"code edit for increasing the number of items on the gamble screen" ? Is that to be found in the Knowledge Base ? I searched in the Code Editing forum and in the knowledge base but I cant seem to find anything like that.

Re: [1.13c] Force an item to appear in the gamble window every time

Posted: Wed Jul 24, 2019 7:37 am
by devurandom
Look for Whist code edit collection I think its in there.

Re: [1.13c] Force an item to appear in the gamble window every time

Posted: Wed Jul 24, 2019 3:28 pm
by keloman
devurandom wrote:
Wed Jul 24, 2019 7:37 am
Look for Whist code edit collection I think its in there.
I found his thread with the link to the code edits but it appears his website is no longer being actively hosted (Chrome gives me a "Can't find Server IP Adress" error). Can anybody here provide a link to the code edits?

Re: [1.13c] Force an item to appear in the gamble window every time

Posted: Thu Jul 25, 2019 12:01 am
by devurandom
it is linked in that thread, you'll have to look further down.

Re: [1.13c] Force an item to appear in the gamble window every time

Posted: Thu Jul 25, 2019 7:36 am
by keloman
Thanks, I found it.

Code: Select all

D2Game.dll - BE611

027BE611    837C24 14 0E    CMP DWORD PTR SS:[ESP+14],0E

Is this the supposed code I should look for? It is in a file called Gamble.asm and it doesn't look like an Assembler loop to me. It changes the amount of items in the gamble window but thats it.

Re: [1.13c] Force an item to appear in the gamble window every time

Posted: Thu Jul 25, 2019 11:32 am
by devurandom
devurandom wrote:
Tue Jul 23, 2019 9:18 pm
You can find that code loop by looking at the code edit for increasing the number of items on gamble screen.

Re: [1.13c] Force an item to appear in the gamble window every time

Posted: Thu Jul 25, 2019 4:11 pm
by keloman
editing1.png
editing1.png (1.78 KiB) Viewed 297 times
So using Ollydbg I disassembled my D2Game.dll and found this. I'm assuming that

Code: Select all

JL 000BE382
is to be executed next so I go to that offset.
editing2.png
This is where that offset brings me. Should any of this (when transformed to decimal) direct me towards an item code or something? I can only understand that a lot of values are being moved around between registers.

Re: [1.13c] Force an item to appear in the gamble window every time

Posted: Fri Jul 26, 2019 2:36 am
by devurandom
This is the part of the code that you'd be interested in:

Code: Select all

000BE44C  ║► │8B4424 14     ║MOV EAX,DWORD PTR SS:[LOCAL.5]	LoopCount
000BE450  ║· │83F8 02       ║CMP EAX,2
000BE453  ║·▼│7D 10         ║JGE SHORT 6FCDE465
000BE455  ║· │85C0          ║TEST EAX,EAX
000BE457  ║· │8B35 801FD36F ║MOV ESI,DWORD PTR DS:[6FD31F80]	nRecord  gnGambleRin
000BE45D  ║·▼│74 06         ║JZ SHORT 6FCDE465
000BE45F  ║· │8B35 7C1FD36F ║MOV ESI,DWORD PTR DS:[6FD31F7C]	nRecord  gnGambleAmu

Re: [1.13c] Force an item to appear in the gamble window every time

Posted: Fri Aug 23, 2019 12:23 am
by JayBrainDead
devurandom wrote:
Fri Jul 26, 2019 2:36 am
This is the part of the code that you'd be interested in:
Code: Select all

000BE44C ║► │8B4424 14 ║MOV EAX,DWORD PTR SS:[LOCAL.5] LoopCount
000BE450 ║· │83F8 02 ║CMP EAX,2
000BE453 ║·▼│7D 10 ║JGE SHORT 6FCDE465
000BE455 ║· │85C0 ║TEST EAX,EAX
000BE457 ║· │8B35 801FD36F ║MOV ESI,DWORD PTR DS:[6FD31F80] nRecord gnGambleRin
000BE45D ║·▼│74 06 ║JZ SHORT 6FCDE465
000BE45F ║· │8B35 7C1FD36F ║MOV ESI,DWORD PTR DS:[6FD31F7C] nRecord gnGambleAmu
How could one figure out what the value would be for any other item than Rings and Amulets ? I believe the information isnt inside D2Game.dll

Re: [1.13c] Force an item to appear in the gamble window every time

Posted: Fri Aug 23, 2019 4:01 am
by devurandom
further up its done in D2Game.dll like so:

Code: Select all

000BE2FF  ║► │A1 7C1FD36F   MOV EAX,DWORD PTR DS:[6FD31F7C]	gGambleAmu
000BE304  ║· │85C0          TEST EAX,EAX
000BE306  ║·▼│75 0F         JNZ SHORT 6FCDE317
000BE308  ║· │68 7C1FD36F   PUSH OFFSET 6FD31F7C                     ; ╓Arg2 = D2Game.6FD31F7C
000BE30D  ║· │68 616D7520   PUSH 20756D61                            ; ║Arg1 = 20756D61 Amu
000BE312  ║· │E8 2BC7F4FF   CALL <JMP.&D2Common.#10450>              ; └D2Common.#10450
								GetItemRecordFromCode

Re: [1.13c] Force an item to appear in the gamble window every time

Posted: Sat Aug 24, 2019 6:22 am
by JayBrainDead
devurandom wrote:
Fri Aug 23, 2019 4:01 am
further up its done in D2Game.dll like so:

Code: Select all

000BE2FF  ║► │A1 7C1FD36F   MOV EAX,DWORD PTR DS:[6FD31F7C]	gGambleAmu
000BE304  ║· │85C0          TEST EAX,EAX
000BE306  ║·▼│75 0F         JNZ SHORT 6FCDE317
000BE308  ║· │68 7C1FD36F   PUSH OFFSET 6FD31F7C                     ; ╓Arg2 = D2Game.6FD31F7C
000BE30D  ║· │68 616D7520   PUSH 20756D61                            ; ║Arg1 = 20756D61 Amu
000BE312  ║· │E8 2BC7F4FF   CALL <JMP.&D2Common.#10450>              ; └D2Common.#10450
								GetItemRecordFromCode
Thanks a lot! That was very helpful

Re: [1.13c] Force an item to appear in the gamble window every time

Posted: Sat Aug 24, 2019 9:14 am
by devurandom
:toasting:
Cheers

Re: [1.13c] Force an item to appear in the gamble window every time

Posted: Tue Aug 27, 2019 4:14 am
by JayBrainDead
Where could find an empty space to jump to to add some custom code inside D2Game ?
I've tried two location that caused an instant crash up entering gamble screen.
Unless the issue is because I cant add a JMP at BE2FF with a JMP to come back to the default code

Re: [1.13c] Force an item to appear in the gamble window every time

Posted: Tue Aug 27, 2019 6:51 am
by devurandom
You can take a call and turn it into a long jump, then execute the missing call at the location of the long jump in the first command, with the args still on the stack. Next add your new code and jump back where you need to go.

Jumps and calls are the safest way to inject new code cause they're already in the dll's .reloc section.