def custom_init( self, nart ): # Create the lever and spirit room. scene = self.elements.get("LOCALE") mygen = nart.get_map_generator( scene ) # Spirit jar room puzzle_room = randmaps.rooms.SharpRoom( tags = (context.ENTRANCE,) ) team = teams.Team(default_reaction=-999, respawn=False ) if random.randint(1,3) == 1: puzzle_room.contents.append( teams.Team(default_reaction=-999, rank=self.rank, strength=100, habitat=scene.get_encounter_request(), fac=scene.fac ) ) self.register_element( "_PUZZLE_ROOM", puzzle_room, dident="LOCALE" ) self.register_element( "_SOURCE", waypoints.SpiritJar(plot_locked=True,anchor=randmaps.anchors.middle), dident="_PUZZLE_ROOM" ) self.spirit_contained = True myhabitat = { (context.MTY_ELEMENTAL,context.MTY_UNDEAD,context.MTY_CELESTIAL,context.MTY_DEMON): True, tuple(self.elements["TARGET"].desctags): True} btype = monsters.choose_monster_type(self.rank,self.rank+2,myhabitat) if btype: boss = self.register_element("_MONSTER",monsters.generate_boss( btype, self.rank+2, team=team )) if random.randint(1,2) == 1: myitem = self.register_element("_ITEM",items.generate_special_item( self.rank + random.randint(1,2))) else: myitem = self.register_element("_ITEM",items.generate_scroll(self.rank+random.randint(1,2))) return btype and myitem
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 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
def custom_init(self, nart): scene = self.elements.get("LOCALE") mygen = nart.get_map_generator(scene) room = mygen.DEFAULT_ROOM() myteam = teams.Team(default_reaction=-999, rank=self.rank + 1, strength=200, habitat={context.MTY_BEAST: True}, hodgepodge=True) room.contents.append(myteam) myhabitat = scene.get_encounter_request() myhabitat[context.MTY_HUMANOID] = True myhabitat[(context.MTY_LEADER, context.MTY_FIGHTER)] = True scene.fac.alter_monster_request(myhabitat) btype = monsters.choose_monster_type(self.rank - 3, self.rank + 1, myhabitat) if btype: boss = monsters.generate_boss(btype, self.rank + 1, team=myteam) myitem = items.generate_special_item(self.rank) if myitem: boss.contents.append(myitem) myspear = items.generate_special_item(self.rank + 1, item_type=items.POLEARM) if myspear: boss.contents.append(myspear) myteam.boss = boss self.register_element("_ROOM", room, dident="LOCALE") self.register_element("BOSS", boss, "_ROOM") return btype
def custom_init(self, nart): scene = self.elements.get("LOCALE") room = randmaps.rooms.SharpRoom() room.DECORATE = randmaps.decor.LibraryDec(win=None) room.contents.append(waypoints.Bookshelf()) # Create a chest, and stock it with magical goodies. mychest = waypoints.LargeChest() mychest.stock(self.rank, item_types=(items.SCROLL, items.POTION)) room.contents.append(mychest) for t in range(random.randint(5, 8)): myitem = items.generate_scroll(self.rank + 1) if myitem: myitem.identified = True mychest.contents.append(myitem) # Create a team for our undead spellcaster. myhabitat = {context.GEN_UNDEAD: True} myteam = self.register_element( "TEAM", teams.Team(default_reaction=-25, rank=self.rank, strength=0, habitat=myhabitat)) room.contents.append(myteam) mh2 = myhabitat.copy() mh2[(context.MTY_MAGE, context.MTY_PRIEST)] = True btype = monsters.choose_monster_type(self.rank - 1, self.rank + 4, mh2) if btype: boss = monsters.generate_boss(btype, self.rank + 4, team=myteam) myitem = items.generate_special_item(self.rank + 2, items.WAND) if myitem: boss.contents.append(myitem) self.register_element("_ROOM", room, dident="LOCALE") self.register_element("BOSS", boss, "_ROOM") # Record the one thing this boss cares about. self.boss_goal = random.choice(self.GOALS) self.boss_shop = self.register_element( "SHOPSERVICE", services.Shop(services.MAGIC_STORE, rank=self.rank + 5, allow_misc=False, num_items=25, turnover=5, npc=boss)) self.shop_open = False return btype
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
def custom_init(self, nart): # Create the lever and spirit room. scene = self.elements.get("LOCALE") mygen = nart.get_map_generator(scene) # Spirit jar room puzzle_room = randmaps.rooms.SharpRoom(tags=(context.ENTRANCE, )) team = teams.Team(default_reaction=-999, respawn=False) if random.randint(1, 3) == 1: puzzle_room.contents.append( teams.Team(default_reaction=-999, rank=self.rank, strength=100, habitat=scene.get_encounter_request(), fac=scene.fac)) self.register_element("_PUZZLE_ROOM", puzzle_room, dident="LOCALE") self.register_element("_SOURCE", waypoints.SpiritJar( plot_locked=True, anchor=randmaps.anchors.middle), dident="_PUZZLE_ROOM") self.spirit_contained = True myhabitat = { (context.MTY_ELEMENTAL, context.MTY_UNDEAD, context.MTY_CELESTIAL, context.MTY_DEMON): True, tuple(self.elements["TARGET"].desctags): True } btype = monsters.choose_monster_type(self.rank, self.rank + 2, myhabitat) if btype: boss = self.register_element( "_MONSTER", monsters.generate_boss(btype, self.rank + 2, team=team)) if random.randint(1, 2) == 1: myitem = self.register_element( "_ITEM", items.generate_special_item(self.rank + random.randint(1, 2))) else: myitem = self.register_element( "_ITEM", items.generate_scroll(self.rank + random.randint(1, 2))) return btype and myitem
def custom_init( self, nart ): # Add a group of humanoids, neutral reaction score. scene = self.elements.get("LOCALE") mygen = nart.get_map_generator( scene ) room = mygen.DEFAULT_ROOM() myhabitat={ context.MTY_HUMANOID: context.PRESENT } myteam = teams.Team(default_reaction=0, rank=self.rank, strength=random.randint(90,120), habitat=myhabitat ) room.contents.append( myteam ) self.register_element( "_ROOM", room, dident="LOCALE" ) myhabitat[ context.MTY_LEADER ] = context.MAYBE btype = monsters.choose_monster_type(self.rank-1,self.rank+2,myhabitat) if btype: boss = monsters.generate_boss( btype, self.rank-1, team=myteam ) myteam.boss = boss self.shop = self.register_element( "SHOPSERVICE", services.Shop( rank=self.rank+3, num_items=15, npc=boss ) ) self.first_time = True self.register_element( "BOSS", boss, "_ROOM" ) return btype
def custom_init(self, nart): scene = self.elements.get("LOCALE") mygen = nart.get_map_generator(scene) # Bridge room bridge_room = randmaps.rooms.FuzzyRoom() mygen.special_c["bridge"] = bridge_room self.register_element("_BRIDGE_ROOM", bridge_room, dident="LOCALE") myhabitat = scene.get_encounter_request() myhabitat[context.MTY_HUMANOID] = context.PRESENT myhabitat[context.MTY_FIGHTER] = context.MAYBE team = self.register_element( "TEAM", teams.Team(default_reaction=-999, rank=self.rank, strength=200, habitat=myhabitat, respawn=False)) myhabitat[(context.MTY_HUMANOID, context.MTY_LEADER)] = True myhabitat[context.MTY_LEADER] = context.MAYBE btype = monsters.choose_monster_type(self.rank, self.rank + 2, myhabitat) if btype: boss = monsters.generate_boss(btype, self.rank + 2) boss.team = team team.boss = boss # Give the boss a magic weapon. weapon = items.choose_item(random.choice(items.WEAPON_TYPES), self.rank) if weapon: items.make_item_magic(weapon, self.rank) weapon.identified = True boss.contents.append(weapon) bridge_room.contents.append(team) bridge_room.contents.append(boss) self._ready = True return btype
def custom_init( self, nart ): scene = self.elements.get("LOCALE") mygen = nart.get_map_generator( scene ) room = mygen.DEFAULT_ROOM() myhabitat = scene.get_encounter_request() myhabitat[ context.MTY_HUMANOID ] = True myteam = teams.Team(default_reaction=-999, rank=self.rank, strength=150, habitat=myhabitat ) room.contents.append( myteam ) mh2 = myhabitat.copy() mh2[(context.MTY_LEADER,context.MTY_BOSS)] = True btype = monsters.choose_monster_type(self.rank-2,self.rank+2,mh2) if btype: boss = monsters.generate_boss( btype, self.rank+3, team=myteam ) myteam.boss = boss myitem = items.generate_special_item( self.rank+1 ) if myitem: boss.contents.append( myitem ) self.register_element( "_ROOM", room, dident="LOCALE" ) self.register_element( "BOSS", boss, "_ROOM" ) return btype
def custom_init(self, nart): scene = self.elements.get("LOCALE") mygen = nart.get_map_generator(scene) room = mygen.DEFAULT_ROOM() myhabitat = scene.get_encounter_request() myhabitat[context.MTY_HUMANOID] = True myteam = teams.Team(default_reaction=-999, rank=self.rank, strength=150, habitat=myhabitat) room.contents.append(myteam) mh2 = myhabitat.copy() mh2[(context.MTY_LEADER, context.MTY_BOSS)] = True btype = monsters.choose_monster_type(self.rank - 2, self.rank + 2, mh2) if btype: boss = monsters.generate_boss(btype, self.rank + 3, team=myteam) myteam.boss = boss myitem = items.generate_special_item(self.rank + 1) if myitem: boss.contents.append(myitem) self.register_element("_ROOM", room, dident="LOCALE") self.register_element("BOSS", boss, "_ROOM") return btype
def custom_init( self, nart ): scene = self.elements.get("LOCALE") mygen = nart.get_map_generator( scene ) # Bridge room bridge_room = randmaps.rooms.FuzzyRoom() mygen.special_c[ "bridge" ] = bridge_room self.register_element( "_BRIDGE_ROOM", bridge_room, dident="LOCALE" ) myhabitat=scene.get_encounter_request() myhabitat[ context.MTY_HUMANOID ] = context.PRESENT myhabitat[ context.MTY_FIGHTER ] = context.MAYBE team = self.register_element("TEAM",teams.Team(default_reaction=-999, rank=self.rank, strength=200, habitat=myhabitat, respawn=False )) myhabitat[(context.MTY_HUMANOID,context.MTY_LEADER)] = True myhabitat[context.MTY_LEADER] = context.MAYBE btype = monsters.choose_monster_type(self.rank,self.rank+2,myhabitat) if btype: boss = monsters.generate_boss( btype, self.rank+2 ) boss.team = team team.boss = boss # Give the boss a magic weapon. weapon = items.choose_item( random.choice( items.WEAPON_TYPES ), self.rank ) if weapon: items.make_item_magic( weapon, self.rank ) weapon.identified = True boss.contents.append( weapon ) bridge_room.contents.append( team ) bridge_room.contents.append( boss ) self._ready = True return btype
def custom_init(self, nart): # Add a group of humanoids, neutral reaction score. scene = self.elements.get("LOCALE") mygen = nart.get_map_generator(scene) room = mygen.DEFAULT_ROOM() myhabitat = {context.MTY_HUMANOID: context.PRESENT} myteam = teams.Team(default_reaction=0, rank=self.rank, strength=random.randint(90, 120), habitat=myhabitat) room.contents.append(myteam) self.register_element("_ROOM", room, dident="LOCALE") myhabitat[context.MTY_LEADER] = context.MAYBE btype = monsters.choose_monster_type(self.rank - 1, self.rank + 2, myhabitat) if btype: boss = monsters.generate_boss(btype, self.rank - 1, team=myteam) myteam.boss = boss self.shop = self.register_element( "SHOPSERVICE", services.Shop(rank=self.rank + 3, num_items=15, npc=boss)) self.first_time = True self.register_element("BOSS", boss, "_ROOM") return btype
def custom_init( self, nart ): scene = self.elements.get("LOCALE") room = randmaps.rooms.SharpRoom() room.DECORATE = randmaps.decor.LibraryDec(win=None) room.contents.append( waypoints.Bookshelf() ) # Create a chest, and stock it with magical goodies. mychest = waypoints.LargeChest() mychest.stock(self.rank,item_types=(items.SCROLL,items.POTION)) room.contents.append( mychest ) for t in range( random.randint(5,8) ): myitem = items.generate_scroll( self.rank + 1 ) if myitem: myitem.identified = True mychest.contents.append( myitem ) # Create a team for our undead spellcaster. myhabitat = {context.GEN_UNDEAD: True } myteam = self.register_element( "TEAM", teams.Team(default_reaction=-25, rank=self.rank, strength=0, habitat=myhabitat ) ) room.contents.append( myteam ) mh2 = myhabitat.copy() mh2[(context.MTY_MAGE,context.MTY_PRIEST)] = True btype = monsters.choose_monster_type(self.rank-1,self.rank+4,mh2) if btype: boss = monsters.generate_boss( btype, self.rank+4, team=myteam ) myitem = items.generate_special_item( self.rank+2, items.WAND ) if myitem: boss.contents.append( myitem ) self.register_element( "_ROOM", room, dident="LOCALE" ) self.register_element( "BOSS", boss, "_ROOM" ) # Record the one thing this boss cares about. self.boss_goal = random.choice( self.GOALS ) self.boss_shop = self.register_element( "SHOPSERVICE", services.Shop( services.MAGIC_STORE, rank=self.rank+5, allow_misc=False, num_items=25, turnover=5, npc=boss ) ) self.shop_open = False return btype
def custom_init( self, nart ): scene = self.elements.get("LOCALE") mygen = nart.get_map_generator( scene ) room = mygen.DEFAULT_ROOM() myteam = teams.Team(default_reaction=-999, rank=self.rank+1, strength=200, habitat={context.MTY_BEAST: True}, hodgepodge=True ) room.contents.append( myteam ) myhabitat = scene.get_encounter_request() myhabitat[ context.MTY_HUMANOID ] = True myhabitat[(context.MTY_LEADER,context.MTY_FIGHTER)] = True scene.fac.alter_monster_request( myhabitat ) btype = monsters.choose_monster_type(self.rank-3,self.rank+1,myhabitat) if btype: boss = monsters.generate_boss( btype, self.rank+1, team=myteam ) myitem = items.generate_special_item( self.rank ) if myitem: boss.contents.append( myitem ) myspear = items.generate_special_item( self.rank + 1,item_type=items.POLEARM ) if myspear: boss.contents.append( myspear ) myteam.boss = boss self.register_element( "_ROOM", room, dident="LOCALE" ) self.register_element( "BOSS", boss, "_ROOM" ) return btype
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): 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
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
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
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