Example #1
0
    def process(self):
        for ent, (renderable, _, death, pos, name) in \
                self.level.world.get_components(Renderable, Dead, Death, Position, Name):
            if death.animation_key:
                self.level.world.create_entity(
                    Renderable(animation_key=death.animation_key,
                               depth=constants.DEPTH_CORPSE),
                    Position(pos.x, pos.y))

            if death.killer:
                killer_name = next(
                    self.level.world.try_component(death.killer, Name))
                assert killer_name is not None
                config.GAME.game_message(
                    name.name + " is slain by " + killer_name.name,
                    constants.COLOR_RED)
                killer_xp = next(
                    self.level.world.try_component(death.killer, Experience),
                    None)
                killed_xp = next(
                    self.level.world.try_component(ent, Experience), None)
                if killer_xp and killed_xp:
                    killer_xp.current_experience += killed_xp.on_death

            else:
                config.GAME.game_message(name.name + " dies",
                                         constants.COLOR_RED_LIGHT)
            if death.custom_death:
                death.custom_death(ent)

            self.level.world.delete_entity(ent)
Example #2
0
def gen_weapon_longsword(level, coords):
    x, y = coords
    bonus = random.randint(1, 2)
    n = random.choice(list(longsword_name_dict.keys()))

    level.world.create_entity(AttackerBonus(attack=bonus),
                              Valuable(100), Item(weight=2, volume=2),
                              Equipment(equip_slot=EquipSlots.WEAPON),
                              Renderable(animation_key="S_WEP_LONGSWORD_" + str(n), depth=constants.DEPTH_ITEM, draw_explored=True),
                              Name(name=longsword_name_dict[n]), Position(x, y)
                              )
Example #3
0
def gen_and_append_gold(level, coords):
    x, y = coords
    value = random.randint(1, 100)

    if value < 31:
        pic = "S_MONEY_SMALL"
    elif value < 67:
        pic = "S_MONEY_MEDIUM"
    else:
        pic = "S_MONEY_LARGE"

    level.world.create_entity(Renderable(animation_key=pic, depth=constants.DEPTH_ITEM, draw_explored=True),
                              Gold(amount=value), Position(x, y))
Example #4
0
def place_map_specific(level):
    if level.name == Levels.WATER1:
        for room in level.rooms:
            for i in range(2):
                x = tcod.random_get_int(None, room.left + 1, room.right - 1)
                y = tcod.random_get_int(None, room.top + 1, room.bottom - 1)
                ent = level.first_entity_at_position(Position(x, y))
                if not ent:
                    level.world.create_entity(
                        Position(x, y), Name("Bubble"),
                        Renderable(animation_key="DECOR_STATUE_01",
                                   depth=constants.DEPTH_STRUCTURES,
                                   special_flags=pygame.BLEND_RGBA_ADD))
Example #5
0
def gen_aquatic_shark_white(level, coords):
    pos = level.world.component_for_player(Position)
    x, y = coords

    level.world.create_entity(Health(20), Position(x, y),
                              Attacker(attack=5, defense=1, hit_chance=90, evasion_chance=30),
                              Name("Great White Shark"), AiChase(pos),
                              Renderable(depth=constants.DEPTH_CREATURE, animation_key="A_AQUATIC_SHARK_WHITE"),
                              Energy(100),
                              BlocksMovement(),
                              Alignment(CreatureAlignment.FOE),
                              Experience(on_death=100),
                              Death(animation_key="S_FLESH_FISH")
                              )
Example #6
0
def gen_demon_buffla(level, coords):
    pos = level.world.component_for_player(Position)
    x, y = coords

    level.world.create_entity(Health(100), Position(x, y),
                              Attacker(attack=12, defense=4, hit_chance=75, evasion_chance=1),
                              Name("Buffla"), AiChase(pos),
                              Renderable(depth=constants.DEPTH_CREATURE, animation_key="A_DEMON_BUFFLA"),
                              Energy(100),
                              BlocksMovement(),
                              Alignment(CreatureAlignment.FOE),
                              Experience(on_death=1000),
                              Death(animation_key="S_DEAD_DEMON")
                              )
Example #7
0
def gen_boss_aquatic_kraken(level, coords):
    pos = level.world.component_for_player(Position)
    x, y = coords

    level.world.create_entity(Health(100), Position(x, y),
                              Attacker(attack=12, defense=4, hit_chance=75, evasion_chance=1),
                              Name("The KRAKEN"), AiChase(pos),
                              Renderable(depth=constants.DEPTH_CREATURE, animation_key="A_BOSS_AQUATIC_KRAKEN"),
                              Energy(60),
                              BlocksMovement(),
                              Alignment(CreatureAlignment.FOE),
                              Experience(on_death=10000),
                              Death(animation_key="S_FLESH_FISH")
                              )
Example #8
0
def gen_aquatic_frog_hypno(level, coords):
    pos = level.world.component_for_player(Position)
    x, y = coords

    level.world.create_entity(Health(20), Position(x, y),
                              Attacker(attack=6, defense=3, hit_chance=80, evasion_chance=20),
                              Name("Hypno Frog"), AiChase(pos),
                              Renderable(depth=constants.DEPTH_CREATURE, animation_key="A_AQUATIC_FROG_HYPNO"),
                              Energy(100),
                              BlocksMovement(),
                              Alignment(CreatureAlignment.FOE),
                              Experience(on_death=100),
                              Death(animation_key="S_FLESH_FISH")
                              )
Example #9
0
def gen_player(level, coords, player_name):
    x, y = coords
    level.world.add_components_to_player(Player(), Persistent(), Position(x, y),
                                         Name(player_name), Health(100),
                                         Stats(10, 10, 10),
                                         Energy(100),
                                         Renderable(animation_key="A_PLAYER", animation_speed=1.0),
                                         Attacker(attack=666, hit_chance=100, evasion_chance=10, defense=5),
                                         Stats(strength=10, dexterity=10, intelligence=10),
                                         BlocksMovement(),
                                         Alignment(CreatureAlignment.PLAYER),
                                         Experience(),
                                         Container(),
                                         Level(1),
                                         Death(animation_key="S_DEAD_DEMON", custom_death=_death.death_player)
                                         )
Example #10
0
def gen_stairs(level, coords, leads_to, downwards=True):
    x, y = coords
    animation_key = "S_STAIRS_DOWN" if downwards else "S_STAIRS_UP"
    level.world.create_entity(Position(x, y), Stairs(leads_to=leads_to, downwards=downwards),
                              Renderable(animation_key=animation_key, depth=constants.DEPTH_STRUCTURES,
                                         draw_explored=True))