def targeting_spherical_area(parameters, radius): """ Function to target a spherical area .. versionadded:: 0.10 """ targets = [] initial = get_target_in_direction(level=parameters.caster.level, location=parameters.caster.location, direction=parameters.direction) if initial and initial.previous_target: splash_center = initial.previous_target.location level = parameters.caster.level matrix = get_fov_matrix(splash_center, level, radius) x_range = range(splash_center[0] - radius, splash_center[0] + radius + 1) y_range = range(splash_center[1] - radius, splash_center[1] + radius + 1) for location, is_visible in matrix.items(): if is_visible: creature = get_character(level, location) if creature: targets.append( TargetData('character', location, creature, None)) elif blocks_los(level, location): targets.append(TargetData('wall', location, None, None)) else: targets.append(TargetData('void', location, None, None)) return targets
def targeting_spherical_area(parameters, radius): """ Function to target a spherical area .. versionadded:: 0.10 """ targets = [] initial = get_target_in_direction(level=parameters.caster.level, location=parameters.caster.location, direction=parameters.direction) if initial and initial.previous_target: splash_center = initial.previous_target.location level = parameters.caster.level matrix = get_fov_matrix(splash_center, level, radius) x_range = range(splash_center[0] - radius, splash_center[0] + radius + 1) y_range = range(splash_center[1] - radius, splash_center[1] + radius + 1) for location, is_visible in matrix.items(): if is_visible: creature = get_character(level, location) if creature: targets.append(TargetData('character', location, creature, None)) elif blocks_los(level, location): targets.append(TargetData('wall', location, None, None)) else: targets.append(TargetData('void', location, None, None)) return targets
def paint(self, s): """ Paint this widget on given surface :param s: surface to paint on :type s: Surface """ player = self.application.world.player level = player.level player.level.full_update_needed = False self.light_matrix = get_fov_matrix(self.application.world, player, 13) sy = 0 for y in range(player.location[1] - 9, player.location[1] + 10): sx = 0 for x in range(player.location[0] - 12, player.location[0] + 13): #draw floor and walls if x >= 0 and y >= 0 and x <= len(level.floor)-1 and y <= len(level.floor[x])-1: tile = self.surface_manager.get_icon(level.floor[x][y]) s.blit(tile, (sx * 32, sy * 32 - 8)) if not level.walls[x][y] == herculeum.config.tiles.WALL_EMPTY: tile = self.surface_manager.get_icon(level.walls[x][y]) s.blit(tile, (sx * 32, sy * 32 - 8)) if self.light_matrix[x][y] == False: tile = self.surface_manager.get_icon(herculeum.config.tiles.FLOOR_EMPTY) s.blit(tile, (sx * 32, sy * 32 - 8)) else: #draw empty tile = self.surface_manager.get_icon(herculeum.config.tiles.FLOOR_EMPTY) s.blit(tile, (sx * 32, sy * 32 - 8)) sx = sx + 1 sy = sy + 1 sx = 0 #draw portals for item in level.portals: x = item.location[0] - player.location[0] + 12 y = item.location[1] - player.location[1] + 9 if x >= 0 and y >= 0 and x <= 24 and y <= 14: if self.light_matrix[x + player.location[0] - 12][y + player.location[1] - 9] == True: tile = self.surface_manager.get_icon(item.icon) s.blit(tile, (x * 32, y *32 - 8)) #draw items for item in level.items: x = item.location[0] - player.location[0] + 12 y = item.location[1] - player.location[1] + 9 if x >= 0 and y >= 0 and x <= 24 and y <= 14: if self.light_matrix[x + player.location[0] - 12][y + player.location[1] - 9] == True: tile = self.surface_manager.get_icon(item.icon) s.blit(tile, (x * 32, y *32 - 8)) #draw creatures for item in level.creatures: x = item.location[0] - player.location[0] + 12 y = item.location[1] - player.location[1] + 9 if x >= 0 and y >= 0 and x <= 24 and y <= 14: if self.light_matrix[x + player.location[0] - 12][y + player.location[1] - 9] == True: tile = self.surface_manager.get_icon(item.icon) s.blit(tile, (x * 32, y *32 - 8)) tile = self.surface_manager.get_icon(player.icon) s.blit(tile, (384, 280))