ScriptName _00E_AltIshmartepEnergySparkScript Extends ObjectReference

import Utility

GlobalVariable Property _00E_AltIshFirstPass auto
GlobalVariable Property _00E_AltIshSecondPass auto

Actor Property playerRef Auto

MiscObject Property sphere Auto
ObjectReference Property slidingGate Auto
ObjectReference Property innerGlow Auto
ObjectReference Property outerGlow Auto
ObjectReference Property energySpark Auto

ObjectReference property doorFX auto

Sound Property moving1 Auto
Sound Property moving2 Auto
Sound Property moving3 Auto
ObjectReference Property rotatingDisk Auto

Bool doOnce = True
Bool translationDone = True

Event OnActivate( ObjectReference ref )

	if( ref == playerRef && ref.GetItemCount( sphere ) > 0 )
	
		if( _00E_AltIshFirstPass.GetValueInt() == 0 || _00E_AltIshSecondPass.GetValueInt() == 0 )	
			ref.RemoveItem( sphere, 1 )
			innerGlow.Enable()
			outerGlow.Enable()
			energySpark.Enable()
			
			if( _00E_AltIshFirstPass.GetValueInt() == 0 )
				_00E_AltIshFirstPass.SetValueInt( 1 )
			ElseIf ( _00E_AltIshSecondPass.GetValueInt() == 0 )
				_00E_AltIshSecondPass.SetValueInt( 1 )
			EndIf
		EndIf	
		
	checkStatus()
	
	EndIf
EndEvent

Function checkStatus()
		
	if( _00E_AltIshFirstPass.GetValueInt() == 1 && _00E_AltIshSecondPass.GetValueInt() == 1 )
		
		if( doOnce )
			doOnce = False
			slidingGate.PlayAnimation( "Open" )
			doorFX.playAnimation("FXDoorOpen")
			Wait( 3 )
			moving3.Play( slidingGate )
			moving1.Play( slidingGate )
			;						  x - start  y - start z - start  x - dest   y - dest   z - dest   speed rotation
			rotatingDisk.TranslateTo( 4456.0000, 2144.0000, 1600.0000, 180.0000, 90.0000, 180.0000, 80.0, 20.0)
			Wait( 2 )
			moving2.Play( slidingGate )
			Wait( 2 )
			moving2.Play( slidingGate )
			moving1.Play( slidingGate )
			Wait( 5 )
			
			moving3.Play( slidingGate )
			rotatingDisk.TranslateTo( 4456.0000, 2144.0000, 1160.0000, 180.0000, 90.0000, 180.0000, 80.0 )
		EndIf
	EndIf
	
EndFunction