Scriptname KA_RevRitualFX extends ObjectReference  
{plays effects for revakheim resurrection}

float property newPriestCount auto

imageSpaceModifier property ImodFX auto

objectReference Property Swirls01 auto
objectReference Property Swirls02 auto

objectReference Property shockWave01 auto
objectReference Property shockWave02 auto
objectReference Property shockWave03 auto
objectReference Property shockWave04 auto

objectReference Property summonFX auto
objectReference Property summonFXOrigin auto

objectReference Property door01 auto
objectReference Property door02 auto

float property reanimTime auto

objectReference Property SummonMarker auto

KA_revRitualMaster property master auto

KA_RevRitualSCRIPT property bust01 auto
KA_RevRitualSCRIPT property bust02 auto
KA_RevRitualSCRIPT property bust03 auto
KA_RevRitualSCRIPT property bust04 auto
KA_RevRitualSCRIPT property bust05 auto
KA_RevRitualSCRIPT property bust06 auto
KA_RevRitualSCRIPT property bust07 auto
KA_RevRitualSCRIPT property bust08 auto

KA_RevRitualSCRIPT property soulgem01 auto
KA_RevRitualSCRIPT property soulgem02 auto
KA_RevRitualSCRIPT property soulgem03 auto
KA_RevRitualSCRIPT property soulgem04 auto
KA_RevRitualSCRIPT property soulgem05 auto
KA_RevRitualSCRIPT property soulgem06 auto
KA_RevRitualSCRIPT property soulgem07 auto
KA_RevRitualSCRIPT property soulgem08 auto

objectReference property gemACT01 auto
objectReference property gemACT02 auto
objectReference property gemACT03 auto
objectReference property gemACT04 auto
objectReference property gemACT05 auto
objectReference property gemACT06 auto
objectReference property gemACT07 auto
objectReference property gemACT08 auto

objectReference property maskACT01 auto
objectReference property maskACT02 auto
objectReference property maskACT03 auto
objectReference property maskACT04 auto
objectReference property maskACT05 auto
objectReference property maskACT06 auto
objectReference property maskACT07 auto
objectReference property maskACT08 auto

actorbase property priest01 auto
actorbase property priest02 auto
actorbase property priest03 auto
actorbase property priest04 auto
actorbase property priest05 auto
actorbase property priest06 auto
actorbase property priest07 auto
actorbase property priest08 auto

objectReference property NahkriinMinion auto
objectReference property VokunMinion auto
objectReference property MorokeiMinion auto
objectReference property RahgotMinion auto

sound property mySFX auto
sound property mySFX2 auto
sound property mySFXBegin auto

activator property KA_SummonFX auto

Auto STATE waiting
EVENT onActivate (objectReference triggerRef)
if  ((master.mask01placed && master.gem01placed) || (master.mask02placed && master.gem02placed) || (master.mask03placed && master.gem03placed) || (master.mask04placed && master.gem04placed) || (master.mask05placed && master.gem05placed) || (master.mask06placed && master.gem06placed) || (master.mask07placed && master.gem07placed) || (master.mask08placed && master.gem08placed)) 
gotoState ("busy")
utility.wait(4.0)
;============
; 	eerie sound 
;============	
	int soundInstance1 = mySFXBegin.play(Self)  
	Sound.SetInstanceVolume(soundInstance1, 1)
;============
; 	shut doors 
;============
	shutDoors()
	blockAll()	
	ImodFX.applyCrossFade(1.0)
	swirls01.enable(1)
	utility.wait(1.5)
	swirls02.enable(1)
	utility.wait(2.5)
;============
; 	Soul Trap Sound
;============	
	int soundInstance2 = mySFX.play(Self)  
	Sound.SetInstanceVolume(soundInstance2, 1)
;============
; 	Wind Sound
;============	
	int soundInstance3 = mySFX2.play(SummonMarker)  
	Sound.SetInstanceVolume(soundInstance3, 1)
;============
; 	Shock Waves
;============
		if (master.mask01placed && master.gem01placed) || (master.mask02placed && master.gem02placed)
			shockWave01.PlayAnimation("PlayAnim02")
		elseif (master.mask03placed && master.gem03placed) || (master.mask04placed && master.gem04placed)
			shockWave02.PlayAnimation("PlayAnim02")
		elseif (master.mask05placed && master.gem05placed) || (master.mask06placed && master.gem06placed)
			shockWave03.PlayAnimation("PlayAnim02")
		elseif (master.mask07placed && master.gem07placed) || (master.mask08placed && master.gem08placed)
			shockWave04.PlayAnimation("PlayAnim02")
		endif
	utility.wait(reanimTime)
	summonFX = SummonMarker.PlaceAtMe(KA_SummonFX)
	utility.wait(0.33)
	summonPriest()
	utility.wait(1.00)
;================
; 	Cleanup
;================
	shockWave01.PlayAnimation("PlayAnim01")
	shockWave02.PlayAnimation("PlayAnim01")
	shockWave03.PlayAnimation("PlayAnim01")
	shockWave04.PlayAnimation("PlayAnim01")	
	Imagespacemodifier.removeCrossFade(1.0)
	summonFX.disable()
	summonFX.delete()
	utility.wait(0.5)
	swirls01.disable(1)	
	utility.wait(1.5)
	swirls02.disable(1)
endif
endEVENT
endSTATE

STATE busy
	EVENT onActivate (objectReference triggerRef)
			;do nothing
	endEVENT
endSTATE

;=================/
;	Shut Doors				/
;=================/
FUNCTION shutDoors()
	if master.door01isOpen == TRUE
		door01.activate(self)
	endIf	
	if master.door02isOpen == TRUE
		door02.activate(self)
	endIf
endFUNCTION

;=================/
;	Block All					/
;=================/
FUNCTION blockAll()
	door01.blockActivation()
	door02.blockActivation()	
endFUNCTION

;=================/
;	Unblock All					/
;=================/
FUNCTION unblockAll()
	door01.blockActivation(FALSE)
	door02.blockActivation(FALSE)
	gotoState ("waiting")
endFUNCTION

;=================/
;	Summon				/
;=================/
FUNCTION summonPriest()
if (master.mask01placed && master.gem01placed)	
	bust01.clearAltar()
	soulgem01.clearAltar()
	SummonMarker.PlaceActorAtMe(Priest01).StartCombat(Game.GetPlayer())		
	updateDPCount()
endif
if (master.mask02placed && master.gem02placed)
	bust02.clearAltar()
	soulgem02.clearAltar()
	SummonMarker.PlaceActorAtMe(Priest02).StartCombat(Game.GetPlayer())	
	vokunMinion.enable()
	updateDPCount()
endif
if (master.mask03placed && master.gem03placed)
	bust03.clearAltar()
	soulgem03.clearAltar()
	SummonMarker.PlaceActorAtMe(Priest03).StartCombat(Game.GetPlayer())	
	updateDPCount()
endif
if (master.mask04placed && master.gem04placed)
	bust04.clearAltar()
	soulgem04.clearAltar()	
	SummonMarker.PlaceActorAtMe(Priest04).StartCombat(Game.GetPlayer())
	MorokeiMinion.enable()
	updateDPCount()
endif
if (master.mask05placed && master.gem05placed)
	bust05.clearAltar()
	soulgem05.clearAltar()
	SummonMarker.PlaceActorAtMe(Priest05).StartCombat(Game.GetPlayer())
	updateDPCount()
endif
if (master.mask06placed && master.gem06placed)
	bust06.clearAltar()
	soulgem06.clearAltar()
	SummonMarker.PlaceActorAtMe(Priest06).StartCombat(Game.GetPlayer())
	updateDPCount()
endif
if (master.mask07placed && master.gem07placed)
	bust07.clearAltar()
	soulgem07.clearAltar()
	SummonMarker.PlaceActorAtMe(Priest07).StartCombat(Game.GetPlayer())	
	nahkriinMinion.enable()
	updateDPCount()
endif
if (master.mask08placed && master.gem08placed)		
	bust08.clearAltar()
	soulgem08.clearAltar()
	SummonMarker.PlaceActorAtMe(Priest08).StartCombat(Game.GetPlayer())
	RahgotMinion.enable()
	updateDPCount()
endif
endFUNCTION

;=================/
;	update DP count		/
;=================/
FUNCTION updateDPCount()
newPriestCount = (master.priestCount + 1)
master.priestCount = newPriestCount
endFUNCTION