ScriptName _amm_SaxhleelDeathScript Extends Actor

Actor Property acPlayer Auto
Actor Property acAnnaig Auto
Actor Property acFhena Auto
Actor Property acAttrebus Auto
Weapon Property wpnUmbra Auto
GlobalVariable Property gvSaxhleelKilled Auto
GlobalVariable Property gvSaxhleelQst Auto
ObjectReference Property orNote01 Auto
ObjectReference Property orGrave Auto
ObjectReference Property orSaxhleelEnabler Auto
ObjectReference Property orDaglinEnabler Auto

Event OnDeath(Actor akKiller)

	Int iNumKilled
	Int iUmbraDmg
	Int iSaxhleelFin = gvSaxhleelQst.GetValue() As Int
	
	If (akKiller == acPlayer)
		If (!acPlayer.IsEquipped(wpnUmbra))
			Self.Resurrect()
		Else
			iNumKilled = gvSaxhleelKilled.GetValue() As Int
			iNumKilled += 1
			gvSaxhleelKilled.SetValue(iNumKilled)
			; If a Saxhleel has been killed Umbra increases in strength
			iUmbraDmg = wpnUmbra.GetBaseDamage()
			wpnUmbra.SetBaseDamage(iUmbraDmg * 1.05 As Int)
			; If all Saxhleel are killed, quest is completed
			If (iNumKilled == 8)
				iSaxhleelFin = 1
			EndIf
			If (iSaxhleelFin == 1)
				gvSaxhleelQst.SetValue(1)
				acAnnaig.Enable()
				acFhena.Enable()
				orNote01.Enable()
				orGrave.Enable()
				acAttrebus.Disable()
				orSaxhleelEnabler.Disable()
				orDaglinEnabler.Disable()
			EndIf
		EndIf
	EndIf

EndEvent
