Skip to content

Make a consumable item

Designer · 45 min · No code

Result: an item, Mend Salve, that the party carries in the bag. Using it spends one and restores the leader's HP.

Read this first: what the template does and does not do

XenoCore has no "use item" command in the menu today. The Items menu lists, sorts and describes items, and nothing in it spends one. Items are spent by quests (turn-in), by shops and trades, and by your own abilities.

This recipe therefore builds the item and a gameplay ability that uses it. You trigger the ability with an input or from another graph. A menu entry that calls it is a UI job; see Add a menu screen.

Before you start

How it is put together

Piece You make Based on
The item ID_MyGame_MendSalve A shipped item from Inventory/Items
The heal GE_MyGame_Mend Lyra's /Game/Environments/Gameplay/GE_GameplayEffectPad_Heal
The use GA_MyGame_UseMendSalve A new Lyra Gameplay Ability

The ability carries a Party Item (XenoCore) cost: it cannot activate unless the party holds a Mend Salve nobody is wearing, and committing the ability spends one. The cost does the bag work through XenoCore's inventory functions, which find the party's bag for you and tell every open screen that the bag changed.

Steps

1. Make the item

  1. Create a MyGame/Items folder under Content.
  2. In Plugins › XenoCore Content › Inventory › Items, right-click ID_XenoCore_CoolPotato, choose Duplicate, move the copy into MyGame/Items and name it ID_MyGame_MendSalve. Never create an item definition from blank.
  3. Open it. In Class Defaults, set Display Name to Mend Salve.
  4. Expand Fragments. In the Xeno Core Fragment Item Category entry, under XenoCore › Item, leave Category on Collectables (the potato's), and set Max Carried to 20 and Sell Value. Max Carried is the most the party may hold; 0 means no limit. Do not pick Items: no Items-menu tab lists that category, so the salve would be carried but never shown.
  5. In the Xeno Core Fragment Item Display entry, set Description and Icon.
  6. Make sure there is no Xeno Core Fragment Equip Slots entry, or the item becomes equipment.
  7. Click Compile, then Save.

2. Make the heal

  1. In the Content Browser, open Content/Environments/Gameplay (Lyra's own content), right-click GE_GameplayEffectPad_Heal, choose Duplicate, move the copy into MyGame/Items and name it GE_MyGame_Mend.
  2. Open it. The heal amount is on its execution, not a modifier: under Executions, in the Lyra Heal Execution entry's Calculation Modifiers, set the BaseHeal modifier's scalable float. Keep its Gameplay Cues entry (GameplayCue.Character.Heal): that is the heal effect you see.
  3. Click Save.

3. Make the ability

  1. In MyGame/Items, right-click and choose Blueprint Class. Under All Classes, pick LyraGameplayAbility. Name it GA_MyGame_UseMendSalve.
  2. Open it. In Class Defaults, set Instancing Policy to Instanced Per Actor and leave Activation Policy on On Input Triggered.
  3. Under Costs, click + beside Additional Costs and choose Party Item (XenoCore) from the entry's class dropdown.
  4. In that entry, under XenoCore › Cost, set Item Definition to ID_MyGame_MendSalve and Quantity to 1.
  5. In the event graph, build this chain from Event ActivateAbility:
    1. Commit Ability. This spends the Mend Salve. Branch on its return value; on False, End Ability and stop.
    2. On True: Apply Gameplay Effect to Owner, Gameplay Effect Class GE_MyGame_Mend.
    3. End Ability.
  6. Click Compile, then Save.

With an empty bag the ability does not activate at all, because the cost is checked before activation.

Without a cost

To spend items from a graph instead, use Consume Items From Party (XenoCore › Inventory) with Item Def and Count. It spends exactly that many or nothing, returns false when there are not enough, and never takes an item someone is wearing. Get Free Party Item Count tells you beforehand how many can be spent.

Fails silently: do not use Lyra's Inventory Item cost

The cost list also offers Lyra's own Inventory Item cost, and it looks like the same thing. In stock Lyra 5.8 its code is compiled out: its check always fails, so an ability carrying it can never activate, with nothing logged. Use Party Item (XenoCore).

Fails silently: spend items with the XenoCore nodes

Lyra's own inventory functions also remove items. XenoCore notices and still updates open screens and quest counters, but Lyra's removal functions can take an item a character is wearing, which then vanishes from the save. Use Consume Items From Party or Remove Item Instance From Party (both under XenoCore › Inventory).

4. Give the party some to use

  1. Open a pawn in the starting party, for example Kael, Characters/VRoid/Kael/B_XenoCore_Party_VRoid_L.
  2. In the Components panel, select its equipment component.
  3. In the Details panel, under XenoCore › Equipment, click + beside Starting Inventory.
  4. In the new entry, set Item Definition to ID_MyGame_MendSalve and Count to 3.
  5. Click Compile, then Save.

Fails silently: a pawn that never spawns

Starting Inventory reaches the bag only when that pawn is spawned. A member who is not in the party's Starting Roster (on Characters/Party/BP_XenoCore_Party), such as the colour mannequins in Characters/Party, or B_XenoCore_Player, never spawns at New Game, so their list is ignored with nothing logged. The shipped roster starts with Kael and Mira.

5. Grant the ability

For a first test, grant it from the console (step 3 of Test it). To keep it:

  1. Open Characters/Party/AbilitySet_XenoCore_PartyMember. Every VRoid member is granted it, through Characters/VRoid/PawnData_XenoCore_Party_VRoid.
  2. Click + beside Granted Gameplay Abilities.
  3. In the new entry, set Ability to GA_MyGame_UseMendSalve.
  4. Set Input Tag to a gameplay tag your input config maps to a key. See Input and camera and Add an input action prompt.
  5. Click Save.

Test it

  1. Open Maps/L_XenoCore_Gym and press Play.
  2. Let a minion hit you so you are below full HP.
  3. Open the console and enter AbilitySystem.Ability.Grant GA_MyGame_UseMendSalve, then AbilitySystem.Ability.Activate GA_MyGame_UseMendSalve.
  4. The leader heals. Open the menu's Collectables tab: the party now holds two Mend Salves.
  5. Activate it three more times. The fourth use does nothing: with the bag empty the cost check fails and the ability does not activate.

If it doesn't work

Symptom Fix
The ability activates but nothing heals The heal effect has no amount, or its cue was removed. Test the effect alone with AbilitySystem.Effect.Apply GE_MyGame_Mend.
The ability never activates The cost's Item Definition is a different item from the one in Starting Inventory; both must be ID_MyGame_MendSalve. Also check that the cost is Party Item (XenoCore), not Lyra's Inventory Item (see the warning above).
The count never goes down The graph does not call Commit Ability. The cost is only paid on commit.
The bag has no Mend Salves at New Game The pawn you gave Starting Inventory to never spawns (see the warning in step 4).

Going further