def do_dialogue(self, event, character): """ Start a dialogue. """ # Get sentence. npc = None if event["npc"]: npc = utils.search_obj_data_key(event["npc"]) if npc: npc = npc[0] sentence_list = DIALOGUE_HANDLER.get_next_sentences_list(character, npc, event["dialogue"], 0, True) character.msg({"dialogues_list": sentence_list})
def show_dialogue(self, npc, dialogue, sentence): """ Show a dialogue. Args: npc: (optional) NPC's object. dialogue: dialogue's key. sentence: sentence's ordinal. Returns: None """ # Get next sentences_list. sentences_list = DIALOGUE_HANDLER.get_next_sentences_list( self, npc, dialogue, sentence, True) # Send dialogues_list to the player. self.save_current_dialogue(sentences_list, npc) self.msg({"dialogues_list": sentences_list})
def continue_dialogue(self, npc, dialogue, sentence): """ Continue current dialogue. Args: npc: (optional) NPC's object. dialogue: current dialogue's key. sentence: current sentence's ordinal. Returns: None """ if GAME_SETTINGS.get("auto_resume_dialogues"): # Check current dialogue. if not self.db.current_dialogue: return if (dialogue, sentence) not in self.db.current_dialogue["sentences_all"]: # Can not find specified dialogue in current dialogues. return try: # Finish current sentence DIALOGUE_HANDLER.finish_sentence(self, npc, dialogue, sentence) except Exception as e: ostring = "Can not finish sentence %s-%s: %s" % (dialogue, sentence, e) logger.log_tracemsg(ostring) # Get next sentences_list. sentences_list = DIALOGUE_HANDLER.get_next_sentences_list( self, npc, dialogue, sentence, False) # Send dialogues_list to the player. self.save_current_dialogue(sentences_list, npc) self.msg({"dialogues_list": sentences_list}) if not sentences_list: # dialogue finished, refresh surroundings self.show_location()
def show_dialogue(self, npc, dialogue, sentence): """ Show a dialogue. Args: npc: (optional) NPC's object. dialogue: dialogue's key. sentence: sentence's ordinal. Returns: None """ # Get next sentences_list. sentences_list = DIALOGUE_HANDLER.get_next_sentences_list(self, npc, dialogue, sentence, True) # Send dialogues_list to the player. self.save_current_dialogue(sentences_list, npc) self.msg({"dialogues_list": sentences_list})
if (dialogue, sentence) not in self.db.current_dialogue["sentences_all"]: # Can not find specified dialogue in current dialogues. return try: # Finish current sentence DIALOGUE_HANDLER.finish_sentence(self, npc, dialogue, sentence) except Exception, e: ostring = "Can not finish sentence %s-%s: %s" % (dialogue, sentence, e) logger.log_tracemsg(ostring) # Get next sentences_list. sentences_list = DIALOGUE_HANDLER.get_next_sentences_list(self, npc, dialogue, sentence, False) # Send dialogues_list to the player. self.save_current_dialogue(sentences_list, npc) self.msg({"dialogues_list": sentences_list}) if not sentences_list: # dialogue finished, refresh surroundings self.show_location() def add_exp(self, exp, combat=False): """ Add character's exp. Args: exp: (number) the exp value to add.
if have_current_dlg: try: # Finish current sentence DIALOGUE_HANDLER.finish_sentence(caller, npc, dialogue, sentence) except Exception, e: ostring = "Can not finish sentence %s-%s: %s" % (dialogue, sentence, e) logger.log_tracemsg(ostring) # Get next sentences_list. sentences_list = DIALOGUE_HANDLER.get_next_sentences_list(caller, npc, dialogue, sentence, False) # Send dialogues_list to the player. caller.msg({"dialogues_list": sentences_list}) #------------------------------------------------------------ # loot objects #------------------------------------------------------------ class CmdLoot(Command): """ Loot from a specified object.