Scriptname _00E_QuestUpdateOnTriggerComplex extends ObjectReference  

Event OnTriggerEnter(ObjectReference akActionREF)
	If akActionRef == PlayerREF && Done == False && Config_UpdateStage
		Int curStage = QuestToSet.GetCurrentStageID()
		If Config_StageRequiredToUpdate
			If curStage == StageRequriedToUpdate
				SetDone(True)
			ElseIf curStage > StageRequriedToUpdate && Config_DisableWhenDone
				SetDone(False)
			EndIf
		Else
			If curStage < DesiredStage
				SetDone(True)
			ElseIf DesiredStage > 0 && Config_DisableWhenDone
				SetDone(False)
			EndIf
		EndIf
	EndIf
EndEvent

Function SetDone(Bool bDoSetStage)
	If Done
		Return
	EndIf
	Done = True

	If bDoSetStage
		QuestToSet.SetCurrentStageID(DesiredStage)
	EndIf

	If Config_DisableWhenDone
		Self.Disable()
		Self.Delete()
	EndIf
EndFunction

Bool Property Config_DisableWhenDone = True Auto
{Should the box be disabled after the stage has been set?}
Bool Property Config_StageRequiredToUpdate Auto ;
{Is a certain stage required for the trigger to fire?}
Bool Property Config_UpdateStage Auto 
{Does this trigger update the quests stage?}

Quest Property QuestToSet Auto 
Actor Property PlayerREF Auto

bool Done = False

int Property StageRequriedToUpdate Auto
int Property DesiredStage Auto