extends "res://src/Spell.gd"

var Spark = preload("res://src/Spark.gd")

var UTIL = preload("res://src/Utility.gd")

var sound_spark = preload("res://sound/spark-0.wav")
var sound_storm = preload("res://sound/wind-0.wav")
var asp # audio player

func _ready():
  castingTime = 2.0
  asp = AudioStreamPlayer.new()
  self.add_child(asp)
  
func effect1():
  var player = $"/root/World/ys/player"
  var pos = player.position + player.spr.offset
  var dir = player.dir
  var spark = Spark.new()
  spark.initialize(pos - Vector2(0, 20), dir)
  $"/root/World/ys/".add_child(spark)
  if not asp.is_playing():
    asp.set_volume_db(-10)
    asp.stream = sound_spark
    asp.play()

func effect2():
  # cause sheep to move faster towards you
  for lamb in get_tree().get_nodes_in_group("lambs"):
      lamb.storm()
  if not asp.is_playing():
    asp.set_volume_db(-10)
    asp.stream = sound_storm
    asp.play()