Esempio n. 1
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))
Esempio n. 2
0
    def process(self):
        for ent, (pos, movement_action, alignment) in \
                self.level.world.get_components(Position, MovementAction, Alignment):

            goal = Position(pos.x + movement_action.dx,
                            pos.y + movement_action.dy)
            self.level.world.remove_component(ent, MovementAction)
            target = self.level.first_entity_components_at_position(
                goal, BlocksMovement, Alignment, exclude_ent=None)
            if target:
                target_ent, (_, alignment_target) = target
                # cannot use movement action normally, check other stuff

                if alignment_target:
                    # if the target has no alignment, no action is made
                    if CreatureAlignment.can_bump(alignment.alignment,
                                                  alignment_target.alignment):
                        if self.level.world.has_component(ent, Attacker):
                            self.level.world.add_component(
                                ent, MeleeAttackAction(target_ent))
                    elif CreatureAlignment.can_swap(
                            alignment.alignment, alignment_target.alignment):
                        pos2 = self.level.world.component_for_entity(
                            target, Position)
                        tmp = pos
                        pos.x, pos.y = pos2.x, pos2.y
                        pos2.x, pos2.y = tmp.x, tmp.y
            else:
                # can freely move
                if self.level.is_walkable_position(goal):
                    pos.x, pos.y = goal.x, goal.y
                    config.FOV_CALCULATE = True
Esempio n. 3
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)
Esempio n. 4
0
def how_much_to_place(level, room_size: int, room: pygame.Rect) -> None:
    count = 2
    for i in range(0, count):
        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:
            generator.what_to_gen(level, (x, y))
Esempio n. 5
0
 def __init__(self, levelname: str, world: esper.World):
     super().__init__()
     self.scene = self
     self.map: Map = Map(settings.BASE_DIR + "\\" + levelname)
     self.camera: Camera = Camera()
     self.entities = []
     self.player = world.create_entity()
     self.world = world
     self.player: Player = Player(world, player_name="ShuzZzle")
     self.player.create((Velocity(velx=10, vely=10), Position(x=0, y=0)))
Esempio n. 6
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)
                              )
Esempio n. 7
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))
Esempio n. 8
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")
                              )
Esempio n. 9
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")
                              )
Esempio n. 10
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")
                              )
Esempio n. 11
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")
                              )
Esempio n. 12
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)
                                         )
Esempio n. 13
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))