def _register_dialog(): bye_option = DialogOptionData("\"Good bye\"", "cancel", None) name = "Tink" low_level_dialog = DialogData( name=name, portrait_icon_sprite=UI_ICON_SPRITE, text_body= "These aren't any regular old statues! They are magical gateways to distant places! " "I'm extracting their powers into something more ... mobile! " "Just give me a while, and come back later!", options=[bye_option]) high_level_dialog = DialogData( name=name, portrait_icon_sprite=UI_ICON_SPRITE, text_body="Hah! I managed to infuse the statues' teleporting powers into these stones. " \ "You can carry them with you and use them any time you want to return to this place! " "Isn't that neat?", options=[buy_consumable_option(ConsumableType.WARP_STONE, 2), bye_option]) def get_dialog_data(game_state: GameState) -> DialogData: if game_state.player_state.level < 2: return low_level_dialog else: return high_level_dialog register_conditional_npc_dialog_data(NPC_TYPE, get_dialog_data)
def register_sorcerer_npc(): size = (30, 30) # Must not align perfectly with grid cell size (pathfinding issues) sprite = Sprite.NEUTRAL_NPC_SORCERER portrait_icon_sprite = PortraitIconSprite.SORCERER npc_type = NpcType.NEUTRAL_SORCERER movement_speed = 0.03 register_npc_data(npc_type, NpcData.neutral(sprite, size, movement_speed)) register_npc_behavior(npc_type, NpcMind) dialog_options = [ buy_consumable_option(ConsumableType.HEALTH, 5), buy_consumable_option(ConsumableType.MANA, 5), buy_consumable_option(ConsumableType.SPEED, 5), buy_consumable_option(ConsumableType.POWER, 10), DialogOptionData("\"Good bye\"", "cancel", None)] dialog_text_body = "Greetings. I am glad to see that you have made it this far! However, great danger lies ahead... " \ "Here, see if any of these potions are of interest to you." dialog_data = DialogData(portrait_icon_sprite, dialog_text_body, dialog_options) register_npc_dialog_data(npc_type, dialog_data) sprite_sheet = SpriteSheet("resources/graphics/enemy_sprite_sheet_3.png") original_sprite_size = (32, 32) scaled_sprite_size = (48, 48) x = 3 indices_by_dir = { Direction.DOWN: [(x, 4), (x + 1, 4), (x + 2, 4)], Direction.LEFT: [(x, 5), (x + 1, 5), (x + 2, 5)], Direction.RIGHT: [(x, 6), (x + 1, 6), (x + 2, 6)], Direction.UP: [(x, 7), (x + 1, 7), (x + 2, 7)] } register_entity_sprite_map(sprite, sprite_sheet, original_sprite_size, scaled_sprite_size, indices_by_dir, (-8, -16)) register_portrait_icon_sprite_path(portrait_icon_sprite, 'resources/graphics/portrait_sorcerer_npc.png')
def _register_dialog(): dialog_options = [ buy_consumable_option(ConsumableType.HEALTH, 5), buy_consumable_option(ConsumableType.MANA, 5), buy_consumable_option(ConsumableType.SPEED, 5), buy_consumable_option(ConsumableType.POWER, 10), DialogOptionData("\"Good bye\"", "cancel", None) ] text_low_level = "Huh?! Well, aren't you the brave one, making it all the way out here! I would think " \ "twice before heading down that way! Well since you are here, see if any of these " \ "potions are of interest." text_high_level = "You are on the doorsteps of the Red Baron's domain! Please be careful. " \ "Here, see if any of these potions can be of use." dialog_low_level = DialogData(PORTRAIT_ICON_SPRITE, text_low_level, dialog_options) dialog_high_level = DialogData(PORTRAIT_ICON_SPRITE, text_high_level, dialog_options) def get_dialog_data(game_state: GameState) -> DialogData: if game_state.player_state.level < 5: return dialog_low_level else: return dialog_high_level register_conditional_npc_dialog_data(NPC_TYPE, get_dialog_data)
def _register_dialog(): dialog_text_body = "Ah.. You're new here, aren't you? Interested in my stock of potions? They come at a price of course..." consumables_1 = [ buy_consumable_option(ConsumableType.BREW, 2), buy_consumable_option(ConsumableType.HEALTH_LESSER, 3), buy_consumable_option(ConsumableType.MANA_LESSER, 3) ] consumables_2 = [ buy_consumable_option(ConsumableType.SPEED, 4), buy_consumable_option(ConsumableType.POWER, 10) ] bye_option = DialogOptionData("\"Good bye\"", "cancel", None) name = "Zak" dialog_low_level = DialogData(name, PORTRAIT_ICON_SPRITE, dialog_text_body, consumables_1 + [bye_option]) dialog_high_level = DialogData( name, PORTRAIT_ICON_SPRITE, dialog_text_body, consumables_1 + consumables_2 + [bye_option]) def get_dialog_data(game_state: GameState) -> DialogData: if game_state.player_state.level < 3: return dialog_low_level else: return dialog_high_level register_conditional_npc_dialog_data(NPC_TYPE, get_dialog_data)
def register_warpstone_merchant_npc(): size = ( 30, 30 ) # Must not align perfectly with grid cell size (pathfinding issues) sprite = Sprite.NEUTRAL_WARPSTONE_MERCHANT npc_type = NpcType.NEUTRAL_WARPSTONE_MERCHANT ui_icon_sprite = PortraitIconSprite.WARPSTONE_MERCHANT movement_speed = 0.03 register_npc_data(npc_type, NpcData.neutral(sprite, size, movement_speed)) register_npc_behavior(npc_type, NpcMind) introduction = "Hah! I managed to infuse the statues' teleporting powers into these stones. " \ "You can carry them with you and use them any time you want to return to this place!" dialog_options = [ buy_consumable_option(ConsumableType.WARP_STONE, 2), DialogOptionData("\"Good bye\"", "cancel", None) ] dialog_data = DialogData(ui_icon_sprite, introduction, dialog_options) register_npc_dialog_data(npc_type, dialog_data) sprite_sheet = SpriteSheet("resources/graphics/manga_spritesheet.png") original_sprite_size = (32, 32) scaled_sprite_size = (48, 48) x = 0 y = 0 indices_by_dir = { Direction.DOWN: [(x, y), (x + 1, y), (x + 2, y)], Direction.LEFT: [(x, y + 1), (x + 1, y + 1), (x + 2, y + 1)], Direction.RIGHT: [(x, y + 2), (x + 1, y + 2), (x + 2, y + 2)], Direction.UP: [(x, y + 3), (x + 1, y + 3), (x + 2, y + 3)] } register_entity_sprite_map(sprite, sprite_sheet, original_sprite_size, scaled_sprite_size, indices_by_dir, (-8, -16)) register_portrait_icon_sprite_path( ui_icon_sprite, 'resources/graphics/portrait_warpstone_merchant_npc.png')
def register_dwarf_npc(): size = ( 30, 30 ) # Must not align perfectly with grid cell size (pathfinding issues) sprite = Sprite.NEUTRAL_NPC_DWARF npc_type = NpcType.NEUTRAL_DWARF movement_speed = 0.03 register_npc_data(npc_type, NpcData.neutral(sprite, size, movement_speed)) register_npc_behavior(npc_type, NpcMind) introduction = "Hello there. I'm always looking for treasure. If you find any, we might be able to strike a deal!" dialog_options = [ sell_item_option( ItemType.GOLD_NUGGET, 20, "I'll give you good money for a nugget of pure gold!"), sell_item_option(ItemType.SAPHIRE, 30, "If you find a saphire I can make you real rich!"), DialogOptionData("\"Good bye\"", "cancel", None) ] dialog_data = DialogData(PortraitIconSprite.VIKING, introduction, dialog_options) register_npc_dialog_data(npc_type, dialog_data) sprite_sheet = SpriteSheet("resources/graphics/enemy_sprite_sheet.png") original_sprite_size = (32, 32) scaled_sprite_size = (48, 48) indices_by_dir = { Direction.DOWN: [(0, 4), (1, 4), (2, 4)], Direction.LEFT: [(0, 5), (1, 5), (2, 5)], Direction.RIGHT: [(0, 6), (1, 6), (2, 6)], Direction.UP: [(0, 7), (1, 7), (2, 7)] } register_entity_sprite_map(sprite, sprite_sheet, original_sprite_size, scaled_sprite_size, indices_by_dir, (-8, -16)) register_portrait_icon_sprite_path( PortraitIconSprite.VIKING, 'resources/graphics/viking_portrait.png')
def register_nomad_npc(): sprite = Sprite.NEUTRAL_NPC_NOMAD npc_type = NpcType.NEUTRAL_NOMAD register_npc_data( npc_type, NpcData.neutral(sprite=sprite, size=(30, 30), speed=0.03)) register_npc_behavior(npc_type, NpcMind) register_entity_sprite_map( sprite=sprite, sprite_sheet=SpriteSheet( "resources/graphics/enemy_sprite_sheet_3.png"), original_sprite_size=(32, 32), scaled_sprite_size=(48, 48), indices_by_dir={ Direction.DOWN: [(3, 0), (4, 0), (5, 0)], Direction.LEFT: [(3, 1), (4, 1), (5, 1)], Direction.RIGHT: [(3, 2), (4, 2), (5, 2)], Direction.UP: [(3, 3), (4, 3), (5, 3)] }, position_relative_to_entity=(-8, -16)) register_quest_giver_dialog( npc_name="Nomad", npc_type=NpcType.NEUTRAL_NOMAD, icon_sprite=PortraitIconSprite.NOMAD, icon_sprite_file_path='resources/graphics/nomad_portrait.png', quest=QUEST, quest_min_level=QUEST_MIN_LEVEL, quest_intro= "The red baron has caused us great trouble. Get rid of him and I'll be forever " "grateful! Oh, and please bring back anything interesting that he's carrying.", boss_npc_type=NpcType.WARRIOR_KING, quest_item_type=QUEST_ITEM_TYPE, custom_options=[ DialogOptionData("Receive blessing", "gain full health", HealAction()), DialogOptionData("Ask for advice", "see random hint", HintAction()) ], dialog_before_quest= "Greetings. I am here only to serve. Seek me out when you are wounded or need guidance!", dialog_give_quest= "Greetings. I am here only to serve. Seek me out when you are wounded or need guidance!", dialog_during_quest= "Greetings. I am here only to serve. Seek me out when you are wounded or need guidance!", dialog_after_completed= "Greetings. I am here only to serve. Seek me out when you are wounded or need guidance!", reward_item_id=lambda _: plain_item_id(ItemType.PORTAL_KEY))
def give_quest_option(quest: Quest, quest_intro: str, boss_npc_type: NpcType, quest_item_type: ItemType) -> DialogOptionData: return DialogOptionData( summary="QUEST: \"%s\"" % quest.name, action_text="accept quest", action=GiveQuestNpcAction(quest, boss_npc_type, quest_item_type), ui_icon_sprite=get_item_data_by_type(quest_item_type).icon_sprite, detail_header=quest.name, detail_body=quest_intro)
def complete_quest_option(quest: Quest, boss_npc_type: NpcType, quest_item_type: ItemType, reward_item_id: Callable[[GameState], Optional[ItemId]]) -> DialogOptionData: return DialogOptionData( summary="QUEST: \"%s\"" % quest.name, action_text="give", action=CompleteQuestNpcAction(quest, boss_npc_type, quest_item_type, reward_item_id), ui_icon_sprite=get_item_data_by_type(quest_item_type).icon_sprite, detail_header=get_item_data_by_type(quest_item_type).base_name, detail_body="...")
def register_quest_giver_dialog( npc_name: str, npc_type: NpcType, icon_sprite: PortraitIconSprite, icon_sprite_file_path: str, quest: Quest, quest_min_level: int, quest_intro: str, boss_npc_type: NpcType, quest_item_type: ItemType, custom_options: List[DialogOptionData], dialog_before_quest: str, dialog_give_quest: str, dialog_during_quest: str, dialog_after_completed: str, reward_item_id: Callable[[GameState], Optional[ItemId]]): bye_option = DialogOptionData("\"Good bye\"", "cancel", None) register_quest(quest.quest_id, quest) give_quest = give_quest_option(quest, quest_intro, boss_npc_type, quest_item_type) complete_quest = complete_quest_option(quest, boss_npc_type, quest_item_type, reward_item_id) dialog_data_before_quest = DialogData( npc_name, icon_sprite, dialog_before_quest, custom_options + [bye_option]) dialog_data_give_quest = DialogData( npc_name, icon_sprite, dialog_give_quest, custom_options + [give_quest, bye_option]) dialog_data_during_quest = DialogData( npc_name, icon_sprite, dialog_during_quest, custom_options + [complete_quest, bye_option]) dialog_data_after_completed = DialogData( npc_name, icon_sprite, dialog_after_completed, custom_options + [bye_option]) def get_dialog_data(game_state: GameState) -> DialogData: if game_state.player_state.has_completed_quest(quest.quest_id): return dialog_data_after_completed elif game_state.player_state.has_quest(quest.quest_id): return dialog_data_during_quest elif game_state.player_state.level >= quest_min_level: return dialog_data_give_quest else: return dialog_data_before_quest register_conditional_npc_dialog_data(npc_type, get_dialog_data) register_portrait_icon_sprite_path(icon_sprite, icon_sprite_file_path)
def _register_dialog(): option_blessing = DialogOptionData("Receive blessing", "gain full health", HealAction()) option_advice = DialogOptionData("Ask for advice", "see random hint", HintAction()) option_accept_quest = DialogOptionData( "QUEST: \"The red baron\"", "accept quest", AcceptQuest(), UiIconSprite.ITEM_KEY, "Key", "The red baron... Yes, he has caused us much trouble. He stole from me a key that may" " lead us out of here. You must bring it back to me!") option_complete_quest = DialogOptionData("QUEST: \"The red baron\"", "give", CompleteQuest(), UiIconSprite.ITEM_KEY, "Key", "...") option_bye = DialogOptionData("\"Good bye\"", "cancel", None) name = "Nomad" dialog_text = "Greetings. I am here only to serve. Seek me out when you are wounded or need guidance!" dialog_before_quest = DialogData( name, PORTRAIT_ICON_SPRITE, dialog_text, [option_blessing, option_advice, option_bye]) dialog_can_give_quest = DialogData( name, PORTRAIT_ICON_SPRITE, dialog_text, [option_blessing, option_advice, option_accept_quest, option_bye]) dialog_during_quest = DialogData( name, PORTRAIT_ICON_SPRITE, dialog_text, [option_blessing, option_advice, option_complete_quest, option_bye]) dialog_after_quest = DialogData( name, PORTRAIT_ICON_SPRITE, "Oh you're back...", [option_blessing, option_advice, option_bye]) def get_dialog_data(game_state: GameState) -> DialogData: if game_state.player_state.has_completed_quest(QUEST_ID): return dialog_after_quest elif game_state.player_state.has_quest(QUEST_ID): return dialog_during_quest elif _is_player_eligible_for_quest(game_state): return dialog_can_give_quest else: return dialog_before_quest register_conditional_npc_dialog_data(NPC_TYPE, get_dialog_data)
def _register_dialog(): bye_option = DialogOptionData("\"Good bye\"", "cancel", None) name = "Oracle" dialog = DialogData( name=name, portrait_icon_sprite=UI_ICON_SPRITE, text_body= "Greetings. Do you seek a new path in life? Anything is possible, for the right price.", options=[reset_talents_option(25), bye_option], ) register_npc_dialog_data(NPC_TYPE, dialog)
def register_young_sorceress_npc(): size = ( 30, 30 ) # Must not align perfectly with grid cell size (pathfinding issues) sprite = Sprite.NEUTRAL_NPC_YOUNG_SORCERESS npc_type = NpcType.NEUTRAL_YOUNG_SORCERESS ui_icon_sprite = PortraitIconSprite.YOUNG_SORCERESS movement_speed = 0.03 register_npc_data(npc_type, NpcData.neutral(sprite, size, movement_speed)) register_npc_behavior(npc_type, NpcMind) introduction = "Hey you! Have you seen my pet frog? I bet it was that old green mean goblin king that took it!" prompt = "> " frog_data = ITEMS[ItemType.FROG] dialog_options = [ DialogOptionData( prompt + frog_data.name, "give", AcceptFrog(), UiIconSprite.ITEM_FROG, frog_data.name, "If you help me get it back, I'll give you something in return!"), DialogOptionData("\"Good bye\"", "cancel", None) ] dialog_data = DialogData(ui_icon_sprite, introduction, dialog_options) register_npc_dialog_data(npc_type, dialog_data) sprite_sheet = SpriteSheet("resources/graphics/manga_spritesheet.png") original_sprite_size = (32, 32) scaled_sprite_size = (48, 48) x = 6 indices_by_dir = { Direction.DOWN: [(x, 4), (x + 1, 4), (x + 2, 4)], Direction.LEFT: [(x, 5), (x + 1, 5), (x + 2, 5)], Direction.RIGHT: [(x, 6), (x + 1, 6), (x + 2, 6)], Direction.UP: [(x, 7), (x + 1, 7), (x + 2, 7)] } register_entity_sprite_map(sprite, sprite_sheet, original_sprite_size, scaled_sprite_size, indices_by_dir, (-8, -16)) register_portrait_icon_sprite_path( ui_icon_sprite, 'resources/graphics/portrait_young_sorceress_npc.png')
def register_nomad_npc(): size = ( 30, 30 ) # Must not align perfectly with grid cell size (pathfinding issues) sprite = Sprite.NEUTRAL_NPC_NOMAD npc_type = NpcType.NEUTRAL_NOMAD movement_speed = 0.03 register_npc_data(npc_type, NpcData.neutral(sprite, size, movement_speed)) register_npc_behavior(npc_type, NpcMind) text_body = "Greetings. I am here only to serve. Seek me out when you are wounded or need guidance!" dialog_options = [ DialogOptionData("Receive blessing", "gain full health", HealAction()), DialogOptionData("Ask for advice", "see random hint", HintAction()), DialogOptionData( "\"The red baron\"", "give", AcceptKey(), UiIconSprite.ITEM_KEY, "Key", "The red baron... Yes, he has caused us much trouble. He stole from me a key that may" " lead us out of here. You must bring it back to me!"), DialogOptionData("\"Good bye\"", "cancel", None) ] dialog_data = DialogData(PortraitIconSprite.NOMAD, text_body, dialog_options) register_npc_dialog_data(npc_type, dialog_data) sprite_sheet = SpriteSheet("resources/graphics/enemy_sprite_sheet_3.png") original_sprite_size = (32, 32) scaled_sprite_size = (48, 48) indices_by_dir = { Direction.DOWN: [(3, 0), (4, 0), (5, 0)], Direction.LEFT: [(3, 1), (4, 1), (5, 1)], Direction.RIGHT: [(3, 2), (4, 2), (5, 2)], Direction.UP: [(3, 3), (4, 3), (5, 3)] } register_entity_sprite_map(sprite, sprite_sheet, original_sprite_size, scaled_sprite_size, indices_by_dir, (-8, -16)) register_portrait_icon_sprite_path( PortraitIconSprite.NOMAD, 'resources/graphics/nomad_portrait.png')
def _register_dialog(): bye_option = DialogOptionData("\"Good bye\"", "cancel", None) name = "Frog" dialog = DialogData( name=name, portrait_icon_sprite=UI_ICON_SPRITE, text_body= "Ribbit! I mean hi! I have been cursed! Once I was a wealthy salesman, but now I have to " "hide out here. Please help a poor frog by buying some of my goods?", options=[ buy_item_option(random_item_one_affix(4), 15), buy_item_option(random_item_one_affix(5), 25), buy_item_option(random_item_one_affix(6), 35), buy_item_option(random_item_one_affix(7), 50), bye_option ], ) register_npc_dialog_data(NPC_TYPE, dialog)
def register_ninja_npc(): size = ( 30, 30 ) # Must not align perfectly with grid cell size (pathfinding issues) sprite = Sprite.NEUTRAL_NPC_NINJA portrait_icon_sprite = PortraitIconSprite.NINJA npc_type = NpcType.NEUTRAL_NINJA movement_speed = 0.03 register_npc_data(npc_type, NpcData.neutral(sprite, size, movement_speed)) register_npc_behavior(npc_type, NpcMind) dialog_options = [ buy_consumable_option(ConsumableType.BREW, 2), buy_consumable_option(ConsumableType.HEALTH_LESSER, 3), buy_consumable_option(ConsumableType.MANA_LESSER, 3), buy_consumable_option(ConsumableType.SPEED, 4), buy_consumable_option(ConsumableType.POWER, 10), DialogOptionData("\"Good bye\"", "cancel", None) ] dialog_text_body = "Ah.. You're new here, aren't you? Interested in my stock of potions? " \ "They come at a price of course..." dialog_data = DialogData(portrait_icon_sprite, dialog_text_body, dialog_options) register_npc_dialog_data(npc_type, dialog_data) sprite_sheet = SpriteSheet("resources/graphics/enemy_sprite_sheet_3.png") original_sprite_size = (32, 32) scaled_sprite_size = (48, 48) x = 6 indices_by_dir = { Direction.DOWN: [(x, 0), (x + 1, 0), (x + 2, 0)], Direction.LEFT: [(x, 1), (x + 1, 1), (x + 2, 1)], Direction.RIGHT: [(x, 2), (x + 1, 2), (x + 2, 2)], Direction.UP: [(x, 3), (x + 1, 3), (x + 2, 3)] } register_entity_sprite_map(sprite, sprite_sheet, original_sprite_size, scaled_sprite_size, indices_by_dir, (-8, -16)) register_portrait_icon_sprite_path( portrait_icon_sprite, 'resources/graphics/ninja_portrait.png')
def register_challenge_starter_npc(): size = ( 30, 30 ) # Must not align perfectly with grid cell size (pathfinding issues) sprite = Sprite.NEUTRAL_NPC_CHALLENGE_STARTER portrait_icon_sprite = PortraitIconSprite.CHALLENGE_STARTER npc_type = NpcType.NEUTRAL_CHALLENGE_STARTER movement_speed = 0.03 register_npc_data(npc_type, NpcData.neutral(sprite, size, movement_speed)) register_npc_behavior(npc_type, NpcMind) dialog_options = [ buy_item_option(ItemType.GLADIATOR_ARMOR, 20), buy_item_option(ItemType.HEALING_WAND, 20), buy_item_option(ItemType.ZULS_AEGIS, 20), buy_item_option(ItemType.WARLOCKS_COWL, 20), buy_item_option(ItemType.DRUIDS_RING, 20), DialogOptionData("\"Good bye\"", "cancel", None) ] dialog_text_body = "Choose wisely." dialog_data = DialogData(portrait_icon_sprite, dialog_text_body, dialog_options) register_npc_dialog_data(npc_type, dialog_data) sprite_sheet = SpriteSheet("resources/graphics/enemy_sprite_sheet_3.png") original_sprite_size = (32, 32) scaled_sprite_size = (48, 48) x = 6 indices_by_dir = { Direction.DOWN: [(x, 0), (x + 1, 0), (x + 2, 0)], Direction.LEFT: [(x, 1), (x + 1, 1), (x + 2, 1)], Direction.RIGHT: [(x, 2), (x + 1, 2), (x + 2, 2)], Direction.UP: [(x, 3), (x + 1, 3), (x + 2, 3)] } register_entity_sprite_map(sprite, sprite_sheet, original_sprite_size, scaled_sprite_size, indices_by_dir, (-8, -16)) register_portrait_icon_sprite_path( portrait_icon_sprite, 'resources/graphics/ninja_portrait.png')