Scriptname aaaTKCDamageCalcScript extends activemagiceffect 

GlobalVariable property Magnitude Auto
String Property SkillName  Auto  
int Property iDmgFrom Auto

Spell Property ResistMultishot Auto
Magiceffect Property ResistEffect Auto

Event OnEffectStart (Actor akTarget, Actor akCaster)

	Actor player		= Game.GetPlayer()

	int BaseDmg		= player.GetEquippedWeapon().GetBaseDamage()
	int SkillLevel		= player.GetActorValue(""+SkillName) as int
	if SkillLevel >= 100
		SkillLevel = 100
	endif
	float SkillCalc	= math.RadiansToDegrees(SkillLevel)
	float Dmg		= ((math.sin(SkillCalc/100)*98) + BaseDmg) * Magnitude.GetValue()

; iDmgFrom 1=ThrowDagger, 2=Multishot, 3=SplashSlam, 4=Rain of Arrows

	if iDmgFrom == 1
		if player.IsDetectedBy(akTarget)
			akTarget.DamageAV("Health", Dmg)
		else
			akTarget.DamageAV("Health", Dmg*2)
		endif
	elseif iDmgFrom == 2
		if !akTarget.Hasmagiceffect(ResistEffect)
			akTarget.DamageAV("Health", Dmg)
			ResistMultishot.Cast(akTarget)
		else
			return
		endif
	elseif iDmgFrom == 3
		float FrostResist = akTarget.GetAVPercentage("FrostResist")
		akTarget.DamageAV("Health", Dmg*(1-FrostResist))
	elseif iDmgFrom == 4
		akTarget.DamageAV("Health", Dmg/4)
	endif

;	debug.notification("dmg" + Dmg)

EndEvent