ScriptName aaaKimachuuEnhanceWeapon Extends ActiveMagicEffect

MagicEffect Property aaaKimachuuEAWME Auto
Potion Property aaaKimachuuEAWPo Auto

Int minValue = 1
Int maxValue = 3

Event OnEffectStart(Actor akTarget, Actor akCaster)
	Actor actSelf = akTarget
	Float[] fMag = new Float[1]
	Int[] iZero = new Int[1]
	MagicEffect[] meME = new MagicEffect[1]

	Weapon myWep = actSelf.GetEquippedWeapon()
	Enchantment myEnch = WornObject.GetEnchantment(actSelf, 1, 0)
	Int myEffects = myEnch.GetNumEffects()
	Float fMagW = myEnch.GetNthEffectMagnitude(0)
	fMag[0] = Utility.RandomInt(minValue, maxValue)
	fMag[0] = fMag[0] + fMagW
	meME[0] = aaaKimachuuEAWME
	MagicEffect meEffect = myEnch.GetNthEffectMagicEffect(0)

	If !myWep
		Debug.Notification("There is no weapon equipped in the right hand.")
		actSelf.AddItem(aaaKimachuuEAWPo, 1)
	ElseIf (myEffects == 0) || (meEffect == aaaKimachuuEAWME)
		WornObject.CreateEnchantment(actSelf, 1, 0, 2000.0, meME, fMag, iZero, iZero)
	Else
		Debug.Notification("This weapon has an enchantment.")
		actSelf.AddItem(aaaKimachuuEAWPo, 1)	
	EndIf

	actSelf = None
	myWep = None
	myEnch = None
EndEvent