def teleporting_bomb(*args, **kwargs): caster = args[0] entities = kwargs.get('entities') fov_map = kwargs.get('fov_map') damage = kwargs.get('damage') damage_radius = kwargs.get('damage_radius') target_coord = Point(kwargs.get('target_coordinates')) target_tile = kwargs.get('target_tile') results = [] if not target_tile.explored: results.append({ 'consumed': False, 'message': Message("You cannot target a tile you haven't explored yet.", libtcod.yellow) }) return results if libtcod.map_is_in_fov(fov_map, target_coord.x, target_coord.y): results.append({ 'consumed': True, 'message': Message( f'The teleporting bomb explodes in a radius of {damage_radius} tiles!', libtcod.orange) }) else: results.append({ 'consumed': True, 'message': Message(f'You hear a distant explosion!', libtcod.orange) }) for entity in [x for x in entities if x.fighter]: distance = target_coord.distance_to(entity.get_coordinates()) if distance <= damage_radius: # 4 : decay constant # TODO: put into a constant file OR pass it as an argument final_damage = int( round(damage / (1 + (distance * 4 / damage_radius)))) if libtcod.map_is_in_fov(fov_map, entity.x, entity.y): results.append({ 'message': Message( f'The {entity.name} gets burned for {final_damage} hit points.', libtcod.orange) }) results.extend(entity.fighter.take_damage(final_damage)) return results
def guided_rocket(*args, **kwargs): caster = args[0] entities = kwargs.get('entities') fov_map = kwargs.get('fov_map') damage = kwargs.get('damage') damage_radius = kwargs.get('damage_radius') target_coor = Point(kwargs.get('target_coordinates')) results = [] if not libtcod.map_is_in_fov(fov_map, target_coor.x, target_coor.y): results.append({ 'consumed': False, 'message': Message('You cannot target a tile outside your field of view.', libtcod.yellow) }) return results results.append({ 'consumed': True, 'message': Message( f'The guided rocket explodes in a radius of {damage_radius} tiles!', libtcod.orange) }) for entity in [x for x in entities if x.fighter]: distance = target_coor.distance_to(entity.get_coordinates()) if distance <= damage_radius: # 4 : decay constant # TODO: put into a constant file OR pass it as an argument final_damage = int( round(damage / (1 + (distance * 4 / damage_radius)))) if libtcod.map_is_in_fov(fov_map, entity.x, entity.y): results.append({ 'message': Message( f'The {entity.name} gets burned for {final_damage} hit points.', libtcod.orange) }) results.extend(entity.fighter.take_damage(final_damage)) return results