Skip to content

Convert NPC dialog in .tab files into resources for client translation. #240

Description

@skittles1

The NPC speech and random dialog in the .tab files are added as strings, so the clients cannot choose which language to use for them. These strings can all be added as resources in library.kod, allowing client translation.

To do so, each string in the tab files needs to be made into a resource with a unique name, as do any triggers. For example:

BarloqueApothecary LIBRES_MOOD_GOOD bye ~kJoguer says, "Must thou make such haste in thy departure? I shall be sorry to see thee go."

becomes

LT_bye = "bye"
LM_joguer_bye = \
   "Must thou make such haste in thy departure? I shall be sorry to see thee go."

This is then added to the speechlib init code in CreateSpeechLibrary:

      plSpeechLib = Cons([&BarloqueApothecary,[
         [[LT_bye],LIBRES_MOOD_GOOD,[LIBACT_SAY,LM_joguer_bye]]
      ]],plSpeechLib);

CreateSpeechLibrary is used for speech triggers and CreateRandomLibrary for random triggers. Some NPCs already have lists in these messages, and the converted .tab entries should be placed into the existing lists.

Some .tab entries require more modification, for example:

BarloqueClerk hello ~kCaramo says, "Welcome to the office of the Justicar, %NAME."

To use this as a resource, the %NAME substring should be converted into definite article/name as follows:

LM_caramo_hello = "Welcome to the office of the Justicar, %s%s."

The corresponding list entry would be:

      plSpeechLib = Cons([&BarloqueClerk,[
         [[LT_hello],0,[LIBACT_SAY_TARG,LM_caramo_hello]]
      ]],plSpeechLib);

LIBACT_SAY_TARG is a LIBACT_SAY type action that adds the target's definite article and name, and there are several LIBACT_SAY types that should cover most of the strings in the .tab files.

Some strings aren't meant to be directly said by the NPC, for example:

BarloqueInnKeeper stunted dwarf ~kThe room goes silent as %NAME mentions stunted dwarf.

These strings will need new LIBACT action types (LIBACT_SAY_ROOM_MSG or similar) to cover them.

Solution

Create a parser that:

  • Scans library.kod and loads its resource names (and possibly the trigger text) into a table to avoid duplicates.
  • Loads library.kod's speech and random list entries into a list by NPC.
  • Reads the trigger and dialog from (English) .tab or .txt files and generates a unique resource name of the form type_classname_description, with type LT for trigger and LM for dialog.
  • Generates an appropriate speech or random lib list entry based on the formatting in the dialog (LIBACT_SAY type), and store this new entry in the appropriate parser list.
  • Output all the data when the tab/txt file has finished being parsed, and stick it all into library.kod.

May need to manually create the German resources, though I assume a lot of them can be accurately guessed by a parser based on matching trigger/mood.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions