Entire Code:
Code:
#PreCheck_0 {
checkQuest(33)
ifNotStarted(#Convo,0)
ifInProgress(#Convo,100)
ifComplete(#PreCheck,1000)
}
#Convo_0 {
NPC_Say(Hello player. I will test how friendly you are... How are you today?)
Player_A_Say(I'm good how are you?)
Player_A_Send(#Convo,1)
Player_B_Say(Don't talk to me)
Player_B_Send(#Convo,5)
}
//If player picks option A, this window is displayed
#Convo_1 {
NPC_Say(You are friendly.)
Player_A_Say(Yes I am nice.)
Player_A_Send(#PromptQuest,33)
}
//Otherwise if player picks option B, this window is displayed
#Convo_5 {
NPC_Say(You are not friendly!)
Player_A_Say(Yes I am evil.)
Player_A_Send(npc.end)
}
//In a PromptQuest dialogue, the Player_A_Send is now the accept button, and the B is the deny.
#PromptQuest_33 {
NPC_Say(Would you like to help me with this quest?)
Player_A_Say(Yes!)
Player_A_Send(#Convo,10,#Convo,11)
Player_B_Say(No...)
Player_B_Send(#Convo,15)
}
//Player accepts and has fulfilled requirements
#Convo_10 {
NPC_Say(You accepted my quest.)
Player_A_Say(Yes I did accept it.)
Player_A_Send(npc.end)
}
//Player accepts and has not fulfilled requirements
#Convo_11 {
NPC_Say(You cannot accept this because you are not strong enough.)
Player_A_Say(I will come back when the time is right.)
Player_A_Send(npc.end)
}
//Player Denies
#Convo_15 {
NPC_Say(You did not accept my quest.)
Player_A_Say(No I did not accept it.)
Player_A_Send(npc.end)
}
//In Progress
#Convo_100 {
NPC_Say(Hope you haven't gotten into too much trouble since we last spoke.)
Player_A_Say(I am doing well.)
Player_A_Send(#CompleteQuest,33)
Player_B_Say(Goodbye.)
Player_B_Send(npc.end)
}
//In a PromptQuest dialogue, the Player_A_Send is now the accept button, and the B is the deny.
#CompleteQuest_33 {
NPC_Say(Would you like to complete the quest?)
Player_A_Say(Yes!)
Player_A_Send(#Convo,110,#Convo,115)
Player_B_Say(No...)
Player_B_Send(#Convo,115)
}
//Player Denies
#Convo_115 {
NPC_Say(You did NOT finish this quest.)
Player_A_Say(Okay I will finish then come back.)
Player_A_Send(npc.end)
}
//Player Denies
#Convo_110 {
NPC_Say(You did finish this quest)
Player_A_Say(I'll take my rewards and leave now.)
Player_A_Send(npc.end)
}
So let's analyze this bit by bit. As always the first tag is
#PreCheck_0. Now I mentioned before that each tag name does something different, and the precheck tag's purpose is to check some requirements before figuring out what to say to the player. For example, if a player hasn't started a quest, we want the NPC to start the conversation that leads up to the quest. If the player is in progress with a quest, we want the NPC to start the conversation that leads up to the checking of the quest. And finally if the player has completed the quest, we want the NPC to know that and respond accordingly, and maybe even offer another quest.
So the first line within the tag reads
checkQuest(33). Complicated right? Not really. This literally sends a request to the server and the server will check whatever quest is in parentheses (in this case
33) and respond with one of 3 things.... (1) the user hasn't started this quest, (2) the user is in progress, and (3) the user has completed the quest.
Now take a look at the next 3 lines. Each one corresponds to one of these 3 responses....
Code:
ifNotStarted(#Convo,0)
ifInProgress(#Convo,100)
ifComplete(#PreCheck,1000)
Within each of these 3 commands, there is another tag and tag number. So let's pretend the user HAS NOT STARTED quest #33. The NPC will do whatever is inside the
ifNotStarted(#Convo,0) command, and ignore the other commands. Specifically, it tells the NPC to go to tag '#Convo' on number '0'.
side note: if you do not wish to check a quest at the beginning, you can specify -1 in the checkQuest command and the NPC will then look for #Convo_0
Now if we scroll down a bit we will find a tag with those exact parameters...
#Convo_0 {
The purpose of the Convo tag is to (1) display NPC dialogue, (2) player dialogue, and like all tags, (3) to control where the dialogue goes next.
Let's look within this tag to learn about the new commands we will find.
Code:
NPC_Say(Hello player. I will test how friendly you are... How are you today?)
Player_A_Say(I'm good how are you?)
Player_A_Send(#Convo,1)
Player_B_Say(Don't talk to me)
Player_B_Send(#Convo,5)
The first command is
NPC_Say and the argument--which is the term for the contents inside the parentheses--is a line of text that the NPC will say. It's that simple.
The next line has the command
Player_A_Say. This is like the above, in that it is a line of text but this time it is what the player will say. But the player can have two options of what to say, so that's what the "A" is for.
Next we have the command
Player_A_Send. The arguments are
(#Convo,1), which is exactly like the parameters for the
ifNotStarted command we played with before. So if the player clicks option A when in game, then the NPC will "SEND" the player to whatever tag is within option A.
Option B is the following two lines and do the exact same thing except it allows the conversation to go in multiple directions.
So let's pretend the player picks option A. We will follow the tag to, as it states, #Convo, and 1.
Looking at the NPC code, this is the next tag.
The entire thing reads:
Code:
#Convo_1 {
NPC_Say(You are friendly.)
Player_A_Say(Yes I am nice.)
Player_A_Send(#PromptQuest,33)
}
Most of this is a repeat of what we already learned. The player is only given one option here, just for the purpose of showing that it is possible to give the player only one choice.
But this time instead of going to another Convo tag it will go to a PromptQuest tag. Let's learn about that.
Code:
#PromptQuest_33 {
NPC_Say(Would you like to help me with this quest?)
Player_A_Say(Yes!)
Player_A_Send(#Convo,10,#Convo,11)
Player_B_Say(No...)
Player_B_Send(#Convo,15)
}
For the most part, you can make the tag numbers whatever you want. But in a PromptQuest tag, you MUST make the tag number the number of the quest that you want to prompt. Additionally, a PromptQuest will make player dialogue buttons A and B turn green and red respectively (normally they are both gray) resembling an accept/decline for a quest. That's the purpose of a PromptQuest, to give the player the ability to accept a quest.
You'll notice that choice B looks the same.... this is what the NPC will follow when the player clicks choice B or decline.
Which takes the player to this tag:
Code:
#Convo_15 {
NPC_Say(You did not accept my quest.)
Player_A_Say(No I did not accept it.)
Player_A_Send(npc.end)
}
And the only new thing here is the npc.end part of choice A, which obviously terminates the NPC conversation.
But let's go back to our example of the PromptQuest_33 one more time. What happens if the player picks choice A?
You'll notice that choice A (the send command) has
two arguments
(#Convo,10,#Convo,11), when we've only seen one in the past.
The reason for this is because the player may choose to accept a quest, but may not be able to actually take the quest because of level restrictions, or unfulfilled pre-reqs. So the first argument
#Convo,10 will take control IF THE PLAYER ACCEPTS THE QUEST AND IS ABLE TO DO SO.
The second argument
#Convo,11 will take control IF THE PLAYER ACCEPTS THE QUEST YET IS
NOT ABLE TO DO SO.
The rest of the progression should be self explanatory at this point.
But really quick, let's go over what would happen if the player went through the progression that we just did, and accepted the quest. The server would now store the information pertaining to this acceptance.
So now let's pretend the player clicks the same NPC once more.
This time, the NPC would still go to the
#PreCheck_0 { tag, as it did before. But now since the player has accepted quest 33 and is in progress with it, this is the line that would be interpreted:
ifInProgress(#Convo,100). So now let's look at #Convo_100...
Code:
#Convo_100 {
NPC_Say(Hope you haven't gotten into too much trouble since we last spoke.)
Player_A_Say(I am doing well.)
Player_A_Send(#CompleteQuest,33)
Player_B_Say(Goodbye.)
Player_B_Send(npc.end)
}
Most of these we have seen before. Option B is an end command, and option A sends the player to a tag. But we haven't dealt with a #CompleteQuest tag yet.
Here's the CompleteQuest Tag
Code:
#CompleteQuest_33 {
NPC_Say(Would you like to complete the quest?)
Player_A_Say(Yes!)
Player_A_Send(#Convo,110,#Convo,115)
Player_B_Say(No...)
Player_B_Send(#Convo,115)
}
This acts exactly like the PromptQuest tag. The tag number MUST be the ID of the quest to be completed. And likewise, the two options, A and B, will turn green and red respectively for completing the quest. Also, you'll notice that option A (for the send) has two arguments
(#Convo,110,#Convo,115). Like the way PromptQuest works, CompleteQuest needs to account for the possibility that a player may want to complete a quest, but does not meet the requirements (i.e. missing an item for completion). So the first set of arguments
(#Convo,110) will activate when the player CAN complete the quest, and the second set of arguments
(#Convo,115) activates when the player wants to complete the quest but IS NOT able to.
The rest has already been covered. Happy NPC coding