Add a stat to equipment¶
Designer · 15 min · No code (a brand-new attribute needs C++)
Result: a weapon or armour piece that grants a stat it did not before, for example a ring of Agility on a pair of boots. The last section covers a stat that is not in the list yet: one row on an effect, plus C++ only if the attribute itself is new.
Before you start¶
- Add a weapon or Add armour.
- Stats and damage: what each stat does in a fight.
How item stats reach a character¶
- An item definition lists its stats in Inventory Fragment Set Stats › Initial Item Stats:
a
XenoCore.Stat.*gameplay tag and a whole number per row. - When the item enters the bag, Lyra copies those numbers onto the item.
- When the item is equipped, its ability set grants the gameplay ability
Inventory/GA_XenoCore_EquipmentStats. That ability applies one shared gameplay effect,Inventory/GE_XenoCore_EquipmentStats. The effect's modifiers are the list of stats: each one names an attribute and a Set By Caller tag, and the ability fills every such tag from the item's number for it (0 if the item has none). - When the item is unequipped, the ability ends and the effect is removed.
So an item never has its own effect asset, and the ability names no stat at all. The effect's modifier rows are the one list of what equipment can grant.
The stats an item can carry¶
| Tag | Attribute it adds to | Unit on the item | Shown on the equipment comparison? |
|---|---|---|---|
XenoCore.Stat.WeaponAttackMin |
Weapon Attack Min | points | Yes |
XenoCore.Stat.WeaponAttackMax |
Weapon Attack Max | points | Yes |
XenoCore.Stat.PhysicalDefence |
Physical Defence | points | Yes |
XenoCore.Stat.EtherDefence |
Ether Defence | points | Yes |
XenoCore.Stat.CriticalRate |
Critical Rate | whole percent (10 = 10%) | Yes |
XenoCore.Stat.BlockRate |
Block Rate | whole percent | Yes |
XenoCore.Stat.Weight |
Weight | points; more is worse | Yes |
XenoCore.Stat.Strength |
Strength | points | No, character sheet only |
XenoCore.Stat.Ether |
Ether | points | No, character sheet only |
XenoCore.Stat.Agility |
Agility | points | No, character sheet only |
Every equipped item adds to the character's base value. Critical and Block Rate are divided by 100 on the way in, because the attributes hold a 0 to 1 fraction.
Steps (existing stat)¶
- Open the item definition, for example your
ID_MyGame_HideVest, and click Class Defaults. - In Display › Fragments, expand the Inventory Fragment Set Stats entry. If the item has none, click + on Fragments and pick Inventory Fragment Set Stats for the new entry.
- Under Equipment › Initial Item Stats, click +. Set the key to
XenoCore.Stat.Agilityand the value to5. - Compile and Save.
That is all. No effect, ability or table needs to change.
Strength, Ether and Agility do not appear on the comparison block
The item comparison block shows seven rows: attack min and max, both defences, crit, block and weight. A Strength, Ether or Agility bonus still works and shows on the character sheet, but the comparison does not list it.
Test it¶
- Open Kael's pawn,
Characters/VRoid/Kael/B_XenoCore_Party_VRoid_L. In the Components panel select the equipment component, then add your item to XenoCore › Equipment › Starting Inventory. Compile and Save. - Open
Maps/L_XenoCore_Gymand press Play. Open the main menu and look at Kael's stats. - Equip the item on the equipment screen. Agility on the character sheet rises by 5. Unequip it: it falls back.
If it doesn't work¶
The item's number shows but the character doesn't get it
The effect has no modifier row for that tag. The item card still shows the number. On equip,
the Output Log warns (LogXenoCoreEquipmentStats): "carries XenoCore.Stat.… but
GE_XenoCore_EquipmentStats has no SetByCaller modifier for it". Add the row (see the last
section).
Fails silently: a stat tag outside XenoCore.Stat
The warning above only checks tags under XenoCore.Stat. A row with any other tag on
Initial Item Stats is ignored with no message. Keep equipment stat tags under
XenoCore.Stat.
Critical Rate of 10 did nothing, or 0.1 did nothing
Values are whole numbers. 10 is 10%. A fraction such as 0.1 cannot be entered, and 1 is 1%.
A screen of your own shows the old numbers
The stats are applied inside the equip call, so they are right the moment it returns. A widget
that reads them only when it opens will not see a later change. Refresh it from the
XenoCore.Equipment.Message.SlotChanged message. See Events.
A stat that is not in the list¶
A stat that is not in the table, such as Max HP on a piece of armour, needs one row on the
effect. XenoCore.Stat.MaxHealth already exists as a tag.
If the attribute already exists¶
- Open
Inventory/GE_XenoCore_EquipmentStats. Under Modifiers, add an entry. Copy the shape of an existing row:- Attribute:
LyraHealthSet.MaxHealth - Modifier Op: Add
- Magnitude Calculation Type: Set By Caller
- Data Tag:
XenoCore.Stat.MaxHealth
- Attribute:
- On the item, add
XenoCore.Stat.MaxHealthto Initial Item Stats with a value. - If the value is authored as a whole percent (15 meaning 15 %), open
Inventory/GA_XenoCore_EquipmentStatsand add the tag to Percent Stat Tags (XenoCore › Equipment). Critical Rate and Block Rate are already treated as percent, so they need no entry.
No graph and no code. Equip the item and the attribute moves.
Key the modifier by tag, not by name
A Set By Caller modifier keyed by a Data Name instead of a Data Tag can never be filled from an item, and always reads 0. The ability logs a warning naming the effect and the attribute.
If the attribute is new¶
Needs a programmer
Attribute sets are C++, so step 1 is a programmer's job. Steps 2 and 3 are editor work.
- The attribute (C++). Attribute sets are C++. Add it to
UXenoCoreStatSet, or to your own set granted in your ability sets, and give the damage formula a use for it if it affects combat. Add a stat to the damage formula walks through both. - The tag. Add
XenoCore.Stat.CriticalDamagein your own tag source (Project Settings › Gameplay Tags), not in XenoCore's. Keep it underXenoCore.Statso the missing-row warning covers it. - Then the three steps above.
Showing it on the menus¶
Needs a programmer
The equipment screen, item card and character sheet list their stat rows from a table written in C++, not from an asset. A stat without a row there applies but does not appear on those screens, and only a programmer can add the row.
For programmers
The table is UXenoCoreInventoryStatics::GetStatDefinitions() (label, order, lower-is-better,
percent, which screens). Add a row with the tag and label, and choose whether it shows on the
comparison block and the character sheet. It is built once per process, so this needs a full
rebuild and a fresh editor.
GE_XenoCore_EquipmentStats is a shipped asset. Note the rows you add for when you take a template
update.