ContentDesigner:Creating Conversations
- Last edited 10 years ago by Vlash Nytefall
ContentDesigner:SpawnScripts - Creating Conversations
Return to: ContentDesigner:SpawnScripts | Tutorials | Portal | Forum | Project Manager | Bug Tracker
The Creating Conversations guide will be broken up into many different sections. The hope is to keep it from being overwhelming when learning to add different parts of conversations to your NPC.
A NPC is not much fun when you first create one. All they do is sand there motionless, and speechless. In order to solve that, a conversation dialog needs to be created. This guide will be using the spawn script of Verex N'Za in Darklight Wood. If you would like you can log on to the emulator and go through the dialog to see how it looks, and if you are a developer you can go to the web db editor under the Verex N'Za spawn section to find the full script. For those who have a local server this is located in worldserver\SpawnScripts\Darklight where you installed you server at. For this guide we want to build the dialog from scratch so we can get a better grasp on building spawn scripts.
First thing to do is create VerexNZa.lua file. If you are using the EQ2LuaEditor then one can be created by going to file->New->Spawn Script. If you are using a text editor like notepad++ then be sure when you save your file you put .lua at the end for the file extention. If you need a template to start off with you can get it at Spawn Script Template at the bottom of that page.
Fill Out The script header --[[ |
Above is an example of what your script header should look like. These are most helpful when a spawn script needs to be edited at a later time, and are required if submitting for use with the emulator.
Function Spawn function spawn(NPC) |
If you notice when you get close to Verex he will motion you over to him and will say something to you as he does. In order to do this it all starts in the spawn function. When a NPC is first created the function spawn is called, and as can be seen in the code above SetPlayerProximityFunction using parameters (NPC, 10, "InRange") will be executed. The SetPlayerProximityFunction allows us to have the NPC say or do something when a player gets within a certain range. We want Verex to call us over when we get close so we have to input the correct parameters for SetPlayerProximityFunction. This is (NPC, 10, "InRange"). The first parameter is NPC and is used to refer to Verex, Next parameter is 10 and is how close to Verex we have to be before he will call us over. Last parameter is "InRange" and is a call to another function called InRange. We will need to create this function so when InRange is called there will be instructions on what needs to be done. But before that we have to add the respawn function.
Function respawn function respawn(NPC) |
The respawn function is needed so if/when a NPC is killed, and it is time for them to respawn, then it will call this function and execute the spawn(NPC) function. This is all that is needed in this function.
Function InRange function InRange(NPC, Spawn) |
Now on to creating the InRange function. The PlayFlavor function inside is what we want Verex to do when a player gets within 10 uints from him. The PlayFlavor function allows you play a voiceover, text, and an emote at the same time. A basic PlayFlavor lua function looks like this.
PlayFlavor(NPC, "", "", "", 0, 0, Spawn)
A quick breakdown of the parameters. NPC points to Verex. The first "" can be filled in with a mp3_filename. The second "" can be filled in with the text that appears in the chat window. The third "" can be filled in with an emote. The first 0 is where you put the first mp3 key if the mp3 file needs a key to be played. The second 0 is where you put the second mp3 key if the mp3 file needs a key to be played. Spawn in this case points to the player.
From the InRange function above we see that PlayFlavor will have the NPC Verex send text to the chat window saying "You there, come here at once! We haven't a second to spare!", and will do the beckon emote to the player.
Function hailed function hailed(NPC, Spawn) |
This is where we are going to start out conversation. So when Verex is hailed it will begin the dialog. Going through the hailed function we want Verex to face the player after they hail. We use the FaceTarget function for this. We need to tell lua to create a conversation. By using the conversation = CreateConversation() statement we are telling lua to set the variable conversation to the CreateConversation function. Now all we have to do is use the word conversation wherever we want a conversation created. We are using PlayFlavor again but this time we have a mp3 file and no text or emote. Also this mp3 file does not need any mp3 keys so they are still set to 0. AddConversationOption function is well you guessed it this adds a conversation option. These are the choices that a player will have in response to what the NPC says, or the chat options. There are two AddConversationOption functions here, and the top AddConversationOption is the top chat option you see when in the game. There are at least two parameters for the AddConversationOption. It has to have converstaion and has to have the text of what you want the chat option to display. Both of these functions have three parameters each. First our conversation that we need to create a conversation, next is "How am I to do that?" and is the text we want to display in our chat option bubble, and last Chat_0_1 this is a call to a function called, you guessed it, Chat_0_1. The next AddConversationOption is where you put the chat option you want to be listed second. If you need another chat option then add another AddConversationOption on a new line under the second AddConversationOption and before StartConverstation. The StartConverstation function will start the conversation. Everything below this function will not be included in the conversation, and this is what the NPC will be saying. There are four parameters here. It too has to have conversation first in order to create the conversation. Next is NPC and points to Verex. After that is who receives the conversation. This is pointing to the player. Last is what the NPC is going to say. Notice that this has a special addition to the NPC text " .. GetName(Spawn) .. ". What this does is get the name of the player and will display that players name in the conversation. Finally be sure to close the function with end.
More Comming Soon...