nPC conversation codes: Difference between revisions
m (→TODO) |
No edit summary |
||
Line 13: | Line 13: | ||
!r<response #> | !r<response #> | ||
|Send a response to the NPC. The response number is the index of the responses in the displayed response list . This is the same as selecting a response when you talk to an NPC. | |Send a response to the NPC. The response number is the index of the responses in the displayed response list . This is the same as selecting a response when you talk to an NPC. | ||
|- | |||
!r="Response Text" | |||
|Send a response to the NPC. The response is the one which exactly matches the given text. | |||
|- | |||
!r~/regex/ | |||
|Send a response to the NPC. The response is the first one which matches the given [http://perldoc.perl.org/perlre.html#Regular-Expressions regular expression]. For simple matches, this can be used to do partial, case-insensitive matches; for example, <code>r~/storage/i</code> will match <code>Open Storage</code>. | |||
|- | |- | ||
!w<seconds> | !w<seconds> | ||
Line 53: | Line 59: | ||
Talk to a NPC at the coordinates (63, 60), using the talk sequence: next; choose fourth response; next; choose first response; next; next; choose first response; next; end. | Talk to a NPC at the coordinates (63, 60), using the talk sequence: next; choose fourth response; next; choose first response; next; next; choose first response; next; end. | ||
[[talknpc]] 63 60 '''c r3 c r0 c c r0 c n''' | [[talknpc]] 63 60 '''c r3 c r0 c c r0 c n''' | ||
=== Handling Randomized Response Lists === | |||
Given: | |||
------ Responses (Kafra Employee) ------ | |||
# Response | |||
0 Save | |||
1 Use Storage | |||
2 Use Teleport Service | |||
3 Rent a Pushcart | |||
4 Check Other Information | |||
5 Cancel | |||
6 Cancel Chat | |||
---------------------------------------- | |||
There are several ways to choose the "Use Storage" option: | |||
* <code>r1</code> | |||
* <code>r="Use Storage"</code> | |||
* <code>r~/storage/</code> | |||
The last two methods will work regardless of the question order. | |||
=== Handling Randomized Questions === | |||
Given a set of questions which may be asked in any order, a regular expression can be used to match the right answers. | |||
Given the questions: | |||
* What swims in the sea? 0 Fish 1 Bird 2 Lizard | |||
* How many months are in the year? 0 10 1 12 2 100 | |||
* What is the tenth month of the year? 0 July 1 February 2 October | |||
The following conversation codes will pick the correct answers no matter what order the questions are asked in: | |||
<code>r~/Bird|12|October/ r~/Bird|12|October/ r~/Bird|12|October/</code> | |||
== TODO == | == TODO == | ||
* Dynamically detect whether autoTalkCont functionality is needed for a sequence, so form without "c"s can always be used? | * Dynamically detect whether autoTalkCont functionality is needed for a sequence, so form without "c"s can always be used? | ||
[[Category:Reference]] | [[Category:Reference]] | ||
[[Category:Feature Request]] | [[Category:Feature Request]] |
Revision as of 05:51, 17 February 2016
NPC conversation codes are used to specify NPC talk sequences of steps (actions) to do.
Syntax
Sequence consists of whitespace-separated codes. Each code is separated with a whitespace.
Code | Description |
---|---|
c | Continue talking to the NPC. This is the same as pressing the Next buttom. |
r<response #> | Send a response to the NPC. The response number is the index of the responses in the displayed response list . This is the same as selecting a response when you talk to an NPC. |
r="Response Text" | Send a response to the NPC. The response is the one which exactly matches the given text. |
r~/regex/ | Send a response to the NPC. The response is the first one which matches the given regular expression. For simple matches, this can be used to do partial, case-insensitive matches; for example, r~/storage/i will match Open Storage .
|
w<seconds> | Wait for the specified number of seconds before continuing to talk to the NPC. |
d<number> | Send a number to the NPC. Use this if the NPC asks you to enter an amount. |
t=<string> | Send a text to the NPC. Use this if the NPC asks you to enter some text. |
s | Go to sell list. This is the same as pressing the sell button when you talk to a buy/sell NPC. |
b | Go to the store list. This is the same as pressing the buy button when you talk to a buy/sell NPC. |
b<store item #>,<amount> | Buy an item from the NPC. See similar buy. Note that the amount is not optional. |
n | Ends and cancel conversation with the NPC. This is the same as pressing the close or cancel button when talking to an NPC. |
e | Pretend like conversation was stopped (doesn't send anything additional). Use this after the s or b talk code when talking to a buy/sell NPC. |
a=<string> | Run a console command. |
x | Reinitiate NPC conversation. This is always prepended to talknpc sequence. Useful to perform multiple transaction with a single NPC. |
API
There is no API for parsing or executing NPC sequences. It's encapsulated in Task::TalkNPC which handles the whole interaction with NPCs.
API for extending (introducing new codes) doesn't exist, but is possible to implement using hooks.
Examples
Talk to a NPC at the coordinates (63, 60), using the talk sequence: next; choose fourth response; next; choose first response; next; next; choose first response; next; end.
talknpc 63 60 c r3 c r0 c c r0 c n
Handling Randomized Response Lists
Given:
------ Responses (Kafra Employee) ------ # Response 0 Save 1 Use Storage 2 Use Teleport Service 3 Rent a Pushcart 4 Check Other Information 5 Cancel 6 Cancel Chat ----------------------------------------
There are several ways to choose the "Use Storage" option:
r1
r="Use Storage"
r~/storage/
The last two methods will work regardless of the question order.
Handling Randomized Questions
Given a set of questions which may be asked in any order, a regular expression can be used to match the right answers.
Given the questions:
- What swims in the sea? 0 Fish 1 Bird 2 Lizard
- How many months are in the year? 0 10 1 12 2 100
- What is the tenth month of the year? 0 July 1 February 2 October
The following conversation codes will pick the correct answers no matter what order the questions are asked in:
r~/Bird|12|October/ r~/Bird|12|October/ r~/Bird|12|October/
TODO
- Dynamically detect whether autoTalkCont functionality is needed for a sequence, so form without "c"s can always be used?