uRPG Support

This page describes how to set up the Dialogue System with Vis2k's uRPG. (uRPG v1.25+ is required.)

uRPG copyright © Vis2k.

Features

The Dialogue System's uRPG integration adds these features:

  • Conversations and barks using the Dialogue System.
  • Quests, quest log window, and quest tracker HUD.
  • Lua functions to control uRPG.

To set up this integration, you will need to make a few small code additions.

Setup

Import the package Third Party Support ► uRPG Support. This will unpack files into the folder Assets ► Pixel Crushers ► Dialogue System ► Third Party Support ► uRPG Support.

Example Scene

The scene in the Example subfolder is configured according to the instructions below.

Configuration

Code Additions

Edit SaveGame.cs. You will need to make 3 small additions:

  1. Add the lines of code ending in "// [PixelCrushers] ==========" to the beginning of the class:
    public class SaveGame
    {
    public delegate void SaveLoadMethodDelegate(SqliteConnection connection, GameObject go); // [PixelCrushers] ==========
    public static event SaveLoadMethodDelegate LoadingCharacter = delegate { }; // [PixelCrushers] ==========
    public static event SaveLoadMethodDelegate SavingCharacter = delegate { }; // [PixelCrushers] ==========
  2. Add this line near the end of the LoadCharacter method:
    LoadingCharacter(connection, go); // [PixelCrushers] ==========
    return go;
    }
    else Debug.LogError("no prefab found for class: " + className);
    }
    return null;
    }
  3. Add this line near the end of the SaveCharacter method:
    SavingCharacter(connection, player); // [PixelCrushers] ==========
    // end transaction
    ExecuteNonQuery("END");
    }

Edit GameStateManager.cs. You will need to make 1 small addition:

  1. Add this line at the beginning of the LeaveWorld method:
    public void LeaveWorld()
    {
    Destroy(DialogueManager.instance.gameObject); // [PixelCrushers] ==========
    // the best way to fully leave the world 100% and reset EVERYTHING is to
    // reload the scene
    // -> otherwise we might forget to reset monsters, etc.
    SceneManager.LoadScene(SceneManager.GetActiveScene().name);
    }

In the Unity editor, select Edit → Project Settings → Player. Add this symbol to Other Settings → Scripting Define Symbols:

URPG_PIXELCRUSHERS

Configure Dialogue Manager

  • Add the prefab Plugins ► Pixel Crushers ► Dialogue System ► Prefabs ► Dialogue Manager to the scene.
  • Set the Dialogue Manager ► Canvas's Sort Order to 1.
  • Add a dialogue UI instance to the Canvas. Assign it to the Dialogue Manager's Dialogue UI field.
  • Assign the dialogue UI's Dialogue Panel (not the dialogue UI GameObject itself) to Main Camera > Cursor Locking > Windows That Unlock Cursor.
  • Add a quest log window to the Canvas.
  • Assign the quest log window's Main Panel (not the quest log window GameObject itself) to Main Camera > Cursor Locking > Windows That Unlock Cursor.
  • Optional: Add a Quest Log Window Hotkey to the quest log window.
  • Remove Instantiate Prefabs ► Standard UI Selector Elements & Quest Log Window.
  • Optimizations (optional):
    • Remove the Input Device Manager component. It isn't necessary unless you need to detect changes between using mouse and gamepad.
    • In Persistent Data Settings, change Record Persistent Data On to Only Registered GameObjects.
  • Add a Dialogue System Saver component.
  • Add a uRPG Save Load Dialogue System component to the Dialogue Manager.
  • Add a uRPG Lua component to the Dialogue Manager.
  • Optional but recommended: Add these components to the Dialogue Manager: Save System, Json Data Serializer, PlayerPrefs Saved Game Data Storer (not used but silences a warning).
    • Untick the Save System's Save Current Scene checkbox since uRPG will handle this.
  • Create a dialogue database and assign it to the Dialogue Manager.
  • Customize the UI. (This step is best saved for later, after you've confirmed everything else is working properly.)

Configure Main Menu

  • Expand Canvas > StartMenu > StartMenuPanel.
  • Add a UI button to open the quest log window.
  • Add a UIStartMenuDialogueSystemExtras component to the StartMenu, and assign the UI button to it.

NPC & Interactable Setup

To configure an NPC for dialogue:

  • Create one of these two assets:
    1. Conversation, Trading and Close dialogue asset: This works like uRPG's "Quests, Trading and Close" asset except it plays access Dialogue System conversation instead of showing uRPG's basic quests window. In addition, all text in the asset can be localized by assigning a text table to the Dialogue Manager and adding translations to the text table.
    2. Conversation dialogue asset: Immediately starts a Dialogue System conversation.
  • Inspect the asset and select a conversation from the dropdown.

To configure some other object to use a Dialogue System Trigger when interacted with:

  • Add a Dialogue System Trigger set to OnUse. Configure its actions (and optionally its conditions).
  • Add a Dialogue System Interactable component.
  • Add a collider so uRPG can detect it as an interactable.

Cutscenes

If you want to play a cutscene and take control of the player's camera, use these two sequencer commands at the beginning to disable uRPG's control:

SetEnabled(PlayerMovement,false,tag=Player);
SetEnabled(PlayerLook,false,tag=Player)
Definition Player_DialogueSystem.cs:13

At the end of the cutscene, use these two sequencer commands to re-enable uRPG's control:

required SetEnabled(PlayerMovement,true,tag=Player);
required SetEnabled(PlayerLook,true,tag=Player)

Quests

  • For kill quests, point the monster's Health > OnEmpty() event to a Dialogue System Trigger that increments a kill count variable, updates a quest state, etc.
  • Set up other quests as normal in the Dialogue System.
  • Can you use the Lua functions below to check the player's stats and inventory, and to give rewards upon quest completion.

Lua Functions

In your conversations and triggers, you can use these Lua functions:

Lua Function Description
GetPlayerName() Returns the player's name.
GetLevel() Returns the player's level.
AddExp(amount) Gives experience points to the player.
AddSkillExp(amount) Gives skill experience points to the player.
GetGold() Returns the amount of gold the player has.
AddGold(amount) Gives gold to the player.
RemoveGold(amount) Removes gold from the player.
GetItemAmount("itemName") Returns the amount of an item that the player has.
AddItem("itemName", amount) Gives items to the player.
RemoveItem("itemName", amount) Removes items from the player.
Trade() Opens the trade window with the current NPC.
GetHealth() Returns the player's current
GetBaseHealth() Returns the player's base health.
AddHealth(amount) Adds to the player's current health.
AddBaseHealth(amount) Adds to the player's base health.
GetMana() Returns the player's current
GetBaseMana() Returns the player's base mana.
AddMana(amount) Adds to the player's current mana.
AddBaseMana(amount) Adds to the player's base mana.
GetEndurance() Returns the player's current endurance.
GetBaseEndurance() Returns the player's base endurance.
AddEndurance(amount) Adds to the player's current endurance.
AddBaseEndurance(amount) Adds to the player's base endurance.
GetStrength() Returns the player's current strength.
AddStrength(amount) Adds to the player's current strength.
GetIntelligence() Returns the player's current intelligence.
AddIntelligence(amount) Adds to the player's current intelligence.

Notes:

  • You can add a Lua Console to the Dialogue Manager if you want to test or access these functions during play.
  • To reference a value such as the player's name in dialogue text, use the [lua] markup tag. Example: "Hello, [lua( GetPlayerName() )]." (See Markup Tags.)

Quests

To automatically update the quest tracker HUD when an item is added or removed from the inventory, add this line of code to the beginning of the Add and Remove methods in uRPG's Inventory.cs:

A static class that provides a simplified interface to the Dialogue System's core functions.
Definition DialogueManager.cs:14
static void SendUpdateTracker()
Sends an "UpdateTracker" message to the Dialogue Manager, which may have a quest tracker component th...
Definition DialogueManager.cs:1147
Definition DemoInputRegistration.cs:4
Definition MessageEventsEditor.cs:7

Sequencer Commands

Warp()

Syntax: Warp(destination, [subject])

Description: Warps a subject to a destination.

  • destination: GameObject name. If inactive, its root parent must be an active GameObject.
  • subject: GameObject to warp. Default: speaker.

Other Notes

  • This addon adds a table named 'dialoguesystem' containing the saved Dialogue System state for each character.

<< Third Party Integration