Scriptname _00E_A0_ActionTrigger_MyradFlight extends ObjectReference  


; ========= ACTIONTYPE INDEX =========
; 1 - Sound: FlyBy close object
; 2 - Sound: FlyBy ground
; 3 - Event: Birds fly away
; 4 - Event: Landing Zone
; 5 - Event: Loading
; ====================================


;How to use:
;===========

; Dem trigger an der gewünschten Stelle erstellen und ein linked Ref 
; setzten, ganz egal was es ist. Das Entscheidene dabei ist das 
; Keyword des links.

; Natürlich kann das linkd Ref auch gezielt auf Objekt
; verweisen, dass im Event Verwendung findet. Bei der Landung ist
; der linked Ref z.B. die camera der Lande cinematic.

; Bei Initialisierung holt sich das script den link und checkt
; anhand des keyword für was es zuständig ist:

;			if GetLinkedRef(FlyByCloseObject) != none
;				ActionRef = GetLinkedRef(FlyByCloseObject)
;				ActionType = 1
;			endif


; Durch hinzufügen von neuen Keywords können schnell neue events
; definiert werden ohne jedes mal einen neuen activator +script 
; erstellen zu müssen. 

; Dabei den ACTIONTYPE INDEX auf den neuesten Stand bringen.

; Beim Erstellen von neuen Event-Keywords immer die Namensgebung 
; einhalten: _00E_ActionTrigger_MyradFlight_NeuerEvent


; Es können natürlich neue ActionTrigger mit einem anderen Zusändigkeitsbereich
; im Kit erstellt werden. Neues script, neue keywords:

; Scriptname: _00E_A0_ActionTrigger_Todesstern
; Keywords: _00E_ActionTrigger_Todesstern_DarthVaderAmbush, _00E_ActionTrigger_Todesstern_AlderanSprengen


Quest Property FlightControl auto

Keyword Property EVENTflyByGround Auto  
Keyword Property EVENTflyByCloseObject Auto  
Keyword Property EVENTbirdsFlyAway Auto  
Keyword Property EVENTLandingZone Auto  
Keyword Property EVENTloading Auto  

objectReference Property ActionRef Auto  hidden
objectReference Property PlayerGoal Auto  hidden

Sound  Property SFXflyByGround Auto
Sound  Property SFXflyByObject Auto
Sound  Property SFXflyByBirds Auto

ImageSpaceModifier Property IMODflyBy  Auto  
ImageSpaceModifier Property IMODflyByDV  Auto  
GlobalVariable Property MyradIsFlying  Auto  

Int Property ACTIONTYPE Auto Hidden



Event OnInit()

		if GetLinkedRef(EVENTflyByCloseObject) != none
			ActionRef = GetLinkedRef(EVENTflyByCloseObject)						; link: egal
			ACTIONTYPE = 1
		endif
		if GetLinkedRef(EVENTflyByGround) != none											
			ActionRef = GetLinkedRef(EVENTflyByGround)									; link: egal
			ACTIONTYPE = 2
		endif
		if GetLinkedRef(EVENTBirdsFlyAway) != none										; link: FXBirdFlockFleePineACT 
			ActionRef = GetLinkedRef(EVENTBirdsFlyAway)
			ACTIONTYPE = 3
		endif
		if GetLinkedRef(EVENTLandingZone) != none
			ActionRef = GetLinkedRef(EVENTLandingZone)									; link 1: xmarkerheading für camera position, land cinematic
			PlayerGoal = ActionRef.GetLinkedRef()											; link 2: xmarkerheading für playergoal, land cinematic
			ACTIONTYPE = 4
		endif
		if GetLinkedRef(EVENTloading) != none
			ActionRef = GetLinkedRef(EVENTloading)										; link 1: xmarkerheading Spawn
			ACTIONTYPE = 5
		endif
ENDevent 


int SFXvolume 	
Event OnTriggerEnter(ObjectReference ActionActor)

	if ActionActor == (FlightControl as _00E_A0_MyradFlightControlQuest).Myrad && MyradIsFlying.getValue() != 0
		if ACTIONTYPE == 1
			SFXvolume = SFXflyByObject.play(ActionActor)	
			Sound.SetInstanceVolume(SFXvolume, 0.85)
			game.shakeCamera(afStrength = 4, afDuration = 3)
			IMODflyByDV.apply()
			
		elseif ACTIONTYPE == 2
			game.shakeCamera(afStrength = 4, afDuration = 2)
			SFXvolume = SFXflyByGround.play(ActionActor)	
			Sound.SetInstanceVolume(SFXvolume, 0.75)
			IMODflyBy.apply()
			
		elseif ACTIONTYPE == 3
			; Als link: FXBirdFlockFleePineACT benutzen!
			ActionRef.PlayAnimation("PlayAnim01")
			SFXvolume = SFXflyByBirds.play(ActionActor)
			Sound.SetInstanceVolume(SFXvolume, 1)
			
		elseif ACTIONTYPE == 4
			if (ActionActor as actor).GetFlyingState() != 0
				(FlightControl as _00E_A0_MyradFlightControlQuest).CamSpawn = ActionRef
				if PlayerGoal != none
					(FlightControl as _00E_A0_MyradFlightControlQuest).PlayerGoal = PlayerGoal
				endif
			endif
			
		elseif ACTIONTYPE == 5
			(FlightControl as _00E_A0_MyradFlightControlQuest).PlayerGoal = ActionRef
			(FlightControl as _00E_A0_MyradFlightControlQuest).Loading()
		endif
	endif
ENDevent 

;Event OnTriggerLeave(ObjectReference ActionActor)

;	if ActionActor == (FlightControl as _00E_A0_MyradFlightControlQuest).Myrad && MyradIsFlying.getValue() != 0
	;	if ACTIONTYPE == 1

	;	endif
;	endif
	
;ENDevent