Esempio n. 1
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
    def custom_init(self, nart):
        """Create the world + base camp."""
        w = worlds.World()
        nart.camp.contents.append(w)
        self.register_element("WORLD", w)
        self.chapter = Chapter(end_rank=0, world=w)
        self.add_first_locale_sub_plot(nart)

        # Determine the chapter sizes.
        if nart.end_rank < 7:
            min_dungeon_size = 2
        else:
            min_dungeon_size = 3
        num_dungeon, extra_points = divmod(nart.end_rank, min_dungeon_size)

        # Step One- Generate a plot sequence, starting at the end and moving
        #  backwards to the beginning.

        # Step Two- Moving forward through the plot, connect the plot points.

        # Step Three- Add resources and whatnot.
        for job in characters.PC_CLASSES:
            self.add_sub_plot(nart, "RESOURCE_JOBTRAINER",
                              PlotState(elements={"JOB": job}))

        return True
Esempio n. 3
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
Esempio n. 4
0
    def custom_init(self, nart):
        """Load dungeon levels, and connect this dungeon to the adventure."""
        # Decide on a good name. Do this first in case we want to generate an antagonist
        # or boss monster to include in the dungeon. The name generator will generate
        # this antagonist, and it will be passed on to the levels of the dungeon.
        self.elements["ANTAGONIST"] = False
        self.dname = self.gen_name()
        # Generate the levels
        self.levels = self.get_dungeon_levels(nart, self.DUNGEON_PATTERN,
                                              self.chapter.start_rank,
                                              self.chapter.end_rank)

        # Connect all the levels, and name them.
        self.add_sub_plot(
            nart, "BARDIC_CONNECTION",
            PlotState(elements={
                "LEVELS": self.levels,
                "DNAME": self.dname
            },
                      rank=self.chapter.start_rank).based_on(self))

        # Set the LAST_DUNGEON element, for use by the next dungeon.
        self.register_element("LAST_DUNGEON", self.levels[-1])

        return True
 def custom_init(self, nart):
     prev = self.elements["PREV"]
     next = self.elements["NEXT"]
     self.move_element(next, prev)
     myzone1 = self.register_element(
         "_P_ROOM",
         nart.get_map_generator(prev).DEFAULT_ROOM(tags=(context.GOAL, )),
         "PREV")
     myzone2 = self.seek_element(nart,
                                 "_N_ROOM",
                                 self.seek_entrance_room,
                                 scope=next,
                                 check_subscenes=False,
                                 must_find=False)
     if not myzone2:
         myzone2 = self.register_element(
             "_N_ROOM", randmaps.rooms.SharpRoom(tags=(context.ENTRANCE, )),
             "NEXT")
     stairs_1 = waypoints.TreeStump()
     stairs_1.mini_map_label = "Tree Stump"
     stairs_1.plot_locked = True
     stairs_2 = waypoints.GateDoor()
     stairs_2.mini_map_label = "Exit"
     self.stump_destination = next
     self.stump_otherside = stairs_2
     stairs_2.destination = prev
     stairs_2.otherside = stairs_1
     self.register_element("TARGET", stairs_1, "_P_ROOM")
     self.register_element("_EXIT", stairs_2, "_N_ROOM")
     self._stump_unlocked = False
     self.add_sub_plot(nart, "PB_OPEN", PlotState().based_on(self))
     return True
Esempio n. 6
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
Esempio n. 7
0
 def custom_init(self, nart):
     """Create the lever, call a getter subplot."""
     lever = self.register_element("_LEVER", waypoints.PuzzleSwitch())
     self.add_sub_plot(nart, "GET_THING",
                       PlotState(elements={
                           "TARGET": lever
                       }).based_on(self))
     return True
Esempio n. 8
0
 def custom_init(self, nart):
     """Create the cousin, add puzzle subplot."""
     npc = self.elements["SHOPKEEPER"]
     the_room = self.seek_element(nart,
                                  "_THE_ROOM",
                                  self.room_seeker,
                                  scope=self.elements.get("BUILDING_INT"))
     the_cousin = monsters.generate_npc(species=npc.species.__class__)
     self.register_element("TARGET", the_cousin)
     self.started = False
     self.dated = False
     self.add_sub_plot(nart, "SB_DATE", PlotState().based_on(self))
     self.add_sub_plot(nart,
                       "REWARD",
                       PlotState(elements={
                           "ORIGIN": npc
                       }).based_on(self),
                       ident="next")
     return True
Esempio n. 9
0
    def custom_init(self, nart):
        """Create map, fill with city + services."""
        biome = self.elements.setdefault("BIOME",
                                         randmaps.architect.make_wilderness())
        archi = self.register_element("ARCHITECTURE",
                                      randmaps.architect.Village(biome.biome))
        culture = self.elements.setdefault("CULTURE", teams.PolisFaction())
        myscene, mymapgen = randmaps.architect.design_scene(
            90,
            90,
            randmaps.EdgeOfCivilization,
            biome,
            secondary=archi,
            setting=self.setting)
        myscene.desctags.append(context.DES_CIVILIZED)
        self.register_scene(nart, myscene, mymapgen, ident="LOCALE")

        castle = self.register_element(
            "CITY",
            randmaps.rooms.CastleRoom(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)
        myent = waypoints.Well()
        myroom.contents.append(myent)
        myroom.contents.append(monsters.generate_npc(team=myteam, fac=culture))
        myroom.contents.append(monsters.generate_npc(team=myteam, fac=culture))

        self.register_element("ENTRANCE", myent)

        self.chapter.world.add_entrance(myscene, myscene.name, worlds.W_CITY,
                                        myent, True)

        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")
        for t in range(random.randint(1, 4)):
            self.add_sub_plot(nart, "ENCOUNTER")
        self.add_sub_plot(nart, "SPECIAL_FEATURE")
        self.add_sub_plot(nart, "TEST_FEATURE", necessary=False)

        self.add_sub_plot(
            nart, "CITY_STORY",
            PlotState(rank=self.random_rank_in_chapter()).based_on(self))

        return True
    def custom_init(self, nart):
        """Create the world + chapter + city, then load INTRO_2"""
        w = worlds.World()
        nart.camp.contents.append(w)
        self.register_element("WORLD", w)
        self.chapter = Chapter(world=w)
        self.add_first_locale_sub_plot(nart)

        sp = self.add_sub_plot(nart, "INTRO_1")

        for job in characters.PC_CLASSES:
            self.add_sub_plot(nart, "RESOURCE_JOBTRAINER",
                              PlotState(elements={"JOB": job}))

        self.add_sub_plot(nart,
                          "TESTPLOT",
                          spstate=PlotState().based_on(sp),
                          necessary=False)

        return True
    def custom_init(self, nart):
        """Create the world + starting scene."""
        w = worlds.World()
        nart.camp.contents.append(w)
        self.register_element("WORLD", w)
        self.chapter = Chapter(end_rank=0, world=w)
        if not self.setting:
            self.setting = context.SET_RENFAN
        self.add_first_locale_sub_plot(nart)

        # Determine the dungeon sizes.
        if nart.end_rank < 7:
            min_dungeon_size = 2
        else:
            min_dungeon_size = 3
        num_dungeon, extra_points = divmod(nart.end_rank, min_dungeon_size)

        prev_chapter = self.chapter
        prev_subplot = self
        for t in range(num_dungeon):
            # We're going to add dungeons/chapters sequentially.
            new_chapter = Chapter(follows=prev_chapter)
            new_chapter.end_rank = new_chapter.start_rank + min_dungeon_size - 1
            if t == num_dungeon - 1:
                new_chapter.end_rank += extra_points
            prev_subplot = self.add_sub_plot(
                nart, "BARDIC_DUNGEON",
                PlotState(chapter=new_chapter).based_on(prev_subplot))
            prev_chapter = new_chapter

        # At this point, we can add the conclusion.
        self.add_sub_plot(nart, "BARDIC_CONCLUSION",
                          PlotState(rank=nart.end_rank).based_on(prev_subplot))

        for job in characters.PC_CLASSES:
            self.add_sub_plot(nart, "RESOURCE_JOBTRAINER",
                              PlotState(elements={"JOB": job}))

        return True
Esempio n. 12
0
    def custom_init( self, nart ):
        """Create map, fill with city + services."""
        biome = self.elements.setdefault( "BIOME", randmaps.architect.make_wilderness() )
        archi = self.register_element( "ARCHITECTURE", randmaps.architect.Village(biome.biome))
        culture = self.register_element( "CULTURE",
          teams.PolisFaction(dungeon_type=("Village","Hamlet","Town")) )
        myscene,mymapgen = randmaps.architect.design_scene( 50, 50,
          randmaps.ForestScene, biome,fac=culture,secondary=archi,
          setting=self.setting)
        myscene.desctags.append( context.DES_CIVILIZED )
        myscene.name = culture.name
        self.register_scene( nart, myscene, mymapgen, ident="LOCALE" )

        castle = self.register_element( "CITY",
         randmaps.rooms.VillageRoom( width=35,height=35,anchor=randmaps.anchors.middle,
         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 )
        myent = waypoints.RoadSignToAdventure()
        myroom.contents.append( myent )
        myroom.contents.append( monsters.generate_npc(team=myteam,fac=culture) )
        myroom.contents.append( monsters.generate_npc(team=myteam,fac=culture) )

        self.register_element( "ENTRANCE", myent )

        #self.chapter.world.add_entrance( myscene, myscene.name, worlds.W_CITY, myent, True )

        self.add_sub_plot( nart, "CITY_GENERALSTORE",spstate=PlotState(rank=random.randint(3,5)).based_on(self))
        self.add_sub_plot( nart, "CITY_LIBRARY",spstate=PlotState(rank=random.randint(3,5)).based_on(self))
        self.add_sub_plot( nart, "CITY_INN" )
        self.add_sub_plot( nart, "CITY_TEMPLE" )
        self.add_sub_plot( nart, "CITY_WEAPONSHOP",spstate=PlotState(rank=random.randint(3,5)).based_on(self))
        self.add_sub_plot( nart, "CITY_ARMORSHOP",spstate=PlotState(rank=random.randint(3,5)).based_on(self))
        self.add_sub_plot( nart, "CITY_ADVGUILD" )

        self.add_sub_plot( nart, "TEST_FEATURE",spstate=PlotState(elements={"LOCALE":castle}).based_on(self), necessary=False )
        return True
    def custom_init(self, nart):
        """Create the world + starting scene."""
        w = worlds.World()
        nart.camp.contents.append(w)
        self.register_element("WORLD", w)
        self.chapter = Chapter(end_rank=10, world=w)
        if not self.setting:
            self.setting = context.SET_RENFAN
        self.add_first_locale_sub_plot(nart, locale_type="ETERNAL_CITY")

        for job in characters.PC_CLASSES:
            self.add_sub_plot(nart, "RESOURCE_JOBTRAINER",
                              PlotState(elements={"JOB": job}))

        return True
 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
Esempio n. 15
0
    def custom_init(self, nart):
        """Load dungeon levels, dungeon entrance, CONCLUSION."""
        # Generate the levels
        self.levels = self.get_dungeon_levels(nart, (context.HAB_CAVE, ),
                                              self.chapter.start_rank,
                                              self.chapter.end_rank)
        # Decide on a good name.
        self.dname = random.choice(self.NAME_PATTERNS).format(
            namegen.random_style_name())
        # Connect all the levels, and name them.
        self.install_dungeon(nart, self.levels, self.elements["LOCALE"],
                             self.dname)

        # Load the conclusion.
        self.add_sub_plot(
            nart, "CONCLUSION",
            PlotState(rank=self.chapter.end_rank,
                      elements={
                          "FINAL_DUNGEON": self.levels[-1]
                      }).based_on(self))

        return True
Esempio n. 16
0
 def custom_init(self, nart):
     sk = self.elements["SHOPKEEPER"]
     the_room = self.seek_element(nart,
                                  "_THE_ROOM",
                                  self.room_seeker,
                                  scope=self.elements.get("BUILDING_INT"))
     npc = monsters.generate_npc(species=sk.species.__class__)
     # Assume a heteronormativity rate of 50%.
     if random.randint(1, 2) == 1:
         if sk.gender == stats.MALE:
             npc.gender = stats.FEMALE
         elif sk.gender == stats.FEMALE:
             npc.gender = stats.MALE
     self.register_element("_NPC", npc, dident="_THE_ROOM")
     self.add_sub_plot(nart,
                       "REWARD",
                       PlotState(elements={
                           "ORIGIN": npc
                       }).based_on(self),
                       ident="next")
     self.quest_started = False
     self.employees = [sk, npc]
     self.needed_stat = random.choice(stats.PRIMARY_STATS)
     return True
Esempio n. 17
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
    def custom_init(self, nart):
        prev = self.elements["PREV"]
        next = self.elements["NEXT"]
        well = self.seek_element(nart,
                                 "_WELL",
                                 self.seek_well,
                                 scope=prev,
                                 check_subscenes=False)
        well.plot_locked = True
        myzone2 = self.seek_element(nart,
                                    "_N_ROOM",
                                    self.seek_entrance_room,
                                    scope=next,
                                    check_subscenes=False,
                                    must_find=False)
        if not myzone2:
            myzone2 = self.register_element(
                "_N_ROOM", randmaps.rooms.SharpRoom(tags=(context.ENTRANCE, )),
                "NEXT")
        stairs_2 = waypoints.GateDoor()
        self.register_element("_EXIT", stairs_2, "_N_ROOM")
        self._the_well_has_been_used = False
        if next.rank > prev.rank:
            # We're gonna add a dungeon.
            self.levels = list()
            pstate = PlotState(elements={
                "DUNGEON_TYPE": (context.HAB_TUNNELS, context.DES_WATER)
            }).based_on(self)
            for l in range(prev.rank + 1, next.rank + 1):
                pstate.rank = l
                sp = self.add_sub_plot(nart, "DUNGEON_LEVEL", pstate)
                if sp:
                    self.levels.append(sp.elements["LOCALE"])

            # Decide on a good name.
            dname = random.choice(self.NAME_PATTERNS).format(
                prev, namegen.random_style_name())

            # Connect all the levels, and name them.
            prv = self.levels[0]
            prv.name = "{0}, Lvl{1}".format(dname, 1)
            if len(self.levels) > 1:
                n = 2
                for nxt in self.levels[1:]:
                    nxt.name = "{0}, Lvl{1}".format(dname, n)
                    n += 1
                    pstate = PlotState(rank=nxt.rank,
                                       elements={
                                           "PREV": prv,
                                           "NEXT": nxt
                                       }).based_on(self)
                    sp = self.add_sub_plot(nart, "CONNECT", pstate)
                    prv = nxt

            # Connect to well and black market.
            stairs_3 = waypoints.StairsUp()
            stairs_4 = waypoints.StairsDown()
            myzone_3 = randmaps.rooms.SharpRoom(tags=(context.ENTRANCE, ),
                                                parent=self.levels[0])
            myzone_4 = randmaps.rooms.SharpRoom(tags=(context.GOAL, ),
                                                parent=self.levels[-1])
            myzone_3.contents.append(stairs_3)
            myzone_4.contents.append(stairs_4)

            self.well_destination = self.levels[0]
            self.well_otherside = stairs_3
            stairs_3.destination = prev
            stairs_3.otherside = well

            stairs_2.destination = self.levels[-1]
            stairs_2.otherside = stairs_4
            stairs_4.destination = next
            stairs_4.otherside = stairs_2
            self.move_element(next, self.levels[-1])
            self.move_element(self.levels[0], prev)
        else:
            self.well_destination = next
            self.well_otherside = stairs_2
            stairs_2.destination = prev
            stairs_2.otherside = well
            self.move_element(next, prev)
        return True
Esempio 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
Esempio n. 20
0
    def custom_init( self, nart ):
        prev = self.elements[ "PREV" ]
        next = self.elements[ "NEXT" ]
        well = self.seek_element( nart, "_WELL", self.seek_well, scope=prev, check_subscenes=False )
        well.plot_locked = True
        myzone2 = self.seek_element( nart, "_N_ROOM", self.seek_entrance_room, scope=next, check_subscenes=False, must_find=False )
        if not myzone2:
            myzone2 = self.register_element( "_N_ROOM", randmaps.rooms.SharpRoom(tags=(context.ENTRANCE,)), "NEXT" )
        stairs_2 = waypoints.GateDoor()
        self.register_element( "_EXIT", stairs_2, "_N_ROOM" )
        self._the_well_has_been_used = False
        if next.rank > prev.rank:
            # We're gonna add a dungeon.
            self.levels = list()
            pstate = PlotState( elements={"DUNGEON_TYPE":(context.HAB_TUNNELS,context.DES_WATER)} ).based_on( self )
            for l in range( prev.rank+1, next.rank+1 ):
                pstate.rank = l
                sp = self.add_sub_plot( nart, "DUNGEON_LEVEL", pstate )
                if sp:
                    self.levels.append( sp.elements[ "LOCALE" ] )

            # Decide on a good name.
            dname = random.choice( self.NAME_PATTERNS ).format( prev, namegen.random_style_name() )

            # Connect all the levels, and name them.
            prv = self.levels[0]
            prv.name = "{0}, Lvl{1}".format( dname, 1 )
            if len( self.levels ) > 1:
                n = 2
                for nxt in self.levels[1:]:
                    nxt.name = "{0}, Lvl{1}".format( dname, n )
                    n += 1
                    pstate = PlotState( rank = nxt.rank, elements={"PREV":prv,"NEXT":nxt} ).based_on( self )
                    sp = self.add_sub_plot( nart, "CONNECT", pstate )
                    prv = nxt

            # Connect to well and black market.
            stairs_3 = waypoints.StairsUp()
            stairs_4 = waypoints.StairsDown()
            myzone_3 = randmaps.rooms.SharpRoom(tags=(context.ENTRANCE,),parent=self.levels[0])
            myzone_4 = randmaps.rooms.SharpRoom(tags=(context.GOAL,),parent=self.levels[-1])
            myzone_3.contents.append( stairs_3 )
            myzone_4.contents.append( stairs_4 )

            self.well_destination = self.levels[0]
            self.well_otherside = stairs_3
            stairs_3.destination = prev
            stairs_3.otherside = well

            stairs_2.destination = self.levels[-1]
            stairs_2.otherside = stairs_4
            stairs_4.destination = next
            stairs_4.otherside = stairs_2
            self.move_element( next, self.levels[-1] )
            self.move_element( self.levels[0], prev )
        else:
            self.well_destination = next
            self.well_otherside = stairs_2
            stairs_2.destination = prev
            stairs_2.otherside = well
            self.move_element( next, prev )
        return True
Esempio n. 21
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