Changeset 570


Ignore:
Timestamp:
06/29/10 17:09:38 (9 years ago)
Author:
beliar
Message:

Patch by Beliar.

  • Quest files are now read in and parsed at the start of the game. and the Quests stored in the quests property of quest_engine. This allows quest variables to be set even when the quest is not active.
  • replaced addQuest with activateQuest which now only accepts the quest_id as a parameter.
  • Removed deleteQuest and added failQuest instead
  • Added a function to restart a quest, this will reset quest_variables that have a "reset_value" property to this value.
  • Modified Dialogue and Quest files to work with the changes
  • Added "QuestsDirectory?" setting to the settings file. Please delete your old settings.xml and let the game recreate it.
Location:
trunk/game
Files:
32 edited

Legend:

Unmodified
Added
Removed
  • trunk/game/dialogue/bouncer.yaml

    r504 r570  
    2929             - "I'm looking for stuff to make beer with." 
    3030             - help_beer 
    31              - quest.hasQuest('beer') and not quest.hasFinishedQuest('beer') and quest['beer'].isGoalValue('beer_instructions') 
     31             - quest.hasActiveQuest('beer') and not quest.hasFinishedQuest('beer') and quest['beer'].isGoalValue('beer_instructions') 
    3232           - 
    3333             - "Do you know Jacob?" 
     
    6161             - "I'm looking for Pekko, you seen him?" 
    6262             - help_fedex 
    63              - quest.hasQuest('fedex') and not quest.hasFinishedQuest('fedex') and not quest['fedex'].isGoalValue('found_pekko') 
     63             - quest.hasActiveQuest('fedex') and not quest.hasFinishedQuest('fedex') and not quest['fedex'].isGoalValue('found_pekko') 
    6464           - 
    6565             - "Hey, back off.  Just making small talk." 
  • trunk/game/dialogue/camilla.yaml

    r504 r570  
    2929              - "I'm looking for stuff to make beer with " 
    3030              - help_beer 
    31               - quest.hasQuest('beer') and not quest.hasFinishedQuest('beer') and quest['beer'].isGoalValue('beer_instructions') 
     31              - quest.hasActiveQuest('beer') and not quest.hasFinishedQuest('beer') and quest['beer'].isGoalValue('beer_instructions') 
    3232            - 
    3333              - "I'd like a drink." 
     
    4646              - "I'm looking for Pekko, you seen him?" 
    4747              - help_fedex 
    48               - quest.hasQuest('fedex') and not quest.hasFinishedQuest('fedex') and not quest['fedex'].isGoalValue('found_pekko') 
     48              - quest.hasActiveQuest('fedex') and not quest.hasFinishedQuest('fedex') and not quest['fedex'].isGoalValue('found_pekko') 
    4949            - 
    5050              - "Did you hear? Pekko's dead.  I found his body." 
  • trunk/game/dialogue/crazy_swede.yaml

    r504 r570  
    116116              - "Yeah, buddy.  You are a long way from home.  Be nice if we had a drink to toast to Norway." 
    117117              - d 
    118               - quest.hasQuest('beer') and quest['beer'].getValue('yeast_available') 
     118              - quest.hasActiveQuest('beer') and quest['beer'].getValue('yeast_available') 
    119119            - 
    120120              - "Yeah, buddy.  You are a long way from home." 
    121121              - dprime 
    122               - quest.hasQuest('beer') and not quest['beer'].getValue('yeast_available') 
     122              - quest.hasActiveQuest('beer') and not quest['beer'].getValue('yeast_available') 
    123123               
    124124    c3: 
  • trunk/game/dialogue/drunkard.yaml

    r504 r570  
    5050              - "Are you drunk?" 
    5151              - elaborate_beer 
    52               - not quest.hasQuest('beer') and not quest.hasFinishedQuest('beer') 
     52              - not quest.hasActiveQuest('beer') and not quest.hasFinishedQuest('beer') 
    5353            # above should always be true since there is no other way to get the quest   
    5454            - 
     
    7171    quest_beer:            
    7272         - say:  "You sir, are a gentleman and a scholar.  I am sure folks around here will help you find what you need." 
    73          - start_quest: quests/beer.yaml 
     73         - start_quest: beer 
    7474         - responses: 
    7575             - 
     
    8686               - "Hey, Bart - here is my shopping list I need to brew us up something tasty.  Can you help?" 
    8787               - help_beer 
    88                - quest.hasQuest('beer') and quest['beer'].isGoalValue('beer_instructions') and not quest.hasFinishedQuest('beer') 
     88               - quest.hasActiveQuest('beer') and quest['beer'].isGoalValue('beer_instructions') and not quest.hasFinishedQuest('beer') 
    8989             - 
    9090               - "By the way, Bart, I am looking for a chap named 'Pekko', you know were I can find him?" 
    9191               - help_fedex 
    92                - quest.hasQuest('fedex') and not quest['fedex'].isGoalValue('found_pekko') 
     92               - quest.hasActiveQuest('fedex') and not quest['fedex'].isGoalValue('found_pekko') 
    9393             - 
    9494               - "Hm.  You got a good buzz on, today?" 
    9595               - elaborate_beer 
    96                - not quest.hasQuest('beer') and not quest.hasFinishedQuest('beer') 
     96               - not quest.hasActiveQuest('beer') and not quest.hasFinishedQuest('beer') 
    9797             - 
    9898               - "Hey, try my fantastic brew!" 
     
    102102               - "Well, I am off to make some beer, wish me luck!" 
    103103               - end 
    104                - quest.hasQuest('beer') and not quest.hasFinishedQuest('beer') and quest['beer'].getValue('beer_quality') == 0 
     104               - quest.hasActiveQuest('beer') and not quest.hasFinishedQuest('beer') and quest['beer'].getValue('beer_quality') == 0 
    105105             - 
    106106               - "Adios, Bart" 
    107107               - end 
    108                - not quest.hasQuest('beer') or quest.hasFinishedQuest('beer') 
     108               - not quest.hasActiveQuest('beer') or quest.hasFinishedQuest('beer') 
    109109             - 
    110110               - "Did you hear about Pekko?" 
    111111               - dead_pekko 
    112                - quest.hasQuest('fedex') and quest['fedex'].isGoalValue('found_pekko') and not quest['fedex'].isGoalValue('accused_of_murder') 
     112               - quest.hasActiveQuest('fedex') and quest['fedex'].isGoalValue('found_pekko') and not quest['fedex'].isGoalValue('accused_of_murder') 
    113113             - 
    114114               - "Pekko was murdered.  And someone's responsible." 
    115115               - murder_accuse 
    116                - quest.hasQuest('fedex') and quest['fedex'].isGoalValue('found_pekko') and not quest['fedex'].isGoalValue('accused_of_murder') 
     116               - quest.hasActiveQuest('fedex') and quest['fedex'].isGoalValue('found_pekko') and not quest['fedex'].isGoalValue('accused_of_murder') 
    117117  
    118118    help_beer: 
     
    494494        #- npc('Bart').poison('beer') 
    495495        # Not sure how to implement poisoning; may not be necessary for the demo 
    496         - delete_quest: beer 
    497         - start_quest: quests/beer.yaml  
     496        - restart_quest: beer 
    498497        - responses: 
    499498           -  
  • trunk/game/dialogue/farm_boy1.yaml

    r504 r570  
    2828              - "I'm looking for stuff to make beer with " 
    2929              - help_beer 
    30               - quest.hasQuest('beer') and not quest.hasFinishedQuest('beer') and quest['beer'].isGoalValue('beer_instructions') 
     30              - quest.hasActiveQuest('beer') and not quest.hasFinishedQuest('beer') and quest['beer'].isGoalValue('beer_instructions') 
    3131           -  
    3232              - "Tell me about the farm" 
     
    3535              - "I'm looking for Pekko, you seen him?" 
    3636              - help_fedex 
    37               - quest.hasQuest('fedex') and not quest.hasFinishedQuest('fedex') and not quest['fedex'].isGoalValue('found_pekko') 
     37              - quest.hasActiveQuest('fedex') and not quest.hasFinishedQuest('fedex') and not quest['fedex'].isGoalValue('found_pekko') 
    3838           - 
    3939              - "Oh, I was looking for Rasmus." 
  • trunk/game/dialogue/farm_boy2.yaml

    r504 r570  
    2828              - "I'm looking for stuff to make beer with " 
    2929              - help_beer 
    30               - quest.hasQuest('beer') and not quest.hasFinishedQuest('beer') and quest['beer'].isGoalValue('beer_instructions') 
     30              - quest.hasActiveQuest('beer') and not quest.hasFinishedQuest('beer') and quest['beer'].isGoalValue('beer_instructions') 
    3131           -  
    3232              - "Tell me about the farm" 
     
    3535              - "I'm looking for Pekko, you seen him?" 
    3636              - help_fedex 
    37               - quest.hasQuest('fedex') and not quest.hasFinishedQuest('fedex') and not quest['fedex'].isGoalValue('found_pekko') 
     37              - quest.hasActiveQuest('fedex') and not quest.hasFinishedQuest('fedex') and not quest['fedex'].isGoalValue('found_pekko') 
    3838           - 
    3939              - "Oh, I was looking for Sami." 
  • trunk/game/dialogue/farmer.yaml

    r504 r570  
    2727              - "I'm looking for stuff to make beer with " 
    2828              - convince_farmer 
    29               - quest.hasQuest('beer') and quest['beer'].isGoalValue('beer_instructions') and not quest.hasFinishedQuest('beer') and not quest['beer'].isGoalValue('farmer_beer_convinced') 
     29              - quest.hasActiveQuest('beer') and quest['beer'].isGoalValue('beer_instructions') and not quest.hasFinishedQuest('beer') and not quest['beer'].isGoalValue('farmer_beer_convinced') 
    3030            -  
    3131              - "You can help me with the beer, thing, right?" 
    3232              - help_beer 
    33               - quest.hasQuest('beer') and quest['beer'].isGoalValue('beer_instructions') and not quest.hasFinishedQuest('beer') and quest['beer'].isGoalValue('farmer_beer_convinced') 
     33              - quest.hasActiveQuest('beer') and quest['beer'].isGoalValue('beer_instructions') and not quest.hasFinishedQuest('beer') and quest['beer'].isGoalValue('farmer_beer_convinced') 
    3434            -  
    3535              - "Hey, that wheat you gave me really made the brew work." 
     
    4343              - "I'm looking for Pekko, you seen him?" 
    4444              - help_fedex 
    45               - quest.hasQuest('fedex') and not quest.hasFinishedQuest('fedex') 
     45              - quest.hasActiveQuest('fedex') and not quest.hasFinishedQuest('fedex') 
    4646            -  
    4747              - "This is quite a nice farm you have here, can you tell me about it?" 
  • trunk/game/dialogue/fguard.yaml

    r504 r570  
    4646              - "Yeah, just blew in with the last storm." 
    4747              - elaborate_fedex 
    48               - not quest.hasQuest('fedex') and not quest.hasFinishedQuest('fedex') 
     48              - not quest.hasActiveQuest('fedex') and not quest.hasFinishedQuest('fedex') 
    4949            # above should always be true since there is no other way to get the quest   
    5050            - 
     
    114114         # above line cuts off after 'making promises' 
    115115         # get_stuff is broken, that's why! 
    116          - start_quest: quests/fedex.yaml 
    117          - get_stuff: box 
     116         - start_quest: fedex 
     117         - get_stuff: Box 
    118118         # I suspect the "get_box" should be rolled into start_quest 
    119119         - responses: 
     
    142142             - "I guess I'll see if I can't find this Pekko character for you." 
    143143             - end 
    144              - quest.hasQuest('fedex') and not quest.hasFinishedQuest('fedex') and not quest['fedex'].isGoalValue('found_pekko') 
     144             - quest.hasActiveQuest('fedex') and not quest.hasFinishedQuest('fedex') and not quest['fedex'].isGoalValue('found_pekko') 
    145145           - 
    146146             - "So long, Janie.  Catch you later." 
    147147             - end 
    148              - not quest.hasQuest('fedex') or quest.hasFinishedQuest('fedex') 
     148             - not quest.hasActiveQuest('fedex') or quest.hasFinishedQuest('fedex') 
    149149           - 
    150150             - "Uh, I opened the box." 
     
    162162             - "What are we going to do about Pekko's murder?" 
    163163             - discuss_murder 
    164              - quest.hasQuest('fedex') and quest['fedex'].getValue('accused_of_murder') 
     164             - quest.hasActiveQuest('fedex') and quest['fedex'].getValue('accused_of_murder') 
    165165 
    166166    help_beer: 
     
    285285     
    286286    drop_quest: 
    287        - complete_quest: fedex 
     287       - fail_quest: fedex 
    288288       - say: "Drop it.  It's bigger than than both of us." 
    289289       - responses: 
     
    373373       - say: "Give me that back! [Janie takes boots from PC and rewraps them].  Now, here.  And don't open it again." 
    374374       # reset the quest: Note we need to make sure we don't generate an infinite supply of combat boots! 
    375        - give_stuff: boots 
    376        - delete_quest: fedex 
    377        - start_quest: quests/fedex.yaml 
    378        - get_stuff: box  
     375       - give_stuff: Boots 
     376       - restart_quest: fedex 
     377       - get_stuff: Box  
    379378       # I suspect this should be rolled into "start_quest" 
    380379       - responses: 
  • trunk/game/dialogue/grifter1.yaml

    r504 r570  
    2929              - "I'm looking for stuff to make beer with. " 
    3030              - help_beer 
    31               - quest.hasQuest('beer') and not quest.hasFinishedQuest('beer') and quest['beer'].isGoalValue('beer_instructions') 
     31              - quest.hasActiveQuest('beer') and not quest.hasFinishedQuest('beer') and quest['beer'].isGoalValue('beer_instructions') 
    3232           -  
    3333              - "My new beer is a great success..." 
     
    3737              - "I'm looking for Pekko, you seen him?" 
    3838              - help_fedex 
    39               - quest.hasQuest('fedex') and not quest.hasFinishedQuest('fedex') and not quest['fedex'].isGoalValue('found_pekko') 
     39              - quest.hasActiveQuest('fedex') and not quest.hasFinishedQuest('fedex') and not quest['fedex'].isGoalValue('found_pekko') 
    4040           - 
    4141              - "Sorry, I'm broke." 
  • trunk/game/dialogue/grifter2.yaml

    r504 r570  
    2929              - "I'm looking for stuff to make beer with " 
    3030              - help_beer 
    31               - quest.hasQuest('beer') and not quest.hasFinishedQuest('beer') and quest['beer'].isGoalValue('beer_instructions') 
     31              - quest.hasActiveQuest('beer') and not quest.hasFinishedQuest('beer') and quest['beer'].isGoalValue('beer_instructions') 
    3232            -  
    3333              - "My new beer is a great success..." 
     
    3737              - "I'm looking for Pekko, you seen him?" 
    3838              - help_fedex 
    39               - quest.hasQuest('fedex') and not quest.hasFinishedQuest('fedex') and not quest['fedex'].isGoalValue('found_pekko') 
     39              - quest.hasActiveQuest('fedex') and not quest.hasFinishedQuest('fedex') and not quest['fedex'].isGoalValue('found_pekko') 
    4040            - 
    4141              - "Sorry, I'm broke." 
  • trunk/game/dialogue/innkeeper.yaml

    r504 r570  
    4242              - "I'm looking for Pekko, you seen him?" 
    4343              - help_fedex 
    44               - quest.hasQuest('fedex') and not quest.hasFinishedQuest('fedex') and not quest['fedex'].isGoalValue('found_pekko') 
     44              - quest.hasActiveQuest('fedex') and not quest.hasFinishedQuest('fedex') and not quest['fedex'].isGoalValue('found_pekko') 
    4545            - 
    4646              - "Pekko's dead.  I found his body." 
     
    120120             - "Can anyone just go get water there?" 
    121121             - help_water 
    122              - quest.hasQuest('beer') and quest.hasQuest('fedex') and not quest['fedex'].isGoalValue('found_pekko') 
     122             - quest.hasActiveQuest('beer') and quest.hasActiveQuest('fedex') and not quest['fedex'].isGoalValue('found_pekko') 
    123123           - 
    124124             - "But you can keep it running indefinitely... and no one else knows how it works?" 
  • trunk/game/dialogue/leader.yaml

    r504 r570  
    4040              - "Have you seen Pekko around?" 
    4141              - pekko_missing 
    42               - quest.hasQuest('fedex') and not quest['fedex'].isGoalValue('found_pekko') 
     42              - quest.hasActiveQuest('fedex') and not quest['fedex'].isGoalValue('found_pekko') 
    4343            - 
    4444              - "Your brother is dead.  I think he was murdered." 
     
    137137              - "Tell me about your brother, Pekko." 
    138138              - explain_pekko 
    139               - quest.hasQuest('fedex') 
     139              - quest.hasActiveQuest('fedex') 
    140140            -  
    141141              - "Tell me about Jacob." 
     
    243243              - "Actually, I am trying to find your Brother, have you seen him?" 
    244244              - pekko_missing 
    245               - quest.hasQuest('fedex') and not quest['fedex'].isGoalValue('found_pekko') 
     245              - quest.hasActiveQuest('fedex') and not quest['fedex'].isGoalValue('found_pekko') 
    246246 
    247247     argue_migration: 
     
    300300              - "You do know he's missing, right?" 
    301301              - pekko_missing 
    302               - quest.hasQuest('fedex') and not quest['fedex'].isGoalValue('found_pekko') 
     302              - quest.hasActiveQuest('fedex') and not quest['fedex'].isGoalValue('found_pekko') 
    303303            - 
    304304              - "What if he's right about the weather?  That's it's getting worse?  You can't stay here." 
  • trunk/game/dialogue/ma.yaml

    r504 r570  
    2929              - "I am trying to make beer, can you help me?" 
    3030              - help_beer 
    31               - quest.hasQuest('beer') and not quest.hasFinishedQuest('beer') and quest['beer'].isGoalValue('beer_instructions') 
     31              - quest.hasActiveQuest('beer') and not quest.hasFinishedQuest('beer') and quest['beer'].isGoalValue('beer_instructions') 
    3232            -  
    3333              - "I'm looking for Pekko, you seen him?" 
    3434              - help_fedex 
    35               - quest.hasQuest('fedex') and not quest.hasFinishedQuest('fedex') and not quest['fedex'].isGoalValue('found_pekko') 
     35              - quest.hasActiveQuest('fedex') and not quest.hasFinishedQuest('fedex') and not quest['fedex'].isGoalValue('found_pekko') 
    3636            - 
    3737              - "I'm new here, I don't believe we've been introduced?" 
  • trunk/game/dialogue/mall_template.yaml

    r504 r570  
    2828              - "I'm looking for stuff to make beer with " 
    2929              - help_beer 
    30               - quest.hasQuest('beer') and not quest.hasFinishedQuest('beer') and quest['beer'].isGoalValue('beer_instructions') 
     30              - quest.hasActiveQuest('beer') and not quest.hasFinishedQuest('beer') and quest['beer'].isGoalValue('beer_instructions') 
    3131            -  
    3232              - "I'm the beer savior, remember?" 
     
    3636              - "I'm looking for Pekko, you seen him?" 
    3737              - help_fedex 
    38               - quest.hasQuest('fedex') and not quest.hasFinishedQuest('fedex') and not quest['fedex'].isGoalValue('found_pekko') 
     38              - quest.hasActiveQuest('fedex') and not quest.hasFinishedQuest('fedex') and not quest['fedex'].isGoalValue('found_pekko') 
    3939            - 
    4040              - "Whoa!  It talks!  Never mind" 
  • trunk/game/dialogue/quartermaster.yaml

    r563 r570  
    3030              - "You're the Quartermaster?  I bet you can help me with some requisitions?" 
    3131              - pre_help_beer 
    32               - quest.hasQuest('beer') and not quest.hasFinishedQuest('beer') and quest['beer'].isGoalValue('beer_instructions') 
     32              - quest.hasActiveQuest('beer') and not quest.hasFinishedQuest('beer') and quest['beer'].isGoalValue('beer_instructions') 
    3333            -  
    3434              - "You going to help me distribute this new beer?" 
     
    3838              - "You haven't seen Pekko around lately, have you?" 
    3939              - help_fedex 
    40               - quest.hasQuest('fedex') and not quest.hasFinishedQuest('fedex') and not quest['fedex'].isGoalValue('found_pekko') 
     40              - quest.hasActiveQuest('fedex') and not quest.hasFinishedQuest('fedex') and not quest['fedex'].isGoalValue('found_pekko') 
    4141            - 
    4242              - "Labor pool?  I forgot my suit." 
     
    5353             - "Really?  Because I am looking for some items to brew some beer..." 
    5454             - pre_help_beer 
    55              - quest.hasQuest('beer') and not quest.hasFinishedQuest('beer') and quest['beer'].isGoalValue('beer_instructions') 
     55             - quest.hasActiveQuest('beer') and not quest.hasFinishedQuest('beer') and quest['beer'].isGoalValue('beer_instructions') 
    5656              
    5757    bribe_comment: 
  • trunk/game/dialogue/quest_sample.yaml

    r504 r570  
    3636              - "Give me a beer! (Cheater!)" 
    3737              - give_beer 
    38               - quest.hasQuest('beer') and not quest.hasFinishedQuest('beer') and not quest['beer'].isGoalValue("beer_gathered") 
     38              - quest.hasActiveQuest('beer') and not quest.hasFinishedQuest('beer') and not quest['beer'].isGoalValue("beer_gathered") 
    3939 
    4040            - 
    4141              - "I'm on it" 
    4242              - main_dialog 
    43               - quest.hasQuest('beer') and not quest.hasFinishedQuest('beer') 
    44                 #pc class should call this function (pc.hasQuest) 
     43              - quest.hasActiveQuest('beer') and not quest.hasFinishedQuest('beer') 
     44                #pc class should call this function (pc.hasActiveQuest) 
    4545 
    4646            - 
    4747              - "Sure, tell me all about it" 
    4848              - listen_more 
    49               - not quest.hasQuest('beer') and not quest.hasFinishedQuest('beer') 
     49              - not quest.hasActiveQuest('beer') and not quest.hasFinishedQuest('beer') 
    5050 
    5151            - 
     
    7171    quest_accept: 
    7272        - say: "All your beer are belong to us!" 
    73         - start_quest: "quests/beer.yaml" 
     73        - start_quest: beer 
    7474        - responses: 
    7575            - 
     
    9898    stop_quest: 
    9999        - say: "Jerk." 
    100         - delete_quest: 'beer' 
     100        - fail_quest: beer 
    101101        - responses: 
    102102            - 
  • trunk/game/dialogue/snowshoveler.yaml

    r504 r570  
    4949             - "I'm looking for stuff to make beer with" 
    5050             - help_beer 
    51              - quest.hasQuest('beer') and not quest.hasFinishedQuest('beer') and quest['beer'].isGoalValue('beer_instructions') 
     51             - quest.hasActiveQuest('beer') and not quest.hasFinishedQuest('beer') and quest['beer'].isGoalValue('beer_instructions') 
    5252           -  
    5353             - "I'm looking for Pekko, you seen him?" 
    5454             - help_fedex 
    55              - quest.hasQuest('fedex') and not quest.hasFinishedQuest('fedex') and not quest['fedex'].isGoalValue('found_pekko') 
     55             - quest.hasActiveQuest('fedex') and not quest.hasFinishedQuest('fedex') and not quest['fedex'].isGoalValue('found_pekko') 
    5656           - 
    5757             - "Oh, were you working?  I'll let you get back to it" 
  • trunk/game/dialogue/synnove.yaml

    r504 r570  
    3636              - "I'm looking for stuff to make beer with " 
    3737              - help_beer 
    38               - quest.hasQuest('beer') and not quest.hasFinishedQuest('beer') and quest['beer'].isGoalValue('beer_instructions') 
     38              - quest.hasActiveQuest('beer') and not quest.hasFinishedQuest('beer') and quest['beer'].isGoalValue('beer_instructions') 
    3939            -  
    4040              - "I'm got my beer made, finally!" 
     
    4444              - "I'm looking for Pekko, you seen him?" 
    4545              - help_fedex 
    46               - quest.hasQuest('fedex') and not quest.hasFinishedQuest('fedex') and not quest['fedex'].isGoalValue('found_pekko') 
     46              - quest.hasActiveQuest('fedex') and not quest.hasFinishedQuest('fedex') and not quest['fedex'].isGoalValue('found_pekko') 
    4747            - 
    4848              - "Never mind, thought you were someone else." 
  • trunk/game/dialogue_demo.py

    r477 r570  
    9999    def start_quest(state, quest): 
    100100        print "You've picked up the '%s' quest!" % quest 
    101         state['quest'].addQuest(quest) 
     101        state['quest'].activateQuest(quest) 
    102102 
    103103    def complete_quest(state, quest_id): 
     
    105105        state['quest'].finishQuest(quest_id) 
    106106 
    107     def delete_quest(state, quest_id): 
    108         print "You've deleted quest %s" % quest_id 
    109         state['quest'].deleteQuest(quest_id) 
     107    def fail_quest(state, quest_id): 
     108        print "You've failed quest %s" % quest_id 
     109        state['quest'].failQuest(quest_id) 
     110 
     111    def restart_quest(state, quest_id): 
     112        print "You've restarted quest %s" % quest_id 
     113        state['quest'].restartQuest(quest_id) 
    110114 
    111115    def increase_value(state, quest_id, variable, value): 
     
    139143        "start_quest": start_quest, 
    140144        "complete_quest": complete_quest, 
    141         "delete_quest": delete_quest, 
     145        "restart_quest": restart_quest, 
     146        "fail_quest": fail_quest, 
    142147        "increase_value": increase_value, 
    143148        "decrease_value": decrease_value, 
  • trunk/game/maps/all_agents.yaml

    r568 r570  
    3535    Position: [-5.0, -3.0, 0.0] 
    3636    Rotation: 0 
     37    Inventory: 
     38        - {ID: "Box", object_type: "Box"} 
    3739--- 
    3840Bart The Drunkard: 
  • trunk/game/objects/ObjectDatabase.yaml

    r568 r570  
    4343      commands: 
    4444        - {Command: SetQuestVariable, ID: beer, Variable: beer_instructions, Value: Read} 
     45--- 
    4546Grain: 
    46     name: Grain 
     47  name: Grain 
     48--- 
     49Box: 
     50  name: Box 
     51  image: /gui/inv_images/inv_giftbox.png 
  • trunk/game/quests/beer.yaml

    r504 r570  
    1717    beer_quality: 
    1818        value: 0 
     19        reset_value: 0 
    1920        goal_value: 5 
    2021        # 0 = no beer, -1 = poison beer, >=1 quality of beer 
  • trunk/game/quests/fedex.yaml

    r531 r570  
    7474    open_box: 
    7575        value: 0 
     76        reset_value: 0 
    7677        goal_value: 0 
    7778        # !=0 box was opened 
  • trunk/game/scripts/dialogue.py

    r553 r570  
    210210                self.callbacks["start_quest"](state, 
    211211                        command.get("start_quest")) 
    212  
     212             
     213            elif command.get("restart_quest"): 
     214                self.callbacks["restart_quest"](state, 
     215                        command.get("restart_quest")) 
     216             
    213217            elif command.get("complete_quest"): 
    214218                self.callbacks["complete_quest"](state, 
    215219                        command.get("complete_quest")) 
    216220 
    217             elif command.get("delete_quest"): 
    218                 self.callbacks["delete_quest"](state, 
    219                         command.get("delete_quest")) 
     221            elif command.get("fail_quest"): 
     222                self.callbacks["fail_quest"](state, 
     223                        command.get("fail_quest")) 
    220224 
    221225            elif command.get("increase_value"): 
  • trunk/game/scripts/dialoguevalidator.py

    r479 r570  
    111111                #TODO: verify person  
    112112                elif action in ("complete_quest", "start_quest", \ 
    113                                 "delete_quest"): 
     113                                "restart_quest", "fail_quest"): 
    114114                    if not isinstance(entry[action], types.StringType): 
    115115                        raise DialogueFormatException(\ 
  • trunk/game/scripts/gamemodel.py

    r569 r570  
    1717 
    1818# there should be NO references to FIFE here! 
    19 import pickle 
    2019import sys 
    2120import os.path 
     
    2827from common.utils import parseBool 
    2928from inventory import Inventory 
     29from scripts.quest_engine import QuestEngine 
     30 
    3031try: 
    3132    import xml.etree.cElementTree as ElementTree 
     
    5556        self.savegame = None 
    5657        self.game_state = GameState() 
     58        self.game_state.quest_engine = QuestEngine(\ 
     59                                            settings.get("PARPG", 
     60                                                         "QuestsDirectory")) 
     61        self.game_state.quest_engine.readQuests() 
    5762        self.pc_run = 1 
    5863        self.target_position = None 
  • trunk/game/scripts/gamestate.py

    r565 r570  
    2222    def __init__(self): 
    2323        self.PlayerCharacter = None 
    24         self.quest_engine = quest_engine.QuestEngine() 
     24        self.quest_engine = None 
    2525        self.objects = {} 
    2626        self.object_ids = {} 
  • trunk/game/scripts/gui/dialoguegui.py

    r569 r570  
    2929        def start_quest(state, quest): 
    3030            print "You've picked up the '%s' quest!" % quest 
    31             state['quest'].addQuest(quest) 
     31            state['quest'].activateQuest(quest) 
    3232 
    3333        def complete_quest(state, quest_id): 
     
    3535            state['quest'].finishQuest(quest_id) 
    3636 
    37         def delete_quest(state, quest_id): 
    38             print "You've deleted quest %s" % quest_id 
    39             state['quest'].deleteQuest(quest_id) 
    40  
    41         def increase_value(state, quest_id, variable, value): 
     37        def fail_quest(state, quest_id): 
     38            print "You've failed quest %s" % quest_id 
     39            state['quest'].failQuest(quest_id) 
     40             
     41        def restart_quest(state, quest_id): 
     42            print "You've restarted quest %s" % quest_id 
     43            state['quest'].restartQuest(quest_id) 
     44 
     45        def increase_quest_value(state, quest_id, variable, value): 
    4246            print "Increased %s by %i"%(variable,value) 
    4347            state['quest'][quest_id].increaseValue(variable,value) 
    4448 
    45         def decrease_value(state, quest_id, variable, value): 
     49        def decrease_quest_value(state, quest_id, variable, value): 
    4650            print "Decreased %s by %i"%(variable,value) 
    4751            state['quest'][quest_id].decreaseValue(variable,value) 
     
    7175        dialogue_callbacks = { 
    7276            'complete_quest': complete_quest, 
    73             'decrease_value': decrease_value, 
    74             'delete_quest'  : delete_quest, 
     77            'decrease_quest_value': decrease_quest_value, 
     78            'fail_quest'  : fail_quest, 
    7579            'end'           : self.handleEnd, 
    7680            'get_stuff'     : get_stuff, 
    77             'increase_value': increase_value, 
     81            'increase_quest_value': increase_quest_value, 
    7882            'meet'          : meet, 
    7983            'npc_name'      : self.handleNpcName, 
     
    8387            'set_value'     : set_value, 
    8488            'start_quest'   : start_quest, 
     89            "restart_quest" : restart_quest, 
    8590            'give_stuff'    : give_stuff 
    8691        } 
  • trunk/game/scripts/gui/inventorygui.py

    r568 r570  
    121121            if item and item.trueAttr("usable"): 
    122122                actions = item.actions 
     123                if not actions: 
     124                    return 
    123125                menu_actions = [] 
    124126                x_pos, y_pos = widget.getAbsolutePos() 
  • trunk/game/scripts/gui/popups.py

    r568 r570  
    125125            if item and item.trueAttr("usable"): 
    126126                actions = item.actions 
     127                if not actions: 
     128                    return 
    127129                menu_actions = [] 
    128130                x_pos, y_pos = widget.getAbsolutePos() 
  • trunk/game/scripts/quest_engine.py

    r476 r570  
    1717 
    1818import yaml 
     19from scripts.common.utils import locateFiles 
     20import os.path 
    1921 
    2022class Quest(object): 
     
    2729        self.description = description 
    2830        self.quest_variables = variables 
    29  
     31        pass 
     32     
    3033    def setValue(self, variable_name, value): 
    3134        """Set the value of a quest variable 
     
    105108        else: 
    106109            return False 
     110     
     111    def restartQuest(self): 
     112        """Restarts the quest. This sets all values to the reset values, 
     113        if there is a reset value present 
     114        """ 
     115        for variable in self.quest_variables: 
     116            if variable.has_key["reset_value"]: 
     117                variable["value"] = variable["reset_value"] 
    107118 
    108119class QuestEngine(dict): 
    109     def __init__(self): 
     120    def __init__(self, quest_dir): 
    110121        """Create a quest engine object""" 
    111122        dict.__init__(self) 
    112         self.empty_quest = Quest(None,None,None,None,{}) 
    113         self.active_quests = {} 
    114         self.finished_quests = {} 
     123        self.empty_quest = Quest(None, None, None, None, {}) 
     124        self.quests = {} 
     125        self.active_quests = [] 
     126        self.finished_quests = [] 
     127        self.failed_quests = [] 
     128        self.quest_dir = quest_dir 
    115129 
    116130    def __str__(self): 
    117         return self.active_quests.__str__() 
     131        return self.quests.__str__() 
    118132 
    119133    def __getitem__(self, key): 
    120134        try: 
    121             return self.active_quests.__getitem__(key) 
     135            return self.quests.__getitem__(key) 
    122136        except KeyError: 
    123137            return self.empty_quest 
    124138 
    125139    def items(self): 
    126         return self.active_quests.items() 
     140        return self.quests.items() 
    127141 
    128142    def values(self): 
    129         return self.active_quests.values() 
     143        return self.quests.values() 
    130144 
    131145    def keys(self): 
    132         return self.active_quests.keys() 
    133  
    134     def addQuest(self, quest): 
     146        return self.quests.keys() 
     147     
     148    def readQuests(self): 
     149        """Reads in the quests in the quest directory""" 
     150        files = locateFiles("*.yaml", self.quest_dir) 
     151        for quest_file in files: 
     152            quest_file = os.path.relpath(quest_file).replace("\\", "/") 
     153            tree = yaml.load(open(quest_file)) 
     154            quest_properties = tree["QUEST_PROPERTIES"] 
     155            variable_defines = tree["DEFINES"] 
     156     
     157            self.quests[quest_properties["quest_id"]] = \ 
     158                                  Quest(quest_properties["quest_id"], 
     159                                        quest_properties["quest_giver_id"], 
     160                                        quest_properties["quest_name"], 
     161                                        quest_properties["description"], 
     162                                        variable_defines) 
     163 
     164    def activateQuest(self, quest_id): 
    135165        """Add a quest to the quest log 
    136            @param quest: the quest file or tree to add to the quest log 
     166           @param quest: the quest id of the quest to add to the quest log 
    137167           @return: True if succesfully added 
    138168           @return: False if failed to add""" 
    139169 
    140         if isinstance(quest, str): 
    141             # Convert YAML to Quest 
    142             tree = yaml.load(file(quest)) 
    143  
    144         if isinstance(quest, dict): 
    145             tree = quest 
    146  
    147         quest_properties = tree["QUEST_PROPERTIES"] 
    148         variable_defines = tree["DEFINES"] 
    149  
    150         self.active_quests[quest_properties["quest_id"]] = \ 
    151                               Quest(quest_properties["quest_id"], 
    152                                     quest_properties["quest_giver_id"], 
    153                                     quest_properties["quest_name"], 
    154                                     quest_properties["description"], 
    155                                     variable_defines) 
    156         return True 
     170        if quest_id in self.quests \ 
     171            and not (quest_id in self.active_quests \ 
     172                        or quest_id in self.finished_quests): 
     173            self.active_quests.append(quest_id) 
     174            return True 
     175        return False 
    157176 
    158177    def finishQuest(self, quest_id): 
     
    161180           @return: True on success 
    162181           @return: False when it failes""" 
    163         if self.active_quests.has_key(quest_id): 
    164             #Transfer to finished list 
     182        if quest_id in self.active_quests: 
    165183            self.finished_quests[quest_id] = self.active_quests[quest_id] 
    166184            del self.active_quests[quest_id] 
    167185            return True 
    168         elif self.finished_quests.has_key(quest_id): 
    169             #Temporary fix 
    170             return True 
    171         else: 
    172             return False 
    173  
     186        return False 
     187     
     188    def restartQuest(self, quest_id): 
     189        """Restart a quest 
     190           @param quest_id: ID of the quest you want to restart 
     191           @return: True on success 
     192           @return: False when it failes""" 
     193        if quest_id in self.active_quests: 
     194            self.quests[quest_id].restartQuest() 
     195     
     196    def failQuest(self, quest_id): 
     197        """Set a quest to failed 
     198           @param quest_id: ID of the quest you want to fail 
     199           @return: True on success 
     200           @return: False when it failes""" 
     201        if quest_id in self.active_quests: 
     202            self.failed_quests[quest_id] = self.active_quests[quest_id] 
     203            del self.active_quests[quest_id] 
     204            return True 
     205        return False 
     206             
    174207    def hasQuest(self, quest_id): 
    175         """Check wether a quest is in the quest log 
    176            @param quest_id: ID of the quest you want to check 
    177            @return: True on when the quest is in the quest log 
    178            @return: False when it's not in the quest log""" 
    179         if quest_id in self.active_quests.keys(): 
    180             return True 
    181         else: 
    182             return False 
     208        """Check whether a quest is present in the quest_list. 
     209        It doesn't matter which state the quest is, or even if its 
     210        started. 
     211        @param quest_id: ID of the quest you want to check 
     212        @return: True on when the quest is in the quest log 
     213        @return: False when it's not in the quest log""" 
     214        return quest_id in self.quests 
     215 
     216    def hasActiveQuest(self, quest_id): 
     217        """Check whether a quest is in the quest log 
     218        @param quest_id: ID of the quest you want to check 
     219        @return: True on when the quest is in the quest log 
     220        @return: False when it's not in the quest log""" 
     221        return quest_id in self.active_quests 
    183222 
    184223    def hasFinishedQuest(self, quest_id): 
    185         """Check wether a quest is in the finished quests log 
    186            @param quest_id: ID of the quest you want to check 
    187            @return: True on when the quest is in the fisnished quests log 
    188            @return: False when it's not in the finished quests log""" 
    189         if quest_id in self.finished_quests.keys(): 
    190             return True 
    191         else: 
    192             return False 
    193  
    194     def deleteQuest(self, quest_id): 
    195         """Delete a quest 
    196            @param quest_id: ID of the quest you want to delete 
    197            @return: True on success 
    198            @return: False when it failes""" 
    199         if quest_id in self.active_quests.keys(): 
    200             del self.active_quests[quest_id] 
    201             return True 
    202         elif quest_id in self.finished_quests.keys(): 
    203             del self.finished_quests[quest_id] 
    204             return True 
    205         return False 
     224        """Check whether a quest is in the finished quests log 
     225        @param quest_id: ID of the quest you want to check 
     226        @return: True on when the quest is in the finished quests log 
     227        @return: False when it's not in the finished quests log""" 
     228        return quest_id in self.finished_quests 
     229     
     230    def hasFailedQuest(self, quest_id): 
     231        """Check whether a quest is in the failed quests log 
     232        @param quest_id: ID of the quest you want to check 
     233        @return: True on when the quest is in the failed quests log 
     234        @return: False when it's not in the failed quests log""" 
     235        return quest_id in self.failed_quests 
  • trunk/game/settings-dist.xml

    r563 r570  
    2929        <Setting name="AgentsDirectory" type="str">objects/</Setting> 
    3030        <Setting name="DialoguesDirectory" type="str">dialogue/</Setting> 
     31        <Setting name="QuestsDirectory" type="str">quests/</Setting>         
    3132        <Setting name="PCSpeed" type="int">3</Setting> 
    3233   </Module> 
Note: See TracChangeset for help on using the changeset viewer.