Announcement

Collapse
No announcement yet.

Durability Question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Durability Question

    Aside from the quality bar, is there another visual indicator of the current durability a weapon has? Perhaps it can be modded to be displayed under the weapon's stat screen?

    #2
    I think I found the xml code tied to item stats that are displayed but not sure where each stat is defined. Perhaps its hard coded?

    Config\XUi_Menu\windows.xml:
    Code:
    <rect depth="3" visible="{showstats}" width="453">
    					<rect pos="-3,0" height="35">
    						<sprite depth="8" sprite="menu_empty3px" height="35" color="[black]" type="sliced" fillcenter="false" />
    						<sprite depth="1" color="[darkestGrey]" pos="0,-1" height="34" type="sliced" />
    						<label depth="3" pos="10,-3" width="430" font_size="26" text="{itemstattitle1}" justify="left" color="[white]" />
    						<label depth="3" pos="10,-3" width="430" font_size="26" text="{itemstat1}" justify="right" color="[selectedColor]" />
    					</rect>
    					<rect pos="-3,-33" height="35">
    						<sprite depth="8" sprite="menu_empty3px" height="34"  color="[black]" type="sliced" fillcenter="false" />
    						<sprite depth="1" color="[darkGrey]" type="sliced" />
    						<label depth="3" pos="10,-3" width="430" font_size="26" text="{itemstattitle2}" justify="left" color="[white]" />
    						<label depth="3" pos="10,-3" width="430" font_size="26" text="{itemstat2}" justify="right" color="[selectedColor]" />
    					</rect>
    					<rect pos="-3,-64" height="35">
    						<sprite depth="8" sprite="menu_empty3px" height="34" color="[black]" type="sliced" fillcenter="false" />
    						<sprite depth="1" color="[darkestGrey]" pos="0,-1" height="33" type="sliced" />
    						<label depth="3" pos="10,-3" width="430" font_size="26" text="{itemstattitle3}" justify="left" color="[white]" />
    						<label depth="3" pos="10,-3" width="430" font_size="26" text="{itemstat3}" justify="right" color="[selectedColor]" />
    					</rect>
    					<rect pos="-3,-94" height="35">
    						<sprite depth="8" sprite="menu_empty3px" height="36"  color="[black]" type="sliced" fillcenter="false" />
    						<sprite depth="1" color="[darkGrey]" type="sliced" />
    						<label depth="3" pos="10,-4" width="430" font_size="26" text="{itemstattitle4}" justify="left" color="[white]" />
    						<label depth="3" pos="10,-4" width="430" font_size="26" text="{itemstat4}" justify="right" color="[selectedColor]" />
    					</rect>
    					<rect pos="-3,-127" height="35">
    						<sprite depth="8" sprite="menu_empty3px" height="35" color="[black]" type="sliced" fillcenter="false" />
    						<sprite depth="1" color="[darkestGrey]" pos="0,-1" height="34" type="sliced" />
    						<label depth="3" pos="10,-4" width="430" font_size="26" text="{itemstattitle5}" justify="left" color="[white]" />
    						<label depth="3" pos="10,-4" width="430" font_size="26" text="{itemstat5}" justify="right" color="[selectedColor]" />
    					</rect>
    					<rect pos="-3,-159" height="35">
    						<sprite depth="8" sprite="menu_empty3px" height="36"  color="[black]" type="sliced" fillcenter="false" />
    						<sprite depth="1" color="[darkGrey]" type="sliced" />
    						<label depth="3" pos="10,-3" width="430" font_size="26" text="{itemstattitle6}" justify="left" color="[white]" />
    						<label depth="3" pos="10,-3" width="430" font_size="26" text="{itemstat6}" justify="right" color="[selectedColor]" />
    					</rect>
    					<rect pos="-3,-192" height="35">
    						<sprite depth="8" sprite="menu_empty3px" height="36" color="[black]" type="sliced" fillcenter="false" />
    						<sprite depth="1" color="[darkestGrey]" pos="0,-1" height="35" type="sliced" />
    						<label depth="3" pos="10,-3" width="430" font_size="26" text="{itemstattitle7}" justify="left" color="[white]" />
    						<label depth="3" pos="10,-3" width="430" font_size="26" text="{itemstat7}" justify="right" color="[selectedColor]" />
    					</rect>
    				</rect>

    Comment


      #3
      I think I was looking at the wrong xml file. I found the following code under the ui_display.xml. Just need to figure out what the display_entry name is for current durability. Any ideas? (already tried Degradation / statDegradation...)

      Code:
      		<item_display_info display_type="rangedGun" display_group="groupRanged">
      			<display_entry name="EntityDamage" title_key="statEntityDamageRanged"/>
      			<display_entry name="MagazineSize" title_key="statMagazineSize" />
      			<display_entry name="RoundsPerMinute" title_key="statRoundsPerMinute"/>
      			<display_entry name="DamageFalloffRange" title_key="statDamageFalloffRange"/>
      			<!-- <display_entry name="WeaponHandling" title_key="statWeaponHandling" display_type="Percent" show_inverted="true"/> -->
      			<display_entry name="DegradationMax" title_key="statDegradationMax" tags="perkGunslinger,perkBoomstick,perkDeadEye,perkMachineGunner,perkBookAutoWeapons,admin"/>
      		</item_display_info>
      Last edited by Laz Man; 02-01-2020, 10:20 AM.

      Comment


        #4
        Originally posted by Laz Man View Post
        I think I was looking at the wrong xml file. I found the following code under the ui_display.xml. Just need to figure out what the display_entry name is for current durability. Any ideas? (already tried Degradation / statDegradation...)

        Code:
        		<item_display_info display_type="rangedGun" display_group="groupRanged">
        			<display_entry name="EntityDamage" title_key="statEntityDamageRanged"/>
        			<display_entry name="MagazineSize" title_key="statMagazineSize" />
        			<display_entry name="RoundsPerMinute" title_key="statRoundsPerMinute"/>
        			<display_entry name="DamageFalloffRange" title_key="statDamageFalloffRange"/>
        			<!-- <display_entry name="WeaponHandling" title_key="statWeaponHandling" display_type="Percent" show_inverted="true"/> -->
        			<display_entry name="DegradationMax" title_key="statDegradationMax" tags="perkGunslinger,perkBoomstick,perkDeadEye,perkMachineGunner,perkBookAutoWeapons,admin"/>
        		</item_display_info>
        Hi Laz Man
        I have achieved that the arrows have level 1, but when making them the arrow has only a gray bar and does not show a level number, the degradation has not worked just like you, I guess it is hard coded.
        Or you already got it.

        Gouki

        Comment


          #5
          No luck yet. I'm still searching if their is a variable that can referenced to display current durability as a number....

          Comment


            #6
            I may be able to help you with this but it will likely require a harmony patch via DMT.

            Comment


              #7
              Originally posted by ExtremeLurker View Post
              I may be able to help you with this but it will likely require a harmony patch via DMT.
              Hi extreme, thanks for the offer. I was hoping for an xml only method. However, I am interested to learn more about dmt.

              Comment


                #8
                Originally posted by Laz Man View Post
                Hi extreme, thanks for the offer. I was hoping for an xml only method. However, I am interested to learn more about dmt.
                Hey. No problem. I spent some time looking into the game source code for you. Unfortunately, it's not possible with XML alone. I'll try to explain..

                The thing you are trying to do, I believe, is show the current durability of an item in the item info panel (the section of the interface you see in your inventory when you click on an item, or when opening a container and clicking on an item). You correctly identified the section of windows.xml that those stats display in, which is inside the <rect visible="{showstats}"> element within the <window name="itemInfoPanel"> element. However, editing this would do us no good because that stat section is dynamic, showing different stats depending on the type of item you have selected. The type of stats that display for different classes of items is controlled in ui_display.xml, as you correctly identified. This is where an edit would be required. As you guessed, you would need to add a <display_entry> element for durability to each class of item you would want to display it for.

                Here's where it gets more complicated. There is a class called UIDisplayInfoFromXml that handles parsing this file, converting the elements into C# objects, and storing them in a class named UIDisplayInfoManager. When it parses a <display_entry> element, it looks at the name attribute and tries to find it within an enum named PassiveEffects, and since durability is not in there, it will not find it. In the case that it comes across a name it cannot find, it stores whatever you put for the value of the name attribute it in a property called CustomName.

                Going back to the item info panel, this panel is managed by a class named XUiC_ItemInfoWindow, which gets the item display entry data from the UIDisplayInfoManager class and uses it to display the stat information on the window. There is a method named GetBindingValue that handles replacing something like {itemstat7} with the actual value of that stat. In doing this it calls another method called GetStatValue. This method calls a method named GetStatItemValueTextWithCompareInfo on a class named XUiM_ItemStack and gives it the display info it retrieved from UIDisplayInfoManager. At this point XUiM_ItemStack.GetStatItemValueTextWithCompareInfo will actually retrieve the value and format it appropriately. It checks to see if the CustomName property is set to figure out where to get the value from. In our case, CustomName would have a value set. When that is the case, it calls a method named GetCustomValue. This method seems to be made specifically to support the following values:
                Mass
                RequiredPower
                MaxDamage
                StabilityGlue
                LightOpacity
                StabilitySupport
                ExplosionResistance
                FertileLevel

                If the CustomName property is not equal to any of those values, it appears to then look through information loaded from items.xml for values inside of <display_value> elements with a name equal to the value of CustomName. It also checks for <triggered_effect> elements of type onSelfPrimaryActionEnd or onSelfSecondaryActionEnd that modify a cvar with a name equal to the value of CustomName and can display the value of that effect. I think this is used to show how much of certain effects an item can have, such as how much it can increase max health.

                I know this is a whole lot of technical implementation details, but I just wanted to explain in detail how this whole system works, as I did the research anyway and maybe it will be useful for someone. To make a rather long story short, the game only supports specific values for the name attribute of <display_entry> elements, and none of them are durability, so the code would need to be patched to support being able to display that value. My recommended course of action would be to attempt to create a Harmony patch that prefixes the XUiM_ItemStack.GetCustomValue method and check if CustomName is equal to something like "Durability", and return the durability value via itemStack.itemValue.UseTimes. If you'd rather not attempt to learn how to do this, let me know and I'll create it for you.
                Last edited by ExtremeLurker; 02-18-2020, 01:20 PM.

                Comment


                  #9
                  Originally posted by ExtremeLurker View Post
                  Hey. No problem. I spent some time looking into the game source code for you. Unfortunately, it's not possible with XML alone. I'll try to explain..

                  The thing you are trying to do, I believe, is show the current durability of an item in the item info panel (the section of the interface you see in your inventory when you click on an item, or when opening a container and clicking on an item). You correctly identified the section of windows.xml that those stats display in, which is inside the <rect visible="{showstats}"> element within the <window name="itemInfoPanel"> element. However, editing this would do us no good because that stat section is dynamic, showing different stats depending on the type of item you have selected. The type of stats that display for different classes of items is controlled in ui_display.xml, as you correctly identified. This is where an edit would be required. As you guessed, you would need to add a <display_entry> element for durability to each class of item you would want to display it for.

                  Here's where it gets more complicated. There is a class called UIDisplayInfoFromXml that handles parsing this file, converting the elements into C# objects, and storing them in a class named UIDisplayInfoManager. When it parses a <display_entry> element, it looks at the name attribute and tries to find it within an enum named PassiveEffects, and since durability is not in there, it will not find it. In the case that it comes across a name it cannot find, it stores whatever you put for the value of the name attribute it in a property called CustomName.

                  Going back to the item info panel, this panel is managed by a class named XUiC_ItemInfoWindow, which gets the item display entry data from the UIDisplayInfoManager class and uses it to display the stat information on the window. There is a method named GetBindingValue that handles replacing something like {itemstat7} with the actual value of that stat. In doing this it calls another method called GetStatValue. This method calls a method named GetStatItemValueTextWithCompareInfo on a class named XUiM_ItemStack and gives it the display info it retrieved from UIDisplayInfoManager. At this point XUiM_ItemStack.GetStatItemValueTextWithCompareInfo will actually retrieve the value and format it appropriately. It checks to see if the CustomName property is set to figure out where to get the value from. In our case, CustomName would have a value set. When that is the case, it calls a method named GetCustomValue. This method seems to be made specifically to support the following values:
                  Mass
                  RequiredPower
                  MaxDamage
                  StabilityGlue
                  LightOpacity
                  StabilitySupport
                  ExplosionResistance
                  FertileLevel

                  If the CustomName property is not equal to any of those values, it appears to then look through information loaded from items.xml for values inside of <display_value> elements with a name equal to the value of CustomName. It also checks for <triggered_effect> elements of type onSelfPrimaryActionEnd or onSelfSecondaryActionEnd that modify a cvar with a name equal to the value of CustomName and can display the value of that effect. I think this is used to show how much of certain effects an item can have, such as how much it can increase max health.

                  I know this is a whole lot of technical implementation details, but I just wanted to explain in detail how this whole system works, as I did the research anyway and maybe it will be useful for someone. To make a rather long story short, the game only supports specific values for the name attribute of <display_entry> elements, and none of them are durability, so the code would need to be patched to support being able to display that value. My recommended course of action would be to attempt to create a Harmony patch that prefixes the XUiM_ItemStack.GetCustomValue method and check if CustomName is equal to something like "Durability", and return the durability value via itemStack.itemValue.UseTimes. If you'd rather not attempt to learn how to do this, let me know and I'll create it for you.
                  First of all, thank you for doing this research and taking the time to write these technical findings. It surely will help out other future modders as well. I appreciate the offer to create what I am looking for but I am good for right now. I will certainly reach out to you at a later time If needed. Much thanks.

                  Comment

                  Working...
                  X