function on_activate(parent, ability)
  local targets = parent:targets():friendly()
  
  local targeter = parent:create_targeter(ability)
  targeter:set_selection_radius(ability:range())
  targeter:add_selectable(parent)
  targeter:set_shape_circle(ability:range())
  targeter:add_all_effectable(targets)
  targeter:invis_blocks_affected_points(true)
  targeter:activate()
end

function on_target_select(parent, ability, targets)
  ability:activate(parent)
  
  local position = targets:selected_point()
  
  local gen = parent:create_particle_generator("wind_particle", 0.6)
  gen:set_initial_gen(1000.0)
  gen:set_position(gen:param(position.x), gen:param(position.y))
  gen:set_particle_size_dist(gen:fixed_dist(0.7), gen:fixed_dist(0.7))
  local speed = ability:range() / 0.5
  gen:set_particle_position_dist(gen:dist_param(gen:uniform_dist(-0.1, 0.1),
                                 gen:angular_dist(0.0, 2 * math.pi, 3.0 * speed / 4.0, speed)))
  gen:set_particle_duration_dist(gen:fixed_dist(0.5))
  gen:set_color(gen:param(0.0), gen:param(0.5), gen:param(1.0), gen:param(1.0, -2.0))
  
  local targets = targets:to_table()
  for i = 1, #targets do
    local cb = ability:create_callback(parent)
	cb:add_target(targets[i])
	cb:set_on_anim_update_fn("apply_effect")
    gen:add_callback(cb, targets[i]:dist_to_point(position) / speed)
  end
  
  gen:activate()
  game:play_sfx("sfx/blessing")
end

function apply_effect(parent, ability, targets)
  local target = targets:first()
  
  target:remove_effects_with_tag("nauseate")
  target:remove_effects_with_tag("cripple")
  target:remove_effects_with_tag("blind")
  target:remove_effects_with_tag("disease")
  target:remove_effects_with_tag("rupture")
  
  local anim = parent:create_anim("water_spin", 0.75)
  anim:set_position(anim:param(target:center_x() - 1.5), anim:param(target:center_y() - 2.0))
  anim:set_particle_size_dist(anim:fixed_dist(4.0), anim:fixed_dist(4.0))
  anim:activate()
end
