Page 1 of 1

Dialogue system Quest Reward direct to Invector inventory ?

Posted: Sun Aug 19, 2018 5:29 am
by Rai Jo
Compatible to give a reward of Dialogue system Quest direct Invector inventory ?

Re: Dialogue system Quest Reward direct to Invector inventory ?

Posted: Sun Aug 19, 2018 10:36 am
by Tony Li
Hi,

There is no built-in way to give an Invector inventory item. Not all of the Invector controllers have an inventory system, so it's not included in the Dialogue System integration. To add a reward, you must write a little code. Here are some different ways to do it:

1. Use the SendMessage() sequencer command. Add a script to the player that has a method named GiveInvectorItem:

Code: Select all

public string GiveInvectorItem(string itemName)
{
    // Your code here to add Invector item to inventory.
 }
In a dialogue entry node, use it like this:
  • Speaker (actor): NPC quest giver
  • Listener (conversant): Player
  • Dialogue Text: "Here is a Fire Sword."
  • Sequence: {{default}}; SendMessage(GiveInvectorItem, Fire Sword, listener)

2. Or you can register a C# method with Lua:

Code: Select all

void OnEnable()
{
    Lua.RegisterFunction("GiveInvectorItemToPlayer", this, SymbolExtensions.GetMethodInfo(() => GiveInvectorItemToPlayer(string.Empty)));
}

public void GiveInvectorItemToPlayer(string itemName)
{
    var player = GameObject.FindObjectWithTag("Player");
    // Your code here to add itemName to player.
}
Use it in a dialogue entry node like this:
  • Speaker (actor): NPC quest giver
  • Dialogue Text: "Here is a Fire Sword."
  • Script: GiveInvectorItemToPlayer("Fire Sword")