/////////////////////////////////////////////////////////////////////
// EFENS.S
/////////////////////////////////////////////////////////////////////

SETUP
	
	IF !gt_PLACED_EFENS_CHARS
		Add gt_PLACED_EFENS_CHARS

		PlaceFrog pEXIT
		PlaceFrog pVAN_11
		PlaceFrog pRENYA
		PlaceFrog pWITCH

		PlaceC DEAD_CREDO pDEAD_CREDO mcap
		PlaceC EF_SPIDER_1 pSPIDER_1
		PlaceC EF_SPIDER_2 pSPIDER_2
		PlaceC EF_SPIDER_3 pSPIDER_3
		PlaceC EF_SPIDER_4 pSPIDER_4
		WanderNotFar			EF_SPIDER_1 2 5
		SwitchOnSightOfPlayer	EF_SPIDER_1 AttackDemo2
		WanderNotFar			EF_SPIDER_2 2 5
		SwitchOnSightOfPlayer	EF_SPIDER_2 AttackDemo2
		WanderNotFar			EF_SPIDER_3 2 5
		SwitchOnSightOfPlayer	EF_SPIDER_3 AttackDemo2
		WanderNotFar			EF_SPIDER_4 2 5
		SwitchOnSightOfPlayer	EF_SPIDER_4 AttackDemo2

		PlaceC EF_EVIL_01 p01
		PlaceC EF_EVIL_02 p02
		PlaceC EF_EVIL_03 p03
		PlaceC EF_EVIL_04 p04
		PlaceC EF_EVIL_05 p05
		PlaceC EF_EVIL_06 p06
		PlaceC EF_EVIL_07 p07
		PlaceC EF_EVIL_08 p08
		PlaceC LORDBANE pBANE
		PlaceC BANE_GUARD1 p1
		PlaceC BANE_GUARD2 p2
		PlaceC BANE_GUARD3 p3
		PlaceC BANE_GUARD4 p4
		MeleeAttackBLands EF_EVIL_01
		MeleeAttackBLands EF_EVIL_02
		MeleeAttackBLands EF_EVIL_03
		MeleeAttackBLands EF_EVIL_04
		MeleeAttackBLands EF_EVIL_05
		MeleeAttackBLands EF_EVIL_06
		MeleeAttackBLands EF_EVIL_07
		MeleeAttackBLands EF_EVIL_08
		MeleeAttack LORDBANE
		MeleeAttack BANE_GUARD1
		MeleeAttack BANE_GUARD2
		MeleeAttack BANE_GUARD3
		MeleeAttack BANE_GUARD4

		Add gt_PLAY_FIGHT
		RunS PlayNicelyNow

		PlaceC					EF_EVIL_09 pRENYA
		Wander					EF_EVIL_09
		SwitchOnSightOfPlayer	EF_EVIL_09 AttackDemo2
		PlaceC					EF_EVIL_10 pWITCH
		Wander					EF_EVIL_10
		SwitchOnSightOfPlayer	EF_EVIL_10 AttackDemo2
	ENDIF

	IF mj_FOUND_BLOODMASTER
		IF !gt_PLACED_THARD_VAN_11
			Add gt_PLACED_THARD_VAN_11

			PlaceC THARD_VAN_11 pVAN_11
			Filter THARD_VAN_11 Timeout 10 MoveC pVAN_11
			AddControl THARD_VAN_11 Filter Timeout 20 Wander
			SequenceLoops THARD_VAN_11
			SwitchOnSightOfPlayer THARD_VAN_11 AttackDemo2

			PlaceC THARD_VAN_12 pVAN_12
			Filter THARD_VAN_12 Timeout 10 MoveC pVAN_12
			AddControl THARD_VAN_12 Filter Timeout 20 Wander
			SequenceLoops THARD_VAN_12
			SwitchOnSightOfPlayer THARD_VAN_12 AttackDemo2

			PlaceC THARD_VAN_13 pVAN_13
			Filter THARD_VAN_13 Timeout 10 MoveC pVAN_13
			AddControl THARD_VAN_13 Filter Timeout 20 Wander
			SequenceLoops THARD_VAN_13
			SwitchOnSightOfPlayer THARD_VAN_13 AttackDemo2

		ENDIF
	ENDIF

	IF mj_DEFEAT_GARGOS_2
		IF !gt_PLACED_WITCH
			Add gt_PLACED_WITCH

			KillC  THARD_VAN_11
			KillC  THARD_VAN_12
			KillC  THARD_VAN_13
			RemoveC LORDBANE
			KillC  EF_EVIL_01
			KillC  EF_EVIL_02
			KillC  EF_EVIL_03
			KillC  EF_EVIL_04
			KillC  EF_EVIL_05
			KillC  EF_EVIL_06
			KillC  EF_EVIL_07
			KillC  EF_EVIL_08
			KillC  EF_EVIL_09
			KillC  EF_EVIL_10

			IF gt_RENYA_IN_FENS
				PlaceC RENYA pRENYA
				PlaceC RENYA_GUARD_1 pG_1
				PlaceC RENYA_GUARD_2 pG_2
				PlaceC RENYA_GUARD_3 pG_3
				PlaceC RENYA_GUARD_4 pG_4
				RunS RenyaActions
			ENDIF

			PlaceC FEN_EVIL_01 pE_01
			PlaceC FEN_EVIL_02 pE_02
			PlaceC FEN_EVIL_03 pE_03
			PlaceC FEN_EVIL_04 pE_04
			PlaceC FEN_EVIL_05 pE_05
			PlaceC FEN_EVIL_06 pE_06
			PlaceC FEN_EVIL_07 pE_07
			PlaceC FEN_EVIL_08 pE_08
			PlaceC FEN_EVIL_09 pE_09
			PlaceC FEN_EVIL_10 pE_10
			PlaceC FEN_EVIL_11 pE_11
			PlaceC FEN_EVIL_12 pE_12
			PlaceC FEN_EVIL_13 pE_13
			PlaceC FEN_EVIL_14 pE_14
			PlaceC FEN_EVIL_15 pE_15
			PlaceC WITCH pWITCH

			RestrictedWanderButAttackOnSight FEN_EVIL_01
			RestrictedWanderButAttackOnSight FEN_EVIL_02
			RestrictedWanderButAttackOnSight FEN_EVIL_03
			RestrictedWanderButAttackOnSight FEN_EVIL_04
			RestrictedWanderButAttackOnSight FEN_EVIL_05
			RestrictedWanderButAttackOnSight FEN_EVIL_06
			RestrictedWanderButAttackOnSight FEN_EVIL_07
			RestrictedWanderButAttackOnSight FEN_EVIL_08
			RestrictedWanderButAttackOnSight FEN_EVIL_09
			RestrictedWanderButAttackOnSight FEN_EVIL_10
			RestrictedWanderButAttackOnSight FEN_EVIL_11
			RestrictedWanderButAttackOnSight FEN_EVIL_12
			RestrictedWanderButAttackOnSight FEN_EVIL_13
			RestrictedWanderButAttackOnSight FEN_EVIL_14
			RestrictedWanderButAttackOnSight FEN_EVIL_15
		ELSE
			IF gt_PLACED_THARDOLIN_CHARS
				RemoveC RENYA
				KillC  RENYA_GUARD_1
				KillC  RENYA_GUARD_2
				KillC  RENYA_GUARD_3
				KillC  RENYA_GUARD_4
				KillC  FEN_EVIL_01
				KillC  FEN_EVIL_02
				KillC  FEN_EVIL_03
				KillC  FEN_EVIL_04
				KillC  FEN_EVIL_05
				KillC  FEN_EVIL_06
				KillC  FEN_EVIL_07
				KillC  FEN_EVIL_08
				KillC  FEN_EVIL_09
				KillC  FEN_EVIL_10
				KillC  FEN_EVIL_11
				KillC  FEN_EVIL_12
				KillC  FEN_EVIL_13
				KillC  FEN_EVIL_14
				KillC  FEN_EVIL_15
				KillC  FEN_EVIL_16
				KillC  FEN_EVIL_17
				KillC  WITCH

			ENDIF
		ENDIF
	ENDIF

END

VIG TempSetup FALSE

	DisableTeleport EF_HEXSTONE

	Set	gd_WEATHER_TYPE	3
	Set gd_WIND_TYPE	5
    RunS CueWeather

	SetLiquid WATER  900 2 10
	SetLiquid WATER2 900 2 10
	SetLiquid WATER3 900 2 10
	SetWaterType 0
	SetWaterAnimSpeed 0

	PlaceFrog pFrog1
//	PlaceFrog pFrog2
	PlaceFrog pFrog3
//	PlaceFrog pFrog4
	PlaceFrog pFrog5

//	PlaceFrog pFrog6
	PlaceFrog pFrog7
//	PlaceFrog pFrog8
	PlaceFrog pFrog9
//	PlaceFrog pFrog10

	PlaceFrog pFrog11
//	PlaceFrog pFrog12
	PlaceFrog pFrog13
//	PlaceFrog pFrog14
	PlaceFrog pFrog15

	CachePortrait PC1.BIN
	CachePortrait LORDBANE.BIN
	CachePortrait CREDO.BIN
	CachePortrait RENYA.BIN

END

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

VIG PlayNicelyNow ONESEC && gt_PLAY_FIGHT

	SetHP EF_EVIL_01	1000
	SetHP EF_EVIL_02	1000
	SetHP EF_EVIL_03	1000
	SetHP EF_EVIL_04	1000
	SetHP EF_EVIL_05	1000
	SetHP EF_EVIL_06	1000
	SetHP EF_EVIL_07	1000
	SetHP EF_EVIL_08	1000
	SetHP LORDBANE		2000
	SetHP BANE_GUARD1	400
	SetHP BANE_GUARD2	400
	SetHP BANE_GUARD3	400
	SetHP BANE_GUARD4	400

END

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

VIG StartFightingProperly ONESEC && gt_PLAY_FIGHT && DISTFROM-P-LORDBANE-18

	//restore HP
	RunS PlayNicelyNow

	// *** RESCUE BANE FROM HIS FIGHT ***

	widescreen TRUE
	freecam
	campan LORDBANE
	UUCameraComplete

	Remove gt_PLAY_FIGHT

	GiveSightOfPlayerTo EF_EVIL_01
	GiveSightOfPlayerTo EF_EVIL_03
	AttackDemo2 EF_EVIL_01
	AttackDemo2 EF_EVIL_03

	Wait 1000

	camcut P
	setcammovenormal
NormalCam
	widescreen FALSE

	//restore HP
	SetHP BANE_GUARD1	200
	SetHP BANE_GUARD2	200
	SetHP BANE_GUARD3	200
	SetHP BANE_GUARD4	200

END

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

VIG TalkToBaneInCombat MSG-iLORDBANE

	//"For the Blood and the White Moon!"
	QuickSay lb0027

END

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

VIG TalkToBKInCombat MSG-iBANE_GUARD1 || MSG-iBANE_GUARD2 || MSG-iBANE_GUARD3 || MSG-iBANE_GUARD4

	//"For the White Moon!"
	QuickSay bk0003 CREDO.BIN

END

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

VIG RescueBane FIVESEC && !mj_RESCUE_BANE && ISDEAD-EF_EVIL_01 && ISDEAD-EF_EVIL_02 && ISDEAD-EF_EVIL_03 && ISDEAD-EF_EVIL_04 && ISDEAD-EF_EVIL_05 && ISDEAD-EF_EVIL_06 && ISDEAD-EF_EVIL_07 && ISDEAD-EF_EVIL_08 && DISTFROM-P-LORDBANE-18

	// *** RESCUE BANE : FIGHT OVER ***
	StopC P
	UnDrawSwordRemember
	QLRemove ql020

	Widescreen TRUE

	LookAtTurnFollow LORDBANE P

	Engage P pBANE 2500
	UUComplete P

	//"Praise to the White Moon!...Your intervention is welcome..."
	QuickSay lb001b

	Engage P pBANE 1000
	AddControl P Engage LORDBANE 350
	LookAtTurnFollow LORDBANE P
	UUSay

	//"I am Bane...Take this - a token of my debt...you will be as a brother..."
	QuickSay lb0002
	ChangeProfileToIdentified Sbloodkin_Bane
	LookAtTurnFollow LORDBANE P

	Wait 5000
	UUComplete P
	Capture LORDBANE cM_TOSS_GENTLE
	Capture P cM_OBJ_ACCEPT_1H1
	UUComplete LORDBANE
	AwardOb P alvaris_key "key"
	UUSay

	UUComplete P
	Capture P cM_OBJ_EXAMINE_SMALL1
	//"Strange. This talisman is in the shape of a key."
	Say Hxtp01

	//"...We travel back to Shadowguard...Will you accompany us?"
	Say lb0003

	ResetChoice
	ClearChoices
	AddChoice 1 txtp01
	AddChoice 2 txtp02
	GetChoice LORDBANE
	SWITCH Choice
		CASE 1
			//"Then let us march..."
			Say lb0004

			Add gt_STRAIGHT_TO_TWM

		CASE 2
			//"Then I wish you good fortune...If you are ever in Shadowguard, seek me...at the Temple...you will always find sanctuary."
			Say lb0005
	ENDSWITCH

	Add mj_RESCUE_BANE
	AwardEP xp_RESCUE_BANE

	EngagePoint LORDBANE pEXIT 1000
	EngagePoint BANE_GUARD1 pEXIT 1000
	EngagePoint BANE_GUARD2 pEXIT 1000
	EngagePoint BANE_GUARD3 pEXIT 1000
	EngagePoint BANE_GUARD4 pEXIT 1000

	DrawSwordRemember

	IF gt_STRAIGHT_TO_TWM
		EngagePoint P pEXIT 1000

		RunS PalFadeBLACK

		RemoveC LORDBANE
		RemoveC BANE_GUARD1
		RemoveC BANE_GUARD2
		RemoveC BANE_GUARD3
		RemoveC BANE_GUARD4

		PostMsg t_MN_LEAVE

	ELSE
		
		WHILE (INAREA-BANE_GUARD1-NEAR_FIGHT && !ISDEAD-BANE_GUARD1) || (INAREA-BANE_GUARD2-NEAR_FIGHT && !ISDEAD-BANE_GUARD2) || (INAREA-BANE_GUARD3-NEAR_FIGHT && !ISDEAD-BANE_GUARD3) || (INAREA-BANE_GUARD4-NEAR_FIGHT && !ISDEAD-BANE_GUARD4)
			Wait 1000
		ENDWHILE

		RemoveC LORDBANE
		IF !ISDEAD-BANE_GUARD1
			RemoveC BANE_GUARD1
		ENDIF
		IF !ISDEAD-BANE_GUARD2
			RemoveC BANE_GUARD2
		ENDIF
		IF !ISDEAD-BANE_GUARD3
			RemoveC BANE_GUARD3
		ENDIF
		IF !ISDEAD-BANE_GUARD4
			RemoveC BANE_GUARD4
		ENDIF

		Widescreen FALSE

	ENDIF

	//prevent bizarre teleportation
	Remove gd_GOT_TO_FENS_HEX

END

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

VIG RenyaActions FALSE

	MoveCDir RENYA pRENYA
	AddControl RENYA Capture cF_STAND_AT_EASE
	AddControl RENYA Capture cF_STAND_AT_EASE2
	AddControl RENYA Capture cF_STAND_AT_EASE3
	SequenceRandomlySelects RENYA

	MoveCDir RENYA_GUARD_1 pG_1
	AddControl RENYA_GUARD_1 Capture cM_STAND_AT_EASE1
	AddControl RENYA_GUARD_1 Capture cM_STAND_AT_EASE2
	AddControl RENYA_GUARD_1 Capture cM_STAND_AT_EASE3
	SequenceRandomlySelects RENYA_GUARD_1

	MoveCDir RENYA_GUARD_2 pG_2
	AddControl RENYA_GUARD_2 Capture cM_STAND_AT_EASE1
	AddControl RENYA_GUARD_2 Capture cM_STAND_AT_EASE2
	AddControl RENYA_GUARD_2 Capture cM_STAND_AT_EASE3
	SequenceRandomlySelects RENYA_GUARD_2

	MoveCDir RENYA_GUARD_3 pG_3
	AddControl RENYA_GUARD_3 Capture cM_STAND_AT_EASE1
	AddControl RENYA_GUARD_3 Capture cM_STAND_AT_EASE2
	AddControl RENYA_GUARD_3 Capture cM_STAND_AT_EASE3
	SequenceRandomlySelects RENYA_GUARD_3

	MoveCDir RENYA_GUARD_4 pG_4
	AddControl RENYA_GUARD_4 Capture cM_STAND_AT_EASE1
	AddControl RENYA_GUARD_4 Capture cM_STAND_AT_EASE2
	AddControl RENYA_GUARD_4 Capture cM_STAND_AT_EASE3
	SequenceRandomlySelects RENYA_GUARD_4

END

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

VIG TalkToRenyaGuard MSG-iRENYA_GUARD_1 || MSG-RENYA_GUARD_2 || MSG-RENYA_GUARD_3 || MSG-RENYA_GUARD_4

	//"We are ready to fight, Young Moon!"
	QuickSay bkm004 CREDO.BIN

END

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

VIG MeetRenya !gt_RENYA_ATTACKS && MSG-iRENYA

	Widescreen TRUE
	
	EngageAndFace P RENYA
	Say pe0009

	ResetChoice
	ClearChoices
	AddChoice 1 txtg01
	AddChoice 0 tx0003
	GetChoice RENYA
	SWITCH Choice
		CASE 1
			//Say pe0013

			EngagePoint P pSCRAP 750
			EngagePoint RENYA pSCRAP 750
			EngagePoint RENYA_GUARD_1 pSCRAP 750
			EngagePoint RENYA_GUARD_2 pSCRAP 750
			EngagePoint RENYA_GUARD_3 pSCRAP 750
			EngagePoint RENYA_GUARD_4 pSCRAP 750
			AddControl RENYA MeleeAttack
			AddControl RENYA_GUARD_1 MeleeAttack
			AddControl RENYA_GUARD_2 MeleeAttack
			AddControl RENYA_GUARD_3 MeleeAttack
			AddControl RENYA_GUARD_4 MeleeAttack

			EngagePoint FEN_EVIL_01 pSCRAP 1000
			EngagePoint FEN_EVIL_02 pSCRAP 1000
			EngagePoint FEN_EVIL_03 pSCRAP 1000
			EngagePoint FEN_EVIL_04 pSCRAP 1000
			EngagePoint FEN_EVIL_05 pSCRAP 1000
			EngagePoint FEN_EVIL_06 pSCRAP 1000
			EngagePoint FEN_EVIL_07 pSCRAP 1000
			EngagePoint FEN_EVIL_08 pSCRAP 1000
			EngagePoint FEN_EVIL_09 pSCRAP 1000
			AddControl FEN_EVIL_01 MeleeAttack
			AddControl FEN_EVIL_02 MeleeAttack
			AddControl FEN_EVIL_03 MeleeAttack
			AddControl FEN_EVIL_04 MeleeAttack
			AddControl FEN_EVIL_05 MeleeAttack
			AddControl FEN_EVIL_06 MeleeAttack
			AddControl FEN_EVIL_07 MeleeAttack
			AddControl FEN_EVIL_08 MeleeAttack
			AddControl FEN_EVIL_09 MeleeAttack
			UUComplete P

			EngagePoint FEN_EVIL_10 pWITCH 1250
			EngagePoint FEN_EVIL_11 pWITCH 1250
			EngagePoint FEN_EVIL_12 pWITCH 1500
			EngagePoint FEN_EVIL_13 pWITCH 1500
			EngagePoint FEN_EVIL_14 pWITCH 1750
			EngagePoint FEN_EVIL_15 pWITCH 1750
			AddControl FEN_EVIL_10 MeleeAttack
			AddControl FEN_EVIL_11 MeleeAttack
			AddControl FEN_EVIL_12 MeleeAttack
			AddControl FEN_EVIL_13 MeleeAttack
			AddControl FEN_EVIL_14 MeleeAttack
			AddControl FEN_EVIL_15 MeleeAttack
			Add gt_RENYA_ATTACKS
			AwardEP xp_RENYA_ATTACKS
		CASE 0
			RunS RenyaActions
	ENDSWITCH

	Widescreen FALSE

END

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

VIG ProceedToTheWitch FIVESEC && gt_RENYA_ATTACKS && !gt_GONE_TO_WITCH

	IF ISDEAD-FEN_EVIL_01 && ISDEAD-FEN_EVIL_02 && ISDEAD-FEN_EVIL_03 && ISDEAD-FEN_EVIL_04 && ISDEAD-FEN_EVIL_05
		IF ISDEAD-FEN_EVIL_06 && ISDEAD-FEN_EVIL_07 && ISDEAD-FEN_EVIL_08 && ISDEAD-FEN_EVIL_09
			Add gt_GONE_TO_WITCH

			EngagePoint RENYA pWITCH 1250
			EngagePoint RENYA_GUARD_1 pWITCH 1250
			EngagePoint RENYA_GUARD_2 pWITCH 1250
			EngagePoint RENYA_GUARD_3 pWITCH 1250
			EngagePoint RENYA_GUARD_4 pWITCH 1250
			AddControl RENYA MeleeAttack
			AddControl RENYA_GUARD_1 MeleeAttack
			AddControl RENYA_GUARD_2 MeleeAttack
			AddControl RENYA_GUARD_3 MeleeAttack
			AddControl RENYA_GUARD_4 MeleeAttack

		ENDIF
	ENDIF

END

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

VIG ApproachWitch gt_PLACED_WITCH && !gt_DONE_WITCH && (INAREA-P-NEAR_WITCH || DAMAGED-WITCH || DISTFROM-P-WITCH-8)

	Add gt_DONE_WITCH

	Widescreen TRUE
	campan WITCH

	LookAtTurn WITCH pSTONE
	UUComplete WITCH
	FX_Sprinkle WITCH
	Capture WITCH cF_ELSBETH_RAISE_HANDS1
	Wait 2000

	PlaceC FEN_EVIL_16 pE_16
	FX_GreenFire FEN_EVIL_16
	PlaceC FEN_EVIL_17 pE_17
	FX_GreenFire FEN_EVIL_17
	MeleeAttack FEN_EVIL_16
	MeleeAttack FEN_EVIL_17
	MeleeAttack WITCH
	camcut P

	Widescreen FALSE

END

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

VIG WitchDead FIVESEC && gt_PLACED_WITCH && !gt_PLACED_THARDOLIN_CHARS

	IF ISDEAD-WITCH
		Widescreen TRUE

		CannotBeHit P
		QLRemove ql301
		PlaySFX		hex-stone-activation.wav
		FX_Teleport P
		Wait 6000
		CanBeHit P
		PostMsg t_TD_EF
		
		Widescreen FALSE
	ELSE
		IF !ISDEAD-FEN_EVIL_10 || !ISDEAD-FEN_EVIL_11 || !ISDEAD-FEN_EVIL_12 || !ISDEAD-FEN_EVIL_13 || !ISDEAD-FEN_EVIL_14 || !ISDEAD-FEN_EVIL_15 || !ISDEAD-FEN_EVIL_16 || !ISDEAD-FEN_EVIL_17
			FX_YellowFire WITCH
			SetHP WITCH 500
		ENDIF
	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 50
	FreeCam
	PhotoOn

	camcut flyby01

	campan flyby06
	UUCameraComplete

	
	PhotoOff

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

	Widescreen FALSE

END

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


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

VIG FlyBy2 FALSE

	Widescreen TRUE

	// *** Alternate fly-by. Same angle not looking down at end ***

	SetCamMoveConstant 50
	FreeCam
	PhotoOn

	camcut flyby01

	campan flyby05
	UUCameraComplete

	
	PhotoOff

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

	Widescreen FALSE

END

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

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