def trigger(self, **kwargs):
     """
     Attempts to drop the parent item at the entity's feet.
     """
     target_entity = kwargs[action.TARGET_ENTITY]
     entities_in_sight = target_entity.vision.get_seen_entities_closest_first(
     )
     entities_in_sight.reverse()
     if not any(entities_in_sight):
         return
     min_push = 2
     max_push = 4
     entity_direction = {}
     entity_push_steps = {}
     max_push_distance = 0
     for entity in entities_in_sight:
         push_direction = geometry.other_side_of_point_direction(
             target_entity.position.value, entity.position.value)
         entity_direction[entity] = push_direction
         entity_push_steps[entity] = random.randrange(
             min_push, max_push + 1)
         max_push_distance = max(entity_push_steps[entity],
                                 max_push_distance)
     for index in range(max_push_distance):
         for entity in entities_in_sight:
             if (entity_push_steps[entity] <= index
                     or self._entity_is_about_to_fall(entity)):
                 break
             entity.stepper.try_push_in_direction(entity_direction[entity])
         target_entity.game_state.value.dungeon_needs_redraw = True
         target_entity.game_state.value.force_draw()
         sleep(0.07)  # todo: standardise frame show time
     msg.send_global_message(messenger.PLAYER_PUSH_SCROLL_MESSAGE)
Exemple #2
0
 def trigger(self, **kwargs):
     """
     Attempts to drop the parent item at the entity's feet.
     """
     target_entity = kwargs[action.TARGET_ENTITY]
     entities_in_sight = target_entity.vision.get_seen_entities_closest_first()
     entities_in_sight.reverse()
     if not any(entities_in_sight):
         return
     min_push = 2
     max_push = 4
     entity_direction = {}
     entity_push_steps = {}
     max_push_distance = 0
     for entity in entities_in_sight:
         push_direction = geometry.other_side_of_point_direction(target_entity.position.value, entity.position.value)
         entity_direction[entity] = push_direction
         entity_push_steps[entity] = random.randrange(min_push, max_push + 1)
         max_push_distance = max(entity_push_steps[entity], max_push_distance)
     for index in range(max_push_distance):
         for entity in entities_in_sight:
             if (entity_push_steps[entity] <= index or
                     self._entity_is_about_to_fall(entity)):
                 break
             entity.stepper.try_push_in_direction(entity_direction[entity])
         target_entity.game_state.value.dungeon_needs_redraw = True
         target_entity.game_state.value.force_draw()
         sleep(0.07)  # todo: standardise frame show time
     msg.send_global_message(messenger.PLAYER_PUSH_SCROLL_MESSAGE)
Exemple #3
0
 def trigger(self, **kwargs):
     target_entity = kwargs[action.TARGET_ENTITY]
     slow_turns = random.randrange(10, 19)
     msg.send_global_message(messenger.FROST_POTION_DRINK_MESSAGE)
     target_entity.effect_queue.add(entityeffect.AddSpoofChild(None, frost_effect_factory(),
                                                               slow_turns * gametime.single_turn, meld_id="frost",
                                                               status_description=FROST_SLOW_STATUS_DESCRIPTION))
    def trigger(self, **kwargs):
        """
        swaps target entity with another random entity on the floor.
        """
        source_entity = kwargs[action.SOURCE_ENTITY]
        dungeon_level = source_entity.dungeon_level.value
        other_entities = [
            e for e in dungeon_level.entities if not e is source_entity
        ]
        if not any(other_entities):
            return

        random.shuffle(other_entities)

        other_entity = other_entities[0]
        other_pos = other_entity.position.value
        my_pos = source_entity.position.value

        other_entity.mover.try_remove_from_dungeon()
        source_entity.mover.try_remove_from_dungeon()

        source_entity.mover.try_move(other_pos, dungeon_level)
        other_entity.mover.try_move(my_pos, dungeon_level)
        source_entity.game_state.value.dungeon_needs_redraw = True
        msg.send_global_message(messenger.PLAYER_SWITCH_MESSAGE)
Exemple #5
0
 def trigger(self, **kwargs):
     """
     teleports target entity.
     """
     target_entity = kwargs[action.TARGET_ENTITY]
     msg.send_global_message(messenger.PLAYER_TELEPORT_MESSAGE)
     teleport_effect = entityeffect.Teleport(target_entity)
     target_entity.effect_queue.add(teleport_effect)
 def trigger(self, **kwargs):
     """
     teleports target entity.
     """
     target_entity = kwargs[action.TARGET_ENTITY]
     msg.send_global_message(messenger.PLAYER_TELEPORT_MESSAGE)
     teleport_effect = entityeffect.Teleport(target_entity)
     target_entity.effect_queue.add(teleport_effect)
 def trigger(self, **kwargs):
     target_entity = kwargs[action.TARGET_ENTITY]
     slow_turns = random.randrange(10, 19)
     msg.send_global_message(messenger.FROST_POTION_DRINK_MESSAGE)
     target_entity.effect_queue.add(
         entityeffect.AddSpoofChild(
             None,
             frost_effect_factory(),
             slow_turns * gametime.single_turn,
             meld_id="frost",
             status_description=FROST_SLOW_STATUS_DESCRIPTION))
Exemple #8
0
 def trigger(self, **kwargs):
     """
     Attempts to drop the parent item at the entity's feet.
     """
     target_entity = kwargs[action.TARGET_ENTITY]
     msg.send_global_message(messenger.PLAYER_MAP_MESSAGE)
     dungeon_level = target_entity.dungeon_level.value
     walkable_positions = dungeon_level.get_walkable_positions(dummy_flyer_open_doors, target_entity.position.value)
     map_positions = extend_points(walkable_positions)
     for p in map_positions:
         tile = dungeon_level.get_tile_or_unknown(p)
         target_entity.memory_map.gain_knowledge_of_terrain_of_tile(tile, p, dungeon_level.depth)
     target_entity.game_state.value.dungeon_needs_redraw = True
 def trigger(self, **kwargs):
     """
     Attempts to drop the parent item at the entity's feet.
     """
     target_entity = kwargs[action.TARGET_ENTITY]
     msg.send_global_message(messenger.PLAYER_MAP_MESSAGE)
     dungeon_level = target_entity.dungeon_level.value
     walkable_positions = dungeon_level.get_walkable_positions(
         dummy_flyer_open_doors, target_entity.position.value)
     map_positions = extend_points(walkable_positions)
     for p in map_positions:
         tile = dungeon_level.get_tile_or_unknown(p)
         target_entity.memory_map.gain_knowledge_of_terrain_of_tile(
             tile, p, dungeon_level.depth)
     target_entity.game_state.value.dungeon_needs_redraw = True
Exemple #10
0
 def trigger(self, **kwargs):
     source_entity = kwargs[action.SOURCE_ENTITY]
     sight_radius = source_entity.sight_radius.value
     dungeon_level = source_entity.dungeon_level.value
     top = source_entity.position.value[1] - sight_radius
     left = source_entity.position.value[0] - sight_radius
     turned_something_to_glass = False
     for x in range(left, left + 2 * sight_radius + 1):
         for y in range(top, top + 2 * sight_radius + 1):
             try:
                 turned_something_to_glass = self._turn_to_glass_if_wall((x, y), dungeon_level)
                 dungeon_level.signal_terrain_changed((x, y))
             except IndexError:
                 continue
     if turned_something_to_glass:
         msg.send_global_message(messenger.GLASS_TURNING_MESSAGE)
Exemple #11
0
    def trigger(self, **kwargs):
        source_entity = kwargs[action.SOURCE_ENTITY]
        dungeon_level = source_entity.dungeon_level.value
        entities_in_sight = source_entity.vision.get_seen_entities()
        if not any(entities_in_sight):
            return
        entities_in_sight.append(source_entity)

        positions = [e.position.value for e in entities_in_sight]
        random.shuffle(positions)

        for entity in entities_in_sight:
            entity.mover.try_remove_from_dungeon()

        for entity in entities_in_sight:
            entity.mover.try_move(positions.pop(), dungeon_level)
        msg.send_global_message(messenger.SWAP_DEVICE_MESSAGE)
 def trigger(self, **kwargs):
     source_entity = kwargs[action.SOURCE_ENTITY]
     sight_radius = source_entity.sight_radius.value
     dungeon_level = source_entity.dungeon_level.value
     top = source_entity.position.value[1] - sight_radius
     left = source_entity.position.value[0] - sight_radius
     turned_something_to_glass = False
     for x in range(left, left + 2 * sight_radius + 1):
         for y in range(top, top + 2 * sight_radius + 1):
             try:
                 turned_something_to_glass = self._turn_to_glass_if_wall(
                     (x, y), dungeon_level)
                 dungeon_level.signal_terrain_changed((x, y))
             except IndexError:
                 continue
     if turned_something_to_glass:
         msg.send_global_message(messenger.GLASS_TURNING_MESSAGE)
    def trigger(self, **kwargs):
        source_entity = kwargs[action.SOURCE_ENTITY]
        dungeon_level = source_entity.dungeon_level.value
        entities_in_sight = source_entity.vision.get_seen_entities()
        if not any(entities_in_sight):
            return
        entities_in_sight.append(source_entity)

        positions = [e.position.value for e in entities_in_sight]
        random.shuffle(positions)

        for entity in entities_in_sight:
            entity.mover.try_remove_from_dungeon()

        for entity in entities_in_sight:
            entity.mover.try_move(positions.pop(), dungeon_level)
        msg.send_global_message(messenger.SWAP_DEVICE_MESSAGE)
Exemple #14
0
    def trigger(self, **kwargs):
        """
        swaps target entity with another random entity on the floor.
        """
        source_entity = kwargs[action.SOURCE_ENTITY]
        dungeon_level = source_entity.dungeon_level.value
        other_entities = [e for e in dungeon_level.entities if not e is source_entity]
        if not any(other_entities):
            return

        random.shuffle(other_entities)

        other_entity = other_entities[0]
        other_pos = other_entity.position.value
        my_pos = source_entity.position.value

        other_entity.mover.try_remove_from_dungeon()
        source_entity.mover.try_remove_from_dungeon()

        source_entity.mover.try_move(other_pos, dungeon_level)
        other_entity.mover.try_move(my_pos, dungeon_level)
        source_entity.game_state.value.dungeon_needs_redraw = True
        msg.send_global_message(messenger.PLAYER_SWITCH_MESSAGE)