Scriptname _00E_A1_OnslaughtImpactSC extends ObjectReference  

;=====================================================================================
;              							EVENTS                   					 
;=====================================================================================

Event OnInit()

	; If !((Math.abs(Self.GetPositionZ() - PlayerREF.GetPositionZ())) > fMaximumZDifference)
		; Dash(False)
	; Else
		; Dash(True)
	; EndIf
	
	; Self.Delete()
	
EndEvent

;=====================================================================================
;              							FUNCTIONS                   					 
;=====================================================================================

Function Dash(bool bCorrectZ = False)

	float fDistance = (Math.abs(Self.GetDistance(PlayerREF)))
	
	If (fDistance > fMaximumDistance)
	
		float fCorrection = Math.abs(fMaximumDistance - fDistance)
		; Debug.MessageBox(fCorrection)
		; Debug.MessageBox("Correct " + Self.GetPositionZ())
		Self.MoveTo(Self, -(fCorrection* Math.Sin(Self.GetAngleZ())), -(fCorrection* Math.Cos(Self.GetAngleZ())), 0.0)
	
	Else
		; Debug.MessageBox("Don't Correct " + Self.GetPositionZ())
		Self.MoveTo(Self, -(75.0 * Math.Sin(Self.GetAngleZ())), -(75.0 * Math.Cos(Self.GetAngleZ())), 0.0)
		
	EndIf

	If bCorrectZ
		Self.SetPosition(Self.GetPositionX(), Self.GetPositionY(), PlayerREF.GetPositionZ())
		akNavmeshRef = Self.PlaceActorAtMe(_00E_NPCOorbayaInvisibeActor)
		Self.SetPosition(akNavmeshRef.GetPositionX(), akNavmeshRef.GetPositionY(), akNavmeshRef.GetPositionZ())
		Self.SetAngle(PlayerREF.GetAngleX(), PlayerREF.GetAngleY(), PlayerREF.GetAngleZ())
		; Debug.MessageBox("Correct Z!")
	Else
		akNavmeshRef = Self.PlaceActorAtMe(_00E_NPCOorbayaInvisibeActor)
		Self.SetPosition(Self.GetPositionX(), Self.GetPositionY(), akNavmeshRef.GetPositionZ())
	EndIf
	
	_00E_A1_OnslaughtCloakSP.Cast(PlayerREF, PlayerREF)
	
	PlayerREF.SplineTranslateToRef(Self, 1.0, 2750.0, 1.0)
	A1_OnslaughtPlayer.ForceRefTo(PlayerREF)
	MAGShoutSprint03.Apply()
	MAGShoutSprintFire.Play(PlayerREF)	
	akNavmeshRef.Delete()
	
EndFunction

;=====================================================================================
;              							PROPERTIES                   					 
;=====================================================================================

float fMaximumZDifference = 350.0
float fMaximumDistance = 1300.0

Actor akNavmeshRef
ReferenceAlias Property A1_OnslaughtPlayer Auto

Sound Property MAGShoutSprintFire Auto
Spell Property _00E_A1_OnslaughtCloakSP Auto

Actor Property PlayerREF Auto

ActorBase Property _00E_NPCOorbayaInvisibeActor Auto

ImageSpaceModifier Property MAGShoutSprint03 Auto