This page describes how to set up the Dialogue System with Vis2k's uSurvival. (uSurvival v1.25+ is required.)
uSurvival copyright © Vis2k.
Features
The Dialogue System's uSurvival integration adds these features:
- Conversations and barks using the Dialogue System.
- Quests, quest log window, and quest tracker HUD.
- Lua functions to control uSurvival.
Unlike uMMORPG, uSurvival doesn't have an addon system. To set up this integration, you will need to make a few small code additions.
Setup
Import the package Third Party Support ► uSurvival Support. This will unpack files into the folder Assets ► uSurvival ► Addons ► Dialogue System for Unity Addon.
Example Scene
The scene in the Example subfolder is configured according to the instructions below. A zombie NPC inside the compound plays a conversation.
Configuration
Code Additions
Edit Database.cs. You will need to make 3 additions:
- Add the lines of code ending in "// [PixelCrushers] ==========" to the beginning of the class:
{
public delegate void GameObjectMethodDelegate(GameObject go);
public static event GameObjectMethodDelegate LoadingCharacter = delegate { };
public static event GameObjectMethodDelegate SavingCharacter = delegate { };
Definition Database_DialogueSystem.cs:6
- Add this line near the end of the CharacterLoad method:
LoadingCharacter(go);
return go;
}
else Debug.LogError("no prefab found for class: " + className);
}
return null;
}
- Add this line near the end of the CharacterSave method:
SavingCharacter(player.gameObject);
if (useTransaction) connection.Commit();
}
In the Unity editor, select Edit → Project Settings → Player. Add this symbol to Other Settings → Scripting Define Symbols:
USURVIVAL_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.
- Add a Quest Log Window Hotkey to the quest log window.
- Remove Instantiate Prefabs ► Standard UI Selector Elements & Quest Log Window.
- Optimizations:
- 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. Untick Include Status and Relationship Data and Include Actor Data.
- Add a uSurvival Save Load Dialogue System component to the Dialogue Manager.
- Add a uSurvival Lua component to the Dialogue Manager. If you've renamed the items Resources folder, set Items Folder Name.
- 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.)
Player Prefab Setup
- Add a Player Dialogue System Data component to your player prefabs.
NPC Setup
To configure an NPC for dialogue:
- Add a Dialogue System Interactable component to the NPC. This will automatically add a Dialogue System Trigger and tie it into uSurvival's interaction system.
- Configure the Dialogue System Trigger to play a conversation.
Lua Functions
In your conversations and triggers, you can use these Lua functions:
Lua Function | Description |
GetPlayerName() | Returns the player's name. |
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. |
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. |
GetHydration() | Returns the player's current hydration. |
GetBaseHydration() | Returns the player's base hydration. |
AddHydration(amount) | Adds to the player's current hydration. |
AddBaseHydration(amount) | Adds to the player's base hydration. |
GetNutrition() | Returns the player's current nutrition. |
GetBaseNutrition() | Returns the player's base nutrition. |
AddNutrition(amount) | Adds to the player's current nutrition. |
AddBaseNutrition(amount) | Adds to the player's base nutrition. |
GetTemperature() | Returns the player's current temperature. |
AddTemperature(amount) | Adds to the player's current temperature. |
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. |
UpdateServer() | Updates Dialogue System data to the server. The server is also automatically updated whenever a conversation ends or a quest state changes. |
Notes:
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 uSurvival'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:1157
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
- By default, the state is synced to the server at the end of conversations and when quest states change.
- This addon adds a table named 'dialoguesystem' containing the saved Dialogue System state for each character.
<< Third Party Integration