Ignore:
Timestamp:
11/17/10 21:44:05 (9 years ago)
Author:
technomage
Message:

Ticket #269: Patch by Technomage.

  • Working prototype of the redesigned DialogueEngine? for the upcoming Techdemo2 release; major redesign of the existing DialogueEngine? and YAML dialogue file syntax.
  • Moved the redesigned DialogueEngine? class to the more descriptive dialogueengine.py module; the DialogueEngine? is now a singleton object and provides all functionality through class methods and attributes, and thus should not be instantiated
  • Abstracted the data structures used to store dialogue data away from the YAML data structures; the relevant classes are stored in the dialogue.py module
  • Abstracted the dialogue commands/actions from the DialogueEngine? code to make modifications and maintenance of dialogue logic easier; the relevant classes are stored in the dialogueactions.py module
  • The PyYAML loader has been replaced with a more robust YamlDialogueParser? class (see the dialogueparsers.py module) that interfaces with the new dialogue data structure classes and supports the new YAML dialogue file syntax; an OldYamlDialogueParser? class is provided to support reading the old Techdemo1 syntax
  • Removed the existing dialogue validator; runtime dialogue validation is not yet implemented
  • Added the convert_dialogue script, which converts dialogue files in the old Techdemo1 format to the new format; all existing dialogue files have been converted to work with the new parser
  • Added two support modules for the new classes and script: ordereddict.py, which provides a Python 2.7-like OrderedDict? class for Python versions 2.4-2.6; optionparser.py, which is a simplified command-line option parser for writing scripts as an alternative to argparse and optparse
  • Updated the dialogue_demo.py script to work with the new DialogueEngine?
  • fixes[s:trac, t:269]
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        44.settings 
        55Thumbs.db 
         6 
         7.externalToolBuilders 
         8 
         9.cproject 
  • trunk/game/dialogue/sample.yaml

    r504 r668  
    1313#   You should have received a copy of the GNU General Public License 
    1414#   along with PARPG.  If not, see <http://www.gnu.org/licenses/>. 
    15  
    1615--- 
    17 NPC: Friendly NPC 
    18 AVATAR: gui/icons/npc.png 
    19 START: main_dialog 
    20  
     16NPC_NAME: Friendly NPC 
     17AVATAR_PATH: gui/icons/npc.png 
     18START_SECTION: main_dialog 
    2119SECTIONS: 
    22     main_dialog: 
    23         - say: "Things are tough around here, let me tell you our problems" 
    24         - responses: 
    25             - 
    26               - "Sure, tell me all about it" 
    27               - listen_more 
    28               - not set(pc.finished_quests).intersection(['raiders','well','beer']) 
    29  
    30             # The 'end' section ends the conversation 
    31             - 
    32               - "That sounds boring. Bye." 
    33               - end 
    34  
    35     listen_more: 
    36         - say: "Raiders stole our cattle, our well was poisoned, and the beer is all gone!" 
    37         - responses: 
    38             # Raiders quest 
    39             - 
    40               - "Tell me about the raiders" 
    41               - elaborate_raiders 
    42               - pc.canAcceptQuest('raiders') 
    43             - 
    44               - "I've taken care of the raiders" 
    45               - complete_raiders 
    46               - pc.hasSatisfiedQuest('raiders') 
    47  
    48             # Well quest 
    49             - 
    50               - "Tell me about the well" 
    51               - elaborate_well 
    52               - pc.canAcceptQuest('well') 
    53             - 
    54               - "I have returned with the antidote" 
    55               - complete_well 
    56               - pc.hasSatisfiedQuest('well') 
    57  
    58             # Beer quest 
    59             - 
    60               - "Tell me about the beer" 
    61               - elaborate_beer 
    62               - pc.canAcceptQuest('beer') 
    63             - 
    64               - "Three cheers the beer is here!" 
    65               - complete_beer 
    66               - pc.hasSatisfiedQuest('beer') 
    67  
    68             # Reward for solving the three "quests" 
    69             - 
    70               - "Guard, I have solved all your problems" 
    71               - all_done 
    72               - pc.finished_quests == set(['raiders','well','beer']) 
    73  
    74             - 
    75               - "Good luck with that" 
    76               - end 
    77  
    78     # Raiders quest 
    79     elaborate_raiders: 
    80         - say: "They mostly come at night... mostly." 
    81         - responses: 
    82             - 
    83               - "I can help you, for a price" 
    84               - quest_raiders 
    85               - pc.canAcceptQuest('raiders') 
    86             - 
    87               - "What was that other stuff you were talking about again?" 
    88               - back 
    89             - 
    90               - "That sounds too dangerous for me, good luck!" 
    91               - end 
    92  
    93     quest_raiders: 
    94         - say: "Thank you so much, these raiders have terrified our village for too long!" 
    95         - start_quest: raiders 
    96         - responses: 
    97             - 
    98               - "Quit your yammering, those raiders won't be a problem anymore." 
    99               - back listen_more 
    100  
    101     complete_raiders: 
    102         - say: "Thank you for defeating those evil doers" 
    103         - complete_quest: raiders 
    104         - responses: 
    105             - 
    106               - "Pffft, it was easy" 
    107               - back listen_more 
    108  
    109     # Well quest 
    110     elaborate_well: 
    111         - say: "A foul and dreadful toxin has contaminated our water well. Rumors tell of an antidote. If only someone could find it." 
    112         - responses: 
    113             - 
    114               - "Wait a second... I'm someone! I will fix your well." 
    115               - quest_well 
    116               - pc.canAcceptQuest('well') 
    117             - 
    118               - "Tell me about that other stuff" 
    119               - back 
    120             - 
    121               - "You're scaring me, bye" 
    122               - end 
    123  
    124     quest_well: 
    125         - start_quest: well 
    126         - say: "You are a brave hero indeed, water bringer." 
    127         - responses: 
    128             - 
    129               - "Fear not, gentle villager. I will return shortly with the antidote." 
    130               - back listen_more 
    131  
    132     complete_well: 
    133         - say: "Thank heavens now the orphans will have water to drink" 
    134         - complete_quest: well 
    135         - dialogue: back 
    136  
    137     # Beer quest 
    138     elaborate_beer: 
    139         - say: "After this keg, and that keg, there is only one keg left! Something must be done." 
    140         - responses: 
    141             - 
    142               - "Running out of beer is no laughing matter. I'll run to the brewery for more" 
    143               - quest_beer 
    144               - pc.canAcceptQuest('beer') 
    145  
    146             - 
    147               - "Tell me about all that other stuff" 
    148               - back 
    149  
    150     quest_beer: 
    151         - start_quest: beer 
    152         - say: "I do not know what we would have done without you." 
    153         - responses:  
    154             - 
    155               - "It's my pleasure" 
    156               - back listen_more 
    157  
    158     complete_beer: 
    159         - say: "Thank heavens now the orphans will have beer to drink" 
    160         - complete_quest: beer 
    161         - responses: 
    162             - 
    163               - "All in a day's work, now gimme some! *glug*" 
    164               - back listen_more 
    165  
    166     # Final reward 
    167     all_done: 
    168         - say: "For saving our village, I will give you the prized McGuffin. Thank you, Player Character" 
    169         - responses: 
    170             - 
    171               - "I am so awesome" 
    172               - end 
     20-   ID: main_dialog 
     21    SAY: "Things are tough around here, let me tell you our problems" 
     22    RESPONSES: 
     23    -   REPLY: "Sure, tell me all about it" 
     24        CONDITION: "not\ 
     25           \ set(pc.finished_quests).intersection(['raiders','well','beer'])" 
     26        GOTO: listen_more 
     27         
     28    -   REPLY: "That sounds boring. Bye." 
     29        GOTO: end 
     30         
     31-   ID: listen_more 
     32    SAY: "Raiders stole our cattle, our well was poisoned, and the beer is all\ 
     33       \ gone!" 
     34    RESPONSES: 
     35    -   REPLY: "Tell me about the raiders" 
     36        CONDITION: "pc.canAcceptQuest('raiders')" 
     37        GOTO: elaborate_raiders 
     38         
     39    -   REPLY: "I've taken care of the raiders" 
     40        CONDITION: "pc.hasSatisfiedQuest('raiders')" 
     41        ACTIONS: 
     42        -   complete_quest: 
     43            - raiders 
     44        GOTO: complete_raiders 
     45         
     46    -   REPLY: "Tell me about the well" 
     47        CONDITION: "pc.canAcceptQuest('well')" 
     48        GOTO: elaborate_well 
     49         
     50    -   REPLY: "I have returned with the antidote" 
     51        CONDITION: "pc.hasSatisfiedQuest('well')" 
     52        ACTIONS: 
     53        -   complete_quest: 
     54            - well 
     55        GOTO: complete_well 
     56         
     57    -   REPLY: "Tell me about the beer" 
     58        CONDITION: "pc.canAcceptQuest('beer')" 
     59        GOTO: elaborate_beer 
     60         
     61    -   REPLY: "Three cheers the beer is here!" 
     62        CONDITION: "pc.hasSatisfiedQuest('beer')" 
     63        ACTIONS: 
     64        -   complete_quest: 
     65            - beer 
     66        GOTO: complete_beer 
     67         
     68    -   REPLY: "Guard, I have solved all your problems" 
     69        CONDITION: "pc.finished_quests == set(['raiders','well','beer'])" 
     70        GOTO: all_done 
     71         
     72    -   REPLY: "Good luck with that" 
     73        GOTO: end 
     74         
     75-   ID: elaborate_raiders 
     76    SAY: "They mostly come at night... mostly." 
     77    RESPONSES: 
     78    -   REPLY: "I can help you, for a price" 
     79        CONDITION: "pc.canAcceptQuest('raiders')" 
     80        ACTIONS: 
     81        -   start_quest: 
     82            - raiders 
     83        GOTO: quest_raiders 
     84         
     85    -   REPLY: "What was that other stuff you were talking about again?" 
     86        GOTO: back 
     87         
     88    -   REPLY: "That sounds too dangerous for me, good luck!" 
     89        GOTO: end 
     90         
     91-   ID: quest_raiders 
     92    SAY: "Thank you so much, these raiders have terrified our village for too\ 
     93       \ long!" 
     94    RESPONSES: 
     95    -   REPLY: "Quit your yammering, those raiders won't be a problem anymore." 
     96        GOTO: back listen_more 
     97         
     98-   ID: complete_raiders 
     99    SAY: "Thank you for defeating those evil doers" 
     100    RESPONSES: 
     101    -   REPLY: "Pffft, it was easy" 
     102        GOTO: back listen_more 
     103         
     104-   ID: elaborate_well 
     105    SAY: "A foul and dreadful toxin has contaminated our water well. Rumors\ 
     106       \ tell of an antidote. If only someone could find it." 
     107    RESPONSES: 
     108    -   REPLY: "Wait a second... I'm someone! I will fix your well." 
     109        CONDITION: "pc.canAcceptQuest('well')" 
     110        ACTIONS: 
     111        -   start_quest: 
     112            - well 
     113        GOTO: quest_well 
     114         
     115    -   REPLY: "Tell me about that other stuff" 
     116        GOTO: back 
     117         
     118    -   REPLY: "You're scaring me, bye" 
     119        GOTO: end 
     120         
     121-   ID: quest_well 
     122    SAY: "You are a brave hero indeed, water bringer." 
     123    RESPONSES: 
     124    -   REPLY: "Fear not, gentle villager. I will return shortly with the\ 
     125           \ antidote." 
     126        GOTO: back listen_more 
     127         
     128-   ID: complete_well 
     129    SAY: "Thank heavens now the orphans will have water to drink" 
     130    RESPONSES: [] 
     131-   ID: elaborate_beer 
     132    SAY: "After this keg, and that keg, there is only one keg left! Something\ 
     133       \ must be done." 
     134    RESPONSES: 
     135    -   REPLY: "Running out of beer is no laughing matter. I'll run to the\ 
     136           \ brewery for more" 
     137        CONDITION: "pc.canAcceptQuest('beer')" 
     138        ACTIONS: 
     139        -   start_quest: 
     140            - beer 
     141        GOTO: quest_beer 
     142         
     143    -   REPLY: "Tell me about all that other stuff" 
     144        GOTO: back 
     145         
     146-   ID: quest_beer 
     147    SAY: "I do not know what we would have done without you." 
     148    RESPONSES: 
     149    -   REPLY: "It's my pleasure" 
     150        GOTO: back listen_more 
     151         
     152-   ID: complete_beer 
     153    SAY: "Thank heavens now the orphans will have beer to drink" 
     154    RESPONSES: 
     155    -   REPLY: "All in a day's work, now gimme some! *glug*" 
     156        GOTO: back listen_more 
     157         
     158-   ID: all_done 
     159    SAY: "For saving our village, I will give you the prized McGuffin. Thank\ 
     160       \ you, Player Character" 
     161    RESPONSES: 
     162    -   REPLY: "I am so awesome" 
     163        GOTO: end 
     164         
     165... 
Note: See TracChangeset for help on using the changeset viewer.