def orc(point=None, dungeon_level=1): #create an orc health_component = Health(20) ai_component = BasicNPC() npc = Character(point, 'O', 'orc', COLORS.get('orc'), ai=ai_component, species=Species.ORC, health=health_component, act_energy=5) npc.add_component(Offence(base_power=10), 'offence') npc.add_component(Defence(defence=4), 'defence') npc.add_component(Level(xp_value=10), 'level') npc.movement.routing_avoid.extend(npc_avoid) item = equipment.create_weapon('shortsword') item.lootable = False npc.inventory.add_item(item) npc.equipment.toggle_equip(item) return npc
def bat(point=None, dungeon_level=1): health_component = Health(4) creature = Character(point, 'B', 'bat', COLORS.get('bat'), ai=PredatorNPC(species=Species.INSECT), species=Species.BAT, health=health_component, act_energy=3) creature.add_component(Offence(base_power=1), 'offence') creature.add_component(Defence(defence=1), 'defence') creature.add_component(Level(xp_value=10), 'level') teeth = equipment.teeth() teeth.lootable = False creature.inventory.add_item(teeth) creature.equipment.toggle_equip(teeth) if randint(1, 100) >= 70: equipment.add_lifedrain(teeth) creature.add_component(Naming(creature.base_name, prefix='Vampiric'), 'naming') return creature
def rat(point=None, dungeon_level=1): health_component = Health(4) creature = Character(point, 'R', 'rat', COLORS.get('rat'), ai=PredatorNPC(species=Species.EGG), species=Species.RAT, health=health_component, act_energy=3) creature.add_component(Offence(base_power=1), 'offence') creature.add_component(Defence(defence=1), 'defence') creature.add_component(Level(xp_value=10), 'level') creature.movement.routing_avoid.extend(creature_avoid) teeth = equipment.teeth() teeth.lootable = False creature.inventory.add_item(teeth) creature.equipment.toggle_equip(teeth) pubsub.pubsub.subscribe( pubsub.Subscription(creature, pubsub.PubSubTypes.ATTACKED, rat_swarm)) return creature
def gelatinous_cube(point=None, dungeon_level=1): npc = Character(point, 'C', 'gelatinous cube', COLORS.get('gelatinous_cube'), ai=CleanerNPC(), species=Species.OOZE, render_order=RenderOrder.OVERLAY, health=Health(20)) npc.add_component(Offence(base_power=1), 'offence') npc.add_component(Defence(defence=1), 'defence') npc.add_component(Level(xp_value=10), 'level') cube_avoid = [ Tiles.INTERNAL_DOOR, Tiles.EXIT_DOOR, Tiles.DOOR, Tiles.CAVERN_FLOOR, Tiles.FUNGAL_CAVERN_FLOOR, Tiles.ROOM_FLOOR, Tiles.SHALLOW_WATER, Tiles.DEEP_WATER, Tiles.STAIRS_FLOOR, Tiles.SPAWN_POINT ] npc.movement.routing_avoid.extend(cube_avoid) pseudopod = equipment.pseudopod() pseudopod.lootable = False equipment.add_paralysis(pseudopod) npc.inventory.add_item(pseudopod) npc.equipment.toggle_equip(pseudopod) return npc
def goblin(point=None, dungeon_level=1): #create a goblin health_component = Health(20) ai_component = BasicNPC() npc = Character(point, 'G', 'goblin', COLORS.get('goblin'), ai=ai_component, species=Species.GOBLIN, health=health_component, act_energy=5) npc.add_component(Offence(base_power=5), 'offence') npc.add_component(Defence(defence=5), 'defence') npc.add_component(Level(xp_value=10), 'level') npc.movement.routing_avoid.extend(npc_avoid) dagger = equipment.create_weapon('dagger') dagger.lootable = False npc.inventory.add_item(dagger) npc.equipment.toggle_equip(dagger) pubsub.pubsub.subscribe( pubsub.Subscription(npc, pubsub.PubSubTypes.DEATH, goblin_observed_death)) return npc
def create_chest(point=None, dungeon_level=1): npc = Character(point, 'C', 'Chest', COLORS.get('chest'), species=Species.NONDESCRIPT) if randint(1, 100) >= 95: return mimic(point, dungeon_level=1) npc.add_component(Health(10), 'health') npc.add_component(Defence(defence=2), 'defence') npc.add_component(Offence(base_power=0), 'offence') #TODO: Generate random level appropriate loot in chest potion = equipment.random_potion(dungeon_level=dungeon_level) potion.lootable = True scroll = equipment.random_scroll(dungeon_level=dungeon_level) scroll.lootable = True weapon = equipment.random_magic_weapon(dungeon_level=dungeon_level) weapon.lootable = True armour = equipment.random_armour(dungeon_level=dungeon_level) armour.lootable = True npc.inventory.add_item(potion) npc.inventory.add_item(scroll) npc.inventory.add_item(weapon) npc.inventory.add_item(armour) return npc
def mimic(point=None, dungeon_level=1): npc = Character(point, 'C', 'Chest', COLORS.get('mimic'), species=Species.CREATURE) npc.add_component(Health(30), 'health') npc.add_component(Offence(base_power=3), 'offence') npc.add_component(Defence(defence=3), 'defence') npc.add_component(Level(xp_value=50), 'level') display_char = ['C'] * 10 display_char.append('M') display_char.append('M') display_char.append('M') display_char.append('M') display_char.append('M') npc.add_component(Display(display_char), 'display') teeth = equipment.teeth() teeth.lootable = False npc.inventory.add_item(teeth) npc.equipment.toggle_equip(teeth) pubsub.pubsub.subscribe( pubsub.Subscription(npc, pubsub.PubSubTypes.ATTACKED, mimic_activate)) return npc
def warlord(point=None, dungeon_level=1): #create a warlord ai_component = WarlordNPC() health_component = Health(50) npc = Character(point, 'W', 'Warlord', COLORS.get('warlord'), ai=ai_component, species=Species.ORC, death=WarlordDeath(), health=health_component) npc.add_component(Offence(base_power=10), 'offence') npc.add_component(Defence(defence=4), 'defence') npc.add_component(Level(xp_value=10), 'level') npc.movement.routing_avoid.extend(npc_avoid) npc_level = (dungeon_level - 1) + randint(-1, 1) if npc_level > 1: npc.level.random_level_up(npc_level - 1) item = equipment.create_weapon('longsword') item.base_name = item.base_name + " of I'll F*****G Have You" item.color = COLORS.get('equipment_epic') item.equippable.power = item.equippable.power * 2 npc.inventory.add_item(item) npc.equipment.toggle_equip(item) shield = equipment.create_armour('steel shield') shield.base_name = shield.base_name + " of Hide and Seek" shield.color = COLORS.get('equipment_epic') shield.equippable.power = item.equippable.defence * 2 npc.inventory.add_item(shield) npc.equipment.toggle_equip(shield) breastplate = equipment.create_armour('breastplate') breastplate.base_name = breastplate.base_name + " of Rebounding" breastplate.color = COLORS.get('equipment_epic') breastplate.equippable.power = item.equippable.defence * 2 npc.inventory.add_item(breastplate) npc.equipment.toggle_equip(breastplate) return npc
def necromancer(point=None, dungeon_level=1): #create a necromancer health_component = Health(30) ai_component = NecromancerNPC() npc = Character(point, 'N', 'necromancer', COLORS.get('necromancer'), ai=ai_component, species=Species.NONDESCRIPT, health=health_component) npc.add_component(Offence(base_power=12), 'offence') npc.add_component(Defence(defence=8), 'defence') npc.add_component(Level(xp_value=10), 'level') npc.add_component(Children(6), 'children') npc.movement.routing_avoid.extend(npc_avoid) npc_level = (dungeon_level - 1) + randint(-1, 1) if npc_level > 1: npc.level.random_level_up(npc_level - 1) weapon = equipment.random_magic_weapon(dungeon_level=dungeon_level) weapon.lootable = True npc.inventory.add_item(weapon) npc.equipment.toggle_equip(weapon) num_of_potions = randint(0, 3) for _ in range(num_of_potions): potion = equipment.random_potion(dungeon_level=dungeon_level) potion.lootable = True npc.inventory.add_item(potion) num_of_scrolls = randint(0, 3) for _ in range(num_of_scrolls): scroll = equipment.random_scroll(dungeon_level=dungeon_level) scroll.lootable = True npc.inventory.add_item(scroll) return npc
def egg(point=None, dungeon_level=1): health_component = Health(4) creature = Character(point, 'E', 'Snake Egg', COLORS.get('snake_egg'), ai=HatchingNPC(snake), species=Species.EGG, health=health_component) creature.movement.routing_avoid.extend(creature_avoid) creature.add_component(Offence(base_power=1), 'offence') creature.add_component(Defence(defence=1), 'defence') return creature
def bountyhunter(point): #create a questgiver ai_component = TetheredNPC(4, point) npc = Character(point, '?', 'Bounty Hunter', COLORS.get('bounty_hunter'), ai=ai_component, interaction=Interactions.QUESTGIVER, species=Species.NONDESCRIPT, act_energy=6) npc.add_component(Offence(base_power=0), 'offence') npc.add_component(Defence(defence=0), 'defence') npc.add_component(Questgiver(), 'questgiver') npc.movement.routing_avoid.extend(npc_avoid) return npc
def hornets(point=None, dungeon_level=1): health_component = Health(2) creature = Character(point, chr(178), 'hornet', COLORS.get('hornet'), ai=BasicNPC(), species=Species.INSECT, health=health_component, act_energy=3) creature.add_component(Offence(base_power=1), 'offence') creature.add_component(Defence(defence=1), 'defence') creature.add_component(Level(xp_value=10), 'level') creature.add_component( Display([ chr(176), chr(176), chr(176), chr(177), chr(177), chr(177), chr(178), chr(178), chr(178) ]), 'display') creature.add_component( DamageModifier(blunt=0.8, slashing=0.8, fire=1.2, ice=1.2, electric=1.2), 'damagemodifier') teeth = equipment.teeth() teeth.lootable = False creature.inventory.add_item(teeth) creature.equipment.toggle_equip(teeth) return creature
def troll(point=None, dungeon_level=1): #create a troll health_component = Health(30) ai_component = BasicNPC() npc = Character(point, 'T', 'troll', COLORS.get('troll'), ai=ai_component, species=Species.TROLL, health=health_component, act_energy=6) npc.add_component(Offence(base_power=12), 'offence') npc.add_component(Defence(defence=8), 'defence') npc.add_component(Level(xp_value=10), 'level') regen = Regeneration() npc.add_component(regen, 'regeneration') npc.add_component(DamageModifier(fire=1.5), 'damagemodifier') regen.start() npc.movement.routing_avoid.extend(npc_avoid) item = None dice = randint(1, 100) if dice > 75: item = equipment.create_weapon('heavy mace') equipment.add_smashing(item) else: item = equipment.create_weapon('longsword') item.lootable = False npc.inventory.add_item(item) npc.equipment.toggle_equip(item) return npc
def snake(point=None, dungeon_level=1): health_component = Health(8) creature = Character(point, 'S', 'snake', COLORS.get('snake'), ai=PredatorNPC(species=Species.RAT), species=Species.SNAKE, health=health_component, act_energy=3) creature.add_component(Offence(base_power=1), 'offence') creature.add_component(Defence(defence=1), 'defence') creature.add_component(Level(xp_value=10), 'level') creature.add_component(Spawn(2, egg), 'spawn') creature.movement.routing_avoid.extend(creature_avoid) teeth = equipment.teeth() if randint(1, 100) >= 50: equipment.add_poison(teeth, 1, 5) creature.add_component(Naming(creature.base_name, prefix='Poisonous'), 'naming') creature.color = COLORS.get('poisonous_snake') teeth.lootable = False creature.inventory.add_item(teeth) creature.equipment.toggle_equip(teeth) pubsub.pubsub.subscribe( pubsub.Subscription(creature, pubsub.PubSubTypes.DEATH, eat_rat)) return creature
def create_player(): #create object representing the player health_component = Health(30) player = Character(None, '@', 'player', COLORS.get('player'), death=PlayerDeath(), health=health_component, species=Species.PLAYER, act_energy=4) player.add_component(Offence(base_power=6), 'offence') player.add_component(Defence(defence=6), 'defence') player.add_component(Level(), 'level') player.add_component(FOV(), 'fov') #initial equipment: a dagger dagger = equipment.create_weapon('dagger') player.inventory.add_item(dagger) player.equipment.toggle_equip(dagger) armour = equipment.create_armour('leather shirt') player.inventory.add_item(armour) player.equipment.toggle_equip(armour) if CONFIG.get('debug'): player.level.random_level_up(30) weapon = equipment.random_magic_weapon() player.inventory.add_item(weapon) player.equipment.toggle_equip(weapon) armour = equipment.random_armour() #equipment.add_damage_aura(armour) player.inventory.add_item(armour) player.equipment.toggle_equip(armour) ring = equipment.random_ring() player.inventory.add_item(ring) player.equipment.toggle_equip(ring) potion = equipment.healing_potion() player.inventory.add_item(potion) potion2 = equipment.power_potion() potion2.identifiable.identified = True player.inventory.add_item(potion2) potion3 = equipment.defence_potion() potion3.identifiable.identified = True player.inventory.add_item(potion3) potion4 = equipment.speed_potion() potion4.identifiable.identified = True player.inventory.add_item(potion4) scroll1 = equipment.lighting_scroll() scroll1.identifiable.identified = True player.inventory.add_item(scroll1) scroll2 = equipment.fireball_scroll() scroll2.identifiable.identified = True player.inventory.add_item(scroll2) scroll3 = equipment.confusion_scroll() scroll3.identifiable.identified = True player.inventory.add_item(scroll3) scroll4 = equipment.identify_scroll() scroll4.identifiable.identified = True player.inventory.add_item(scroll4) scroll5 = equipment.speed_scroll() scroll5.identifiable.identified = True player.inventory.add_item(scroll5) scroll6 = equipment.teleport_scroll() scroll6.identifiable.identified = True player.inventory.add_item(scroll6) scroll7 = equipment.map_scroll() scroll7.identifiable.identified = True player.inventory.add_item(scroll7) scroll8 = equipment.chain_lightning_scroll() scroll8.identifiable.identified = True player.inventory.add_item(scroll8) pubsub.pubsub.subscribe( pubsub.Subscription(player, pubsub.PubSubTypes.EARNEDXP, earn_quest_xp)) return player