Here is a simple example, for a complete comparison of a hailed function check the spoiler at the end of the post.
Now how to actually use this, first thing you need to do in your spawn script is to include it at the top of the file
Code: Select all
require "SpawnScripts/Generic/DialogModule"
Code: Select all
function hailed(NPC, Spawn)
Dialog.New(NPC, Spawn)
The next step would be to add a dialog with AddDialog(), this will be what the npc says to the player
Code: Select all
Dialog.AddDialog("Was that all three?")
Code: Select all
Dialog.AddVoiceover("voiceover/english/neriak/calnozz_j_melvirr/darklight_wood/tvatar_post/calnozz/calnozz008_progress.mp3", 1983465757, 3955037985)
If the NPC plays an emote when they say this dialog we can add that with AddEmote()
Code: Select all
Dialog.AddEmote("cheer")
We can only show this dialog if the player meets certain requirements by using AddRequirement()
Code: Select all
Dialog.AddRequirement(REQ_QUEST_HAS_COMPLETED_QUEST, 155)
Code: Select all
local DrawUponWellsprings = 155
...
Dialog.AddRequirement(REQ_QUEST_HAS_COMPLETED_QUEST, DrawUponWellsprings)
Code: Select all
Dialog.AddRequirement(REQ_QUEST_ON_STEP, StunningRevelation, 2)
Here is all the currently supported requirement types.
Code: Select all
REQ_RACE
REQ_CLASS
REQ_LEVEL
REQ_LEVEL_GREATER_OR_EQUAL
REQ_LEVEL_LESS_OR_EQUAL
REQ_QUEST_ELIGIBLE
REQ_QUEST_ON_STEP
REQ_QUEST_BEFORE_STEP
REQ_QUEST_PAST_STEP
REQ_QUEST_HAS_QUEST
REQ_QUEST_DOESNT_HAVE_QUEST
REQ_QUEST_NOT_ON_STEP
REQ_QUEST_HAS_COMPLETED_QUEST
REQ_QUEST_NOT_HAS_COMPLETED_QUEST
REQ_TEMP_VAR_NOT_SET
REQ_TEMP_VAR_SET
REQ_LUA_HISTORY_SET
REQ_LUA_HISTORY_NOT_SET
REQ_LOCATION_ID
REQ_TSLEVEL
REQ_TSLEVEL_GREATER_OR_EQUAL
REQ_TSLEVEL_LESS_OR_EQUAL
Code: Select all
Dialog.AddDialog("Did you collect them?")
Dialog.AddRequirement(REQ_QUEST_HAS_COMPLETED_QUEST, StunningRevelation)
Dialog.AddRequirement(REQ_QUEST_DOESNT_HAVE_QUEST, InfantileIngredients)
Dialog.AddRequirement(REQ_QUEST_NOT_HAS_COMPLETED_QUEST, InfantileIngredients)
To add an option to the dialog you would use AddOption()
Code: Select all
Dialog.AddOption("Yes, I have them here.", "Quest_DustToDust")
Dialog.AddOption("Not Yet")
Code: Select all
function Quest_DudtToDust(NPC, Spawn)
end
We can also add requirements to options so they are only displayed when the player passes the check, for this we use AddOptionRequirement()
Code: Select all
Dialog.AddOptionRequirement(REQ_QUEST_NOT_ON_STEP, InfantileIngredients, 2)
Finally when you are done setting up your dialog you will call Start() to show it to the player
Code: Select all
Dialog.Start()
The order you add dialogs matters. Requirements will be checked from the first dialog added to last and as soon as it finds a dialog it can display it will not bother checking the following dialogs. So if you have a dialog that has no requirements then it should be the very last one you add just before you call Start()
Any requirements you add the player has to pass ALL of them in order to see the dialog or option they are assigned to.
Here is a comparison of a script I updated to use the DialogModule