def ORIGIN_offers(self, explo): ol = list() npc = self.elements.get("TARGET") if self._interested and self._told_problem: r1 = dialogue.Reply( "{0} would like to go out with you.".format(npc), destination=dialogue.Offer( "Really? Great! Could you bring {0} my invitation?".format( npc.object_pronoun()), effect=self.ask_invitation)) ol.append( dialogue.Offer("Yes, what is it?", context=context.ContextTag( [context.BRINGMESSAGE, context.GOODNEWS]), replies=[ r1, ])) else: myoffer = dialogue.Offer( "I would like to ask someone to the festival dance, but I don't know anyone...", context=context.ContextTag([context.PROBLEM, context.PERSONAL]), effect=self.tell_problem) ol.append(myoffer) if self._interested: myoffer.replies.append( dialogue.Reply( "Why don't you ask {0}?".format(npc), destination=dialogue.Offer( "Would {0} be interested in going with me? I cannot leave here right now; could you deliver my invitation?" .format(npc.subject_pronoun()), effect=self.ask_invitation))) return ol
def get_generic_offers(self, npc, explo): ol = list() if npc.team is self.elements["TEAM"]: ol.append( dialogue.Offer( msg= "That is a relief. This place is quite dangerous, you know.", context=context.ContextTag([context.TRUCE]), effect=self.do_truce)) ol.append( dialogue.Offer(msg="[ATTACK]", context=context.ContextTag([context.ATTACK]))) return ol
def NPC_offers(self, explo): # Return list of shopkeeper offers. ol = list() ol.append( dialogue.Offer("[SERVICE_TEMPLE]", context=context.ContextTag( [context.SERVICE, context.HEALING]), effect=self.shop)) ol.append( dialogue.Offer( "[HELLO] If you are in need of healing, I may be able to help.", context=context.ContextTag( [context.HELLO, context.SERVICE, context.HEALING]))) return ol
def NPC_offers(self, explo): # Return list of shopkeeper offers. ol = list() ol.append( dialogue.Offer("[SHOP_GENERAL]", context=context.ContextTag( [context.SHOP, context.GENERALSTORE]), effect=self.shop)) if self.first_time: ol.append( dialogue.Offer( "If you need any adventuring supplies, I do a bit of trading.", context=context.ContextTag( [context.HELLO, context.SHOP, context.GENERALSTORE]), effect=self.SpeakFirstTime)) return ol
def ORIGIN_offers(self, explo): ol = list() ol.append( dialogue.Offer("Here is some gold to thank you for your help.", context=context.ContextTag([context.REWARD]), effect=self.give_reward)) return ol
def NPC_offers(self, explo): # Return list of shopkeeper offers. ol = list() ol.append( dialogue.Offer("[SHOP_ARMOR]", context=context.ContextTag( [context.SHOP, context.ARMOR]), effect=self.shop)) if self.first_time: ol.append( dialogue.Offer( "During my travels I have collected a lot of armor. If you like, I can show it to you.", context=context.ContextTag( [context.HELLO, context.SHOP, context.ARMOR]), effect=self.SpeakFirstTime)) return ol
def NPC_offers(self, explo): # Return list of shopkeeper offers. ol = list() ol.append( dialogue.Offer("[SHOP_MAGIC]", context=context.ContextTag( [context.SHOP, context.MAGICGOODS]), effect=self.shop)) if self.first_time: ol.append( dialogue.Offer( "I have some magical supplies for sale, if you need any potions or scrolls.", context=context.ContextTag( [context.HELLO, context.SHOP, context.MAGICGOODS]))) self.first_time = False return ol
def SHOPKEEPER_offers(self, explo): # Return list of shopkeeper offers. ol = list() ol.append( dialogue.Offer("[SHOP_GENERAL]", context=context.ContextTag( [context.SHOP, context.GENERALSTORE]), effect=self.shop)) if self.first_time: ol.append( dialogue.Offer( "Welcome to [scene]. I know this seems like a weird place to build a shop, but you just can't beat the rent!", context=context.ContextTag( [context.HELLO, context.SHOP, context.GENERALSTORE]), effect=self.SpeakFirstTime)) return ol
def NPC_offers(self, explo): # Return list of shopkeeper offers. ol = list() ol.append( dialogue.Offer("[SHOP_WEAPON]", context=context.ContextTag( [context.SHOP, context.WEAPON]), effect=self.shop)) if self.first_time: ol.append( dialogue.Offer( "In addition to adventuring, I also buy and sell weapons. I can get you a [adjective] [weapon].", context=context.ContextTag( [context.HELLO, context.SHOP, context.WEAPON]), effect=self.SpeakFirstTime)) return ol
def BOSS_offers(self, explo): # Return list of shopkeeper offers. ol = list() ol.append( dialogue.Offer("[SHOP_GENERAL]", context=context.ContextTag( [context.SHOP, context.GENERALSTORE]), effect=self.shop)) if self.first_time: ol.append( dialogue.Offer( "I am a wandering trader, interested in both buying and selling. This is a dangerous place. You could use a good [weapon].", context=context.ContextTag( [context.HELLO, context.SHOP, context.GENERALSTORE]), effect=self.SpeakFirstTime)) return ol
def TARGET_offers(self, explo): ol = list() if self.dated: myoffer = dialogue.Offer("Thanks for helping me out.", context=context.ContextTag( [context.HELLO])) ol.append(myoffer) return ol
def SHOPKEEPER_offers(self, explo): # Return list of shopkeeper offers. ol = list() ol.append( dialogue.Offer("[SHOP_MAGIC]", context=context.ContextTag( [context.SHOP, context.MAGICGOODS]), effect=self.shop)) return ol
def SHOPKEEPER_offers(self, explo): ol = list() myoffer = dialogue.Offer( msg= "When we were working on the basiment earlier we broke through into some kind of dungeon. You're free to go downstairs and check it out.", context=context.ContextTag([context.INFO, context.HINT]), effect=self.end_plot) ol.append(myoffer) return ol
def get_generic_offers(self, npc, explo): # Return list of shopkeeper offers. ol = list() if self._still_looking and random.randint( 1, 4) == 1 and npc is not self.elements[ "BMKEEPER"] and explo.camp.current_root_scene( ) is self.elements["LOCALE"]: ol.append( dialogue.Offer( "If you are unhappy with the selection in my store, you can always try the black market. Good luck finding it, though.", context=context.ContextTag([context.HELLO, context.SHOP]), replies=[ dialogue.Reply( "I will just look at your wares, thanks.", destination=dialogue.Cue( context.ContextTag([context.SHOP]))), ])) return ol
def SHOPKEEPER_offers(self, explo): # Return list of shopkeeper offers. ol = list() ol.append( dialogue.Offer("[SERVICE_INN]", context=context.ContextTag( [context.SERVICE, context.INN]), effect=self.shop)) return ol
def _NPC_offers(self, explo): # Return list of NPC offers. ol = list() ol.append( dialogue.Offer(random.choice(self.OFFER_PATTERNS).format( self.elements["TARGET"]), context=context.ContextTag( [context.INFO, context.HINT]), effect=self.hear_secret)) return ol
def _NPC_offers(self, explo): # Return list of necromancer offers. ol = list() if not self.wme.visible: ol.append( dialogue.Offer( "There's a haunted crypt near here. The place is dangerous, but I hear it's full of treasure.", context=context.ContextTag([context.INFO, context.HINT]), effect=self.open_crypt)) return ol
def BMKEEPER_offers(self, explo): # Return list of shopkeeper offers. ol = list() ol.append( dialogue.Offer( "If anyone asks, you did not get this stuff from me, understand?", context=context.ContextTag([context.SHOP, context.BLACKMARKET]), effect=self.shop)) return ol
def ORIGIN_offers(self, explo): ol = list() npc = self.elements.get("TARGET") ol.append( dialogue.Offer( "{0} is cute and awesome, and I don't care who knows! I'd tell {1} myself, but I'm too scared..." .format(npc, npc.object_pronoun()), context=context.ContextTag([context.INFO, context.PERSONAL]), effect=self.ask_invitation)) return ol
def TARGET_offers(self, explo): ol = list() ol.append( dialogue.Offer( "It's a lonely life out here... I wish I had someone to do fun things with.", context=context.ContextTag([ context.HELLO, ]), effect=self.desire_expressed)) return ol
def _NPC_offers(self, explo): ol = list() if not self.quest_started: sk = self.elements["SHOPKEEPER"] myoffer = dialogue.Offer( msg= "{0} is always busy these days. We should get some help, but we're too busy to go looking!" .format(sk, sk.subject_pronoun()), context=context.ContextTag([context.HELLO]), replies=[ dialogue.Reply( "I could do that for you.", destination=dialogue.Offer( msg= "Really? We need three {0} folks to cover all this work. Let me know if you find anyone." .format(self.STAT_DESC[self.needed_stat]), context=context.ContextTag([context.PERSONAL]), effect=self.start_quest)) ]) ol.append(myoffer) else: myoffer = dialogue.Offer( msg="Have you found me three {0} folks yet?".format( self.STAT_DESC[self.needed_stat]), context=context.ContextTag([context.HELLO])) if len(self.employees) >= 5: myoffer.replies.append( dialogue.Reply( "I found everyone you need.", destination=dialogue.Offer( msg= "Great! With {0}, {1}, and {2} on staff things here will be much easier. Thank you so much." .format(self.employees[2], self.employees[3], self.employees[4]), context=context.ContextTag([context.PERSONAL]), effect=self.end_quest, replies=[ dialogue.Reply("You're welcome.", destination=dialogue.Cue( context.ContextTag( [context.REWARD]))) ]))) else: myoffer.replies.append( dialogue.Reply("I'm still working on it.", destination=dialogue.Cue( context.ContextTag([context.GOODLUCK ])))) ol.append( dialogue.Offer( msg= "Good luck with that. I'll be waiting right here... as if I had time to go anywhere else.", context=context.ContextTag([context.GOODLUCK]))) ol.append(myoffer) return ol
def get_generic_offers(self, npc, explo): ol = list() city = self.elements["LOCALE"] if self.chapter.active and explo.camp.current_root_scene() is city: if not self._welcomed: ol.append( dialogue.Offer( msg= "Welcome to {0}, but you have picked a bad time to visit." .format(city), context=context.ContextTag( [context.HELLO, context.PROBLEM, context.LOCAL]), effect=self._do_welcome)) ol.append( dialogue.Offer( msg= "Monsters have been appearing in the wilderness around town. People are frightened, and for good reason." .format(city), context=context.ContextTag( [context.PROBLEM, context.LOCAL]))) return ol
def get_generic_offers(self, npc, explo): ol = list() if self.quest_started and npc not in self.employees and npc.get_stat( self.needed_stat) > (12 + self.rank // 2) and len( self.employees) < 5: qgnpc = self.elements["_NPC"] myoffer = dialogue.Offer( msg="What is it?", context=context.ContextTag( [context.BRINGMESSAGE, context.QUESTION]), replies=[ dialogue.Reply( "{0} is looking for help.".format(qgnpc), destination=dialogue.Offer( msg=random.choice(self.ACCEPT_JOB_REPLIES).format( qgnpc.object_pronoun()), context=context.ContextTag([context.PERSONAL]), effect=self.add_this_npc)) ]) ol.append(myoffer) return ol
def BOSS_offers(self, explo): # Return list of boss offers. ol = list() if self.shop_open: # If you make friends with this boss, you can buy magic here. ol.append( dialogue.Offer("[SHOP_MAGIC]", context=context.ContextTag( [context.SHOP, context.GENERALSTORE]), effect=self.boss_shop)) else: # If you haven't yet made friends, things could be tricky... challenge1 = dialogue.Offer( "Who dares to disturb my eternal studies? Speak, mortals, and tell me what you expect to find!", context=context.ContextTag([ context.THREATEN, ])) challenge2 = dialogue.Offer( "Tell me, mortals... what is it that you seek in life?", context=context.ContextTag([ context.HELLO, ])) right_answer = dialogue.Offer("Then that is what you shall find!", effect=self.answer_correctly) wrong_answer = dialogue.Offer( "Fools! Your inevitable death shall be meaningless!", effect=self.answer_incorrectly) for t, goal in enumerate(self.GOALS): myreply = dialogue.Reply("We seek {}.".format(goal)) if goal is self.boss_goal: # Congratulations, you've figured it out. myreply.destination = right_answer else: # This is the wrong answer, by undead standards. myreply.destination = wrong_answer challenge1.replies.append(myreply) challenge2.replies.append(myreply) ol += [challenge1, challenge2] return ol
def SHOPKEEPER_offers(self, explo): ol = list() the_cousin = self.elements["TARGET"] if self.dated and self.subplots["next"].active: myoffer = dialogue.Offer( msg= "Thanks for getting {0} out of my hair; {1} still hangs around here too much but it's better than it used to be." .format(the_cousin, the_cousin.subject_pronoun()), context=context.ContextTag([context.HELLO, context.REWARD]), replies=[ dialogue.Reply("You're welcome.", destination=dialogue.Cue( context.ContextTag([context.REWARD]))) ]) ol.append(myoffer) elif not self.started: myoffer = dialogue.Offer( "It's my cousin {0}... {1} hangs out here all day bothering me." .format(the_cousin, the_cousin.subject_pronoun()), context=context.ContextTag([context.PROBLEM, context.PERSONAL]), effect=self.tell_problem) ol.append(myoffer) return ol
def _MYNPC_offers(self, explo): ol = list() if self.invited: npc = self.elements["TARGET"] r1 = dialogue.Reply( "Would you like to go out with {0}?".format(npc), destination=dialogue.Offer( "{0}? Yes, you may tell {1} that I would like that very much!" .format(npc, npc.object_pronoun()), effect=self.accept_invitation)) ol.append( dialogue.Offer("Yes, what is it?", context=context.ContextTag( [context.BRINGMESSAGE, context.QUESTION]), replies=[ r1, ])) return ol
def converse(explo, pc, npc, cue): # The party is going to converse with someone. # During the conversation, the Exploration object will have an attribute # called "convo" which is a tuple containing the pc, npc, and conversation. crd = ConvoRedraw(npc, screen=explo.screen, predraw=explo.view) offers = list() mygram = grammar.base_grammar(pc, npc, explo) for p in explo.camp.active_plots(): offers += p.get_dialogue_offers(npc, explo) pgram = p.get_dialogue_grammar(npc, explo) if pgram: grammar.absorb(mygram, pgram) # Add special offers- Job Training. That's it for now. if npc.mr_level and npc.mr_level.__class__ in characters.PC_CLASSES: add_ok = False for chara in explo.camp.party: if chara.xp >= chara.xp_for_next_level( ) and npc.mr_level.can_take_level(chara): add_ok = True if add_ok: offers.append( Offer("[TRAINING]", context=context.ContextTag([context.TRAINING]), effect=services.JobTraining([npc.mr_level.__class__]))) conversation = build_conversation(cue, offers) coff = conversation explo.convo = (pc, npc, conversation) pc_voice = pc.get_voice() npc_voice = npc.get_voice() while coff: crd.friendliness = npc.get_friendliness(explo.camp) crd.text = personalize_text(coff.msg, npc_voice, mygram) mymenu = rpgmenu.Menu(explo.screen, crd.menu_rect.x, crd.menu_rect.y, crd.menu_rect.width, crd.menu_rect.height, border=None, predraw=crd) for i in coff.replies: mymenu.add_item(personalize_text(i.msg, pc_voice, mygram), i.destination) if crd.text and not mymenu.items: mymenu.add_item("[Continue]", None) else: mymenu.sort() nextfx = coff.effect coff = mymenu.query() if nextfx: nextfx(explo) del explo.convo
import image def harvest(mod, class_to_collect): mylist = [] for name in dir(mod): o = getattr(mod, name) if isinstance(o, class_to_collect): mylist.append(o) return mylist standard_replies = harvest(replies, Reply) standard_offers = harvest(offers, Offer) CUE_HELLO = Cue(context.ContextTag([context.HELLO])) CUE_THREATEN = Cue(context.ContextTag([context.THREATEN])) def build_anchor_list(conversation, context_type): # Find all offers in this conversation whose context matches the context_type. # One of these offers can be used as an anchor for attaching a new reply link # to the conversation. anchor_list = [] if context_type.matches(conversation.context): anchor_list.append(conversation) for r in conversation.replies: anchor_list += build_anchor_list(r.destination, context_type) return anchor_list