Scriptname __WhistleMyFoalScript extends activemagiceffect  

sound property WhistleSound auto
actor property MyFoal auto
GlobalVariable Property FoalDisabled Auto



Event OnEffectStart(Actor akTarget, Actor akCaster)
	int instanceID = WhistleSound.play(akCaster)
if FoalDisabled.GetValue() == 1
debug.notification("Your foal is too far away to hear you.")
else
	If akCaster.GetParentCell().IsInterior()
		Debug.notification("You are in interior, Foaly can't hear you.")
	Else
		If akCaster.GetDistance(MyFoal) > 4096.0
			MyFoal.MoveTo(akCaster, -1024.0 * Math.Sin(akCaster.GetAngleZ()), -1024.0 * Math.Cos(akCaster.GetAngleZ()))
		EndIf
		MyFoal.PathToReference(akCaster, 1)
	EndIf
	utility.wait(2.0)
	Sound.StopInstance(instanceID)
endif	
endEvent
