Scriptname _00E_MiningControl extends Quest Hidden

;=====================================================================================
;              							 FUNCTIONS                   					 
;=====================================================================================

Function TransmuteOre(Form akSource, MineOreEnderal oreREF, int iCurrentResources)

	if akSource == _05E_FS_SaldrinsTouch
	
		if oreREF.ResourceCountCurrent > 0
			
			_00E_FS_MAGSaldrinsTouchM.Play(PlayerREF)
			_00E_MAGEldritchCastIMOD.Apply()
			Game.ShakeCamera(afStrength = 0.2)
	
			float fGoldDivider = PlayerREF.GetActorValue("Alteration")/65
			
			if fGoldDivider < 0.5
				fGoldDivider = 0.5
			endif
			
			float iGoldAmount = ((oreREF.Ore.GetGoldValue()/1.5*fGoldDivider))*oreREF.ResourceCountTotal
			oreREF.ResourceCountCurrent = 0
			PlayerREF.AddItem(Gold001, iGoldAmount as int)
			oreREF.damageObject(50)
			;DrScOreOpen.play(oreREF)
			oreREF.setDestroyed(true)
			_00E_OreVeinsMined.SetValueInt(_00E_OreVeinsMined.GetValueInt() +1)
			
		Else
			
			MiningDepletedMessage.Show()
			MAGFail.Play(PlayerREF)
			
		EndIf
		
	EndIf

EndFunction

;=====================================================================================
;              							 PROPERTIES                   					 
;=====================================================================================

Actor Property PlayerREF Auto

MiscObject Property Gold001 Auto

Sound Property _00E_FS_MAGSaldrinsTouchM Auto
Sound Property MAGFail Auto

Spell Property _05E_FS_SaldrinsTouch Auto

Message Property MiningDepletedMessage Auto

ImageSpaceModifier Property _00E_MAGEldritchCastIMOD Auto

GlobalVariable Property _00E_OreVeinsMined Auto