/////////////////////////////////////////////////////////////////////
// ERIV.S
/////////////////////////////////////////////////////////////////////

SETUP

	// *** INIT GAME ***
	IF !gd_RUN_STARTUP
		Add         gd_RUN_STARTUP	  

		LoadScript	setup.s
		RunS		InitialSetup

		Add			gg_PLAY_INTRO
//		Add			f_ATTUNED_DREAMS
//		Add			f_ATTUNED_ARROWS
//		Add			f_ATTUNED_KNIVES
//		Add			f_ATTUNED_MEDICINES
//		Add			f_ATTUNED_TRINKETS

		SetPCModel				PCstage1
		ChangeProfilePortrait P	PC1.BIN
	ENDIF
    
	// *** INTRO ***
	IF !gd_PLACED_ALLIS_AND_PLAYER
		Add         gd_PLACED_ALLIS_AND_PLAYER

		// *** PLACE PLAYER AND ALLIS ***

		MessagesOff
		PlaceC      P       pP_START
		MessagesOn
		PlaceC      ALLIS   pALLIS_START

	ENDIF

	IF mj_SLEPT_AT_ANDRUS && gd_ALLIS_LOCKED_DOOR
        Remove          gd_ALLIS_LOCKED_DOOR
        IDoorClosed     dallis
	ENDIF

	// *** BRIGANDS ***
	IF !mj_SLEPT_AT_ANDRUS
		IF mj_DEFEAT_BART
			IF gd_PLACED_ER_BRIGAND_2
				Remove gd_PLACED_ER_BRIGAND_2
				KillC  ER_BRIG_2
			ENDIF
		ELSE
			IF !gd_PLACED_ER_BRIGAND_2
				Add gd_PLACED_ER_BRIGAND_2

				// *** PLACE ERIV BRIGANDS ***
				PlaceC  ER_BRIG_2 pER_BRIG_2
				AwardOb ER_BRIG_2 brignote "comoro-letter"
				
				WaitUntilDamaged		ER_BRIG_2
				AddFilter ER_BRIG_2 CompletesOnSightOfPlayer

				AddControl ER_BRIG_2 FILTER timeout 3 setscriptflagcontrol gg_BrigSeesPlayer

				AddControl ER_BRIG_2 RestrictedWanderButAttackOnSight    
			//ELSE
			// removed - if chars lose their controllers this is a general bug
			// and a local fix isn't good enough
			//	RestrictedWanderButAttackOnSight ER_BRIG_2
			ENDIF
        ENDIF
	ENDIF

	// *** CAVE TELEPORT AND SPIDER ***
	IF !mj_SLEPT_AT_ANDRUS && !gt_PLACED_SEWER_SPIDER
		IF !gd_PLACED_ER_SPIDER && !gd_REMOVED_SPIDER
            Add     gd_PLACED_ER_SPIDER
			PlaceC  ER_SPIDER_2 pE3_SPIDER_START
		ENDIF
	ELSE
		IF gd_PLACED_ER_SPIDER
			Remove  gd_PLACED_ER_SPIDER
			RemoveC ER_SPIDER_2
		ENDIF
	ENDIF

	// *** HAMMER ***
	IF mj_SLEPT_AT_ANDRUS
		IF gt_FESTIVAL_PREP
			IF mj_RECOVER_CROWN
				//on faith map for invasion / teleport to gthor
				Set gt_NEED_HAMMER 0
			ELSE
				IF mj_BEEN_TO_HEX
					//working
					Set gt_NEED_HAMMER 1
				ELSE
					//at festival
					Set gt_NEED_HAMMER 0
				ENDIF
			ENDIF
		ELSE
			//working
			Set gt_NEED_HAMMER 1
		ENDIF
	ELSE
		//not needed yet
		Set gt_NEED_HAMMER 0
	ENDIF			

	IF gt_NEED_HAMMER=1
    	PlaceC      HAMMER pANVIL
		SetObjInLeftHand HAMMER hammer
		IDoorOpen   dhammer
		RunS		HammerActions
	ELSE
		RemoveC HAMMER
	ENDIF

	IF gt_FESTIVAL_PREP && (!mj_DEFEAT_GARGOS_1 || !mj_BEEN_TO_HEX)
		RemoveC ALLIS
	ELSE
		IF !ONMAP-ALLIS && (!mj_BARTS_ASSAULT || mj_DEFEAT_BART)
			PlaceC ALLIS pP_POINT
		ENDIF
	ENDIF

	// *** FARMER ***
	IF mj_FREED_FARMERS
		IF mj_RECOVER_CROWN
			IF gt_PLACED_MAD_FARMER_2
				Remove gt_PLACED_MAD_FARMER_2
				KillC  MAD_FARMER_2
			ENDIF
		ELSE
			IF !gt_PLACED_MAD_FARMER_2
				Add gt_PLACED_MAD_FARMER_2
				PlaceC MAD_FARMER_2 pMADF_2
				Wander MAD_FARMER_2
			ENDIF
		ENDIF
	ENDIF

	IF mj_DEFEAT_BART
		IF !gt_BLOODKIN_ARMY_IN_MADRIGAL
			IF !gt_PLACED_CHANT_ON_ERIV
				Add gt_PLACED_CHANT_ON_ERIV
				KillC  MAD_FARMER_2
				PlaceC LAEN pLAEN_DOCK
				PlaceC CANDICE5 pCANDICE_DOCK
				PlaceC LAEN_GUARD_1 pG_1
				PlaceC LAEN_GUARD_2 pG_2
				PlaceC LAEN_GUARD_3 pG_3
				PlaceC LAEN_GUARD_4 pG_4
				PlaceC LAEN_GUARD_5 pG_5
				PlaceC LAEN_GUARD_6 pG_6
				PlaceC LAEN_GUARD_7 pG_7
				PlaceC LAEN_GUARD_8 pG_8
			ENDIF
		ELSE
			RemoveC LAEN
			RemoveC CANDICE5
			RemoveC LAEN_GUARD_5
			RemoveC LAEN_GUARD_6
			RemoveC LAEN_GUARD_7
			RemoveC LAEN_GUARD_8
		ENDIF
		IF gt_DONE_MIRES_PIT
			KillC  LAEN_GUARD_1
			KillC  LAEN_GUARD_2
			KillC  LAEN_GUARD_3
			KillC  LAEN_GUARD_4
		ENDIF
	ENDIF

	Add gt_CUE_MELTDOWN

END

VIG TempSetup FALSE

	//AddBigFire 13599 20688 outdoor fire not appropriate
	AddBigFire 1416 2712
	//PlaceBeehive 11770 3571 1500
	SetLiquid ALL 80 20 5
	SetWaterType 0

	IF gd_PLACED_ALLIS_AND_PLAYER
		RunS AndrusWeather
		Set gd_WIND_TYPE	1
		RunS CueWeather
	ENDIF
	//IF mj_BEEN_TO_HEX && !mj_DEFEAT_GARGOS_1
	//	SwapObj boat fish
	//ENDIF

	CachePortrait ALLIS.BIN
	CachePortrait PC1.BIN
	CachePortrait BRIGAND1.BIN

END

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

VIG Meltdown FIVESEC && gt_CUE_MELTDOWN

	Remove gt_CUE_MELTDOWN

	IF ISINSHOP-HAMM_SHOP-diingot
		DelStock HAMM_SHOP diingot
	ENDIF
	IF ISINSHOP-HAMM_SHOP-gem
		DelStock HAMM_SHOP gem
	ENDIF
	IF ISINSHOP-HAMM_SHOP-knife
		DelStock HAMM_SHOP knife
		DelStock HAMM_SHOP knife
		Stock HAMM_SHOP knife 2
	ENDIF
	IF ISINSHOP-HAMM_SHOP-shortsword
		DelStock HAMM_SHOP shortsword
		DelStock HAMM_SHOP shortsword
		Stock HAMM_SHOP shortsword 2
	ENDIF
	IF ISINSHOP-HAMM_SHOP-longsword
		DelStock HAMM_SHOP longsword
		DelStock HAMM_SHOP longsword
		Stock HAMM_SHOP longsword 2
	ENDIF
	IF ISINSHOP-HAMM_SHOP-bow
		DelStock HAMM_SHOP bow
		DelStock HAMM_SHOP bow
		Stock HAMM_SHOP bow 2
	ENDIF
	IF ISINSHOP-HAMM_SHOP-arrow
		DelStock HAMM_SHOP arrow
		DelStock HAMM_SHOP arrow
		Stock HAMM_SHOP arrow 25
	ENDIF
	IF ISINSHOP-HAMM_SHOP-spear
		DelStock HAMM_SHOP spear
		DelStock HAMM_SHOP spear
		Stock HAMM_SHOP spear 2
	ENDIF
	IF ISINSHOP-HAMM_SHOP-club
		DelStock HAMM_SHOP club
		DelStock HAMM_SHOP club
		Stock HAMM_SHOP club 2
	ENDIF
	IF ISINSHOP-HAMM_SHOP-ar_ltr_am_vamb
		DelStock HAMM_SHOP ar_ltr_am_vamb
		DelStock HAMM_SHOP ar_ltr_am_vamb
		Stock HAMM_SHOP ar_ltr_am_vamb 2
	ENDIF
	IF ISINSHOP-HAMM_SHOP-ar_ltr_hn_cure
		DelStock HAMM_SHOP ar_ltr_hn_cure
		DelStock HAMM_SHOP ar_ltr_hn_cure
		Stock HAMM_SHOP ar_ltr_hn_cure 2
	ENDIF
	IF ISINSHOP-HAMM_SHOP-ar_ltr_hn_glov
		DelStock HAMM_SHOP ar_ltr_hn_glov
		DelStock HAMM_SHOP ar_ltr_hn_cure
		Stock HAMM_SHOP ar_ltr_hn_glov 2
	ENDIF
	IF ISINSHOP-HAMM_SHOP-ar_ltr_ft_soft
		DelStock HAMM_SHOP ar_ltr_ft_soft
		DelStock HAMM_SHOP ar_ltr_ft_soft
		Stock HAMM_SHOP ar_ltr_ft_soft 2
	ENDIF
	IF ISINSHOP-HAMM_SHOP-ar_ltr_ft_hard
		DelStock HAMM_SHOP ar_ltr_ft_hard
		DelStock HAMM_SHOP ar_ltr_ft_hard
		Stock HAMM_SHOP ar_ltr_ft_hard 2
	ENDIF
	IF ISINSHOP-HAMM_SHOP-ar_ltr_hd_hood
		DelStock HAMM_SHOP ar_ltr_hd_hood
		DelStock HAMM_SHOP ar_ltr_hd_hood
		Stock HAMM_SHOP ar_ltr_hd_hood 2
	ENDIF
	IF ISINSHOP-HAMM_SHOP-ar_ltr_hd_cap
		DelStock HAMM_SHOP ar_ltr_hd_cap
		DelStock HAMM_SHOP ar_ltr_hd_cap
		Stock HAMM_SHOP ar_ltr_hd_cap 2
	ENDIF
	IF ISINSHOP-HAMM_SHOP-ar_ltr_cl_smpl
		DelStock HAMM_SHOP ar_ltr_cl_smpl
		DelStock HAMM_SHOP ar_ltr_cl_smpl
		Stock HAMM_SHOP ar_ltr_cl_smpl 2
	ENDIF
	IF ISINSHOP-HAMM_SHOP-ar_ltr_bd_jkn
		DelStock HAMM_SHOP ar_ltr_bd_jkn
		DelStock HAMM_SHOP ar_ltr_bd_jkn
		Stock HAMM_SHOP ar_ltr_bd_jkn 2
	ENDIF
	IF ISINSHOP-HAMM_SHOP-ar_ltr_bd_cure
		DelStock HAMM_SHOP ar_ltr_bd_cure
		DelStock HAMM_SHOP ar_ltr_bd_cure
		Stock HAMM_SHOP ar_ltr_bd_cure 2
	ENDIF
	IF ISINSHOP-HAMM_SHOP-ar_chn_bd_vest
		DelStock HAMM_SHOP ar_chn_bd_vest
		DelStock HAMM_SHOP ar_chn_bd_vest
		Stock HAMM_SHOP ar_chn_bd_vest 2
	ENDIF
	IF ISINSHOP-HAMM_SHOP-ar_ltr_lg_pant
		DelStock HAMM_SHOP ar_ltr_lg_pant
		DelStock HAMM_SHOP ar_ltr_lg_pant
		Stock HAMM_SHOP ar_ltr_lg_pant 2
	ENDIF



END

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

VIG TalkToMadFarmer_2 MSG-iMAD_FARMER_2

	Widescreen TRUE
	StopC MAD_FARMER_2
	EngageAndFace P MAD_FARMER_2

	IF mj_DEFEAT_GARGOS_2
		Say fam204 farmerm1.bin
	ELSE
		//"Good day to you. You're well, I hope?"
		IF LANG-English || LANG-German
			Say fa8001 FARMERM1.BIN
		ELSE
			Say fa1003 farmerm1.bin
		ENDIF
	ENDIF
	Wander MAD_FARMER_2
	widescreen FALSE

END

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

VIG ReturnToMadrigal  ONESEC && gd_USED_FERRY
    Remove  gd_USED_FERRY

    RunS PalFadeRPG
	Say     ah2003

    PlayerControl   On
   	MoveC_1tel		ALLIS			ER_ALLIS_HUT_OUT			pALLIS_IN_HUT 
	Widescreen FALSE

END

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

VIG ErivFerryVig !gd_PLAYED_INTRO && gg_PLAY_INTRO
	Add gd_PLAYED_INTRO

	Widescreen TRUE

	// *** PERFORM FADE UP AT START OF GAME ***

	//HideWorld	TRUE
	Fade 100 0
	Wait 500
camcut pos100
	
	// *** START FERRY VIGNETTE ***


    // *** On ferry ***

	//"Wake up, sir!"
	QuickSay ah0001
	Wait 500
	//HideWorld	FALSE
	RunS QPalFadeRPG
	UUSay

	PlayMusic Rpg11.wav

	LookAtTurn P ALLIS
	Wait 500
	//"...strangest dream..."
	Say Hx0001

    MoveCDir        P               pP_POINT
    UUComplete      P

	CueSnow 4 50

    Capture         P               cM_POINT
	//"Is this it, ferryman?"
    Say             Hx0002

    LookAtTurn      ALLIS           P
	UUComplete		ALLIS

    Capture         ALLIS           cM_TALK_AGREE1
	//"Aye, sir: Madrigal."
    QuickSay		ah001a
    UUComplete      ALLIS

	// *** Get off boat ***

    MoveC	        ALLIS           pALLIS_JUMP
	UUComplete		ALLIS

	//adjust this delay so the player arrives at pP_TALK just before Allis gets to pALLIS_TALK
	//(only needed if anything changes with character controllers)
	Wait 2000

    Capture         P               cM_V1_STRIDE_JETTY3_JUMP
    UUComplete      P

    MoveC			P               pP_TALK
	UUComplete      ALLIS

    MoveC			ALLIS           pALLIS_TALK
	UUComplete		P

	setcammoveconstant 5
	campan chat

    // *** Talk on jetty ***

	//"...I'm looking for...Andrus."
	UUSay
    QuickSay        Hx0004
    LookAtTurn      P               pALLIS_TALK
	UUComplete		ALLIS

	LookAtTurn		ALLIS			P
	UUComplete		ALLIS

    UUSay

	Capture         ALLIS           cM_TALK_AGREE2
	//"Aye...not one for visitors though"
    Say             ah0002

    UUComplete      ALLIS

	//"I have news for him from Kalaran."
    Say             Hx0005

	// *** Pay ferryman ***

    Capture         ALLIS           cM_TIP_HAT
	Wait 30
    Capture         P               cM_TOSS_GENTLE
    UUComplete      P

	Gold-			P	1
    UUComplete      ALLIS

	camcut jetty04 
	//"...river's freezing..."
    QuickSay             ah003a
	Wait 3750

    Capture         ALLIS           cM_TALK_REFER_LEFT1
    UUComplete      ALLIS

	UUSay

	// *** Pay another coin ***

    Capture         ALLIS           cM_TIP_HAT
	Wait 30
    Capture         P               cM_TOSS_GENTLE
	//"...So where can I find Andrus?"
    QuickSay		Hx0006

    UUComplete      P

	Gold-			P	1
    UUComplete      ALLIS

	UUSay

	//"...you have a map?"
	Say ah0004

	//"I have a map..."
	Say Hx0007

	//"Let's have a look then."
	Say ah004a

	Capture P cM_TOSS_GENTLE
	Capture ALLIS cM_OBJ_ACCEPT_1H1
	UUComplete ALLIS
//	DeleteObjectsInBackpackWithID P mad_map

	//"...I've marked your map...follow the road north...can't miss it."
    Say             ah004b

	Capture ALLIS cM_TOSS_GENTLE
	Capture P cM_OBJ_ACCEPT_1H1

	camcut chat	
	//"Thanks...I had best be going..."
	QuickSay		Hx007a
	UUComplete ALLIS
//	AwardOb P mad_map "map-again"
//	Identify mad_map
	UUSay

	LookAtTurn ALLIS pP_END
	//"My name's Allis...do me a favour?"
	Say		ah004c
	ChangeProfileToIdentified Mcitizen_AllisHam

	LookAtTurn P pP_END

	//"What is it?"
	Say Hx007b

	//"...brigands...here's the key to my shack...I'll give you this small trinket..."
	QuickSay ah004d

	LookAtTurn P ALLIS
	LookAtTurn ALLIS P
	Wait 5000
	Capture ALLIS cM_TOSS_GENTLE
	Capture P cM_OBJ_ACCEPT_1H1
	UUComplete P
	AwardOb P allis_key "key-to-allis-hut"
//	AwardOb P wand_fireball "tempfballwand"
	QLAdd ql001 qlt001 qlb001
	QLAdd ql002 qlt002 qlb002
	UUSay

    // *** Player walks away ***

	setcammovenormal
	camcut p 90
//PhotoOn
    PlayerControl   off
    CamCentre		P
    MoveC	        P               pP_END
	

    Wait            500

	MoveC_1tel		ALLIS			ER_ALLIS_HUT_OUT			pALLIS_IN_HUT 
    UUComplete      P
    UUComplete      Allis
//PhotoOff
    RdoorClosed     dallis
    UUdoorStill     dallis
    IdoorLocked     dallis
    Add             gd_ALLIS_LOCKED_DOOR

	Widescreen FALSE
    PlayerControl   on

	Set	gd_WEATHER_TYPE	0
	Set gd_WIND_TYPE	1

END

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

VIG ErivBrigand2Attack gd_PLACED_ER_BRIGAND_2 && !gt_PLAYED_ER_BRIGAND_2 && gg_BrigSeesPlayer && !ISDEAD-ER_BRIG_2
	Add			gt_PLAYED_ER_BRIGAND_2
	UnimportantSay    br011b ER_BRIG_2
END

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

VIG ErivSpiderRun ONESEC && !gd_SPIDER_RUN && !ISDEAD-ER_SPIDER_2 && (INAREA-P-Spider || DAMAGED-ER_SPIDER_2 || DISTFROM-P-ER_SPIDER_2-24) 

	ClearDamaged ER_SPIDER_2
	Add     gd_SPIDER_RUN
	MoveC   ER_SPIDER_2 pE3_SPIDER_RUN
END

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

VIG ErivSpiderAtCave ONESEC && gd_SPIDER_RUN && !gd_MOVED_SPIDER && (INAREA-P-er_near_cave || DAMAGED-ER_SPIDER_2) && !ISDEAD-ER_SPIDER_2
	Add     gd_MOVED_SPIDER
	MoveC   ER_SPIDER_2 pER_SPIDER_2
END

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

VIG RemoveSpider gd_MOVED_SPIDER && !gd_REMOVED_SPIDER && CC-ER_SPIDER_2 && !ISDEAD-ER_SPIDER_2
	RemoveC ER_SPIDER_2
	Add gd_REMOVED_SPIDER 
	Remove  gd_PLACED_ER_SPIDER
END

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

VIG AllisBellRing FALSE

	//ring bell SFX
	PlaySFXPerson IG_52.WAV P

END

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

VIG ErivRingAllisBell   MSG-iALLISBELL

    TDCapture       P cM_RING_BELL2   pRING_BELL 120 9 notifies 3 150 AllisBellRing 190 AllisBellRing 230 AllisBellRing
	AddControl      P SetScriptFlagControl    gg_RUNG_ALLIS_BELL

END

VIG RungAllisBell gg_RUNG_ALLIS_BELL
	Remove gg_RUNG_ALLIS_BELL

    IF mj_SLEPT_AT_ANDRUS && INAREA-ALLIS-er_allis_hut
		IF !ISDEAD-ER_BRIG_2
			//"You haven't driven off the brigand yet! There's no way I'm going outside..."
			Say ah005a
		ELSE
			//"Alright, alright. I'm coming..."
			Say             ah025i
			MoveC_1tel      ALLIS   ER_ALLIS_HUT_IN   pALLIS_END
			UUComplete      ALLIS
			MoveC           ALLIS   pALLIS_BELL
			UUComplete      ALLIS
			LookAtTurn      P       ALLIS
			UUComplete      ALLIS
			LookAtTurn      ALLIS   P
			UUComplete      ALLIS
			// start a conversation?
			PostMsg         i_ALLIS
		ENDIF
    ENDIF
END

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

VIG ErivAllisDoor gd_ALLIS_LOCKED_DOOR && MSG-c_o_dALLIS
    IF !gd_ALLIS_TALKED_1
		//"Go away, brigand. The only person who's going to come in here already has a key!"
        Say ah0005
        Add gd_ALLIS_TALKED_1
    ENDIF
END

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

VIG TalkToAllis MSG-iALLIS

	UnDrawSwordRemember
	Widescreen TRUE
	EngageAndFace P ALLIS

	IF mj_DEFEAT_BART
		Say ah0061
	ELSE

		IF !ISDEAD-ER_BRIG_2
			//"You haven't driven off the brigand yet! There's no way I'm going outside..."
			Say ah005a
		ELSE
			IF !gt_ALLIS_GIVEN_RUNE_OF_KNIVES
				Add gt_ALLIS_GIVEN_RUNE_OF_KNIVES
				QLRemove ql001
				AwardEP xp_ALLIS_BRIGAND
				//"Thank you...this is something I found..."
				Say ah005b
				UUComplete P
				Capture ALLIS cM_TOSS_GENTLE
				Capture P cM_OBJ_ACCEPT_1H1
				UUComplete P
				AwardOb P knives_rune "an-flashy-magical-item"
				//"...the sewers under Madrigal..."
				Say ah005c
			ELSE
				IF !mj_SLEPT_AT_ANDRUS
					//"Thank you for helping me out..."
					Say ah005d
				ELSE
					// *** Select a greeting ***
					IF mj_BEEN_TO_HEX
						IF mj_DEFEAT_GARGOS_2 && !co_ALKADATH && !mj_RECOVER_CROWN
							//"News spreads quick, my lord, about you...come to save us all..."
							Say ah0034
							//"...Dragon Soldiers arrived... their captain's called Al'Kadath..."
							Say ah0042
							Add co_ALKADATH
						ELSE
							IF  f_USED_FERRY
	    						Say ah2004
							ELSE
    							Say ah0022
							ENDIF
						ENDIF
					ELSE
						Say ah0011
					ENDIF

					ResetChoice
					WHILE !MenuExit
						ClearChoices
						IF co_ALKADATH
							AddChoice 5 tx0118
						ENDIF
						IF mj_BEEN_TO_HEX
							AddChoice       3 tx8900
							IF !mj_DEFEAT_GARGOS_2
								AddChoice       4 tx8901
							ENDIF
						ELSE
    						IF co_JAKE && !f_JAKE_DEAD
    							AddChoice 1 tx0019
    						ENDIF
						ENDIF
						IF f_USED_FERRY
    						AddChoice 2 txah02
						ELSE
       						AddChoice 2 tx0002
						ENDIF
						AddChoice 0 tx0003

						GetChoice ALLIS

						SWITCH CHOICE
							CASE 1
								// *** Jake ***
								Say ah0014
							CASE 2
								// *** Ferry ***
								IF mj_BEEN_TO_HEX && mj_DEFEAT_GARGOS_1
									IF f_USED_FERRY
										Say ah2005
									ELSE
										Say ah0028

									ENDIF
									UUComplete P

									IF  INAREA-ALLIS-er_allis_hut
										MoveC_1tel      ALLIS   ER_ALLIS_HUT_IN     pALLIS_START
										MoveC_1tel      P       ER_ALLIS_HUT_IN     pP_START
									ELSE
										MoveC      ALLIS   pALLIS_START
										MoveC      P       pP_START
									ENDIF
									
									UUComplete P
									UUComplete ALLIS

									RunS PalFadeBLACK

									Add gd_USED_FERRY

									PostMsg t_CT_JETTY

    								SetChoiceToExit
								ELSE
									Say ah0021
								ENDIF
							CASE 0
								// *** Leave ***
								IF f_ANDRUS_DEAD
    								Say ah031a
								ELSE
    								Say ah025a
								ENDIF
								IF !INAREA-ALLIS-er_allis_hut
									// ** Return to Hut.
                					MoveC_1tel		ALLIS			ER_ALLIS_HUT_OUT			pALLIS_IN_HUT 
								ENDIF
							CASE 3
								// *** Barthelago ***
								IF mj_DEFEAT_GARGOS_2
									Say ah0040
								ELSE
									Say ah030a
								ENDIF
							CASE 4
								// *** Chant ***
								Say ah030b
							CASE 5
								// *** Al'Kadath ***
								Say ah0042
						ENDSWITCH
					ENDWHILE
				ENDIF
			ENDIF
		ENDIF
	ENDIF
	Widescreen FALSE
//	DrawSwordRemember
END

/////////////////////////////////////////////////////////////////////
// HAMMER MAKING ITEMS
/////////////////////////////////////////////////////////////////////

VIG HammerMakes_1 FIVESEC && !gt_HAMMER_MADE_1 && mj_HEX_COMPASS

	Add gt_HAMMER_MADE_1
	Stock	HAMM_SHOP ar_ltr_hn_stud 1
	Stock	HAMM_SHOP sl_arrow 5

END

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

VIG HammerMakes_2 FIVESEC && !gt_HAMMER_MADE_2 && f_JAKE_DEAD

	Add gt_HAMMER_MADE_2
	Stock	HAMM_SHOP ar_plt_hd_merc 1
	ReStock	HAMM_SHOP sl_arrow 10
	Stock	HAMM_SHOP ap_arrow 5

END

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

VIG HammerMakes_3 FIVESEC && !gt_HAMMER_MADE_3 && gd_PLACED_RC_MONSTERS

	Add gt_HAMMER_MADE_3
	ReStock	HAMM_SHOP sl_arrow 10
	ReStock	HAMM_SHOP ap_arrow 10
	Stock	HAMM_SHOP ex_arrow 5

END

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

VIG HammerMakes_4 FIVESEC && !gt_HAMMER_MADE_4 && gd_SHADOWS_ARRIVED

	Add gt_HAMMER_MADE_4
	Stock	HAMM_SHOP ar_plt_hd_str 1
	ReStock	HAMM_SHOP ex_arrow 10

END

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

VIG HammerAnvilDing FALSE

	//anvil ding SFX
	PlaySFXPosid IG_65.WAV pANVIL

END

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

VIG HammerForgeHiss FALSE

	//forge hiss SFX
	PlaySFXPosid IG_68.WAV pFIRE

	FX_YellowFire 2432 27520

END

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

VIG HammerActions FALSE

	//old values
	TDCapture	HAMMER				cM_HAMMER_ANVIL		pANVIL	220	9 notifies 3 220 HammerAnvilDing 350 HammerAnvilDing 500 HammerAnvilDing
	//new values
	//TDCapture	HAMMER				cM_HAMMER_ANVIL		pANVIL	220	9 notifies 3 250 HammerAnvilDing 380 HammerAnvilDing 530 HammerAnvilDing

	AddControl	HAMMER	TDCapture	cM_PLUNGE_SHOE		pFIRE	295 9 notify 295 HammerForgeHiss
	SequenceRandomlySelects HAMMER

END

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

VIG TalkToHammer MSG-iHAMMER

	Widescreen TRUE
	UnDrawSwordRemember
	EngageAndFace P HAMMER
	UUComplete P

	IF mj_DEFEAT_BART

		Say ha075a HAMMER.BIN

	ELSE
		IF !mj_BEEN_TO_HEX
			IF  !ce_HAMMER
				Say     ha0001 HAMMER.BIN
				Say     ha001d HAMMER.BIN
				Add     ce_HAMMER
				ChangeProfileToIdentified Mcitizen_Hammer
			ELSE
				Say     ha003a HAMMER.BIN
			ENDIF
		ELSE
			IF mj_DEFEAT_AL && !gt_HAA401

				Add gt_HAA401 HAMMER.BIN

				//"...You've done a fine job...killing Al'Kadath."
				Say haa401 HAMMER.BIN

			ELSE

				IF mj_DEFEAT_GARGOS_2 && !gt_HAMMER_STAGE_3_INTRO
					Add gt_HAMMER_STAGE_3_INTRO
					Say ha0028 HAMMER.BIN
					Add co_RAINBOWROCK
				ELSE
					IF f_USED_FERRY
						IF mj_DEFEAT_GARGOS_2
							Say     ha2001 HAMMER.BIN
						ELSE
							Say     ha2001 HAMMER.BIN
						ENDIF
					ELSE
						IF !gt_HA138A
							Add gt_HA138A
							Say ha138a HAMMER.BIN

							Capture HAMMER cM_TOSS_GENTLE
							Capture P cM_OBJ_ACCEPT_1H1
							UUComplete P

							AwardOb P demonpapers3 wahoo
							Add co_SHADOWGUARD
							Add co_THEGUILD
						ELSE
							Say ha003a HAMMER.BIN
						ENDIF
					ENDIF
				ENDIF
			ENDIF
		ENDIF

		REM *** Interactions ***

		ResetChoice
		WHILE !MenuExit
			ClearChoices

			IF !f_USED_FERRY
				// Work
				AddChoice 1 tx0004
			ENDIF
        
			// Shadowguard
			IF mj_BEEN_TO_HEX
				AddChoice 7 txh001
			ENDIF

			IF mj_DEFEAT_GARGOS_2
				IF !mj_RECOVER_CROWN
					//Dragon Soldiers
					AddChoice 13 tx0117
				ENDIF

				//Thardolin
				AddChoice 14 tx0120

				IF gt_ASKED_HAMMER_ABOUT_DRAGON_SOLDIERS
					IF !mj_RECOVER_CROWN
						//Al'Kadath
						AddChoice 15 tx0118
					ENDIF
					//Cerebella
					AddChoice 16 tx0x21
					//The Pact
					AddChoice 17 tx0x22
				ENDIF
			ELSE
				IF f_USED_FERRY
					IF co_LORDBANE
						AddChoice   8   txh202
					ENDIF

					IF co_LORDCRUX
						AddChoice   10   txpw06
					ENDIF

					IF co_LIGHTSTEALER
						AddChoice   11   txpw07
					ENDIF

					IF co_BLOODMASTER
						AddChoice   12   txpw08
					ENDIF
				ELSE
					// Diamond Iron
					IF gd_TALKED_HAM_DIAMOND_IRON
						// Diamond Iron
						AddChoice 2 tx0027
					ENDIF

					IF co_TEMPLE_OF_SHADOWS && !mj_FOUND_TOME
						// Temple
						AddChoice 3 tx0015
					ENDIF
				ENDIF
				// Anvil Of Horath
				IF mj_HEX_COMPASS && co_ANVIL_OF_HORATH
					AddChoice 6 tx0056
				ENDIF
			ENDIF

			// Trade
			AddChoice 4 tx0008

			// Repair
			AddChoice 5 tx0086

			//Identify
			AddChoice 18 txid01

			IF POS-P-powders_mtl
				AddChoice   9   txh203
			ENDIF

			// Exit
			AddChoice 0 tx0003

			GetChoice HAMMER

			SWITCH CHOICE
				CASE 1
					// *** Work ***
					IF mj_DEFEAT_GARGOS_2
						Say     ha0010 HAMMER.BIN
					ELSE
						Say     ha0010 HAMMER.BIN
					ENDIF
					IF !gd_TALKED_HAM_DIAMOND_IRON
						Add gd_TALKED_HAM_DIAMOND_IRON
						// DIAMON IRON CHOICE BECOMES AVAILABLE
						AddChoice 2 tx0027
						QLAdd ql009 qlt009 qlb009
					ENDIF
				CASE 2
					// *** DIAMOND IRON ***
					IF mj_DEFEAT_GARGOS_2
						Say     ha010d HAMMER.BIN
					ELSE
						Say     ha010d HAMMER.BIN
					ENDIF
				CASE 3
					// *** TEMPLE OF SHADOWS ***
					IF mj_DEFEAT_GARGOS_2
						Say     ha0015 HAMMER.BIN
						Say     ha015a HAMMER.BIN
					ELSE
						Say     ha0015 HAMMER.BIN
						Say     ha015a HAMMER.BIN
					ENDIF
				CASE 4
					// *** Trade ***
					MessagesOff
					ShopPanel	HAMM_SHOP	100		65		HAMMER			BUYSELL
					MessagesOn

					IF ISINSHOP-HAMM_SHOP-diingot && !gt_IRON_QUEST && gd_TALKED_HAM_DIAMOND_IRON
						Add gt_IRON_QUEST
						AwardEP xp_IRON_QUEST
						QLRemove ql009
					ENDIF
				
				CASE 5
					// *** Repair ***
					MessagesOff
					ShopPanel	HAMM_SHOP	100		100		HAMMER			REPAIR
					MessagesOn
				
				CASE 6
					// *** Anvil of Horath ***
					IF mj_DEFEAT_GARGOS_2
						Say     ha1031 HAMMER.BIN
					ELSE
						Say     ha1031 HAMMER.BIN
					ENDIF
				CASE 7
					// *** Shadowguard ***
					IF f_USED_FERRY
						IF mj_DEFEAT_GARGOS_2
							Say     ha2002 HAMMER.BIN
						ELSE
							Say     ha2002 HAMMER.BIN
						ENDIF
						IF !co_LORDBANE
							Add co_LORDBANE
						ENDIF
					ELSE
						IF mj_DEFEAT_GARGOS_2
							Say     ha138b HAMMER.BIN
						ELSE
							Say     ha138b HAMMER.BIN
						ENDIF
					ENDIF
				CASE 8
					// *** Blood-Kin ***
					IF mj_DEFEAT_GARGOS_2
						Say     ha2003 HAMMER.BIN
					ELSE
						Say     ha2003 HAMMER.BIN
					ENDIF
				CASE 9

					Capture     HAMMER  cM_OBJ_ACCEPT_1H1
					Capture     P       cM_TOSS_GENTLE
					UUComplete  HAMMER
					DeleteObjectsInBackpackWithID P powders_mtl

					// *** Give Hammer Powder's metal ***
					Capture     HAMMER  cM_OBJ_EXAMINE_SMALL1
					Wait        1000
					IF mj_DEFEAT_GARGOS_2
						Say     ha2004 HAMMER.BIN
					ELSE
						Say     ha2004 HAMMER.BIN
					ENDIF

					LookAtTurnFollow P HAMMER

					UUComplete  HAMMER
					//old values
					TDCapture	HAMMER				cM_HAMMER_ANVIL		pANVIL	220	9 notifies 3 220 HammerAnvilDing 350 HammerAnvilDing 500 HammerAnvilDing
					//new values
					//TDCapture	HAMMER				cM_HAMMER_ANVIL		pANVIL	220	9 notifies 3 250 HammerAnvilDing 380 HammerAnvilDing 530 HammerAnvilDing
					UUComplete  HAMMER
					TDCapture	HAMMER				cM_HAMMER_ANVIL		pANVIL	220	9 notifies 3 220 HammerAnvilDing 350 HammerAnvilDing 500 HammerAnvilDing
					UUComplete  HAMMER

					IF mj_DEFEAT_GARGOS_2
						Say     ha2005 HAMMER.BIN
					ELSE
						Say     ha2005 HAMMER.BIN
					ENDIF

					// give vambraces to player.
					LookAtTurnFollow HAMMER P
					Wait 750
					Capture     HAMMER  cM_TOSS_GENTLE
					Capture     P       cM_OBJ_ACCEPT_1H1

					UUComplete  P
					AwardOb     P       ar_plt_am_shny          "Magic Vambrace"
					AwardEP xp_HAMMER_METALWORK
				CASE 10
					// *** Lord Crux ***
					IF mj_DEFEAT_GARGOS_2
						Say     ha2006 HAMMER.BIN
					ELSE
						Say     ha2006 HAMMER.BIN
					ENDIF
				CASE 11
					// *** Lightstealer ***
					IF mj_DEFEAT_GARGOS_2
						Say     ha2007 HAMMER.BIN
					ELSE
						Say     ha2007 HAMMER.BIN
					ENDIF
				CASE 12
					// *** Bloodmaster ***
					IF mj_DEFEAT_GARGOS_2
						Say     ha2008 HAMMER.BIN
					ELSE
						Say     ha2008 HAMMER.BIN
					ENDIF
					Add co_RAINBOWROCK
				CASE 13
					// *** Dragon soldiers ***
					IF mj_DEFEAT_GARGOS_2
						Say     ha0039 HAMMER.BIN
					ELSE
						Say     ha0039 HAMMER.BIN
					ENDIF
					Add gt_ASKED_HAMMER_ABOUT_DRAGON_SOLDIERS
				CASE 14
					// *** Thardolin ***
					IF mj_DEFEAT_GARGOS_2
						Say     ha0040 HAMMER.BIN
					ELSE
						Say     ha0040 HAMMER.BIN
					ENDIF
				CASE 15
					// *** Al'Kadath ***
					IF mj_DEFEAT_GARGOS_2
						Say     ha034d HAMMER.BIN
					ELSE
						Say     ha034d HAMMER.BIN
					ENDIF
				CASE 16
					// *** Cerebella ***
					IF mj_DEFEAT_GARGOS_2
						Say     ha040a HAMMER.BIN
					ELSE
						Say     ha040a HAMMER.BIN
					ENDIF
				CASE 17
					// *** The Pact ***
					IF mj_DEFEAT_GARGOS_2
						Say     ha0037 HAMMER.BIN
					ELSE
						Say     ha0037 HAMMER.BIN
					ENDIF
				CASE 18
					//Identify

					MessagesOff
					ShopPanel	HAMM_SHOP	100		65		HAMMER			IDENTIFY
					MessagesOn

				CASE 0
					// *** Leave ***
					IF f_USED_FERRY
						IF mj_DEFEAT_GARGOS_2
							Say     ha2009 HAMMER.BIN
						ELSE
							Say     ha2009 HAMMER.BIN
						ENDIF
					ELSE
						IF mj_DEFEAT_GARGOS_2
							Say     ha0024 HAMMER.BIN
						ELSE
							Say     ha0024 HAMMER.BIN
						ENDIF
					ENDIF
			ENDSWITCH
		ENDWHILE

		RunS HammerActions
	ENDIF
	Widescreen FALSE
//	DrawSwordRemember
END

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

VIG TalkToLaenGuard MSG-iLAEN_GUARD_1 || MSG-LAEN_GUARD_2 || MSG-LAEN_GUARD_3 || MSG-LAEN_GUARD_4 || MSG-LAEN_GUARD_5 || MSG-LAEN_GUARD_6 || MSG-LAEN_GUARD_7 || MSG-LAEN_GUARD_8

	//"We stand with you Light Bringer..."
	QuickSay bk0102 CREDO.BIN

END

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

VIG MeetChant (MSG-iLAEN || MSG-iCANDICE5) && !gt_BLOODKIN_ARMY_IN_MADRIGAL

	Widescreen TRUE

	MoveCDir P pTALK_LAEN
	LookAtTurnFollow CANDICE5 P
	LookAtTurnFollow LAEN P

	//"...We left...as soon as we heard..."
	Say daer01
	//"...Barthelago returned...he killed your sister. He killed Renya."
	Say hxer20

	MoveCDir LAEN pLAEN_RIVER
	LookAtTurnFollow CANDICE5 LAEN
	Wait 750
	Capture CANDICE5 cF_OBJ_ACCEPT_1H1
	UUComplete LAEN

	Wait 3000
	LookAtTurn LAEN P

	//"Then...to Galdon Thor...against the Revenants."
	Say daer02

	LookAtTurn CANDICE5 P

	//"...we are to fight after all..."
	Say nd0010 CANDICE5.BIN

	LookAtTurn CANDICE5 P

	//"We shall be at Chant's shack..."
	Say nd0011 CANDICE5.BIN

	MoveC_1tel CANDICE5 ER_SOUTH_ARCH pDEMO2
	Wait 1000
	MoveC_1tel LAEN ER_SOUTH_ARCH pDEMO1
	Wait 2500

	EngagePoint LAEN_GUARD_1 pP_END 1000
	EngagePoint LAEN_GUARD_2 pER_BRIG_FIRE  1000
	EngagePoint LAEN_GUARD_3 pE3_SPIDER_RUN 1000
	EngagePoint LAEN_GUARD_4 pP_KNOCK_HAMMER 1000
	AddControl LAEN_GUARD_1 Wander
	AddControl LAEN_GUARD_2 Wander
	AddControl LAEN_GUARD_3 Wander
	AddControl LAEN_GUARD_4 Wander
	Wait 2500
	MoveC_1tel LAEN_GUARD_5 ER_SOUTH_ARCH pSS_DRAGON_1
	MoveC_1tel LAEN_GUARD_6 ER_SOUTH_ARCH pSS_DRAGON_2
	MoveC_1tel LAEN_GUARD_7 ER_SOUTH_ARCH pSS_BRIG_1_START
	MoveC_1tel LAEN_GUARD_8 ER_SOUTH_ARCH pSS_BRIG_2_START

	Add gt_BLOODKIN_ARMY_IN_MADRIGAL

	Widescreen FALSE

END

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




