Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Identifying materials  (Read 1373 times)

bartavelle

  • Bay Watcher
  • Coin coin!
    • View Profile
Identifying materials
« on: December 10, 2007, 07:47:00 am »

When looking at the mood inner workings, i found out that a material is here described as four 16bits integers which could be:

item type:item subtype:item material:material id

For example, with -1 meaning "any" afaik:
3:-1:-1:-1 -> gem:any:any:any
0:-1:2:-1 -> bar:any:metal:any
55:-1:-1-1 -> leather:any:any:any

and so on. Is anybody familiar with this way of describing materials? If so, how would it be possible to decode this data and perhaps altering it so that an artifact would be made with choosen items?

Logged

bartavelle

  • Bay Watcher
  • Coin coin!
    • View Profile
Re: Identifying materials
« Reply #1 on: December 10, 2007, 02:18:00 pm »

Ok found out, in 0x01461F10 there is a vector of ptr to the metal structures. First item in this structure is a string struct with the metal token name, and you just have to use 0:-1:2:id to assign this id to the metal. I can now produce arbitrary artifacts  :) (selection of item type and materials!)
Logged

I3erent

  • Bay Watcher
  • The mounted dwarf has gone bErZeRk
    • View Profile
Re: Identifying materials
« Reply #2 on: December 10, 2007, 03:20:00 pm »

In normal guy speak this means?
Logged
quot;I got really stoned a couple days ago and ended up talking to THIS GUY. anyway... I''m really drunk now. The guy said: There is this application called "Mya" MI-AH that makes animations of people that he paid $2000 for. F- that Jazz ARMOK ROCKS. FIGHT THE MAN, GO TEAM!

Zurai

  • Bay Watcher
    • View Profile
Re: Identifying materials
« Reply #3 on: December 10, 2007, 04:57:00 pm »

It means bartavelle could make a tool that allows us to edit the strange mood materials requested by a dwarf.
Logged

bartavelle

  • Bay Watcher
  • Coin coin!
    • View Profile
Re: Identifying materials
« Reply #4 on: December 10, 2007, 06:35:00 pm »

I actually wrote it. Only thing left is controlling the amount of material needed ...
Logged

BurnedToast

  • Bay Watcher
  • Personal Text
    • View Profile
Re: Identifying materials
« Reply #5 on: December 11, 2007, 01:44:00 pm »

quote:
Originally posted by bartavelle:
<STRONG>I actually wrote it. Only thing left is controlling the amount of material needed ...</STRONG>

 :eek:

hooray turning my stupid raw clear glass wants into platinum aluminum or steel!

double hooray for turning my weaponsmith's wants into adamantine!

Logged
An ambush! curse all friends of nature!

0x517A5D

  • Bay Watcher
  • Hex Editor‬‬
    • View Profile
Re: Identifying materials
« Reply #6 on: December 12, 2007, 09:26:00 pm »

bartavelle, this is in .33d, right?  I see a vector there in .33d but not in b, c, or e.

Has this been put on the wiki yet?

Logged

Torak

  • Bay Watcher
  • God of Gods of Blood.
    • View Profile
Re: Identifying materials
« Reply #7 on: December 12, 2007, 10:27:00 pm »

Pull this off and you're my god.
Logged
As you journey to the center of the world, feel free to read the death announcements of those dwarves that suffer your neglect.

One billion b-balls dribbling simultaneously throughout the galaxy. One trillion b-balls being slam dunked through a hoop throughout the cosmos. I can feel every single b-ball that has ever existed at my fingertips, I can feel their collective knowledge channeling through my veins. Every jumpshot, every rebound and three-pointer, every layup, dunk and free throw.

bartavelle

  • Bay Watcher
  • Coin coin!
    • View Profile
Re: Identifying materials
« Reply #8 on: December 13, 2007, 02:20:00 am »

This is in .d, and i didn't test it elsewhere. I updated the creature struct in .c for mood vectors, but i still have to finish reversing the different material descriptions to update it.
Logged

sphr

  • Bay Watcher
    • View Profile
Re: Identifying materials
« Reply #9 on: December 13, 2007, 05:33:00 am »

even the lesser function, something that actually decode the materials needed for the artifact will already be a wonderful thing  :)

bartavelle

  • Bay Watcher
  • Coin coin!
    • View Profile
Re: Identifying materials
« Reply #10 on: December 13, 2007, 07:25:00 am »

Ok for those who wanna play with it, take a look at my page and follow the link to "dfedit". Instructions should be printed, and please do not hesitate completing the table.

It should be noted that the installation of python and pydbg is required for this program to work!

Logged

Torak

  • Bay Watcher
  • God of Gods of Blood.
    • View Profile
Re: Identifying materials
« Reply #11 on: December 13, 2007, 09:28:00 am »

Why does 65535 show up so many times?
Logged
As you journey to the center of the world, feel free to read the death announcements of those dwarves that suffer your neglect.

One billion b-balls dribbling simultaneously throughout the galaxy. One trillion b-balls being slam dunked through a hoop throughout the cosmos. I can feel every single b-ball that has ever existed at my fingertips, I can feel their collective knowledge channeling through my veins. Every jumpshot, every rebound and three-pointer, every layup, dunk and free throw.

bartavelle

  • Bay Watcher
  • Coin coin!
    • View Profile
Re: Identifying materials
« Reply #12 on: December 13, 2007, 10:06:00 am »

it means 'any' AFAIK (if you're referring to the mood stuff)
Logged

0x517A5D

  • Bay Watcher
  • Hex Editor‬‬
    • View Profile
Re: Identifying materials
« Reply #13 on: December 13, 2007, 02:44:00 pm »

Here are four search patterns that find this vector.  They are written to use my homebrewed search function.  All four patterns feel a little fragile to me, which is why I found so many.  If you go this route, I suggest doing all of the patterns, throwing out any zero results, and then comparing all of the remaining results to verify that they point to the same location.
code:
   // no good way to find this vector, so here's 4 patterns, run them all,
   // throw out any where d was 0, check that all the results are the same.
   //C7 87 40 02 00 00 04 00+          mov     dword ptr [edi+240h], 4
   //8B 0D 14 1F 46 01                 mov     ecx, metal_tokens_vector.start
   d = hexsearch(4+4,
         DWORD_, 0x00000240, DWORD_, 0x00000004,
         0x8B, ANYBYTE, HERE, ADDRESS);
   metal_tokens_vector_loc = peekd(d) - 4;
   dump(metal_tokens_vector_loc);
   // doesn't work in .32a
   //C7 40 04 E2 00 00 00              mov     dword ptr [eax+4], 0E2h
   //0F 84 5B 2F 00 00                 jz      loc_4EE328
   //8B 0D 14 1F 46 01                 mov     ecx, metal_tokens_vector.start
   d = hexsearch(5+1+4,
         0xC7, ANYBYTE, 0x04, DWORD_, 0x000000E2,
         JZ,
         0x8B, ANYBYTE, HERE, ADDRESS);
   metal_tokens_vector_loc = peekd(d) - 4;
   dump(metal_tokens_vector_loc);
   //8D B7 48 02 00 00                 lea     esi, [edi+248h]
   //E8 74 D1 EF FF                    call    sub_408B20
   //8B 15 14 1F 46 01                 mov     edx, metal_tokens_vector.start
   // there were also variants using 0x1A8, 0x1E8, 0x348
   d = hexsearch(4+1+4,
         0x8D, ANYBYTE, DWORD_, 0x00000248,
         CALL,
         0x8B, ANYBYTE, HERE, ADDRESS);
   metal_tokens_vector_loc = peekd(d) - 4;
   dump(metal_tokens_vector_loc);
   //A1 18 1F 46 01                    mov     eax, metal_tokens_vector.end
   //2B C1                             sub     eax, ecx
   //C1 F8 02                          sar     eax, 2
   //8D 9E 68 03 00 00                 lea     ebx, [esi+368h]
   d = hexsearch(3+2+3+4,
         0xA1, HERE, ADDRESS,
         0x2B, 0xC1,
         0xC1, 0xF8, 0x02,
         0x8D, ANYBYTE, DWORD_, 0x00000368);
   metal_tokens_vector_loc = peekd(d) - 8;
   dump(metal_tokens_vector_loc);

Obviously, this is in C, not in Python or whatnot.  I don't know how to link C to python, sorry.
Logged

bartavelle

  • Bay Watcher
  • Coin coin!
    • View Profile
Re: Identifying materials
« Reply #14 on: December 13, 2007, 03:59:00 pm »

Using multiple patterns is quite a good idea. my python stuff is just a quick hack, and i hope somebody  with a good knowledge of windows GUI will write something useful  :)

I'll try your approach anyway!

Logged