This page describes how to set up the Dialogue System with Action-RPG Starter Kit and how to use them together. (Action-RPG Starter Kit is required.)
Action-RPG Starter Kit copyright © Hitbear Studio.
Follow these steps to set up the Dialogue System with Action-RPG Starter Kit.
Import the package Assets ► Plugins ► Pixel Crushers ► Dialogue System ► Third Party Support ► Action-RPG Starter Kit Support. This will unpack files into the folder Assets ► Pixel Crushers ► Dialogue System ► Third Party Support ► Action-RPG Starter Kit Support.
In the first scene that will spawn the PC or will involve the Dialogue System, add a Dialogue Manager.
Most of the setup is done in the player prefab, which is the prefab that's spawned by Player Spawnpoint. You may want to make a copy of an existing ARPG prefab and customize it.
Select the player prefab. Then select menu item Tools → Pixel Crushers → Dialogue System → Third Party → Action-RPG Starter Kit → Setup Player Prefab.
This will add several components to your player prefab. Afterward, you will need to customize these components:
Finally, point Player Spawnpoint (in your scene) to your prefab.
You will also need to Setup Death Body Prefab.
On the player prefab's StatusC component, examine the prefab assigned to Death Body. (In the example scene, the prefab is HeroineDeathC DS.) Replace the death body prefab's GameOverC component with the Dialogue System version, DS GameOverC, and assign your player prefab to the Player property.
On your NPCs, add these components:
Vanilla Action-RPG projects use TeleporterC to change scenes. With the Dialogue System, use DS Teleporter instead.
For a new teleporter, select menu item Component → Pixel Crushers → Dialogue System → Third Party → Action-RPG Starter Kit → DS Teleporter.
For existing teleporters:
By default, a teleporter activates when the player enters its trigger collider. If you change Activation Method to OnUse, it will activate when the player presses the Proximity Selector's "Use" key ("E" by default). In this case, add a Usable component to the teleporter to make it usable.
The Example folder contains example scenes.
To play, add these scenes to build settings:
Then play Action-RPG Starter Kit Example.
In front of the player is an NPC titled "Dialogue". You can run up to the NPC and press E
to talk.
The NPC's conversation demonstrates how to access ARPG data (such as player health), add and remove items, manage quests, and open the NPC's shop. You don't have to add quests and a shop to every NPC. This example NPC just has everything so it can demonstrate how they all work together.
The example scene uses the Dialogue System's quest system. At this time, the quest systems provided by ARPG and the Dialogue System are not integrated together. We suggest you choose one quest system – for example, the Dialogue System's quest system (see Quests) – and design all quests with that system and its associated UI elements.
The player's DS Save Load component works on top of ARPG's SaveLoadC component. It acts as a Save System saver for player data. It also presents a simple menu where you can access the quest log and save, load, and quit your game. You can disable this menu by unticking Menu Enabled.
The DS Save Load component has a "Quit to Title" menu option. Due to the way ARPG handles cursors, this option leaves the cursor hidden when returning to the title scene. Add a Set Cursor On Start component to your title scene to work around this issue.
The NPC's quest requires the player to kill two goblins. The goblins have Increment On Destroy components that increment a variable in the dialogue database to keep track of how many the player has killed.
The example scene has one teleporter to the a customized SpiderDungeon DS scene. The teleporter uses a Dialogue System Trigger that runs the ARPGLoadLevel() sequencer command (see Sequencer Commands below). To keep the package smaller, it doesn't include a modified copy of the SpiderDungeon scene, so teleporting back to the example scene won't use the Dialogue System.
During conversations, you can read and write the following Lua fields in your dialogue entry Scripts and Conditions:
Variable | Description |
---|---|
Actor["Player"].level | The player's current level |
Actor["Player"].atk | The player's current attack value |
Actor["Player"].def | The player's current defense value |
Actor["Player"].matk | The player's current magic attack value |
Actor["Player"].mdef | The player's current magic defense value |
Actor["Player"].exp | The player's current experience |
Actor["Player"].maxExp | The player's max experience |
Actor["Player"].health | The player's current health |
Actor["Player"].maxHealth | The player's max health |
Actor["Player"].mana | The player's current mana |
Actor["Player"].maxMana | The player's max mana |
Actor["Player"].statusPoint | The player's status points |
Actor["Player"].cash | The player's current cash |
Actor["Player"].Item# | The item ID number associated with item slot # (0-15) |
Actor["Player"].ItemQty# | The quantity of these items in item slot # (0-15) |
Actor["Player"].Equipm# | The item ID number associated with equipment slot # (0-7) |
Actor["Player"].WeaEquip | The item ID of the currently-equipped weapon |
Actor["Player"].ArmoEquip | The item ID of the currently-equipped armor |
Actor["Player"].Skill# | The skill associated with skill slot # (0-2) |
Actor["Player"].SkillList# | The skill value associated with skill list slot # (0-8) |
For example, if the player is talking with an NPC, and the NPC decides to fully heal the player, you could add this to the dialogue entry's Script field:
Actor["Player"].health = Actor["Player"].maxHealth
If your player is named something different in the dialogue database, replace "Player" with the name in the database.
These values are copied into the Dialogue System's Lua environment at the start of the conversation, and are copied back to ARPG at the end of the conversation. If you need the values to take effect in ARPG immediately, use the Lua functions listed below.
During conversations, you can use these Lua functions in your dialogue entry Scripts and Conditions:
Function | Returns | Description |
---|---|---|
SetPlayerLevel(#) | (nothing) | Sets the player's current level |
SetPlayerAtk(#) | (nothing) | Sets the player's current attack value |
SetPlayerDef(#) | (nothing) | Sets the player's current defense value |
SetPlayerMAtk(#) | (nothing) | Sets the player's current magic attack value |
SetPlayerMDef(#) | (nothing) | Sets the player's current magic defense value |
SetPlayerExp(#) | (nothing) | Sets the player's current experience |
AdjustPlayerExp(#) | (nothing) | Increments the player's current experience (e.g., AdjustPlayerExp(50) to grant 50 experience) |
SetPlayerMaxExp(#) | (nothing) | Sets the player's max experience |
SetPlayerHealth(#) | (nothing) | Sets the player's current health |
SetPlayerMaxHealth(#) | (nothing) | Sets the player's max health |
SetPlayerMana(#) | (nothing) | Sets the player's current mana |
SetPlayerMaxMana(#) | (nothing) | Sets the player's max mana |
SetPlayerStatusPoint(#) | (nothing) | Sets the player's status points |
GetItemCount(id) | Number | Returns the number of items with the specified item ID. Item IDs are defined in ARPG item prefab ItemC components |
AddItem(id, quantity) | (nothing) | Gives the player a quantity of items with the specified item ID |
RemoveItem(id, quantity) | (nothing) | Removes a quantity of items from the player |
HasEquipment(id) | Boolean | Returns true if the player has an equipment item; otherwise false |
AddEquipment(id) | (nothing) | Gives the player an equipment item |
RemoveEquipment(id) | (nothing) | Removes an equipment item from the player, even if it's currently equipped |
You can use the following sequencer commands in your dialogue entries' Sequence fields to interface with ARPG.
Syntax: ARPGAdjustHealth(
subject, amount, element)
Description: Adjusts the health of any character that has an ARPG StatusC component.
Parameters:
speaker
99999
0
(none)Example:
ARPGAdjustHealth()
(Heal the speaker for 99999 points)ARPGAdjustHealth(Lord Voldemort, -125, 1)
(Inflict 125 damage of element type #1 on the GameObject named "Lord Voldemort")Syntax:ARPGOpenShop(
subject)
Description: Opens the shop of any character that has an ARPG ShopC component.
Parameters:
speaker
Example:
ARPGOpenShop(listener)
(Open the shop of the dialogue entry's listener)Syntax:ARPGLoadLevel(
levelName, spawnPointName)
Description: This is a variation of the LoadLevel() sequencer command that works with ARPG. This command changes levels with full Dialogue System data persistence.
Parameters:
Example:
ARPGLoadLevel(Scene2, Spawn From Scene1)
(Teleport to "Spawn From Scene1" in the level "Scene2")More info: Cutscene Sequences