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 npc_death(self, game_map): if self.owner.health and self.owner.health.on_death: print(">>>>>>>On death trigger") self.owner.health.on_death(self.owner) return GameStates.PLAYER_TURN #transform it into a nasty corpse! it doesn't block, can't be #attacked and doesn't move self.owner.char = '%' self.owner.color = COLORS.get('corpse') self.owner.ai = None self.owner.render_order = RenderOrder.CORPSE if self.owner.display: self.owner.del_component("display") if self.owner.inventory: for item in self.owner.inventory.items: if (item.lootable): item.x = self.owner.x item.y = self.owner.y #npc.inventory.drop_item(item) game_map.current_level.add_entity(item) game_map.current_level.remove_entity(self.owner) self.owner.blocks = False game_map.current_level.add_entity(self.owner) self.rotting = True self.owner.add_component( Naming(self.owner.base_name, prefix='Rotting corpse of'), 'naming') return GameStates.PLAYER_TURN
def add_shocking(item): item.add_component( ExtraDamage(number_of_dice=1, type_of_dice=6, name="shock", damage_type=DamageType.ELECTRIC), 'ablity') if not item.naming: item.add_component(Naming(item.base_name, suffix='of shocking'), 'naming')
def jailor(point=None, dungeon_level=1, upgrade_chance=98): npc = random_npc(point, dungeon_level, upgrade_chance) upgrade_npc(npc) npc.add_component(Naming(npc.base_name, prefix='Jailor'), 'naming') npc.movement.routing_avoid.extend(npc_avoid) return npc
def add_flaming(item): item.add_component( ExtraDamage(number_of_dice=1, type_of_dice=6, name="fire", damage_type=DamageType.FIRE), 'ablity') if not item.naming: item.add_component(Naming(item.base_name, prefix='Flaming'), 'naming') else: item.naming.prefix += " flaming"
def add_chain_lightning(item): item.add_component( SpellAbility(spell=tome.chain_lightning, number_of_dice=2, type_of_dice=10, radius=2), 'ablity') if not item.naming: item.add_component(Naming(item.base_name, suffix='of chain lightning'), 'naming') else: item.naming.prefix += " shocking"
def add_infection(item, name="Infection", chance=50, on_turn=None, on_death=None): item.add_component( Infection(name=name, chance=chance, on_turn=on_turn, on_death=on_death), 'ablity') if not item.naming: item.add_component(Naming(item.base_name, suffix=f"of {name}"), 'naming')
def convert_to_skeleton(npc): npc.char = 'S' npc.add_component(Naming(npc.base_name, prefix='Skeletal'), 'naming') npc.add_component(BasicNPC(), 'ai') npc.add_component(Health(max(1, npc.health.max_hp // 3)), 'health') npc.add_component(DamageModifier(blunt=1.2, slashing=0.8, poison=0), 'damagemodifier') npc.species = Species.UNDEAD npc.movement.routing_avoid.append(Tiles.SHALLOW_WATER) return npc
def random_magic_weapon(dungeon_level=1): item = random_weapon(dungeon_level=dungeon_level) dice = randint(1, 1000) item.add_component(IdentifiableWeapon(item.base_name), "identifiable") naming = Naming(item.base_name) if (dice <= 500): naming.prefix = "Remarkable" item.color = COLORS.get('equipment_uncommon') item.equippable.number_of_dice = 2 elif (dice <= 750): naming.prefix = "Excellent" item.color = COLORS.get('equipment_rare') item.equippable.number_of_dice = 3 elif (dice <= 900): naming.prefix = "Exceptional" item.color = COLORS.get('equipment_epic') item.equippable.number_of_dice = 4 elif (dice <= 950): naming.prefix = "Phenomenal" item.color = COLORS.get('equipment_legendary') item.equippable.number_of_dice = 5 else: create_unique_weapon(item) item.add_component(naming, 'naming') add_random_weapon_ablity(item) return item
def convert_to_vampire(npc): npc.char = 'V' npc.add_component(Naming(npc.base_name, prefix='Vampiric'), 'naming') npc.add_component(Health(npc.health.max_hp * 1.5), 'health') npc.species = Species.UNDEAD npc.movement.routing_avoid.append(Tiles.SHALLOW_WATER) teeth = equipment.teeth() equipment.add_lifedrain(teeth) teeth.lootable = False npc.inventory.add_item(teeth) npc.equipment.toggle_equip(teeth) return npc
def captain(point=None, dungeon_level=1, upgrade_chance=98, troops=5): npc = random_npc(point, dungeon_level, upgrade_chance) upgrade_npc(npc) if npc.species == Species.TROLL: underling = troll elif npc.species == Species.ORC: underling = orc elif npc.species == Species.GOBLIN: underling = goblin npc.add_component(CaptainNPC(underling), 'ai') npc.add_component(Children(troops), 'children') npc.add_component(Naming(npc.base_name, prefix='Captain'), 'naming') npc.movement.routing_avoid.extend(npc_avoid) return npc
def convert_to_zombie(npc): npc.char = 'Z' npc.add_component(Naming(npc.base_name, prefix='Zombie'), 'naming') npc.add_component(ZombieNPC(species=npc.species), 'ai') npc.add_component(Health(max(1, npc.health.max_hp // 2)), 'health') npc.add_component(DamageModifier(blunt=0.8, slashing=1.2, poison=0), 'damagemodifier') npc.species = Species.ZOMBIE npc.movement.routing_avoid.append(Tiles.SHALLOW_WATER) teeth = equipment.teeth() teeth.lootable = False equipment.add_infection(teeth, name="Zombification", chance=50, on_turn=None, on_death=convert_to_zombie) npc.inventory.add_item(teeth) npc.equipment.toggle_equip(teeth) 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 add_speed(item): item.add_component(Speed(), 'ablity') if not item.naming: item.add_component(Naming(item.base_name, suffix='of speed'), 'naming')
def add_regeneration(item): item.add_component(Defence(defence=10), 'ablity') if not item.naming: item.add_component(Naming(item.base_name, suffix='of regeneration'), 'naming')
def add_power(item): item.add_component(Defence(defence=1), 'ablity') if not item.naming: item.add_component(Naming(item.base_name, suffix='of power'), 'naming')
def add_paralysis(item): item.add_component(Paralysis(), 'ablity') if not item.naming: item.add_component(Naming(item.base_name, suffix='of paralysis'), 'naming')
def add_lifedrain(item): item.add_component(LifeDrain(), 'ablity') if not item.naming: item.add_component(Naming(item.base_name, suffix='of life drain'), 'naming')
def add_spawning(item, entity): item.add_component(Spawning(maker=entity), 'ablity') if not item.naming: item.add_component(Naming(item.base_name, suffix='of spawning'), 'naming')
def add_smashing(item): item.add_component(PushBack(), 'ablity') if not item.naming: item.add_component(Naming(item.base_name, suffix='of smashing'), 'naming')
def add_poison(item, damage=1, duration=10): item.add_component(Poisoning(0, damage, duration), 'ablity') if not item.naming: item.add_component(Naming(item.base_name, suffix='of poisoning'), 'naming')
def add_defence(item): item.add_component(Defence(defence=10), 'ablity') if not item.naming: item.add_component(Naming(item.base_name, suffix='of defence'), 'naming')