set Bool for NPC that is convinced to join my party

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
americanbob
Posts: 1
Joined: Sun Apr 01, 2018 12:32 pm

set Bool for NPC that is convinced to join my party

Post by americanbob »

hello,
i write a simple party system for the npc of my game, they to follow me, help in fights,, i'm control these functions with a bool on the npc "inParty" so if inParty is true for a npc, it will disable the "conversation trigger" collider and they will follow me etc.

i see there is variables section in dialogue but i'm not sure will help i need to set bool on my script for individual npc. is there a good way this can be with dialogue system?
User avatar
Tony Li
Posts: 22059
Joined: Thu Jul 18, 2013 1:27 pm

Re: set Bool for NPC that is convinced to join my party

Post by Tony Li »

Hi,

Instead of using a bool in your C# script, you can define a field in your NPC actor:

Image

To set the field's value in a dialogue entry, use Script:

Image

To check or set the field's value in a C# script, use DialogueLua:

Code: Select all

using PixelCrushers.DialogueSystem;
...
// Is Fred in the party?
bool isInParty = DialogueLua.GetActorField("Fred the Warrior", "inParty").AsBool;
...
// Fred leaves the party:
DialogueLua.SetActorField("Fred the Warrior", "inParty", false);
DialogueManager.BarkString("Goodbye for now.", fred.transform);
Fields are included in saved games. When you load a game or change scenes, you can automatically activate/deactivate the NPC's conversation collider using a Persistent Active Data component:

Image
Post Reply