def custom_init(self, nart):
        myscene = maps.Scene(80,
                             80,
                             sprites={
                                 maps.SPRITE_WALL: "terrain_wall_bone.png",
                                 maps.SPRITE_GROUND:
                                 "terrain_ground_under.png",
                                 maps.SPRITE_FLOOR: "terrain_floor_tile.png",
                                 maps.SPRITE_CHEST: "terrain_chest_metal.png"
                             },
                             biome=context.HAB_TUNNELS,
                             setting=self.setting,
                             fac=self.elements.get("ANTAGONIST"),
                             desctags=(context.MAP_DUNGEON, context.MAP_GODOWN,
                                       context.GEN_UNDEAD))
        mymapgen = randmaps.SubtleMonkeyTunnelScene(myscene)
        self.register_scene(nart, myscene, mymapgen, ident="LOCALE")
        self.add_custom_decor(myscene, mymapgen)

        for t in range(random.randint(5, 8)):
            self.add_sub_plot(nart, "ENCOUNTER")
        self.add_sub_plot(nart, "SPECIAL_FEATURE")
        self.add_sub_plot(nart, "SPECIAL_ENCOUNTER")

        return True
Ejemplo n.º 2
0
    def custom_init(self, nart):
        """Create the crypt and add a person saying where."""
        myscene = maps.Scene(129,
                             129,
                             sprites={
                                 maps.SPRITE_GROUND:
                                 "terrain_ground_forest.png",
                                 maps.SPRITE_WALL: "terrain_wall_darkbrick.png"
                             },
                             biome=context.HAB_FOREST,
                             setting=self.setting,
                             desctags=(
                                 context.MAP_WILDERNESS,
                                 context.DES_CIVILIZED,
                             ))
        myscene.name = "Crypt Thing"
        mymapgen = randmaps.ForestScene(myscene)
        self.register_scene(nart, myscene, mymapgen, ident="WILDERNESS")

        myroom = randmaps.rooms.FuzzyRoom(tags=(context.ENTRANCE, ),
                                          parent=myscene,
                                          anchor=randmaps.anchors.northwest)
        myent = waypoints.Well()
        myroom.contents.append(myent)

        wme = self.chapter.world.add_entrance(myscene, myscene.name,
                                              worlds.W_DUNGEON, myent, False)
        self.wme = wme

        room = self.seek_element(nart, "_ROOM", self.seek_room)
        npc = monsters.generate_npc(job=characters.Necromancer)
        self.register_element("_NPC", npc, dident="_ROOM")

        return True
Ejemplo n.º 3
0
    def custom_init( self, nart ):
        """Create the final dungeon, boss encounter, and resolution."""
        btype = monsters.choose_monster_type(self.rank+1,self.rank+4,{(context.MTY_HUMANOID,context.MTY_LEADER):True,context.MTY_LEADER:context.MAYBE})
        boss = monsters.generate_boss( btype, self.rank+4 )

        interior = maps.Scene( 65,65, sprites={maps.SPRITE_WALL: "terrain_wall_darkbrick.png", 
            maps.SPRITE_FLOOR: "terrain_floor_dungeon.png", },
            biome=context.HAB_BUILDING, setting=self.setting, desctags=(context.MAP_DUNGEON,context.MTY_HUMANOID) )
        igen = randmaps.SubtleMonkeyTunnelScene( interior )
        interior.name = "{0}'s Base".format( boss )

        self.register_scene( nart, interior, igen, ident="_LAIR" )
        self.add_sub_plot( nart, "CONNECT", PlotState( elements={"PREV":self.elements["FINAL_DUNGEON"],"NEXT":interior} ).based_on( self ) )

        team = teams.Team(default_reaction=-999, rank=self.rank, strength=200,
         habitat=interior.get_encounter_request(), respawn=False, boss=boss )
        int_goalroom = randmaps.rooms.SharpRoom( tags=(context.GOAL,), parent=interior )
        int_goalroom.contents.append( team )
        boss.team = team
        self.register_element( "_LAIR_ROOM", int_goalroom )
        self.register_element( "ENEMY", boss, "_LAIR_ROOM" )
        self.add_sub_plot( nart, "DUNGEON_ARMORY", PlotState( elements={"LOCALE":interior} ).based_on( self ) )
        self.add_resolution( nart, "RESOLVE_FIGHT", ident="next" )
        self.enemy_defeated = False

        #self.add_sub_plot( nart, "CONNECT", PlotState( elements={"PREV":self.elements["LOCALE"],"NEXT":interior} ).based_on( self ) )

        return True
Ejemplo n.º 4
0
    def custom_init( self, nart ):
        """Install the dungeon."""
        # Create the intermediary level.
        interior = maps.Scene( 65,65, sprites={maps.SPRITE_WALL: "terrain_wall_darkbrick.png", maps.SPRITE_GROUND: "terrain_ground_under.png", maps.SPRITE_FLOOR: "terrain_floor_tile.png" },
            fac=self.elements["ANTAGONIST"],
            biome=context.HAB_TUNNELS, setting=self.setting, desctags=(context.MAP_DUNGEON,) )
        igen = randmaps.SubtleMonkeyTunnelScene( interior )
        self.register_scene( nart, interior, igen, ident="LOCALE" )

        # Create the goal room.
        team = teams.Team(default_reaction=-999, rank=self.rank, strength=50, habitat=interior.get_encounter_request(),
         fac=self.elements["ANTAGONIST"], respawn=False )
        int_goalroom = randmaps.rooms.SharpRoom( tags=(context.GOAL,), parent=interior )
        int_goalroom.contents.append( team )

        # Create the guardian.
        boss = self.register_element( "_BOSS", monsters.generate_npc(team=team,upgrade=True,rank=self.rank+3) )
        self.enemy_defeated = False
        interior.name = "{}'s Chamber".format( boss )
        int_goalroom.contents.append( boss )

        for t in range( random.randint(2,4) ):
            self.add_sub_plot( nart, "ENCOUNTER" )

        # Connect to previous level.
        self.add_sub_plot( nart, "CONNECT", PlotState( elements={"PREV":self.elements["LAST_DUNGEON"],"NEXT":interior} ).based_on( self ) )

        # Add a BARDIC_FRESHSTART to install the dungeon somewhere else.
        sp = self.add_sub_plot( nart, "BARDIC_FRESHSTART" )
        self.register_element( "DESTINATION", sp.elements.get( "LOCALE" ) )
        return True
    def custom_init(self, nart):
        myscene = maps.Scene(80,
                             80,
                             sprites={
                                 maps.SPRITE_WALL: "terrain_wall_cave.png",
                                 maps.SPRITE_GROUND:
                                 "terrain_ground_under.png",
                                 maps.SPRITE_FLOOR: "terrain_floor_gravel.png"
                             },
                             biome=context.HAB_CAVE,
                             setting=self.setting,
                             fac=self.elements.get("ANTAGONIST"),
                             desctags=(context.MAP_DUNGEON, context.MAP_GODOWN,
                                       context.DES_EARTH))
        mymapgen = randmaps.CaveScene(myscene,
                                      decorate=randmaps.decor.RockyDec())
        self.register_scene(nart, myscene, mymapgen, ident="LOCALE")
        #self.add_custom_decor( myscene, mymapgen )

        for t in range(random.randint(5, 8)):
            self.add_sub_plot(nart, "ENCOUNTER")
        self.add_sub_plot(nart, "SPECIAL_FEATURE")
        self.add_sub_plot(nart, "SPECIAL_ENCOUNTER")

        return True
    def custom_init(self, nart):
        myscene = maps.Scene(120,
                             120,
                             sprites={
                                 maps.SPRITE_WALL: "terrain_wall_cave.png",
                                 maps.SPRITE_GROUND:
                                 "terrain_ground_cthonic.png",
                                 maps.SPRITE_FLOOR: "terrain_floor_gravel.png",
                                 maps.SPRITE_CHEST: "terrain_chest_metal.png"
                             },
                             biome=context.HAB_CAVE,
                             setting=self.setting,
                             fac=self.elements.get("ANTAGONIST"),
                             desctags=(context.MAP_DUNGEON, context.MAP_GODOWN,
                                       context.DES_FIRE))
        mymapgen = randmaps.DividedIslandScene(myscene)
        self.register_scene(nart, myscene, mymapgen, ident="LOCALE")
        self.add_custom_decor(myscene, mymapgen)

        self.add_sub_plot(nart, "DIVIDED_ISLAND_COMPLICATION")
        for t in range(random.randint(7, 12)):
            self.add_sub_plot(nart, "ENCOUNTER")
        self.add_sub_plot(nart, "SPECIAL_ENCOUNTER")

        return True
Ejemplo n.º 7
0
    def custom_init(self, nart):
        exterior = randmaps.rooms.BuildingRoom(tags=(context.CIVILIZED, ))
        exterior.special_c["window"] = maps.DARK_WINDOW
        self.register_element("_EXTERIOR", exterior, dident="LOCALE")
        locale = self.elements.get("LOCALE")
        interior = maps.Scene(50,
                              50,
                              sprites={
                                  maps.SPRITE_WALL: "terrain_wall_dungeon.png",
                                  maps.SPRITE_FLOOR:
                                  "terrain_floor_dungeon.png",
                                  maps.SPRITE_CHEST: "terrain_chest_metal.png",
                                  maps.SPRITE_INTERIOR:
                                  "terrain_int_temple.png"
                              },
                              biome=context.HAB_BUILDING,
                              setting=self.setting,
                              desctags=(context.MAP_DUNGEON,
                                        context.GEN_UNDEAD, context.DES_LUNAR,
                                        context.MTY_UNDEAD))
        igen = randmaps.SubtleMonkeyTunnelScene(interior)
        interior.name = "{0} Manor".format(namegen.ELDRITCH.gen_word())
        gate_1 = waypoints.OpenGateDoor()
        gate_2 = waypoints.GateDoor()
        gate_1.destination = interior
        gate_1.otherside = gate_2
        gate_1.mini_map_label = "Haunted House"
        gate_2.destination = locale
        gate_2.otherside = gate_1
        self.register_scene(nart,
                            interior,
                            igen,
                            ident="BUILDING_INT",
                            dident="LOCALE")
        exterior.special_c["door"] = gate_1
        int_mainroom = randmaps.rooms.SharpRoom(tags=(context.ENTRANCE, ),
                                                anchor=randmaps.anchors.south,
                                                parent=interior)
        int_mainroom.contents.append(gate_2)
        int_mainroom.contents.append(maps.SKULL_ALTAR)
        gate_2.anchor = randmaps.anchors.south

        # Add the goal room, move the target there.
        int_goalroom = randmaps.rooms.SharpRoom(tags=(context.GOAL, ),
                                                parent=interior)
        target = self.elements["TARGET"]
        if isinstance(target, items.Item):
            dest = waypoints.SmallChest()
            dest.stock(self.rank)
            int_goalroom.contents.append(dest)
        else:
            dest = int_goalroom
        self.move_element(ele=target, dest=dest)

        # Add some encounters. Mostly for the treasure chests.
        pstate = PlotState(elements={"LOCALE": interior}).based_on(self)
        for t in range(random.randint(1, 3)):
            self.add_sub_plot(nart, "ENCOUNTER", pstate)
        return True
Ejemplo n.º 8
0
    def custom_init(self, nart):
        w = random.randint(7, 10)
        exterior = randmaps.rooms.BuildingRoom(w,
                                               17 - w,
                                               tags=(context.CIVILIZED, ))
        exterior.special_c["window"] = maps.SMALL_WINDOW
        self.register_element("_EXTERIOR", exterior, dident="LOCALE")

        interior = maps.Scene(
            50,
            50,
            sprites={maps.SPRITE_FLOOR: "terrain_floor_wood.png"},
            biome=context.HAB_BUILDING,
            setting=self.setting,
            desctags=(context.DES_CIVILIZED, ))
        igen = randmaps.BuildingScene(interior)

        gate_1 = waypoints.GateDoor()
        gate_2 = waypoints.GateDoor()
        gate_1.destination = interior
        gate_1.otherside = gate_2
        gate_2.destination = self.elements.get("LOCALE")
        gate_2.otherside = gate_1

        self.register_scene(nart,
                            interior,
                            igen,
                            ident="_INTERIOR",
                            dident="LOCALE")
        exterior.special_c["door"] = gate_1

        int_mainroom = randmaps.rooms.SharpRoom(tags=(context.CIVILIZED, ),
                                                anchor=randmaps.anchors.south,
                                                parent=interior)
        int_mainroom.contents.append(gate_2)
        gate_2.anchor = randmaps.anchors.south
        int_mainroom.DECORATE = randmaps.decor.BedroomDec()

        npc = monsters.generate_npc(fac=pstate.elements["LOCALE"].fac)
        interior.name = "{0}'s Home".format(npc)
        gate_1.mini_map_label = interior.name
        suitor = self.elements.get("TARGET")
        # Assume a heteronormativity rate of 50%.
        if random.randint(1, 2) == 1:
            if suitor.gender == stats.MALE:
                npc.gender = stats.FEMALE
            elif suitor.gender == stats.FEMALE:
                npc.gender = stats.MALE
        int_mainroom.contents.append(npc)
        self.register_element("RESOURCE", npc)

        return True
Ejemplo n.º 9
0
def design_scene(width,
                 height,
                 mapgen,
                 primary,
                 setting=None,
                 fac=None,
                 secondary=None):
    """Return tuple of scene and scenegen for the requested stuff."""
    myscene = maps.Scene(width, height, setting=setting, fac=fac)
    mymapgen = mapgen(myscene)
    if secondary:
        secondary(myscene, mymapgen, False)
    primary(myscene, mymapgen, True)
    return (myscene, mymapgen)
Ejemplo n.º 10
0
 def custom_init(self, nart):
     locale = self.seek_element(nart, "_LOCALE", self.seek_scene)
     exterior = randmaps.rooms.BuildingRoom(tags=(context.CIVILIZED, ))
     exterior.special_c["window"] = maps.CASTLE_WINDOW
     exterior.special_c["sign1"] = maps.SWORD_SIGN
     exterior.special_c["sign2"] = maps.SHIELD_SIGN
     self.register_element("_EXTERIOR", exterior, dident="_LOCALE")
     interior = maps.Scene(50,
                           50,
                           sprites={
                               maps.SPRITE_WALL:
                               "terrain_wall_darkbrick.png",
                               maps.SPRITE_FLOOR: "terrain_floor_stone.png"
                           },
                           biome=context.HAB_BUILDING,
                           setting=self.setting,
                           desctags=(context.DES_CIVILIZED, ))
     igen = randmaps.BuildingScene(interior)
     gate_1 = waypoints.GateDoor()
     gate_2 = waypoints.GateDoor()
     gate_1.destination = interior
     gate_1.otherside = gate_2
     gate_2.destination = self.elements.get("_LOCALE")
     gate_2.otherside = gate_1
     self.register_scene(nart,
                         interior,
                         igen,
                         ident="BUILDING_INT",
                         dident="_LOCALE")
     exterior.special_c["door"] = gate_1
     int_mainroom = randmaps.rooms.SharpRoom(tags=(context.CIVILIZED,
                                                   context.ROOM_PUBLIC),
                                             anchor=randmaps.anchors.south,
                                             parent=interior)
     int_mainroom.contents.append(gate_2)
     int_mainroom.contents.append(maps.PILED_GOODS)
     int_mainroom.contents.append(maps.PILED_GOODS)
     gate_2.anchor = randmaps.anchors.south
     int_mainroom.DECORATE = randmaps.decor.GeneralStoreDec(
         win=maps.CASTLE_WINDOW)
     npc = monsters.generate_npc(job=self.elements["JOB"])
     npc.tags.append(context.CHAR_SHOPKEEPER)
     interior.name = random.choice(self.NAME_PATTERNS).format(npc)
     gate_1.mini_map_label = "Dungeon Shop"
     int_mainroom.contents.append(npc)
     self.register_element("SHOPKEEPER", npc)
     self.shop = self.register_element(
         "SHOPSERVICE", services.Shop(rank=locale.rank + 3, npc=npc))
     self.first_time = True
     return True
Ejemplo n.º 11
0
    def custom_init(self, nart):
        """Create the climax level."""
        interior = maps.Scene(65,
                              65,
                              sprites={
                                  maps.SPRITE_WALL:
                                  "terrain_wall_darkbrick.png",
                                  maps.SPRITE_GROUND:
                                  "terrain_ground_under.png",
                                  maps.SPRITE_FLOOR: "terrain_floor_gravel.png"
                              },
                              biome=context.HAB_TUNNELS,
                              setting=self.setting,
                              desctags=(context.MAP_DUNGEON,
                                        context.MAP_GODOWN))
        igen = randmaps.SubtleMonkeyTunnelScene(interior)
        self.register_scene(nart, interior, igen, ident="LOCALE")

        # Create the guardiarn.
        btype = monsters.choose_monster_type(
            self.rank, self.rank + 2, {
                (context.DES_EARTH, context.MTY_FIGHTER, context.MTY_CONSTRUCT):
                True,
                context.DES_EARTH: context.MAYBE
            })
        boss = monsters.generate_boss(btype, self.rank + 3)
        interior.name = "{0}'s Lair".format(boss)

        # Create the goal room.
        team = teams.Team(default_reaction=-999,
                          rank=self.rank,
                          strength=200,
                          habitat=interior.get_encounter_request(),
                          respawn=False,
                          boss=boss)
        int_goalroom = randmaps.rooms.SharpRoom(tags=(context.GOAL, ),
                                                parent=interior)
        int_goalroom.contents.append(team)
        int_goalroom.contents.append(boss)
        boss.team = team

        # Alter the plot state to reflect this climax.
        self.register_element("SP_GOAL", context.SP_GOAL_SUMMON_DARKGOD)
        self.register_element("SP_MOT", context.SP_MOT_DESTROY_THE_WORLD)

        return True
Ejemplo n.º 12
0
 def custom_init(self, nart):
     """Create the black market, add secret connection."""
     locale = self.elements["LOCALE"]
     interior = maps.Scene(50,
                           50,
                           sprites={
                               maps.SPRITE_WALL:
                               "terrain_wall_darkbrick.png",
                               maps.SPRITE_FLOOR: "terrain_floor_wood.png"
                           },
                           biome=context.HAB_BUILDING,
                           setting=self.setting,
                           desctags=(context.DES_CIVILIZED, ))
     igen = randmaps.BuildingScene(interior)
     self.register_scene(nart,
                         interior,
                         igen,
                         ident="BUILDING_INT",
                         dident="LOCALE")
     int_mainroom = randmaps.rooms.SharpRoom(
         tags=(context.CIVILIZED, context.ENTRANCE),
         anchor=randmaps.anchors.northwest,
         parent=interior)
     int_mainroom.contents.append(maps.PILED_GOODS)
     int_mainroom.contents.append(maps.PILED_GOODS)
     int_mainroom.DECORATE = randmaps.decor.GeneralStoreDec()
     npc = monsters.generate_npc(job=monsters.base.Merchant)
     npc.tags.append(context.CHAR_SHOPKEEPER)
     interior.name = random.choice(self.NAME_PATTERNS).format(npc)
     int_mainroom.contents.append(npc)
     self.register_element("BMKEEPER", npc)
     self.shop = services.Shop(rank=self.rank + 3, turnover=2, npc=npc)
     self.add_sub_plot(
         nart, "SECRET_CONNECT",
         PlotState(elements={
             "PREV": locale,
             "NEXT": interior
         }).based_on(self))
     self._still_looking = True
     return True
Ejemplo n.º 13
0
    def custom_init( self, nart ):
        # Add the forest itself.
        myscene = maps.Scene( min( 95 + self.rank * 3, 129 ), min( 95 + self.rank * 3, 129 ), 
            sprites={maps.SPRITE_WALL: "terrain_wall_woodfort.png", maps.SPRITE_GROUND: "terrain_ground_forest.png",
             maps.SPRITE_FLOOR: "terrain_floor_gravel.png" },
            biome=context.HAB_FOREST, setting=self.setting, fac=None,
            desctags=(context.MAP_WILDERNESS,) )
        mymapgen = randmaps.ForestScene( myscene )
        self.register_scene( nart, myscene, mymapgen, ident="LOCALE" )

        # Add a village.
        castle = self.register_element( "CITY", randmaps.rooms.VillageRoom( width=35,
            height=35,tags=(context.CIVILIZED,context.ROOM_PUBLIC,context.MAP_ON_EDGE), parent=myscene ) )
        myroom = randmaps.rooms.FuzzyRoom( tags=(context.ENTRANCE,), parent=castle )
        myteam = teams.Team( strength=0, default_reaction=characters.SAFELY_FRIENDLY)
        castle.contents.append( myteam )
        myent = waypoints.Well()
        myroom.contents.append( myent )
        myroom.contents.append( monsters.generate_npc(species=characters.Elf, team=myteam) )
        myroom.contents.append( monsters.generate_npc(species=characters.Elf, team=myteam) )
        self.add_sub_plot( nart, "CITY_GENERALSTORE" )
        self.add_sub_plot( nart, "CITY_LIBRARY" )
        self.add_sub_plot( nart, "CITY_INN" )
        self.add_sub_plot( nart, "CITY_EXTRASHOP" )

        # Add world map entrance.
        self._entrance = self.chapter.world.add_entrance( myscene, myscene.name, worlds.W_VILLAGE, myent, False )

        for t in range( random.randint(2+min(self.rank//3,6),4+min(self.rank//2,6)) ):
            self.add_sub_plot( nart, "ENCOUNTER" )
        self.add_sub_plot( nart, "SPECIAL_FEATURE" )

        # Install the dungeon here.
        self.install_dungeon( nart, self.elements[ "LEVELS" ], myscene, self.elements["DNAME"] )
        self._ready = True
        return True
Ejemplo n.º 14
0
    def custom_init(self, nart):
        myscene = maps.Scene(100,
                             100,
                             sprites={
                                 maps.SPRITE_WALL: "terrain_wall_woodfort.png",
                                 maps.SPRITE_GROUND:
                                 "terrain_ground_forest.png",
                                 maps.SPRITE_FLOOR: "terrain_floor_gravel.png"
                             },
                             biome=context.HAB_FOREST,
                             setting=self.setting,
                             fac=self.elements.get("ANTAGONIST"),
                             desctags=(context.MAP_WILDERNESS, ))
        mymapgen = randmaps.ForestScene(myscene)
        self.register_scene(nart, myscene, mymapgen, ident="LOCALE")
        #self.add_custom_decor( myscene, mymapgen )

        for t in range(random.randint(3, 6)):
            self.add_sub_plot(nart, "ENCOUNTER")
        self.add_sub_plot(nart, "SPECIAL_FEATURE")
        self.add_sub_plot(nart, "SPECIAL_ENCOUNTER")
        self.add_sub_plot(nart, "SUPPLEMENTAL_TREASURE")

        return True
Ejemplo n.º 15
0
    def custom_init(self, nart):
        scene = self.elements.get("LOCALE")
        mygen = nart.get_map_generator(scene)
        room = mygen.DEFAULT_ROOM()
        room.DECORATE = randmaps.decor.CarnageDec()
        # The lair entrance may be guarded.
        if random.randint(1, 2) != 1:
            myhabitat = scene.get_encounter_request()
            myhabitat[context.GEN_DRAGON] = context.MAYBE
            room.contents.append(
                teams.Team(default_reaction=-999,
                           rank=self.rank,
                           strength=100,
                           habitat=myhabitat,
                           fac=scene.fac))

        self.register_element("_EXTERIOR", room, dident="LOCALE")

        interior = maps.Scene(
            50,
            50,
            sprites={
                maps.SPRITE_WALL: "terrain_wall_mine.png",
                maps.SPRITE_GROUND: "terrain_ground_under.png",
                maps.SPRITE_FLOOR: "terrain_floor_gravel.png",
                maps.SPRITE_CHEST: "terrain_chest_metal.png",
                maps.SPRITE_INTERIOR: "terrain_int_temple.png"
            },
            biome=context.HAB_CAVE,
            setting=self.setting,
            desctags=(context.MAP_DUNGEON, context.MAP_GODOWN,
                      context.GEN_DRAGON, context.MTY_BEAST))
        igen = randmaps.CaveScene(interior)

        gate_1 = waypoints.Pit()
        gate_2 = waypoints.StairsUp()
        gate_1.destination = interior
        gate_1.otherside = gate_2
        gate_2.destination = scene
        gate_2.otherside = gate_1

        self.register_scene(nart,
                            interior,
                            igen,
                            ident="BUILDING_INT",
                            dident="LOCALE")

        room.contents.append(gate_1)

        int_mainroom = igen.DEFAULT_ROOM(tags=(context.ENTRANCE, ),
                                         anchor=randmaps.anchors.west,
                                         parent=interior)
        int_mainroom.contents.append(gate_2)
        gate_2.anchor = randmaps.anchors.west

        # Add some encounters, maybe.
        if random.randint(1, 3) != 2:
            for t in range(random.randint(1, 2)):
                self.add_sub_plot(
                    nart, "ENCOUNTER",
                    PlotState(elements={
                        "LOCALE": interior
                    }).based_on(self))

        # Add the goal room, stick the boss monster there.
        int_goalroom = igen.DEFAULT_ROOM(tags=(context.GOAL, ),
                                         parent=interior)
        int_goalroom.DECORATE = randmaps.decor.CarnageDec()

        # Create the dragon.
        myteam = self.register_element(
            "TEAM", teams.Team(default_reaction=-999, strength=0))
        btype = monsters.choose_monster_type(
            self.rank + 2, self.rank + 3, {
                (context.MTY_DRAGON, context.MTY_BEAST): context.PRESENT,
                context.MTY_BOSS: context.PRESENT,
                context.GEN_DRAGON: context.MAYBE,
                context.MTY_DRAGON: context.MAYBE
            })
        if btype:
            boss = monsters.generate_boss(btype, self.rank + 4, team=myteam)
            interior.name = "{0}'s Lair".format(boss)
            int_goalroom.contents.append(boss)

            # Create the chests.
            chests = list()
            for t in range(random.randint(2, 4)):
                mychest = random.choice(
                    (waypoints.SmallChest, waypoints.MediumChest,
                     waypoints.LargeChest))()
                mychest.stock(self.rank)
                int_goalroom.contents.append(mychest)
                chests.append(mychest)
            # And the special treasure.
            for t in range(3):
                myitem = items.generate_special_item(self.rank +
                                                     random.randint(0, 1))
                if myitem:
                    random.choice(chests).contents.append(myitem)
            return True
        else:
            # No dragon, no encounter.
            return False
Ejemplo n.º 16
0
        myset.add(chara.pos)
        reach = (chara.get_move() + 1) // 2
        super(MoveMap,
              self).__init__(scene,
                             myset,
                             limits=pygame.Rect(chara.pos[0] - reach,
                                                chara.pos[1] - reach,
                                                reach * 2 + 1, reach * 2 + 1),
                             avoid_models=avoid_models)


if __name__ == '__main__':
    import timeit
    import maps

    myscene = maps.Scene(100, 100)
    for x in range(5, myscene.width):
        for y in range(5, myscene.height):
            if random.randint(1, 3) == 1:
                myscene.map[x][y].wall = maps.BASIC_WALL

    myset = set()
    myset.add((23, 23))

    class OldWay(object):
        def __init__(self, m):
            self.m = m

        def __call__(self):
            HotMap(self.m, myset)
Ejemplo n.º 17
0
    def custom_init(self, nart):
        scene = self.elements.get("LOCALE")
        mygen = nart.get_map_generator(scene)
        fortress = randmaps.rooms.CastleRoom(width=21,
                                             height=21,
                                             tags=(context.GOAL, ))
        myhabitat = scene.get_encounter_request()
        myhabitat[context.MTY_HUMANOID] = True
        myhabitat[(context.MTY_FIGHTER, context.MTY_LEADER)] = context.MAYBE
        myteam = teams.Team(default_reaction=-999,
                            rank=self.rank,
                            strength=200,
                            habitat=myhabitat,
                            fac=scene.fac)
        fortress.contents.append(myteam)
        self.register_element("_ROOM", fortress, dident="LOCALE")

        # Create the buildings.
        buildings = list()
        for t in range(random.randint(1, 3)):
            exterior = randmaps.rooms.BuildingRoom(tags=(context.CIVILIZED, ))
            exterior.special_c["window"] = maps.SMALL_WINDOW
            self.register_element("_EXTERIOR{0}".format(t),
                                  exterior,
                                  dident="_ROOM")
            interior = maps.Scene(40,
                                  40,
                                  sprites={
                                      maps.SPRITE_WALL:
                                      "terrain_wall_wood.png",
                                      maps.SPRITE_FLOOR:
                                      "terrain_floor_wood.png"
                                  },
                                  biome=context.HAB_BUILDING,
                                  setting=self.setting,
                                  desctags=(context.MTY_HUMANOID, ))
            interior.name = "Building {}".format(t + 1)
            igen = randmaps.BuildingScene(interior)
            gate_1 = waypoints.GateDoor()
            gate_2 = waypoints.GateDoor()
            gate_1.destination = interior
            gate_1.otherside = gate_2
            gate_2.destination = scene
            gate_2.otherside = gate_1
            self.register_scene(nart,
                                interior,
                                igen,
                                ident="_BUILDING_{}".format(t),
                                dident="LOCALE")
            exterior.special_c["door"] = gate_1
            int_mainroom = randmaps.rooms.SharpRoom(
                anchor=randmaps.anchors.south, parent=interior)
            int_mainroom.contents.append(gate_2)
            gate_2.anchor = randmaps.anchors.south
            # Have a second room with guards. Probably. If you want.
            if random.randint(1, 4) != 1:
                int_otherroom = randmaps.rooms.SharpRoom(parent=interior)
                bteam = teams.Team(default_reaction=-999,
                                   rank=self.rank,
                                   strength=130,
                                   habitat=myhabitat,
                                   fac=scene.fac)
                int_otherroom.contents.append(bteam)
                int_otherroom.DECORATE = randmaps.decor.BuildingDec()
                buildings.append(int_otherroom)
            else:
                buildings.append(int_mainroom)

        # Create the chests and place them.
        for t in range(random.randint(4, 6)):
            mychest = random.choice(
                (waypoints.SmallChest, waypoints.MediumChest,
                 waypoints.LargeChest))()
            mychest.stock(self.rank)
            random.choice(buildings).contents.append(mychest)

        return True
Ejemplo n.º 18
0
    def custom_init(self, nart):
        exterior = randmaps.rooms.BuildingRoom(tags=(context.CIVILIZED, ))
        exterior.special_c["window"] = maps.SMALL_WINDOW
        exterior.special_c["sign1"] = maps.DRINK_SIGN
        self.register_element("_EXTERIOR", exterior, dident="LOCALE")
        interior = maps.Scene(50,
                              50,
                              sprites={
                                  maps.SPRITE_WALL: "terrain_wall_wood.png",
                                  maps.SPRITE_FLOOR: "terrain_floor_wood.png"
                              },
                              biome=context.HAB_BUILDING,
                              setting=self.setting,
                              desctags=(context.DES_CIVILIZED, ))
        igen = randmaps.BuildingScene(interior)
        gate_1 = waypoints.GateDoor()
        gate_2 = waypoints.GateDoor()
        gate_1.destination = interior
        gate_1.otherside = gate_2
        gate_2.destination = self.elements.get("LOCALE")
        gate_2.otherside = gate_1
        self.register_scene(nart,
                            interior,
                            igen,
                            ident="BUILDING_INT",
                            dident="LOCALE")
        exterior.special_c["door"] = gate_1
        int_mainroom = randmaps.rooms.SharpRoom(random.randint(12, 20),
                                                random.randint(12, 20),
                                                tags=(context.CIVILIZED,
                                                      context.ROOM_PUBLIC),
                                                anchor=randmaps.anchors.south,
                                                parent=interior)
        int_mainroom.contents.append(gate_2)
        int_mainroom.contents.append(waypoints.Bookshelf())
        int_mainroom.contents.append(maps.FIREPLACE)
        gate_2.anchor = randmaps.anchors.south
        int_mainroom.DECORATE = randmaps.decor.TavernDec(win=maps.SMALL_WINDOW)
        npc = monsters.generate_npc(job=monsters.base.Innkeeper)
        npc.tags.append(context.CHAR_INNKEEPER)
        interior.name = random.choice(self.NAME_PATTERNS).format(
            npc,
            random.choice(monsters.MONSTER_LIST).name,
            random.choice(monsters.MONSTER_LIST).name)
        gate_1.mini_map_label = "Traveler's Inn"
        int_mainroom.contents.append(npc)
        self.register_element("SHOPKEEPER", npc)
        int_mainroom.contents.append(maps.TABLE)
        int_mainroom.contents.append(maps.TABLE)
        int_mainroom.contents.append(maps.TABLE)
        # Add at least one visitor.
        npc = self.register_element(
            "NPC", monsters.generate_npc(rank=self.rank + 2, upgrade=True))
        self.add_sub_plot(nart, "RESOURCE_NPCCONVO")
        int_mainroom.contents.append(npc)

        int_bedroom = randmaps.rooms.SharpRoom(tags=(context.CIVILIZED, ),
                                               parent=interior)
        int_bedroom.contents.append(maps.LIGHT_STAND)
        int_bedroom.DECORATE = randmaps.decor.BedroomDec()
        self.shop = services.Inn()
        return True
Ejemplo n.º 19
0
    def custom_init(self, nart):
        # Create the boss monster.
        btype = monsters.choose_monster_type(
            self.rank, self.rank + 2, {
                context.MTY_UNDEAD: True,
                context.DES_LUNAR: context.MAYBE,
                context.MTY_BOSS: context.MAYBE
            })
        if btype:
            # We have a boss type, which means we can get a boss monster.
            bteam = teams.Team(default_reaction=-999,
                               rank=self.rank,
                               strength=200,
                               habitat={
                                   context.MTY_UNDEAD: True,
                                   context.DES_LUNAR: context.MAYBE
                               },
                               fac=None)
            boss = monsters.generate_boss(btype, self.rank + 2, team=bteam)
            bteam.boss = boss
            for t in range(3):
                myitem = items.generate_special_item(self.rank + 1)
                if myitem:
                    boss.contents.append(myitem)

            locale = self.elements.get("LOCALE")

            # Create the tomb.
            myfaction = teams.AntagonistFaction(primary=context.GEN_UNDEAD)
            myscene = maps.Scene(
                60,
                60,
                sprites={
                    maps.SPRITE_WALL: "terrain_wall_darkstone.png",
                    maps.SPRITE_GROUND: "terrain_ground_canyon.png",
                    maps.SPRITE_CHEST: "terrain_chest_metal.png",
                    maps.SPRITE_FLOOR: "terrain_floor_gravel.png"
                },
                biome=context.HAB_CAVE,
                setting=self.setting,
                fac=None,
                desctags=(context.MAP_DUNGEON, context.MAP_GODOWN,
                          context.DES_LUNAR, context.GEN_UNDEAD,
                          context.MTY_UNDEAD))
            mymapgen = randmaps.DividedIslandScene(myscene)
            self.register_scene(nart,
                                myscene,
                                mymapgen,
                                ident="_CRYPT",
                                dident="LOCALE")
            myscene.name = "Crypt of {}".format(boss)

            # Connect the scene to LOCALE.
            self.add_sub_plot(
                nart, "CONNECT",
                PlotState(rank=self.rank,
                          elements={
                              "PREV": locale,
                              "NEXT": myscene
                          }).based_on(self))

            # Add the bridge room
            bridge_room = randmaps.rooms.BottleneckRoom()
            self._bridge_door = waypoints.PuzzleDoor()
            bridge_room.special_c["door"] = self._bridge_door
            mymapgen.special_c["bridge"] = bridge_room
            self.register_element("_BRIDGE_ROOM", bridge_room, dident="_CRYPT")

            # Pre-bridge warning
            room = mymapgen.DEFAULT_ROOM()
            mymapgen.special_c["before_bridge"] = room
            room.contents.append(
                teams.Team(default_reaction=-999,
                           rank=self.rank,
                           strength=100,
                           habitat={
                               (context.MTY_UNDEAD, context.MTY_CONSTRUCT):
                               True,
                               context.DES_SOLAR: context.MAYBE
                           }))
            mysign = waypoints.Signpost(
                desc=
                "'This crypt was built to imprison the evil of {} the {} for all time. Whosoever releases these bonds shall be punished by death.'"
                .format(boss, boss.monster_name))
            mysign.anchor = randmaps.anchors.middle
            room.contents.append(mysign)
            self.register_element("_ROOM", room, dident="_CRYPT")

            # Lever room
            lever_room = randmaps.rooms.SharpRoom(tags=(context.ENTRANCE, ))
            lever_room.contents.append(
                teams.Team(default_reaction=-999,
                           rank=self.rank,
                           strength=100,
                           habitat={
                               (context.MTY_UNDEAD, context.MTY_CONSTRUCT):
                               True,
                               context.DES_SOLAR: context.MAYBE
                           }))
            self.register_element("_LEVER_ROOM", lever_room, dident="_CRYPT")
            lever = waypoints.PuzzleSwitch()
            self.register_element("_LEVER", lever, dident="_LEVER_ROOM")

            # Create the treasure room.
            int_otherroom = randmaps.rooms.FuzzyRoom(random.randint(10, 16),
                                                     random.randint(10, 16),
                                                     parent=myscene,
                                                     tags=(context.GOAL, ))
            int_otherroom.contents.append(bteam)
            int_otherroom.contents.append(boss)

            # Create the chests and place them.
            for t in range(random.randint(3, 5)):
                mychest = random.choice(
                    (waypoints.SmallChest, waypoints.MediumChest,
                     waypoints.LargeChest))()
                mychest.stock(self.rank)
                int_otherroom.contents.append(mychest)

            # Add an extra encounter, just because.
            self.add_sub_plot(
                nart, "ENCOUNTER",
                PlotState(elements={
                    "LOCALE": myscene,
                    "ANTAGONIST": myfaction
                }).based_on(self))

        return btype
Ejemplo n.º 20
0
    def custom_init(self, nart):
        scene = self.elements.get("LOCALE")
        mygen = nart.get_map_generator(scene)
        entryroom = mygen.DEFAULT_ROOM()
        myhabitat = scene.get_encounter_request()
        myhabitat[context.MTY_HUMANOID] = True
        myfaction = teams.AntagonistFaction(primary=context.MTY_THIEF,
                                            dungeon_type=("Cave", "Guild"))

        myteam = teams.Team(default_reaction=-999,
                            rank=self.rank,
                            strength=120,
                            habitat=myhabitat,
                            fac=myfaction)
        entryroom.contents.append(myteam)
        self.register_element("_ROOM", entryroom, dident="LOCALE")

        # Create the cave with the treasure.
        interior = maps.Scene(50,
                              50,
                              sprites={
                                  maps.SPRITE_WALL: "terrain_wall_cave.png",
                                  maps.SPRITE_GROUND:
                                  "terrain_ground_under.png",
                                  maps.SPRITE_FLOOR: "terrain_floor_gravel.png"
                              },
                              biome=context.HAB_CAVE,
                              setting=self.setting,
                              fac=myfaction,
                              desctags=(context.MAP_DUNGEON,
                                        context.MAP_GODOWN, context.MTY_THIEF))
        interior.name = myfaction.name
        mymapgen = randmaps.CaveScene(interior)

        gate_1 = waypoints.Pit()
        gate_2 = waypoints.GateDoor()
        gate_1.destination = interior
        gate_1.otherside = gate_2
        gate_2.destination = scene
        gate_2.otherside = gate_1
        self.register_scene(nart,
                            interior,
                            mymapgen,
                            ident="_THIEFCAVE",
                            dident="LOCALE")

        gate_1.anchor = randmaps.anchors.middle
        entryroom.contents.append(gate_1)

        int_mainroom = randmaps.rooms.FuzzyRoom(anchor=randmaps.anchors.south,
                                                parent=interior)
        int_mainroom.contents.append(gate_2)
        gate_2.anchor = randmaps.anchors.south

        int_otherroom = randmaps.rooms.FuzzyRoom(random.randint(10, 16),
                                                 random.randint(10, 16),
                                                 parent=interior)
        bteam = teams.Team(default_reaction=-999,
                           rank=self.rank,
                           strength=200,
                           habitat=myhabitat,
                           fac=myfaction)
        int_otherroom.contents.append(bteam)

        # Create the chests and place them.
        for t in range(random.randint(3, 5)):
            mychest = random.choice(
                (waypoints.SmallChest, waypoints.MediumChest,
                 waypoints.LargeChest))()
            mychest.stock(self.rank)
            int_otherroom.contents.append(mychest)

        # Add an extra encounter, just because.
        self.add_sub_plot(
            nart, "ENCOUNTER",
            PlotState(elements={
                "LOCALE": interior,
                "ANTAGONIST": myfaction
            }).based_on(self))

        return True
Ejemplo n.º 21
0
    def custom_init( self, nart ):
        """Install the dungeon."""
        # Create the intermediary level.
        interior = maps.Scene( 65,65, sprites={maps.SPRITE_WALL: "terrain_wall_cave.png", maps.SPRITE_GROUND: "terrain_ground_under.png", maps.SPRITE_FLOOR: "terrain_floor_gravel.png" },
            biome=context.HAB_TUNNELS, setting=self.setting, desctags=(context.MAP_DUNGEON,context.MAP_GODOWN) )
        igen = randmaps.SubtleMonkeyTunnelScene( interior )
        self.register_scene( nart, interior, igen, ident="_LAIR" )

        # Create the guardian.
        btype = monsters.choose_monster_type(self.rank,self.rank+2,{(context.DES_EARTH,context.MTY_FIGHTER,context.MTY_CONSTRUCT):True,context.DES_EARTH:context.MAYBE})
        boss = self.register_element( "_BOSS", monsters.generate_boss( btype, self.rank+3 ) )
        interior.name = "{0}'s Lair".format( boss )

        # Connect to previous level.
        self.add_sub_plot( nart, "CONNECT", PlotState( elements={"PREV":self.elements["LAST_DUNGEON"],"NEXT":interior} ).based_on( self ) )

        # Create the goal room.
        team = teams.Team(default_reaction=-999, rank=self.rank, strength=150,
         habitat=interior.get_encounter_request(), respawn=False, boss=boss )
        int_goalroom = randmaps.rooms.SharpRoom( tags=(context.GOAL,), parent=interior )
        int_goalroom.contents.append( team )
        int_goalroom.contents.append( boss )
        boss.team = team
        stairs_1 = waypoints.SpiralStairsDown()
        int_goalroom.contents.append( stairs_1 )

        # Create the Dwarven City.
        myscene = maps.Scene( 65, 65, 
            sprites={maps.SPRITE_WALL: "terrain_wall_cave.png", maps.SPRITE_GROUND: "terrain_ground_under.png", maps.SPRITE_FLOOR: "terrain_floor_gravel.png"},
            biome=context.HAB_BUILDING, setting=self.setting,
            name=random.choice( self.NAME_PATTERNS ).format( namegen.DWARF.gen_word() ),
            desctags=(context.MAP_DUNGEON,context.DES_CIVILIZED,context.MAP_GODOWN) )
        mymapgen = randmaps.CaveScene( myscene )
        self.register_scene( nart, myscene, mymapgen, ident="LOCALE" )

        castle = self.register_element( "CITY", randmaps.rooms.VillageRoom( width=35,height=35,tags=(context.CIVILIZED,context.ROOM_PUBLIC), parent=myscene ) )
        myroom = randmaps.rooms.FuzzyRoom( tags=(context.ENTRANCE,), parent=castle )
        myteam = teams.Team( strength=0, default_reaction=characters.SAFELY_FRIENDLY)
        castle.contents.append( myteam )
        stairs_2 = waypoints.SpiralStairsUp()
        myroom.contents.append( stairs_2 )
        myroom.contents.append( monsters.generate_npc(species=characters.Dwarf, team=myteam) )
        myroom.contents.append( monsters.generate_npc(species=characters.Dwarf, team=myteam) )

        # Connect the stairs.
        self.move_element( myscene, interior )
        stairs_1.destination = myscene
        stairs_1.otherside = stairs_2
        stairs_2.destination = interior
        stairs_2.otherside = stairs_1

        # Add some city services.
        self.add_sub_plot( nart, "CITY_GENERALSTORE" )
        self.add_sub_plot( nart, "CITY_LIBRARY" )
        self.add_sub_plot( nart, "CITY_INN" )
        self.add_sub_plot( nart, "CITY_TEMPLE" )
        self.add_sub_plot( nart, "CITY_EXTRASHOP" )

        # Install the dungeon in the city.
        self.install_dungeon( nart, self.elements[ "LEVELS" ], self.elements[ "LOCALE" ], self.elements["DNAME"] )
        return True