Scriptname _00E_FS_NQ10_StaticScript extends ObjectReference  

Event OnActivate(ObjectReference akActionRef)

	If akActionRef == PlayerREF && !Self.IsActivationBlocked()
		
		Self.BlockActivation(true)
		int iCurrentStage = FS_NQ10.GetStage()
		If iCurrentStage == 0
			FS_NQ10.SetStage(10)
			FS_NQ10.SetObjectiveDisplayed(5)
			FS_NQ10.SetObjectiveDisplayed(10)
		ElseIf iCurrentStage == 5
			FS_NQ10.SetStage(15)
			FS_NQ10.SetObjectiveDisplayed(10)
		EndIf
		
		TryToEnableStatics()
		
		If _00E_FS_NQ10_StaticCountGlobal.GetValue() == 9
			FS_NQ10.SetStage(30)
		EndIf
		Self.BlockActivation(False)

	EndIf
	
EndEvent

Function TryToEnableStatics()

	Int iStaticsEnabled = 0
	Int iIndex = 9
	While iIndex > 0
		iIndex -= 1
		MiscObject oMiscPiece = _00E_FS_NQ10_MiscList.GetAt(iIndex) as MiscObject
		If PlayerREF.GetItemCount(oMiscPiece) == 1
			PlayerREF.RemoveItem(oMiscPiece, 1)
			ObjectReference oStaticPiece = _00E_FS_NQ10_StaticList.GetAt(iIndex) as ObjectReference
			oStaticPiece.Enable()
			iStaticsEnabled += 1
		EndIf
	EndWhile
	
	If iStaticsEnabled > 0
		FS_NQ10.ModObjectiveGlobal(iStaticsEnabled, _00E_FS_NQ10_StaticCountGlobal, 10, 9, true)
		_00E_FS_NQ10_PlacePartM.Play(PlayerREF)
	EndIf

EndFunction

bool DoOnce = false

Formlist Property _00E_FS_NQ10_MiscList Auto
Formlist Property _00E_FS_NQ10_StaticList Auto

Actor Property PlayerREF Auto
Quest Property FS_NQ10 Auto
GlobalVariable Property _00E_FS_NQ10_StaticCountGlobal Auto
Sound Property _00E_FS_NQ10_PlacePartM Auto