February
18
2016

Use the Selected Data feature to create custom equipment upgrade systems.

Selected data is a very useful feature available in the event system and formulas – you can learn more about it in this how-to.

This tutorial is based on the game tutorial series – we’ll create a new game event for handling the weapon upgrades and add a new NPC to the town scene. The weapon upgrades will require special upgrade items that we’ll also set up.

Weapon upgrade items

First, we’ll set up the items required for weapon upgrades. Open the ORK Framework editor and navigate to Inventory > Items. Add a new item to the list and change the following settings.

Weapon ATK+1

  • Name
    Set to Weapon ATK+1.
  • Description
    Set to: Increases weapon ATK bonus by 1.

Item Settings

  • Item Type
    Select Special Items.
  • Item Prefab
    Select ItemPrefab.
    The prefab can be found at Assets/Tutorial Resources/Prefabs/Items/.

Price Settings

  • Buy Price
    Set to 100.
  • Sellable
    Enable this setting.
    The default settings (selling at 50% of the buy price) are enough.

Use Settings

  • Usable In
    Select None.
    This is not a useable item.

That’s it for the first item – the others will just be copies with slight variations.

Weapon ATK+5

Copy the previous item and change the following settings.

  • Name
    Set to Weapon ATK+5.
  • Description
    Set to: Increases weapon ATK bonus by 5.

Price Settings

  • Buy Price
    Set to 250.

Weapon ATK+10

Copy the previous item and change the following settings.

  • Name
    Set to Weapon ATK+10.
  • Description
    Set to: Increases weapon ATK bonus by 10.

Price Settings

  • Buy Price
    Set to 500.

That’s it for the items.

A new shopping experience

Next, we’ll add the new items to be sold in the game’s shop. Navigate to World > Shops and change the following settings in the Convenience Store.

Items

Click on Add Item to add a new item to the shop.

  • Item
    Select Weapon ATK+1.
  • Limit Quantity
    Enable this setting.
    We don’t want the player to be able to limitless purchase upgrade items.
  • Quantity
    Set to 10.

Copy the item we just added and change the following settings.

  • Item
    Select Weapon ATK+5.
  • Limit Quantity
    Enable this setting.
    We don’t want the player to be able to limitless purchase upgrade items.
  • Quantity
    Set to 5.

Again, copy the item and change the following settings.

  • Item
    Select Weapon ATK+10.
  • Limit Quantity
    Enable this setting.
    We don’t want the player to be able to limitless purchase upgrade items.
  • Quantity
    Set to 3.

That’s it for the shop. Click on Save Settings to save the changes.

The upgrade event

Now, we’ll set up the game event that’ll handle the upgrading. Navigate to Events and create a new game event – change the following settings.

gameplay_21_weapon_upgrade_npc1

Event Settings

The event should block the player and camera controls.

  • Block Player Control
    Enable this setting.
  • Block Camera Control
    Enable this setting.

Event Actors

We’ll add the player as an actor to allow access to the equipment and inventory. Click on Add Actor to add an actor to the event.

  • Type
    Select Player.

Show Dialogue

Add > UI > Dialogue > Show Dialogue

First, we’ll let the player decide which weapon equipment part (left or right hand) he wants to upgrade.

  • Dialogue Type
    Select Choice.
  • GUI Box
    Select Bottom Dialogue.
  • Message
    Set to:
    Hey there, want to upgrade your weapons?

Click on Add Choice to add a new choice.

  • Choice Text
    Set to:
    Upgrade Right Hand Weapon

Click on Add Choice to add another choice.

  • Choice Text
    Set to:
    Upgrade Left Hand Weapon

Click on Add Choice to add another choice.

  • Choice Text
    Set to:
    Don’t upgrade anything

Check Equipment

Add > Combatant > Equipment > Check Equipment

We’ll check if the player has a weapon equipped on the Right Hand equipment part.

This step is connected to the Choice 0 slot of the first dialogue step.

  • Object
    Select Actor.
  • Actor
    Select Player.
  • Equipment Part
    Select Right Hand.
  • Equip
    Select Weapon.
  • Check Equipment Part
    Enable this setting.
    This will check if any weapon is equipped on the part.

Select Equipment

Add > Event > Selected Data > Select Equipment

We’ll use this step to set the equipment of the Right Hand part of the player as selected data, using the selected key weapon.

This step is connected to the Success slot of the previous Check Equipment step.

Selected Key

  • Value Type (Selected Key)
    Select Value.
  • Value (Selected Key)
    Set to weapon.
  • Change Type
    Select Set.

Equipment Settings

  • All Equipment
    Disable this setting.
  • Equipment Part
    Select Right Hand.

Combatant Settings

  • Object
    Select Actor.
  • Actor
    Select Player.

Check Equipment

Add > Combatant > Equipment > Check Equipment

We’ll check if the player has a weapon equipped on the Left Hand equipment part.

This step is connected to the Choice 1 slot of the first dialogue step.

  • Object
    Select Actor.
  • Actor
    Select Player.
  • Equipment Part
    Select Left Hand.
  • Equip
    Select Weapon.
  • Check Equipment Part
    Enable this setting.

Select Equipment

Add > Event > Selected Data > Select Equipment

We’ll use this step to set the equipment of the Left Hand part of the player as selected data, using the selected key weapon.

This step is connected to the Success slot of the previous Check Equipment step.

Selected Key

  • Value Type (Selected Key)
    Select Value.
  • Value (Selected Key)
    Set to weapon.
  • Change Type
    Select Set.

Equipment Settings

  • All Equipment
    Disable this setting.
  • Equipment Part
    Select Left Hand.

Combatant Settings

  • Object
    Select Actor.
  • Actor
    Select Player.

Show Dialogue

Add > UI > Dialogue > Show Dialogue

In case the player doesn’t have a weapon equipped, we’ll let the player know.

This step is connected to the Failed slots of both Check Equipment steps.

  • Dialogue Type
    Select Message.
  • GUI Box
    Select Bottom Dialogue.
  • Message
    Set to:
    You don’t have anything equipped there …

Show Dialogue

Add > UI > Dialogue > Show Dialogue

After the weapon has been checked and selected, we’ll let the player decide which weapon upgrade he wants to use.

This step is connected to the Next slots of both Select Equipment steps.

  • Dialogue Type
    Select Choice.
  • GUI Box
    Select Bottom Dialogue.
  • Message
    Set to:
    Select the upgrade material.

Click on Add Choice to add a new choice.

  • Choice Text
    Set to:
    Weapon ATK+1

Click on Add Choice to add another choice.

  • Choice Text
    Set to:
    Weapon ATK+5

Click on Add Choice to add another choice.

  • Choice Text
    Set to:
    Weapon ATK+10

Click on Add Choice to add another choice.

  • Choice Text
    Set to:
    Don’t upgrade anything

Has In Inventory

Add > Combatant > Inventory > Had In Inventory

Now, we’ll check if the combatant has 1 Weapon ATK+1 item.

This step is connected to the Choice 0 slot of the upgrade material selection Show Dialogue step.

  • Object
    Select Actor.
  • Actor
    Select Player.

Change the following settings in the already added item.

  • Type
    Select Item.
  • Selection
    Select Weapon ATK+1.
  • Value (Quantity)
    Set to 1.

Remove From Inventory

Add > Combatant > Inventory > Remove From Inventory

The player has the item, so let’s remove it.

This step is connected to the Success slot of the previous Has In Inventory step.

  • Object
    Select Actor.
  • Actor
    Select Player.

Change the following settings in the already added item.

  • Type
    Select Item.
  • Selection
    Select Weapon ATK+1.
  • Value (Quantity)
    Set to 1.

Change Equip Status Value

Add > Combatant > Equipment > Change Equip Status Value

We’ll use this step to chante the ATK bonus of the selected weapon.

Selected Key

  • Value Type (Selected Key)
    Select Value.
  • Value (Selected Key)
    Set to weapon.

Status Value Changes

  • Status Value
    Select ATK.
  • Operator
    Select Add.
  • Value Type
    Select Value.
  • Value
    Set to 1.

Has In Inventory

Add > Combatant > Inventory > Had In Inventory

Now, we’ll check if the combatant has 1 Weapon ATK+5 item.

This step is connected to the Choice 1 slot of the upgrade material selection Show Dialogue step.

  • Object
    Select Actor.
  • Actor
    Select Player.

Change the following settings in the already added item.

  • Type
    Select Item.
  • Selection
    Select Weapon ATK+5.
  • Value (Quantity)
    Set to 1.

Remove From Inventory

Add > Combatant > Inventory > Remove From Inventory

The player has the item, so let’s remove it.

This step is connected to the Success slot of the previous Has In Inventory step.

  • Object
    Select Actor.
  • Actor
    Select Player.

Change the following settings in the already added item.

  • Type
    Select Item.
  • Selection
    Select Weapon ATK+5.
  • Value (Quantity)
    Set to 1.

Change Equip Status Value

Add > Combatant > Equipment > Change Equip Status Value

We’ll use this step to chante the ATK bonus of the selected weapon.

Selected Key

  • Value Type (Selected Key)
    Select Value.
  • Value (Selected Key)
    Set to weapon.

Status Value Changes

  • Status Value
    Select ATK.
  • Operator
    Select Add.
  • Value Type
    Select Value.
  • Value
    Set to 5.

Has In Inventory

Add > Combatant > Inventory > Had In Inventory

Now, we’ll check if the combatant has 1 Weapon ATK+10 item.

This step is connected to the Choice 2 slot of the upgrade material selection Show Dialogue step.

  • Object
    Select Actor.
  • Actor
    Select Player.

Change the following settings in the already added item.

  • Type
    Select Item.
  • Selection
    Select Weapon ATK+10.
  • Value (Quantity)
    Set to 1.

Remove From Inventory

Add > Combatant > Inventory > Remove From Inventory

The player has the item, so let’s remove it.

This step is connected to the Success slot of the previous Has In Inventory step.

  • Object
    Select Actor.
  • Actor
    Select Player.

Change the following settings in the already added item.

  • Type
    Select Item.
  • Selection
    Select Weapon ATK+10.
  • Value (Quantity)
    Set to 1.

Change Equip Status Value

Add > Combatant > Equipment > Change Equip Status Value

We’ll use this step to chante the ATK bonus of the selected weapon.

Selected Key

  • Value Type (Selected Key)
    Select Value.
  • Value (Selected Key)
    Set to weapon.

Status Value Changes

  • Status Value
    Select ATK.
  • Operator
    Select Add.
  • Value Type
    Select Value.
  • Value
    Set to 10.

Reset Combatant Status

Add > Combatant > Status > Reset Combatant Status

This node will recalculate all status values and bonuses of a combatant – since we’ve changed the status bonuses of an equipped weapon through the selected data feature, we need to actively handle that. Otherwise, the bonuses will only affect the player’s stats the next time the recalculation happens (e.g. when equipping something or when a status effect is applied).

This step is connected to the Next slots of the 3 Change Equip Status Value steps.

  • Object
    Select Actor.
  • Actor
    Select Player.

Show Dialogue

Add > UI > Dialogue > Show Dialogue

 

After upgrading the weapon, we’ll let the player know that we’re done.

  • Dialogue Type
    Select Message.
  • GUI Box
    Select Bottom Dialogue.
  • Message
    Set to:
    There you go, champ!

Show Dialogue

Add > UI > Dialogue > Show Dialogue

Finally, in case the player doesn’t have the required upgrade material, we’ll display a message.

This step is connected to the Failed slots of the 3 Has In Inventory steps.

  • Dialogue Type
    Select Message.
  • GUI Box
    Select Bottom Dialogue.
  • Message
    Set to:
    You don’t have the material …

And that’s it for the upgrade event – click on Save Event and save it as weaponUpgradeNPC in Assets/Events/Town/.

Adding the upgrade NPC

Now, all we need to do is add the NPC that will handle our weapon upgrades – open the town scene (1 Town, found at Assets/Tutorial Resources/Scenes/).

We’ll use the NPC_red prefab (found at Assets/Tutorial Resources/NPCs/), drag him into the scene and place him where you want. I’ve placed my NPC behind the tree in the center of town (X=23.47, Y=3.58, Z=27.59).

Add an Event Interaction component to the NPC (e.g. through the inspector: Add Component > ORK Framework > Events > Event Interaction) and change the following settings.

  • Event Asset
    Select the weaponUpgradeNPC event asset we just saved.

Click on Ok to use the selected event.

  • Start Type
    Select Interact.
  • Turn Player To Event
    Enable this setting.
  • Turn Event To Player
    Enable this setting.

And that’s it – don’t forget to save the scene.

Testing

When testing, don’t forget to first purchase the required materials at the shop NPC (the yellow guy in the backyard area).

gameplay_21_weapon_upgrade_npc2

The upgraded weapon’s stats will also be saved with save games.

Tip: Useable item upgrades

If you don’t want an upgrade NPC in your game, you can use useable items instead.

Items that are only useable in the Field can call Global Events – which use regular game events. This way, you can handle the weapon upgrade similar to this tutorial (you probably don’t want the upgrade material selection in this case) without using an NPC.