/////////////////////////////////////////////////////////////////////
// JAKE.S
/////////////////////////////////////////////////////////////////////

SETUP

	IF !gt_CLEAR_MINES && mj_FREED_FARMERS
		Add gt_CLEAR_MINES
	ENDIF

	// *** NOTE ***
	// Jake is placed by the vignette, the first time he is met

	IF gt_JAKE_GONE
		KillC  JAKE
	ELSE
		IF ce_JAKE
			IDoorClosed djake
			IF  !f_JAKE_DEAD
    			PlaceC JAKE pJAKE_JAKES_STUDY
			ENDIF
		ELSE
			IDoorLocked djake
		ENDIF
	ENDIF

	IF gt_TAKEN_CASKET && !gt_JAKE_NAMED
		Add gt_JAKE_NAMED
		ChangeProfileToIdentified Mcitizen_Jake
	ENDIF

	IF mj_FREED_FARMERS
		IF !gt_PLACED_MAD_FARMER_8
			Add gt_PLACED_MAD_FARMER_8
			PlaceC MAD_FARMER_8 pMADF_8
			Wander MAD_FARMER_8
		ENDIF
	ENDIF

	IF mj_FOUND_BLOODMASTER
		IF !gt_PLACED_THARD_VAN_1
			Add gt_PLACED_THARD_VAN_1
			PlaceC THARD_VAN_1 pVAN_1
			Wander THARD_VAN_1
			SwitchOnSightOfPlayer THARD_VAN_1 AttackDemo2
			PlaceC THARD_VAN_2 pVAN_2
			Wander THARD_VAN_2
			SwitchOnSightOfPlayer THARD_VAN_2 AttackDemo2
			PlaceC THARD_VAN_3 pVAN_3
			Wander THARD_VAN_3
			SwitchOnSightOfPlayer THARD_VAN_3 AttackDemo2
			PlaceC THARD_VAN_4 pVAN_4
			Wander THARD_VAN_4
			SwitchOnSightOfPlayer THARD_VAN_4 AttackDemo2
			PlaceC THARD_VAN_5 pVAN_5
			Wander THARD_VAN_5
			SwitchOnSightOfPlayer THARD_VAN_5 AttackDemo2
		ENDIF
	ENDIF

    IF  mj_RECOVER_CROWN
        IF !gd_PLACED_JF_DRAGONS

            IF gt_PLACED_THARD_VAN_1
                KillC  THARD_VAN_1
                KillC  THARD_VAN_2
                KillC  THARD_VAN_3
                KillC  THARD_VAN_4
                KillC  THARD_VAN_5
            ENDIF

            Add gd_PLACED_JF_DRAGONS

            PlaceC              JF_DRAGON_1 pJF_DRAGON_1
            AddControl          JF_DRAGON_1 Capture     cM_GUARD_STAND1
            AddControl          JF_DRAGON_1 Capture     cM_GUARD_STAND2
            AddControl          JF_DRAGON_1 Capture     cM_GUARD_STAND3
            SequenceRandomlySelects JF_DRAGON_1
            SwitchOnSightOfPlayer JF_DRAGON_1 AttackDemo2

            PlaceC              JF_DRAGON_2 pJF_DRAGON_2
            AddControl          JF_DRAGON_2 Capture     cM_GUARD_STAND1
            AddControl          JF_DRAGON_2 Capture     cM_GUARD_STAND2
            AddControl          JF_DRAGON_2 Capture     cM_GUARD_STAND3
            SequenceRandomlySelects JF_DRAGON_2
            SwitchOnSightOfPlayer JF_DRAGON_2 AttackDemo2

            PlaceC              ALKADATH    pJF_ALKADATH_START
            IDoorLocked         djake
                    
        ENDIF
    ENDIF 

END

VIG TempSetup FALSE

	RunS AndrusWeather
	Set gd_WIND_TYPE	1
    RunS CueWeather

	IF f_JAKE_DEAD
		CachePortrait ALKADATH.BIN
		CachePortrait FARMERM2.BIN
		CachePortrait PC3.BIN
		CachePortrait PC4.BIN
	ELSE
		CachePortrait CARRAN.BIN
		CachePortrait JAKE.BIN
		CachePortrait PC1.BIN
		CachePortrait RAAL.BIN
	ENDIF

END

/////////////////////////////////////////////////////////////////////

VIG TalkToMadFarmer_8 MSG-iMAD_FARMER_8

	IF mj_DEFEAT_GARGOS_2
		Say fam404 farmerm2.bin
	ELSE
		//"Good day to you. You're well, I hope?"
		IF LANG-English || LANG-German
			Say fa8001 FARMERM2.BIN
		ELSE
			Say fa1003 farmerm2.bin
		ENDIF
	ENDIF

END

/////////////////////////////////////////////////////////////////////

VIG MeetJake ONESEC && !ce_JAKE && !gt_JAKE_GONE && INAREA-P-NEAR_JAKES_HOUSE

	Widescreen TRUE
	// *** START OF CONFRONTATION WITH JAKE ***
	
	playmusic rpg27.wav
	FreeCam
	CamCut High01
	SetCamMoveConstant 4
	CamPan Low01

	// *** player walks up to door ***
	
	MoveCDir P pP_JAKE
	UUComplete P 

	// *** player knocks on door ***
	Capture P cF_KNOCK_ON_DOOR

	//knock on door SFX
	PlaySFXPerson IG_17.WAV P

	//MakeHeld JAKE xbow
	PlaceC JAKE pJAKE_AMBUSH_START
	MoveCDir JAKE pJAKE_COVER_PLAYER

	Wait 3000
	//"Move away from the door, stranger...who sent you?"
	QuickSay ja0001

	// w.t.f....?
	Wait 250
	MoveC P P_moveForJake
	UUComplete P
	LookAtTurn P JAKE
	UUComplete P
	UnDrawSwordRemember
	UUSay

	IF POS-P-casket
		//"Will Farshore sent me. He gave me a parcel to deliver to you"
		Say HxJ001
		//"A parcel, huh?"
		Say ja0002
	ELSE
		//"Nobody sent me. Chant..."
		Say HxJ002
		//"Chant, huh?"
		Say ja0003
	ENDIF

	//"You'd better come inside..."
	Say ja0004

	// *** door opens and player walks in ***
	// *** [AndyR] Door remains closed until someone opens it. ***
	IDoorClosed djake
	//RDoorOpen djake
	//UUDoorStill djake

	// Player goes to door, opens door, enters then waits inside in corridor

	MoveC_1tel P JF_HOUSE_OUT P_GoInsideAndWait
	Capture JAKE cM_V6_LOOK_AROUND2_BETTER

	// *** Jake follows player in ***
	//Wait 4000

	while !INAREA-p-justinside
		wait 250
	endwhile

	CamCut Cam03

	UnDrawSword JAKE
	MoveC_1tel JAKE JF_HOUSE_OUT pJAKE_JAKES_STUDY
	UUComplete P 
	LookAtTurn P JAKE

	Wait 1000

	MoveCDir P pP_JAKES_STUDY
	SetCamMoveNormal 1
	CamPan high04

	UUComplete P
	UUComplete JAKE

	CamCut Cam05

	//"Now, tell me exactly why you are here."
	Say ja0005

	// *** END OF CONFRONTATION WITH JAKE ***

	Add gt_TALK_TO_JAKE_NOW


END

/////////////////////////////////////////////////////////////////////

VIG DropCasket FALSE

		SetNoObjInLeftHand P
		DeleteObjectsInBackpackWithID P casket
		Reveal casket casket

END

/////////////////////////////////////////////////////////////////////

VIG TalkToJake (MSG-iJAKE || gt_TALK_TO_JAKE_NOW) && !f_JAKE_DEAD

	IF ce_JAKE
		Widescreen TRUE
		MoveCDir P pP_JAKES_STUDY
		FreeCam
		CamCut Cam05
		UUComplete P
		UUComplete JAKE
		UnDrawSwordRemember

		//"You again. What do you want?"
		Say ja0006
	ELSE
		Add ce_JAKE
		//Name2 JAKE
		Remove gt_TALK_TO_JAKE_NOW
	ENDIF

	// **** MAIN JAKE CONVERSATION ****

	Set gt_JAKE_SCARE_COUNT 0
	Set gt_JAKE_ANNOY_COUNT 0
	Remove gt_JAKE_SCARE_MSG
	Remove gt_JAKE_ANNOY_MSG
	Remove gt_JAKE_SAID_3
	Remove gt_JAKE_SAID_4
	Remove gt_JAKE_SAID_5
	Remove gt_JAKE_SAID_6
	Remove gt_JAKE_SAID_7
			
	ResetChoice
	WHILE !MenuExit

		// *** BUILD THE MENU ***
		ClearChoices

		IF POS-P-casket
			IF gt_JAKE_SEEN_CASKET
				//Open Casket
				AddChoice 2 txj002
			ELSE
				//Show Casket
				AddChoice 1 tx0018
			ENDIF
		ENDIF

		//Chant
		AddChoice 3 txpw02

		IF co_GUILDSEAL
			//Seal with 3 knives
			AddChoice 4 txt200
		ENDIF

		IF co_THEGUILD
			//Guild of assassins
			AddChoice 5 tx0097
		ENDIF

		IF co_TEMPLE_OF_SHADOWS
			//Temple of shadows
			AddChoice 6 tx0015
		ENDIF

		IF co_RAAL
			//Raal
			AddChoice 7 tx0032
		ENDIF

		//bye
		AddChoice 0 tx0003

		// *** DISPLAY THE MENU ***
		GetChoice JAKE

		// *** DEAL WITH THE CHOICE ***
		SWITCH CHOICE
			CASE 1
				// *** Show Casket ***

				Add gt_JAKE_SEEN_CASKET
				//"...for me?...You open it..."
				Say ja0013

			CASE 2
				// *** Open Casket ***

				Add gt_JAKE_OPEN_CASKET_NOW

			CASE 3
				// *** Chant ***

				IF !gt_JAKE_SAID_3
					Add gt_JAKE_SAID_3
					AddTo gt_JAKE_ANNOY_COUNT 1
				ENDIF
				//"...trust Chant..."
				Say ja0012

			CASE 4
				// *** seal with 3 knives ***

				IF !gt_JAKE_SAID_4
					Add gt_JAKE_SAID_4
					AddTo gt_JAKE_SCARE_COUNT 1
					AddTo gt_JAKE_ANNOY_COUNT 1
				ENDIF
				//"It sounds like Lord Crux's coat of arms..."
				Say ja0007
				ChangeProfileToIdentified Sassassin_Crux

			CASE 5
				// *** Guild of assassins ***

				IF !gt_JAKE_SAID_5
					Add gt_JAKE_SAID_5
					AddTo gt_JAKE_SCARE_COUNT 2
					AddTo gt_JAKE_ANNOY_COUNT 2
				ENDIF
				//"I don't know..."
				Say ja0008
				//"...I have no interest in murderers..."
				Say ja0009

			CASE 6
				// *** Temple of shadows ***

				IF !gt_JAKE_SAID_6
					Add gt_JAKE_SAID_6
					AddTo gt_JAKE_ANNOY_COUNT 1
				ENDIF
				//"Ah, yes...to the west..."
				Say ja0010

			CASE 7
				// *** Raal ***

				IF !gt_JAKE_SAID_7
					Add gt_JAKE_SAID_7
					AddTo gt_JAKE_SCARE_COUNT 1
					AddTo gt_JAKE_ANNOY_COUNT 1
				ENDIF
				//"...demons...evil..."
				Say ja0011

			CASE 0
				// *** bye ***
				//"Don't hurry back..."
				Say ja0016

				//prevent parting comments
				Add gt_JAKE_SCARE_MSG
				Add gt_JAKE_ANNOY_MSG

		ENDSWITCH

		// Is the conversation over? Or, is Jake scared or annoyed enough yet?

		IF gt_JAKE_OPEN_CASKET_NOW
			SetChoiceToExit
		ELSE
			IF gt_JAKE_ANNOY_COUNT>3 && !gt_JAKE_ANNOY_MSG
				Add gt_JAKE_ANNOY_MSG
				//"Either say what you came to, or leave..."
				Say ja0015
			ELSE
				IF gt_JAKE_SCARE_COUNT>2 && !gt_JAKE_SCARE_MSG
					Add gt_JAKE_SCARE_MSG
					//"You had better hurry up... I don't like the direction this conversation is going"
					Say ja0014
				ENDIF
			ENDIF
		ENDIF

	ENDWHILE

	// **** END OF MAIN JAKE CONVERSATION ****

	IF gt_JAKE_OPEN_CASKET_NOW

		// *** JAKE DEATH VIGNETTE ***
		SetObjInLeftHand P casket
		CamCut SwapCam

		//player drops casket

		Capture P cM_OBJ_FROM_BKPK_2H_TABLE_PLACE notify 550 DropCasket 

		UUComplete P
		FX_Carran_head_appears pCARRAN
		DeleteObjectsInWorldWithID casket

		wait 10000		
	
		//"The Guild, father. The Guild is coming..."
		Say ca0001 CARRAN.BIN

		FX_carran_head_explodes pCARRAN

		SetCamMoveNormal 1
		CamPan Shad03

		//"Carran! My son! Why?!"
		Say ja0017

		PlaceC			JAKE_RAAL		pSHAD3_TABLE
		FX_GreenFire	JAKE_RAAL
		PlaySFXPerson Raal1.wav JAKE_RAAL
		Wait 125
		PlaceC			JAKE_SHADOW1	pSHAD1_TABLE
		FX_GreenFire	JAKE_SHADOW1
		Wait 100
		PlaceC			JAKE_SHADOW2	pSHAD5_TABLE
		FX_GreenFire	JAKE_SHADOW2

		LookAtTurn JAKE_RAAL JAKE
		LookAtTurn JAKE JAKE_RAAL
		//"What sorcery is this?"
		Say ja0018
		Capture JAKE_RAAL cM_POINT
		//"The Master has ordered you silenced, betrayer."
		Say raJ001
		LookAtTurn JAKE P
		//"No!...Find the Guild...Avenge me!"
		QuickSay ja0019

		Wait 1000

		Capture JAKE_RAAL cM_CAST_SPELL20_MISC
		FX_Sprinkle JAKE_RAAL

		Add co_THEGUILD

		//Jake throws key to player
		UUComplete JAKE
		Capture JAKE cM_TOSS_MEDIUM
		Wait 250
		FX_Sprinkle JAKE_RAAL
		Capture P cM_OBJ_ACCEPT_1H1

		UUSay

		SetCamMoveNormal 3
		CamPan shad02

		FX_GreenFire	JAKE
		KillC 			JAKE
		Wait 100
		FX_GreenFire	JAKE_RAAL
		KillC 			JAKE_RAAL
		Wait 200
		FX_GreenFire	JAKE_SHADOW1
		KillC 			JAKE_SHADOW1
	
		UUComplete P
		AwardOb P jakes_key "Jakes key"
		Wait 1000

		//the remaining shadow attacks the player

		AttackDemo2 JAKE_SHADOW2
			
		// *** END JAKE DEATH VIGNETTE ***

		Add f_JAKE_DEAD
		QLRemove ql008
		AwardEP xp_DELIVER_CASKET
		QLAdd ql015 qlt015 qlb015
		DrawSwordRemember
	ENDIF

	// [AndyR] Clean up camera at end of vignette.
	SetCamMoveNormal 10
	NormalCam	
	Camcut P 300	
	Widescreen FALSE

END

/////////////////////////////////////////////////////////////////////

VIG AlkadathRumble  gd_PLACED_JF_DRAGONS && ISDEAD-JF_DRAGON_1 && ISDEAD-JF_DRAGON_2 && !gd_JF_ALKADATH_RUMBLE
widescreen true  
//camcut alkadath
 // Walk Alkadath walks out of Jake's house
    IDoorClosed djake
    RDoorOpen   djake

	ChangeProfileToNotDestiny Tsoldier_AlKadath
    MoveC_1tel  ALKADATH    JF_HOUSE_IN    pJF_ALKADATH_1
	UUComplete	ALKADATH

    Say         lk0006

    EngageAndFace   ALKADATH    P

    QuickSay    hxak01
    Wait        500
    Capture     P       cM_TALK_THREATEN1

    UUSay
    QuickSay    lk0010
    Wait        500
    Capture     ALKADATH    cM_TALK_DISAGREE1

	UUSay
	
	SetGoodBad ALKADATH bad
    AttackDemo2 ALKADATH
    Add         gd_JF_ALKADATH_RUMBLE
	camcut p
	setcammovenormal
	widescreen false  
END

/////////////////////////////////////////////////////////////////////

VIG AlKadathIsDead TENSEC && mj_RECOVER_CROWN && !mj_DEFEAT_AL && ISDEAD-ALKADATH

	Add mj_DEFEAT_AL
	AwardEP xp_DEFEAT_AL
	QLRemove ql029

END

/////////////////////////////////////////////////////////////////////

VIG DRAlkadath  MSG-DR_ALKADATH

	IF !gg_DR_ALKADATH
		Add gg_DR_ALKADATH
		QuickSay lk0011
	ELSE
		RunS GenericDR
	ENDIF
END

/////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////

VIG FlyBy FALSE

	Widescreen TRUE

	// *** EXAMPLE CAMERA FLY-BY CODE ***

	// use Wait at start and end to help when editing the final recording
	// use UUCameraComplete to wait for a pan to finish
	// use SetCamMoveConstant to set camera movement per frame
	//     - remember the movie is played at 25fps no matter how slow it records

	SetCamMoveConstant 30
	FreeCam
	PhotoOn

	camcut flyby01

	campan flyby02
	UUCameraComplete

	campan flyby03
	UUCameraComplete

	PhotoOff

	// *** END OF FLY-BY ***

	Widescreen FALSE

END

/////////////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////////////
