Scriptname _00E_NQ09_CasketScript extends ObjectReference  


Event OnCellAttach() ;FIRE WHEN PLAYER ENTERS THE CELL THE NEEDED ACTOR IS IN

if (NQ09.GetStage() < 30)

	int doOnce
	
	if ( doOnce == 0 )
		BlockActivation()
		doOnce = 1
	endif
	
endif
	
EndEvent

Event OnActivate(ObjectReference akActionRef)

	if (NQ09.GetStage() <= 20)
        _00E_NQ09_Casket_mb.show()
        int soundInstanceID = _00E_Casket_LockedSound.Play(Self)
		;Debug.Notification(sNQ09CasketLockedMessage)
	Elseif NQ09.GetStage() >= 27
		Self.Activate(akActionRef, True)
	EndIf
	
; ; FIRST CASKET ; old code -- removed since it duplicates above.
;	if (Self.GetBaseObject() == _00E_NQ09_Casket01)	
;		if (IsActivationBlocked())
;			int soundInstanceID = _00E_Casket_LockedSound.Play(Self)
;			_00E_NQ09_Casket_mb.show()
;		endIf		
;	endif
	
; ; SECOND CASKET ; old code -- there is no second casket in the
;                 ; current version of NQ09 anymore.
;	if (Self.GetBaseObject() == _00E_NQ09_Casket02)
;		BlockActivation(false)
;		if (NQ09.GetStage() == 60)
;			Activate(Game.GetPlayer(), true)
;			NQ09.SetStage(65)	
;		endif
;	endif
	
EndEvent

Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)

if (NQ09.GetStage() < 20)
    _00E_NQ09_Casket_notyet_mb.Show()
	return
endif

if (NQ09.GetStage() < 60) && NQ09.GetStage() >= 20
	
	if (IsActivationBlocked())
		int soundInstanceID = _00E_NQ09_RustyCasketOpenSound.Play(Self) 
		int soundInstanceID2 = _00E_NQ09_RustyCasketOpenSealSound.Play(Self)
		NQ09.SetStage(25)
		NQ09.SetObjectiveCompleted(20)
		Self.SetOpen(True)
	
	endif
	
endif

EndEvent

;String Property sNQ09CasketLockedMessage = "No matter how hard you try, the lock doesn't give in." Auto

Quest property NQ09 auto 
;Container Property _00E_NQ09_Casket01 Auto
;Container Property _00E_NQ09_Casket02 Auto
Message property _00E_NQ09_Casket_mb auto
Message property _00E_NQ09_Casket_notyet_mb auto
Sound property _00E_Casket_LockedSound auto
Sound property _00E_NQ09_RustyCasketOpenSound auto
Sound property _00E_NQ09_RustyCasketOpenSealSound auto