nPC conversation codes
NPC conversation codes are used to specify NPC talk sequences of steps (actions) to do.
Sequence consists of whitespace-separated codes. Each code is separated with a whitespace.
|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, |
|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.|
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.
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
------ 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:
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~/Fish|12|October/ r~/Fish|12|October/ r~/Fish|12|October/
- Dynamically detect whether autoTalkCont functionality is needed for a sequence, so form without "c"s can always be used?