from .. import Region, Node, Ifc, Utl, Map, Monster, g from ..data import Species, Items def ZeiusRegion(origin, region, direction): origin.color = Ifc.BRIGHT_YELLOW origin.name = "Eerie Passageway" origin.description = """This area seems strange. You feel unsettled by it in a difficult-to-explain, primal way.""" oldnode, newnode=None, origin for i in xrange(3): oldnode, newnode=newnode, FillerTunnel(region=region) Region.makelink(newnode, oldnode, direction) for i in xrange(4): oldnode, newnode=newnode, FillerTunnel(region=region) Region.makelink(newnode, oldnode, direction) left = traps[i](region=region) if i < 3: oldnode = right = BadGuyTunnel(region=region, which_enemy=i) else: oldnode = right = FillerTunnel(region=region) if Utl.rn(): left, right=right, left Region.makelink(newnode, right, Map.rotate(direction, 1)) Region.makelink(newnode, left, Map.rotate(direction, -1)) if i < 3: newnode = KeyedTunnel(region=region, key_required=i + 1) else: newnode = FillerTunnel(region=region) Region.makelink(newnode, oldnode, direction) for i in xrange(3): oldnode, newnode=newnode, FillerTunnel(region=region) Region.makelink(newnode, oldnode, direction) lab_x, lab_y = Utl.rn(3) + 1, Utl.rn(3) + 1 mat = [] for x in xrange(5): mat_col = [] for y in xrange(5): if x == lab_x and y == lab_y: mat_col.append(EvilLab(region=region)) else: mat_col.append(MatTunnel(region=region)) mat.append(mat_col) for x in xrange(5): for y in xrange(5): if x > 0: mat[x][y].west = mat[x - 1][y] if x < 4: mat[x][y].east = mat[x + 1][y] if y > 0: mat[x][y].north = mat[x][y - 1] if y < 4: mat[x][y].south = mat[x][y + 1] for x in xrange(6): tmp = Species.beacon.make() g.beacons.append(tmp) mat[Utl.rn(5)][Utl.rn(5)].add(tmp) oldnode, newnode=newnode, KeyedTunnel(region=region, key_required=4) if direction == Map.NORTH: Region.makelink(mat[Utl.rn(5)][4], oldnode, Map.NORTH) Region.makelink(newnode, mat[Utl.rn(5)][0], Map.NORTH) elif direction == Map.SOUTH: Region.makelink(mat[Utl.rn(5)][0], oldnode, Map.SOUTH) Region.makelink(newnode, mat[Utl.rn(5)][4], Map.SOUTH) elif direction == Map.WEST: Region.makelink(mat[4][Utl.rn(5)], oldnode, Map.WEST) Region.makelink(newnode, mat[0][Utl.rn(5)], Map.WEST) elif direction == Map.EAST: Region.makelink(mat[0][Utl.rn(5)], oldnode, Map.EAST) Region.makelink(newnode, mat[4][Utl.rn(5)], Map.EAST) _dir = Map.rotate(direction, 1) for x in xrange(5): oldnode, newnode=newnode, FillerTunnel(region=region) Region.makelink(newnode, oldnode, _dir) choices = [] for i in xrange(3): __dir = Map.rotate(_dir, 3 + i) tmp = FillerTunnel(region=region) Region.makelink(tmp, newnode, __dir) choices.append((tmp, __dir)) g.rng.shuffle(choices) newnode, _dir = choices.pop() Region.makelink(TeleporterTrapTunnel(region=region), newnode, _dir) newnode, _dir = choices.pop() Region.makelink(ArmoryRoom(region=region), newnode, _dir) newnode, _dir = choices.pop() Region.makelink(FinalEncounter(region=region), newnode, _dir) class ZeiusTunnel(Node.Node): def xmake(self): self.color = Ifc.BRIGHT_YELLOW self.name = "Ominous Tunnel" filler_desc = [ "A chill breeze runs down this forboding tunnel.", "It's quiet. Too quiet.", "This tunnel is disturbingly unusual.", "There is something vaugely unsettling here.", "You have a bad feeling about this.", "This tunnel seems to radiate malenvonence.", "You feel unhappy and disquieted by this place." ] class FillerTunnel(ZeiusTunnel): def xinit(self): self.description = Utl.rn_seq(filler_desc) class FireTrapTunnel(ZeiusTunnel): def xinit(self): self.description = "There are unusual holes in the ceiling overhead." self.tripped = False def check_trap(self, mon, origin): if self.tripped: return 1 if mon is g.player and g.player.int > Utl.rn(20) and not Ifc.yn('You sense danger. Proceed? '): return 0 return 2 def do_trap(self, mon): self.tripped = True Ifc.you('|are| enveloped in a torrent of flaming chemicals!', mon) if not mon.damage(Utl.d(8, 20), usearmor=0, msg='Flaming Death from Above'): for itm in Utl.gen_shuffle(mon.inventory): if not itm.kind.pc_only and not itm.wielded and not itm.worn: Ifc.your('%s is destroyed by the heat!' % itm.kind.name, mon) itm.destroy() break class GlassTrapTunnel(ZeiusTunnel): def xinit(self): self.description = "This room is full of broken glassware." def check_trap(self, mon, origin): return 2 def do_trap(self, mon): if mon.dex > Utl.rn(20): Ifc.you('almost trip|s| and fall|s|.', mon) else: Ifc.you('stumble|s| and fall|s| on some broken glass!', mon) mon.damage(Utl.d(4, 10), usearmor=0, msg='accidental self-impalement with broken glass') class CloneTrapTunnel(ZeiusTunnel): def xinit(self): self.description = "An arcane device, devoid of power, rests against the far wall." self.tripped = False def check_trap(self, mon, origin): if self.tripped: return 1 return 2 def do_trap(self, mon): self.tripped = True evil_clone = mon.species.make(xenophobic=True, rabid=True) evil_clone.hp = evil_clone.mhp = mon.mhp evil_clone.str = evil_clone.mst = mon.mst evil_clone.dex = evil_clone.mdx = mon.mdx evil_clone.int = evil_clone.min = mon.min if mon.name: evil_clone.name = "%s's Evil Clone" % mon.name evil_clone.gender = mon.gender if mon.wielded and not mon.wielded.kind.pc_only: evil_clone.add(mon.wielded.kind.make()) evil_clone.setup_inventory() Ifc.you('feel|s| a strange sensation, almost like being scanned.', mon) Ifc.you('|are| very surprised to see a duplicate of |your|self!', mon) self.add(evil_clone) class TeleporterTrapTunnel(ZeiusTunnel): def xinit(self): self.description = "A large machine occupies most of the back wall." self.tripped = 0 def check_trap(self, mon, origin): if self.tripped == g.turns: return 1 return 2 def do_trap(self, mon): self.tripped = g.turns Ifc.you('|are| momentarily blinded by a sudden flash!', mon) toughest = None for m in g.monsters: if m.species.boss or m is mon or m is g.player or m.dead or not m.will_fight(mon): continue if not toughest or m.xp > toughest.xp: toughest = m if not toughest: Ifc.you('hear|s| a fizzling sound, and nothing more happens.', mon) else: Ifc.you('disappear|s| in a flash!', toughest) toughest.here.mons.remove(toughest) self.add(toughest) Ifc.you('appear|s| in the tunnel!', toughest) traps = [TeleporterTrapTunnel, GlassTrapTunnel, FireTrapTunnel, CloneTrapTunnel] class KeyedTunnel(Node.Node): def xinit(self): self.locked = True self.color = Ifc.BRIGHT_YELLOW self.name = "Security Room" self.description = "You are on the other side of a large, solid door." def check_trap(self, mon, origin): if not self.locked: return 1 if mon is not g.player: return 0 Ifc.you('come to a solid door with a keyhole.') key = Ifc.choice('Use which item as a key? ', g.player.inventory) if not key: return 0 if key.kind is not Items.key: Ifc.you("can't fit the %s in the keyhole." % key.kind.name) return 0 if self.key_required != key.keyval: Ifc.you("insert the key into the lock, but it won't turn.") return 0 Ifc.you('unlock the door and continue.') self.locked = False return 1 class BadGuyTunnel(ZeiusTunnel): descriptions = ( "see|s| a sharply-dressed young man with an air of confidance.", "see|s| a determined-looking young woman wearing a lab-coat.", "see|s| a young man with a crazed expression on his face." ) names = "Frederick", "Olivia", "Marcus" genders = 1, 2, 1 species = ( Species.artsie, Species.nerd, Species.jock ) mon_items = ( ( Items.top_hat, Items.vest, Items.cloak, Items.bulletproof_vest ), ( Items.lab_coat, Items.t_shirt ), ( Items.jacket, Items.metal_slab, Items.metal_slab, Items.pikachu_egg, Items.flask ) ) def inventory_fred(mon): if g.major != 1: mon.add(Items.pen.make()) mon.add(Items.flask.make(type=4, uses=20)) mon.add(Items.dragon_fang.make(blessed=True)) mon.add(Items.key.make(keyval=1, name="Frederick's key")) def inventory_olivia(mon): if g.major != 0: mon.add(Items.zaurus.make()) mon.add(Items.wand.make(charges=5, blessed=True)) mon.add(Items.textbook.make(topic=2)) mon.add(Items.flask.make(type=3, uses=5)) mon.add(Items.flask.make(type=4, uses=20)) mon.add(Items.flask.make(type=0, uses=10)) mon.add(Items.key.make(keyval=2, name="Olivia's key")) def inventory_marcus(mon): if g.major != 2: mon.add(Items.nerf_sword.make()) else: mon.add(Items.lightsaber.make()) mon.add(Items.key.make(keyval=3, name="Marcus's key")) mon_inventory = [inventory_fred, inventory_olivia, inventory_marcus] def xinit(self): self.name = "Ominous Tunnel" self.description = "This is a side-room in this strange complex." self.tripped = False def check_trap(self, mon, origin): if self.tripped: return 1 if mon is not g.player: return 0 self.tripped = True return 2 def do_trap(self, mon): Ifc.you('see someone ahead of you!') Ifc.you(self.descriptions[self.which_enemy]) foe = self.species[self.which_enemy].make(ai=Monster.ATTACKING, inventory=[], xenophobic=True) for itm in self.mon_items[self.which_enemy]: foe.add(itm.make()) self.mon_inventory[self.which_enemy](foe) foe.name = self.names[self.which_enemy] foe.gender = self.genders[self.which_enemy] foe.fmt.update(Monster.GENDER_FMT[foe.gender]) leveltarget = g.player.level + 5 * self.which_enemy if g.player.level > 10 else 15 + 5 * self.which_enemy foe.species.level.levels(foe, leveltarget) foe.level = leveltarget foe.setup_inventory() self.add(foe) class MatTunnel(Node.Node): def xinit(self): self.color = Ifc.MAJOR_YELLOW self.name = "Evil Lab" self.description = "This is a large laboratory, populated with strange instruments." for x in xrange(Utl.rn(5)): self.add(Utl.rn_seq(Species.zeius_spawn).make()) class EvilLab(Node.Node): def xinit(self): self.special_symbol = 'X' self.color = Ifc.MAJOR_YELLOW self.name = "Mad Lab Tech's Lair" self.description = """This evil lab is filled with the remains of vile experiments. There is an evil aura here.""" self.unique = True self.locked = True self.tunnel = False nem = Species.nemesis.make() self.add(nem) class ArmoryRoom(ZeiusTunnel): def xinit(self): self.description = """You see an assortment of ancient, obsolete weapons mounted against the back wall. Other weapons in various states of disrepair sit on a desk.""" self.add(Items.knife.make()) self.add(Items.knife.make()) self.add(Items.wand.make(charges=0)) self.add(Items.wand.make(charges=Utl.rn(3))) self.add(Items.fur_scrap.make(tainted=True)) self.add(Items.flask.make(type=2, uses=2)) self.add(Items.scythe.make()) class FinalEncounter(ZeiusTunnel): def xinit(self): self.nem = Species.enemesis.make() self.add(self.nem) self.tripped = False def check_trap(self, mon, origin): if not self.tripped: self.nem.add(g.artifact) self.tripped = True return 1