Difference between revisions of "ContentDesigner:Creating Conversations"

Line 26: Line 26:
 
|Function Spawn
 
|Function Spawn
 
|function spawn(NPC)<br/>
 
|function spawn(NPC)<br/>
SetPlayerProximityFunction(NPC, 10, "InRange")<br/>
+
&nbsp;&nbsp;&nbsp;&nbsp;SetPlayerProximityFunction(NPC, 10, "InRange")<br/>
 
end
 
end
 
|BackgroundColor=ffffff
 
|BackgroundColor=ffffff
 
|FontColor=000000}}
 
|FontColor=000000}}
 
|}
 
|}
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.
+
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.
 +
{|style="table-layout:fixed; width: 100%;"
 +
|{{TextBox
 +
|Function respawn
 +
|function respawn(NPC)<br/>
 +
&nbsp;&nbsp;&nbsp;&nbsp;spawn(NPC)<br/>
 +
end
 +
|BackgroundColor=ffffff
 +
|FontColor=000000}}
 +
|}
 +
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.
 +
 
 
{|style="table-layout:fixed; width: 100%;"
 
{|style="table-layout:fixed; width: 100%;"
 
|{{TextBox
 
|{{TextBox
 
|Function InRange
 
|Function InRange
 
|function InRange(NPC, Spawn)<br/>
 
|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/>
+
&nbsp;&nbsp;&nbsp;&nbsp;PlayFlavor(NPC, "", "You there, come here at once! We haven't a second to spare!", "beckon", 0, 0, Spawn)<br/>
 
end
 
end
 
|BackgroundColor=ffffff
 
|BackgroundColor=ffffff
 
|FontColor=000000}}
 
|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.
+
Now on to creating the InRange function. The ''PlayFlavor'' function inside 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. 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.
 +
 
 +
 
 +
 
  
 
'''''More Comming Soon...'''''
 
'''''More Comming Soon...'''''

Revision as of 21:51, 10 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 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)
    spawn(NPC)
end

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)
    PlayFlavor(NPC, "", "You there, come here at once! We haven't a second to spare!", "beckon", 0, 0, Spawn)
end

Now on to creating the InRange function. The PlayFlavor function inside 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. 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.



More Comming Soon...