Back to NxLabs

NxLabs / Vintage Story

Attributer

YBy Yew

A patch that allows attributes applied to items to modify stats. Does nothing by itself.

Description


A multi-class patch that makes lets you set attributes per item dynamically.

Basically wherever the code says "get parent object attribute" it instead "get object attribute if exists first".

Also adds a few new attributes that can be applied to items to modify their functionality.


Requirements:

  • None.

Incompatibilities:

  • Other mods which significantly overwrite base item types.

Mods requiring this:

New Attributes:

  • maxdurability.

Supported Attributes:

  • defaultProtLoss
  • protectionModifiers
    • protectionTier
    • highDamageTierResistant
    • flatDamageReduction
    • relativeProtection
  • statModifiers
    • healingeffectiveness
    • hungerrate
    • rangedWeaponsAcc
    • rangedWeaponsSpeed
    • walkSpeed
  • damage
  • attackpower
  • attackrange
  • miningspeed
  • miningtier
  • health
  • clothescategory
  • breakChanceOnImpact
  • requiresAnvilTier
  • workableTemperature

- Please note, some attributes are enabled by the api by default and do not need this mod.
- Search the official API and official survival mod github repositorys to check.

Attribute Exceptions:

  • perTierFlatDamageReductionLoss
  • perTierRelativeProtectionLoss

These aren't mirrored as other attributes are, as arrays aren't supported by the API.
Instead, they should be TreeAttributes, with the float values of "0" and "1" placed into them.
This is a workaround until the API updates.

How to use (For developers):

  1. Set an attribute on an item.<span style="background-color: #2b3e50; color: #ffffff;">
    </span>
    1. Example (Set an items attack power):

      1. <span style="background-color: #2b3e50; color: #ffffff;">itemstack.Attributes.SetFloat("attackpower", 12f);

        </span>
    2. Example (Set an items flat damage reduction):
      <span style="background-color: #2b3e50; color: #ffffff;">
      </span>
      1. <span style="background-color: #2b3e50; color: #ffffff;">itemstack.Attributes.GetTreeAttribute("protectionModifiers").SetFloat("flatDamageReduction", 8f);

        </span>
  2. That's it. It should work if the attribute is supported.

How to use (Standalone):

  1. Use an command that supports or sets attributes.
    1. Example (Set the weapon in your hand's attack power.):

      1. <span style="color: #ecf0f1; background-color: #2b3e50;">/debug heldstattr attackpower float 1000000

        </span>
  2. That should do it.

<span style="text-decoration: underline;">Please note you must mirror attributes exactly, including trees, to how the parent item is.</span>

Ratings & reviews

No ratings yet

Sign in to leave a rating or comment.