v50 Steam/Premium information for editors
  • v50 information can now be added to pages in the main namespace. v0.47 information can still be found in the DF2014 namespace. See here for more details on the new versioning policy.
  • Use this page to report any issues related to the migration.
This notice may be cached—the current version can be found here.

Editing 23a:Item quality

Jump to navigation Jump to search

Warning: You are not logged in.
Your IP address will be recorded in this page's edit history.

You are editing a page for an older version of Dwarf Fortress ("Main" is the current version, not "23a"). Please make sure you intend to do this. If you are here by mistake, see the current page instead.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 124: Line 124:
  
 
According to inspections of the memory values, it seems that artifacts have a quality of 5.
 
According to inspections of the memory values, it seems that artifacts have a quality of 5.
 
:::::::::''Full code breakdown here:''
 
{{Spoil small|Here is Quietust's disassembly and analysis of version 0.23.130.23a:<br /><br />
 
 
---------------------------------------------------------------------------------
 
<nowiki>
 
; First, check what skill is being used
 
                push    1              ; ignore_building
 
                mov    ecx, ebx        ; job *
 
                call    job_getSkill
 
 
; Next, get the level of that skill, if there is one (if not, it will use 0 instead)
 
                mov    edi, [esp+2Ch+maker]
 
                push    eax            ; skill
 
                mov    ecx, edi        ; unit *
 
                call    unit_getSkillLevel
 
 
; Cap the skill level to a maximum of 20
 
                mov    esi, eax
 
                cmp    esi, 20
 
                mov    [ebp+item_craftedst.skill_level], si
 
                jle    short loc_5DC657
 
                mov    esi, 20
 
 
; Check if the item's type/subtype match any Item preferences in the maker
 
loc_5DC657:
 
                mov    eax, [ebp+itemst.vftable]
 
                push    1              ; activatePrefs
 
                push    -1              ; matgloss
 
                push    -1              ; material
 
                mov    ecx, ebp
 
                call    [eax+vtable_item.getSubtype]
 
                mov    edx, [ebp+itemst.vftable]
 
                push    eax            ; item_subtype
 
                mov    ecx, ebp
 
                call    [edx+vtable_item.getType]
 
                push    eax            ; item_type
 
                push    LikeItem        ; prefType
 
                mov    ecx, edi        ; unit *
 
                call    unit_likesItem
 
                test    al, al
 
                jz      short loc_5DC67C
 
                inc    esi            ; if so, increase skill level by 1
 
 
; Check if the item's material/matgloss match any Material preferences in the maker
 
loc_5DC67C:
 
                mov    ax, [ebp+item_craftedst.material]
 
                cmp    ax, 0FFFFh      ; skip if item has no material
 
                jz      short loc_5DC6A0
 
                mov    cx, [ebp+item_craftedst.matgloss]
 
                push    1              ; activatePrefs
 
                push    ecx            ; matgloss
 
                push    eax            ; material
 
                push    -1              ; item_subtype
 
                push    -1              ; item_type
 
                push    LikeMaterial    ; prefType
 
                mov    ecx, edi        ; unit *
 
                call    unit_likesItem
 
                test    al, al
 
                jz      short loc_5DC6A0
 
                inc    esi            ; if so, increase skill level by 1
 
 
; We roll a d5 and compare the result with the creator's skill level.
 
; (Technically, we compare d5 - 1 against skill_level - 1.)
 
loc_5DC6A0:
 
                push    5              ; max
 
                mov    [ebp+item_craftedst.quality], 0
 
                call    trandom        ; generate number from 0-4
 
                add    esp, 4
 
                cmp    eax, esi
 
                jge    short loc_5DC6B8
 
                                        ; If the random number was less than
 
                                        ; the skill level, increment quality
 
                inc    [ebp+item_craftedst.quality]
 
 
; Now we roll a d10 and compare.  It's important to note that the roll
 
; of the d10 is independent, not conditional, of the roll of the d5.
 
 
loc_5DC6B8:
 
                push    10              ; max
 
                call    trandom
 
                add    esp, 4
 
                cmp    eax, esi
 
                jge    short loc_5DC6CA
 
                                        ; If d10 < skill, bump quality
 
                inc    [ebp+item_craftedst.quality]
 
 
loc_5DC6CA:                            ; Same thing for a d15
 
                push    15              ; max
 
                call    trandom
 
                add    esp, 4
 
                cmp    eax, esi
 
                jge    short loc_5DC6DC
 
                                        ; If d15 < skill, bump quality
 
                inc    [ebp+item_craftedst.quality]
 
 
loc_5DC6DC:                            ; Same thing for a d20
 
                push    20              ; max
 
                call    trandom
 
                add    esp, 4
 
                cmp    eax, esi
 
                jge    short loc_5DC6EE
 
                                        ; If d20 < skill, bump quality
 
                inc    [ebp+item_craftedst.quality]
 
 
loc_5DC6EE:                            ; Now we roll a d25
 
                push    25              ; max
 
                call    trandom
 
                add    esp, 4
 
                cmp    eax, esi        ; Compare against skill,
 
                jge    short loc_5DC70E
 
                push    3              ; max
 
                call    trandom        ; AND roll a d3
 
                add    esp, 4
 
                test    eax, eax
 
                                        ; The d3 result must be 1.
 
                                        ; (Technically, d3-1 is tested against 0.)
 
                jnz    short loc_5DC70E
 
                                        ; If d25 < skill AND d3 = 1, bump
 
                inc    [ebp+item_craftedst.quality]
 
 
loc_5DC70E:
 
                cmp    [ebp+item_craftedst.quality], 5
 
                jnz    loc_5DC7EC
 
                ...
 
                mov    dword ptr [esp+2Ch+__$EHRec$.state], eax
 
                lea    eax, [esp+2Ch+message]
 
                push    eax            ; str
 
                push    edi            ; name
 
                call    formatLanguageName
 
                mov    edi, offset aHasCreatedAMas ; " has created a masterpiece!"
 
                ...
 
</nowiki>
 
}}
 
  
 
==Effects of Quality==
 
==Effects of Quality==

Please note that all contributions to Dwarf Fortress Wiki are considered to be released under the GFDL & MIT (see Dwarf Fortress Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following CAPTCHA:

Cancel Editing help (opens in new window)