Scriptname _00E_FS_NQR05_PerversionSC extends Actor  

Event OnInit()
	SetAV("UnarmedDamage", 35)
EndEvent

Event OnEnterBleedout()
	PlayDeathFX()
EndEvent

Event OnDying(Actor akKiller)
	; Perversions are essential by default, but the death FX make them non-essential for a short time.
	; This is a safeguard for a perversion dying while its actor base is non-essential because another perversion of the same base started its death FX a bit earlier.
	PlayDeathFX()
EndEvent

Bool bIsDying = False

Function PlayDeathFX()
	If bIsDying
		Return
	EndIf
	bIsDying = True

	SetGhost(True)
	ActorBase myActorBase = GetActorBase()

	_00E_FS_NPC_PerversionDeathM.Play(Self)
	_00E_HighOnesDisintegrate.Play(Self)
	Utility.Wait(1.9)
	SetCriticalStage(CritStage_DisintegrateStart)
	AbsorbRedImod.Apply()
	PlaceAtMe(_00E_FS_NQR05_BloodGeysir)
	PlaceAtMe(_00E_FS_NQR05_PerversionExp)
	StopCombat()

	myActorBase.SetEssential(False)
	Kill(None)
	AttachAshPile(_00E_CorpseExplosionPile_Remains)
	SetAlpha(0.0, True)
	SetCriticalStage(CritStage_DisintegrateEnd)
	myActorBase.SetEssential(True)

	If RewardExp > 0
		If (Game.GetPlayer() as _00E_EPUpdateFunctions).receiveEP(RewardExp)
			; Player receives EXP
		EndIf
	EndIf
EndFunction

Explosion Property _00E_FS_NQR05_PerversionExp Auto 
Explosion Property _00E_FS_NQR05_BloodGeysir Auto 
Sound Property _00E_FS_NPC_PerversionDeathM Auto
ImageSpaceModifier Property AbsorbRedImod Auto
EffectShader Property _00E_HighOnesDisintegrate Auto
Activator Property _00E_CorpseExplosionPile_Remains Auto
Int Property RewardExp Auto