Crossfire Server, Trunk
Dialog system

The dialog system used by NPCs and magic ear works in the following way:

  • the message is stored in the object::msg field
  • the first time the NPC is talked to, this structure is parsed to the object::dialog_information field
  • this field contains all information needed to know what words the NPC reacts too.

The core dialog is in communicate().

When a player talks, there are two cases:

  • said text is a reply for an NPC. In this case, the display of the actual's player message is done in do_talk_npc() based on the reply
  • when the text doesn't match anything, the display is done in communicate() directly.

This enables special things like 'Player asks: What is this?'.

The following tags can be used in the object::msg field:

  • @match xxx introduces a dialog message. xxx can be either '*' or a regexp, with | to separate alternatives
  • @reply value text is one possible reply the player can give to the message. value is what the player should say (using say value), test is what will be actually displayed
  • @question value text is the same as @reply except the player will ask text
  • @identify Identifies the speaker when the message containing it is matched

Note that value can't contain spaces.

  • update dialog_information when msg changes.
  • have a real regexp parser