[HOWTO] How To: Do Skill Checks in Conversations

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

[HOWTO] How To: Do Skill Checks in Conversations

Post by Tony Li »

Here is a skill check example:

DS_SkillCheckExample_2024-02-08.unitypackage

In it, the player is trying to get a security code from an NPC. The player can choose a nice answer ("Please?"), a goodbye answer, or an [Intimidate] answer that runs a skill check. The details of how the conversation is set up are noted in the nodes' Description fields.

To set it up, the [Intimidate] node's Script runs a skill check if selected. In the example, it simply uses math.random() to allow the skill to be successful 50% of the time. This leads to either a success node or a failure node. In practice, you will probably want to register Lua functions to check your player's skill levels. (*See below.)

The [Intimidate] response text uses [em] tags to show "[Intimidate]" with special formatting. It also uses the [position=#] tag to place it in a specific response button position. These tags are optional, but you can use them if you consistently want to show certain categories of skills in certain positions or with certain formatting.

You may also want to show invalid responses -- for example, if the player doesn't meet a minimum skill level. To always show invalid responses, tick the Dialogue Manager's Input Settings > Include Invalid Entries. Their response buttons will be non-interactable. You can also specify an emphasis setting ([em] code) for invalid entries to further distinguish them from clickable responses. If you want to conditionally show some invalid responses but not others, see this post.

EDIT: There's now a third skill check example that uses a Lua function GetLockpickSkill() as a percent (e.g., 50). It then rolls a random number 0-100 to check if the player successfully picked the lock.

* The Dialogue System Extras page has an older, version 1.x skill check example that registers Lua functions. You can import this into a project and run Tools > Pixel Crushers > Dialogue System > Tools > Run 1x to 2x Updater to check it out.
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: [HOWTO] How To: Do Skill Checks in Conversations

Post by Tony Li »

The example on the Extras page (direct download) now also includes a second example that demonstrates how to register Lua functions to get and set the value of a C# "Intimidate" bool variable.

In the second example scene, the Dialogue Manager has a SkillCheckExample script that registers Lua functions. The "Skill Check Example 2" conversation checks the Intimidate bool value to decide whether the NPC is intimidated or not. To test it, you can tick the SkillCheckExample component's Intimidate checkbox during runtime to set the bool value.
hhyu
Posts: 11
Joined: Fri Jul 05, 2024 9:31 am

Re: [HOWTO] How To: Do Skill Checks in Conversations

Post by hhyu »

thx!!
Post Reply