Difference between revisions of "ContentDesigner:Creating Conversations"

(Created page with "{{PageHeaderChild|ContentDesigner:SpawnScripts|Creating Conversations}} The Creating Conversations guide will be broken up into many different sections. The hope is to keep it f...")
 
Line 4: Line 4:
  
  
{{Header|The Template|BackgroundColor=3d78b4|FontColor=ffffff}}
+
{{Header|Getting A NPC To Talk|BackgroundColor=3d78b4|FontColor=ffffff}}
In order to have a spawn script that can be submitted to the server you must follow a certain structure. First will be a break down of the code with an explanation of what each part does. At the bottom there will be the full template. If you are using the EQ2EmuLuaEditor then one can be created by going to file->New->Spawn Script.
+
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 [[ContentDesigner:Spawn_Script_Template | Spawn Script Template]] at the bottom of that page.
 
{|style="table-layout:fixed; width: 100%;"
 
{|style="table-layout:fixed; width: 100%;"
 
|{{TextBox
 
|{{TextBox
|Comments Section
+
|Fill Out The Comments Section
 
|--[[<br/>
 
|--[[<br/>
Script Name : <script-name><br/>
+
Script Name : SpawnScripts/DarklightWood/VerexNZa.lua<br/>
Script Purpose : <purpose><br/>
+
Script Purpose : Verex N'Za (340030)<br/>
Script Author : <author-name><br/>
+
Script Author : Cynnar<br/>
Script Date : 9/7/2015<br/>
+
Script Date : 2015.07.01<br/>
Script Notes : <special-instructions><br/>
+
Script Notes :<br/>
 
--]]
 
--]]
 
|BackgroundColor=ffffff
 
|BackgroundColor=ffffff
 
|FontColor=000000}}
 
|FontColor=000000}}
 
|}
 
|}
In the comments section is where information goes about the spawn script that is being made. This information is useful when you or someone else needs to look at the script if an error occurs at a later date. A comment section can be quickly located by the two dashes followed by two left square brackets at the beginning of a line ''--[['' and has two dashes followed by two right square brackets ''--]]'' on the last line after the comment. As we can see from the code above there is a place for the scripts name, purpose, author, date, and notes.<br/>
+
Above is an example of what your comments section should look like. These are most helpful when a spawn script needs to be edited at a later time.
'''Script Name:''' This is where the the name of the NPC the script is created for will go. It also includes the location of that script and will look something like this.
+
{|style="table-layout:fixed; width: 100%;"
  Script Name : SpawnScripts/Darklight/VerexNZa.lua
+
|{{TextBox
The above example is case sensitive, and all spawn scripts will go into a folder called ''SpawnScripts''. This is the first line as can be seen in the example above. Next is the zone of the NPC. This NPC is located in Darklight Wood, so it will go into a folder named ''Darklight''. After that is the name of the NPC that this spawn script will be assigned to. As can be seen above ''VerexNZa'' the name of the NPC Verex N'Za. Notice that the ' has been removed in the naming process. Last is the .lua. Since LUA is the scritping language that the emulator uses so it must be present.<br/>
+
|Function Spawn
'''Script Purpose:''' This is where the name of the NPC will go. For extra clarification the spawn ID can be placed in here as well. This will help later on to identify the NPC in the database. It will look something like this.
+
|function spawn(NPC)<br/>
  Script Purpose : Verex N'Za (340030)
+
SetPlayerProximityFunction(NPC, 10, "InRange")<br/>
'''Script Author:''' This is where the author of the script goes. Easy enough to figure out, and could possibly let someone know who to contact with either help on the script, or questions on why they done something the way they did. Just to keep the layout of this page the same here is what it will look like.
+
end
  Script Author : Cynnar
+
|BackgroundColor=ffffff
'''Script Date:''' This is where the date you made the script goes. It could be helpful if there is a server code change and scripts before that date need to be edited to reflect those changes. Here is what it will look like.
+
|FontColor=000000}}
  Script Date : 2015.07.01
+
|}
'''Script Notes:''' Here is where any special notes goes. An example would be if there is something that needs to be added to the spawn script but is not able to be added at the current time of coding. Here is what it should look like.
+
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 those parameters in ''(NPC, 10, "InRange")''. The first parameter is ''NPC'' and is used to refer to Verex, Next parameter is ''10'' and is how far away from Verex we want him to call us over. Last parameter is ''"InRange"'' and is a call to the function InRange.
  Script Notes : Missing PlayFlavor information for the hail function.
+
{|style="table-layout:fixed; width: 100%;"
<br/>
+
|{{TextBox
 +
|Function InRange
 +
|function InRange(NPC, Spawn)<br/>
 +
PlayFlavor(NPC, "", "You there, come here at once! We haven't a second to spare!", "beckon", 0, 0, Spawn)<br/>
 +
end
 +
|BackgroundColor=ffffff
 +
|FontColor=000000}}
 +
|}
 +
The ''PlayFlavor'' function inside the ''function InRange'' is what we want Verex to do when a player gets within 10 m from him. The ''PlayFlavor'' function allows you play a voiceover, text, and an emote at the same time.
 +
 
 
'''''More Comming Soon...'''''
 
'''''More Comming Soon...'''''

Revision as of 00:08, 8 September 2015

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.


Getting A NPC To Talk

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 Comments Section

--[[
Script Name : SpawnScripts/DarklightWood/VerexNZa.lua
Script Purpose : Verex N'Za (340030)
Script Author : Cynnar
Script Date : 2015.07.01
Script Notes :
--]]

Above is an example of what your comments section should look like. These are most helpful when a spawn script needs to be edited at a later time.

Function Spawn

function spawn(NPC)
SetPlayerProximityFunction(NPC, 10, "InRange")
end

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 those parameters in (NPC, 10, "InRange"). The first parameter is NPC and is used to refer to Verex, Next parameter is 10 and is how far away from Verex we want him to call us over. Last parameter is "InRange" and is a call to the function InRange.

Function InRange

function InRange(NPC, Spawn)
PlayFlavor(NPC, "", "You there, come here at once! We haven't a second to spare!", "beckon", 0, 0, Spawn)
end

The PlayFlavor function inside the function InRange is what we want Verex to do when a player gets within 10 m from him. The PlayFlavor function allows you play a voiceover, text, and an emote at the same time.

More Comming Soon...