ScriptName dunHalldirGhostAmbushScript extends MasterAmbushScript
{Variation on the standard ambush script: Ghosts are invisible until activated.}

EffectShader property GhostShader Auto
float property GhostAlpha Auto

auto State waiting
	;NEW in this variant. Ghosts begin ghosted.
	Event OnLoad()
		Utility.Wait(2)
		self.SetAlpha(0)
		GhostShader.Stop(self)
		self.SetActorValue("Aggression", 0)
		If helpAlliesOnTrigger
			self.SetActorValue("Assistance", 0) ; Help nobody
		EndIf
	EndEvent
	
	;if any of the events above are caught, we leave this state, but first we need to take care
	;of setting up everything we need when we get out of our furniture.
	Event onEndState()
		;handle things like sarcophagus lids that are the linkedRef of the furniture
		If _TryActivateLinkedRef(getLinkedRef())
			_TryActivateLinkedRef(getNthLinkedRef(2))
		EndIf
		
		;set actor variables
		self.SetActorValue(ACTOR_VARIABLE, ACTOR_VARIABLE_ON_TRIGGER)
		_RaiseAggression()
		
		;NEW for this variant. Ghost fades in and solidifies when activated.
		self.SetAlpha(GhostAlpha, True)
		GhostShader.Play(self)
		
		;check to see if actor has a linkedRef with this keyword, if so, then activate it
		If linkKeyword
			_TryActivateLinkedRef(GetLinkedRef(linkKeyword))
		EndIf
	endEvent
endState