/////////////////////////////////////////////////////////////////////
// BARROWIN.S
/////////////////////////////////////////////////////////////////////

SETUP

    IF !gd_PLACED_BARROW_BOYS
        Add gd_PLACED_BARROW_BOYS
		IDoorOpen dGARGOS

        PlaceC  HORATH          pHORATH_BODY mcap
		FreezeC HORATH
        //Capture HORATH          cM_FALL_N_DIE_DIE_DIE1

        PlaceC  BARROW_SKEL_1   pBARROW_BOY1
		RestrictedWanderButAttackOnSight BARROW_SKEL_1

        PlaceC  BARROW_SKEL_2   pBARROW_BOY_2A
        AddControl  BARROW_SKEL_2   MoveC   pBARROW_BOY_2B
        AddControl  BARROW_SKEL_2   MoveC   pBARROW_BOY_2A
        SequenceLoops   BARROW_SKEL_2
        SwitchOnSightOfPlayer   BARROW_SKEL_2   AttackDemo2

        PlaceC  BARROW_UNDEAD_1   pBARROW_BOY_3A
        AddControl  BARROW_UNDEAD_1   Capture cM_GUARD_STAND1
        AddControl  BARROW_UNDEAD_1   Capture cM_GUARD_STAND2
        AddControl  BARROW_UNDEAD_1   Capture cM_GUARD_STAND3
        SequenceRandomlySelects   BARROW_UNDEAD_1
        SwitchOnSightOfPlayer   BARROW_UNDEAD_1 SetScriptFlagControl    gd_BARROW_BOYS_ATTACK

        PlaceC  BARROW_UNDEAD_2   pBARROW_BOY_3B
        AddControl  BARROW_UNDEAD_2   Capture cM_GUARD_STAND1
        AddControl  BARROW_UNDEAD_2   Capture cM_GUARD_STAND2
        AddControl  BARROW_UNDEAD_2   Capture cM_GUARD_STAND3
        SequenceRandomlySelects   BARROW_UNDEAD_2
        SwitchOnSightOfPlayer   BARROW_UNDEAD_2 SetScriptFlagControl   gd_BARROW_BOYS_ATTACK

        PlaceC  BARROW_SKEL_3   pBARROW_BOY_4
        RestrictedWanderButAttackOnSight    BARROW_SKEL_3
    ENDIF

	RunS PuzzleInit

END

VIG TempSetup FALSE

	DisableTeleport BI_ANVIL
	DisableTeleport BI_TELEPORT

	SetLiquid newlava 325 15 5
	SetWaterAnimSpeed 0
    SetWeather  0 0 0 0 0 0 0 0
	SetDoorSpeed dGargos 600

	CachePortrait PC1.BIN
	CachePortrait GARGSHMN.BIN
	CachePortrait TALOS.BIN
	CachePortrait TANGARIS.BIN

END

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

VIG BarrowBoysAttack    !gd_BARROW_BOYS_UNITE && (INAREA-P-barrow_boys3 || gd_BARROW_BOYS_ATTACK)
    Add gd_BARROW_BOYS_UNITE

    AttackDemo2 BARROW_UNDEAD_1
    AttackDemo2 BARROW_UNDEAD_2
END

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

//VIG PlaceGargosTalosTrap !gd_PLACED_GARGOS_TALOS_TRAP && POS-P-anvilhorath && INAREA-P-bi_place_gargos
//	Add gd_PLACED_GARGOS_TALOS_TRAP
	//PlaceC GARGOS pGARGOS_START
	//PlaceC TALOS pTALOS_START
//END

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

VIG GargosTrap gd_PLACED_GARGOS_TALOS_TRAP && !gd_PLAYED_GARGOS_TRAP && INAREA-P-bi_p_leave

	FreezeC BARROW_SKEL_1
	FreezeC BARROW_SKEL_2
	FreezeC BARROW_SKEL_3
	FreezeC BARROW_UNDEAD_1
	FreezeC BARROW_UNDEAD_2
	Add gd_PLAYED_GARGOS_TRAP

    StopC   P

	Widescreen TRUE

	IF ONMAP-PUZZLE_DUDE_1
		MoveC PUZZLE_DUDE_1 p1 run
	ENDIF

	IF ONMAP-PUZZLE_DUDE_2
		MoveC PUZZLE_DUDE_2 p2 run
	ENDIF

	FREECAM
	CAMCUT START
	SETCAMMOVECONSTANT 3
	CAMPAN END01
	PlaceC GARGOS pGARGOS_START
	PlaceC TALOS pTALOS_START

	// *** START OF GARGOS BARROW TRAP ***

	Playmusic rpg29.wav
	wait 2000
	QuickSay os0007 GARGSHMN.BIN
	ChangeProfileToIdentified Esoldier_Talos
	Capture GARGOS cM_CLAPPING1
    UUSay
	QuickSay Ta0007
    Capture TALOS cM_TALK_AGREE1
	ChangeProfileToIdentified erev_gargos1
    UUSay

	MoveCDir GARGOS pGARGOS_TRAP
	MoveCDir TALOS pTALOS_TRAP
	MoveCDir P pP_LEAVE

	UUComplete GARGOS
	UUComplete TALOS
	UUComplete P

	CAMCUT POS01

	QuickSay Hx0223
    Wait     500
    Capture P cM_TALK_REFER_OTHER_PERSON1
    UUSay
	UUComplete  P

	QuickSay os0013 GARGSHMN.BIN
    Wait     250
    Capture GARGOS cM_TALK_REFER_SELF2
    UUSay

	UUComplete  GARGOS
	QuickSay os0016 GARGSHMN.BIN
    Capture GARGOS cM_TALK_BECKON_BEHIND3
    UUComplete  GARGOS
    Capture GARGOS cM_TALK_THREATEN1
    UUSay

	QuickSay    Ta0013
    LookAtTurn  TALOS GARGOS
	UUComplete  TALOS
    Capture     TALOS cM_BOW_THANKS3
	UUComplete  TALOS
camcut pos01
	// *TALOS LEAVES*
	MoveC_1tel TALOS BI_MAIN_IN pTALOS_LEAVE
    Wait    2000

    // GARGOS CASTS A SPELL TO BLOCK THE DOOR
    MoveCDir    GARGOS  pGARGOS_FACE_DOOR
	UUComplete GARGOS
	UUComplete TALOS
    Capture GARGOS cM_CAST_SPELL18_MISC
	FX_BurnPerson GARGOS
	UUComplete GARGOS
	RemoveC TALOS

	RDoorLocked dGARGOS
	PlaySFXPerson Mech.wav GARGOS
	FX_LockDoor pDOOR_TRAP
	FX_BurnPerson GARGOS

    //FX_Greenfire    24922 18330


    DisableTeleport BI_MAIN_IN
	UUComplete GARGOS
    LookAtTurn  GARGOS  P
setcammoveconstant 3
campan pos03

	Say os0017 GARGSHMN.BIN

	// *** END OF GARGOS BARROW TRAP ***
	CAMCUT P
	setCammovenormal
NormalCam

	IF ONMAP-PUZZLE_DUDE_1
		AttackDemo2 PUZZLE_DUDE_1
	ENDIF

	IF ONMAP-PUZZLE_DUDE_2
		AttackDemo2 PUZZLE_DUDE_2
	ENDIF

	Widescreen FALSE

	AttackDemo2 GARGOS
	UnFreezeC BARROW_SKEL_1
	UnFreezeC BARROW_SKEL_2
	UnFreezeC BARROW_SKEL_3
	UnFreezeC BARROW_UNDEAD_1
	UnFreezeC BARROW_UNDEAD_2

END

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

VIG GargosDeath gd_PLAYED_GARGOS_TRAP && !mj_DEFEAT_GARGOS_1 && ISDEAD-GARGOS
    EnableMover BI_MAIN_IN
	RDoorOpen dGARGOS
    //IF mj_BEEN_TO_HEX
        // It stops snowing and starts raining.
        //Set         gd_WEATHER_TYPE 2
    //ENDIF
    Add mj_DEFEAT_GARGOS_1

	//init counter for special effect
	Set gg_FX_GARGOS_DEATH 0
END

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

VIG DRGargos MSG-DR_GARGOS

	QuickSay Hx225a

END

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

VIG DRHorath MSG-DR_HORATH

	IF !gt_DR_HORATH
		Widescreen TRUE

		Add gt_DR_HORATH
		
		Say	ho0001
		Say	Hx219n
		Say	ho0003
		Say	ho0004
		Say	Hx219p
		Say	ho0005

		ChangeProfileToIdentified Rcitizen_Horath

		Widescreen FALSE
	ELSE
		QuickSay hxdr01
	ENDIF
END

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

//VIG ArriveAtAnvil HALFSEC && !gd_ARRIVED_AT_ANVIL && INAREA-P-bi_anvil_arrive
//    ADD gd_ARRIVED_AT_ANVIL
//	DisableTeleport BI_ANVIL
//END

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

VIG PickedUpAnvil HALFSEC && !gd_PICKED_UP_ANVIL && POS-P-anvilhorath

	Add		gd_PICKED_UP_ANVIL

	Add gd_PLACED_GARGOS_TALOS_TRAP
	DestroyHexCompass pANVIL_SPOT

	FX_CircEffect	36296	17850	300
	FX_CircEffect	35298	15833	300
	FX_CircEffect	36345	14811	300
	FX_CircEffect	36328	16873	300
	PlaceC				BARROW_GARG_1	pGARG1
	PlaceC				BARROW_GARG_2	pGARG2
	PlaceC				BARROW_GARG_3	pGARG3
	PlaceC				BARROW_GARG_4	pGARG3
	GiveSightOfPlayerTo	BARROW_GARG_1
	GiveSightOfPlayerTo	BARROW_GARG_2
	GiveSightOfPlayerTo	BARROW_GARG_3
	GiveSightOfPlayerTo	BARROW_GARG_4
	AttackDemo2			BARROW_GARG_1
	AttackDemo2			BARROW_GARG_2
	AttackDemo2			BARROW_GARG_3
	AttackDemo2			BARROW_GARG_4

	Playmusic rpg32.wav
END

//VIG PickedUpAnvil HALFSEC && !gd_PICKED_UP_ANVIL && POS-P-anvilhorath
//  widescreen true
//  ADD             gd_PICKED_UP_ANVIL
//
//	CAMCUT          pos1000
//setcammoveconstant 4
//campan pos2000
//    FX_CircEffect   38106 15855 300
//    Wait          500
//	PlaceC          BARROW_GARG_3 pGARG3
//    LookAtTurn      BARROW_GARG_3 P
//    UUComplete      BARROW_GARG_3
//    Wait            1000
//    Capture         BARROW_GARG_3 cM_V4_LOOK_AROUND1
//    UUComplete      BARROW_GARG_3
//
//	
//    FX_CircEffect   36304 17634 300
//    Wait            500
//	CAMCUT         pos4000
//PlaceC          BARROW_GARG_1 pGARG1
//    LookAtTurn      BARROW_GARG_1 P
//    UUComplete      BARROW_GARG_1
//    Wait            1000
//    Capture         BARROW_GARG_1 cM_COME_HERE
//    UUComplete      BARROW_GARG_1
//
//	CAMCUT          pos5000
//    FX_CircEffect   34534 15836 300
//    Wait            500
//	PlaceC          BARROW_GARG_2 pGARG2
//    LookAtTurn      BARROW_GARG_2 P
//    UUComplete      BARROW_GARG_2
//    Wait            1000
//    Capture         BARROW_GARG_2 cM_V27_SWING_ARM_POINT1
//    UUComplete      BARROW_GARG_2
//
//	CAMCUT          P
//    LookAtTurn      P BARROW_GARG_2
//    UUComplete      P
//
//    AttackDemo2      BARROW_GARG_1
//    AttackDemo2      BARROW_GARG_2
//    AttackDemo2      BARROW_GARG_3
//setcammovenormal
//camcut p
//widescreen false
//
//END
//
/////////////////////////////////////////////////////////////////////
//
//VIG AnvilAndGargoyles   gd_PICKED_UP_ANVIL && !gd_ACTIVATED_TELEPORT && ISDEAD-BARROW_GARG_1 && ISDEAD-BARROW_GARG_2 && ISDEAD-BARROW_GARG_3
//  
//FX_GreenFire    BARROW_GARG_1
//    FX_GreenFire    BARROW_GARG_2
//    FX_GreenFire    BARROW_GARG_3
//    RemoveC         BARROW_GARG_1
//    RemoveC         BARROW_GARG_2
//    RemoveC         BARROW_GARG_3
//    Wait 500
//	FX_CircEffect 36358 15819 300
//    Wait 500
//    EnableMover     BI_ANVIL
//
//    Add             gd_ACTIVATED_TELEPORT
//
//END
//
/////////////////////////////////////////////////////////////////////

VIG ActiveTeleportEffects   FIVESEC

    FX_WhiteFireGlow pTEL_TO

	//IF gd_ACTIVATED_TELEPORT
		FX_WhiteFireGlow pTELE_FROM
	//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

	Freecam
	SetCamMoveConstant 15

	PhotoOn

	camcut flyby01

	campan flyby02
	UUCameraComplete

	campan flyby03
	UUCameraComplete

	SetCamMoveConstant 4

	campan flyby04
	UUCameraComplete

	SetCamMoveConstant 150
	
	campan flyby05
	UUCameraComplete

	PhotoOff

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

	Widescreen FALSE

END

/////////////////////////////////////////////////////////////////////
// !!!!!!!! THE NEW BARROW PUZZLE !!!!!!!!
/////////////////////////////////////////////////////////////////////
//
// Each pillar has 3 states
//
//      1 = Manifest
//		2 = Burn
//		3 = Freeze
//
/////////////////////////////////////////////////////////////////////

VIG PuzzleInit FALSE
	
	IF !gg_InitPuzzle

		Add gg_InitPuzzle

		Set gg_P1 3
		Set gg_P2 3
		Set gg_P3 3
		Set gg_P4 3

		Set gg_FX_Cycle 1
		Set gg_PILLAR_STAG 1

		Remove	gg_PuzzleDude1
		Remove	gg_PuzzleDude2

		RemoveC PUZZLE_DUDE_1
		RemoveC PUZZLE_DUDE_2

	ENDIF

END

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

VIG StartUpPuzzle !gg_PuzzleCam && INAREA-P-barrow_sigil

	Add gg_PuzzleCam

	// Stop the player and cut the camera to the puzzle
	///////////////////////////////////////////////////

	StopC P

	Widescreen TRUE

	FreezeC GARGOS

	Set gg_P1 1
	Set gg_P2 1
	Set gg_P3 1
	Set gg_P4 1

	CamCut cPuzzle
	LookAtTurn P pSpawn
	
	// Fire off the effects
	///////////////////////

	RunS UpdatePuzzleEffects
	Wait 250
	RunS UpdatePuzzleEffects
	Wait 250
	RunS UpdatePuzzleEffects
	Wait 250
	RunS UpdatePuzzleEffects
	Wait 250

	// Place Dude
	/////////////

	RunS MonitorPuzzleManifest

	FreezeC PUZZLE_DUDE_1
	FreezeC PUZZLE_DUDE_2

	// Some more effects
	////////////////////

	RunS UpdatePuzzleEffects
	Wait 250
	RunS UpdatePuzzleEffects
	Wait 250
	RunS UpdatePuzzleEffects
	Wait 250
	RunS UpdatePuzzleEffects
	Wait 250

	UnFreezeC PUZZLE_DUDE_1
	UnFreezeC PUZZLE_DUDE_2
	UnFreezeC GARGOS

	camcut P
	Widescreen FALSE

END

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

VIG UpdatePuzzleEffects HALFSEC && gg_PuzzleCam

	logoff

	IF gg_PILLAR_STAG=1
		SWITCH FLAG-gg_FX_Cycle
			CASE 1
				SWITCH FLAG-gg_P1
					CASE 1
						FX_PuzzleManifest p1A
						FX_PuzzleManifest p1B
						FX_PuzzleManifest p1C
						FX_PuzzleManifest p1D
					CASE 2
						FX_PuzzleBurn p1A
						FX_PuzzleBurn p1B
						FX_PuzzleBurn p1C
						FX_PuzzleBurn p1D
					CASE 3
						FX_PuzzleFreeze p1A
						FX_PuzzleFreeze p1B
						FX_PuzzleFreeze p1C
						FX_PuzzleFreeze p1D
				ENDSWITCH
			CASE 2
				SWITCH FLAG-gg_P2
					CASE 1
						FX_PuzzleManifest p2A
						FX_PuzzleManifest p2B
						FX_PuzzleManifest p2C
						FX_PuzzleManifest p2D
					CASE 2
						FX_PuzzleBurn p2A
						FX_PuzzleBurn p2B
						FX_PuzzleBurn p2C
						FX_PuzzleBurn p2D
					CASE 3
						FX_PuzzleFreeze p2A
						FX_PuzzleFreeze p2B
						FX_PuzzleFreeze p2C
						FX_PuzzleFreeze p2D
				ENDSWITCH
			CASE 3
				SWITCH FLAG-gg_P3
					CASE 1
						FX_PuzzleManifest p3A
						FX_PuzzleManifest p3B
						FX_PuzzleManifest p3C
						FX_PuzzleManifest p3D
					CASE 2
						FX_PuzzleBurn p3A
						FX_PuzzleBurn p3B
						FX_PuzzleBurn p3C
						FX_PuzzleBurn p3D
					CASE 3
						FX_PuzzleFreeze p3A
						FX_PuzzleFreeze p3B
						FX_PuzzleFreeze p3C
						FX_PuzzleFreeze p3D
				ENDSWITCH
			CASE 4
				SWITCH FLAG-gg_P4
					CASE 1
						FX_PuzzleManifest p4A
						FX_PuzzleManifest p4B
						FX_PuzzleManifest p4C
						FX_PuzzleManifest p4D
					CASE 2
						FX_PuzzleBurn p4A
						FX_PuzzleBurn p4B
						FX_PuzzleBurn p4C
						FX_PuzzleBurn p4D
					CASE 3
						FX_PuzzleFreeze p4A
						FX_PuzzleFreeze p4B
						FX_PuzzleFreeze p4C
						FX_PuzzleFreeze p4D
				ENDSWITCH
		ENDSWITCH

		// Cycle to the next pillar
		///////////////////////////

		AddTo gg_FX_Cycle 1
		IF gg_FX_Cycle>4
			Set gg_FX_Cycle 1
		ENDIF
	ENDIF

	AddTo gg_PILLAR_STAG 1
	IF gg_PILLAR_STAG>3
		Set gg_PILLAR_STAG 1
	ENDIF

	logon

END

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

VIG MonitorPuzzleManifest FIVESEC && gg_P1=1 && gg_P2=1 && gg_P3=1 && gg_P4=1

	IF !gg_PuzzleDude1
		
		// Place Dude 1
		///////////////

		Add gg_PuzzleDude1
		PlaceC PUZZLE_DUDE_1 pSPAWN
		SamplesOff
		FX_Visible PUZZLE_DUDE_1
		SamplesOn

		// Make the dude attack
		///////////////////////

		AttackDemo2 PUZZLE_DUDE_1

	ELSE
		IF !gg_PuzzleDude2

			// Place Dude 2
			///////////////

			Add gg_PuzzleDude2
			PlaceC PUZZLE_DUDE_2 pSPAWN
			SamplesOff
			FX_Visible PUZZLE_DUDE_2
			SamplesOn

			// Make the dude attack
			///////////////////////

			AttackDemo2 PUZZLE_DUDE_2

		ENDIF
	ENDIF

END

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

VIG LookForBodiesToCleanUp FIVESEC

	// This make sure bodies linger for 5-10 seconds before the invisble
	// effect is done on them. Then they linger for another 5-10
	// seconds before being whipped of the map

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

	IF gg_PuzzleDude1 && !gg_DUDE_1_IS_DEAD && ONMAP-PUZZLE_DUDE_1 && ISDEAD-PUZZLE_DUDE_1

		Add gg_DUDE_1_IS_DEAD

	ELSE
		IF gg_DUDE_1_IS_DEAD && !gg_DUDE_1_READY

			SamplesOff
			FX_Invisible PUZZLE_DUDE_1
			SamplesOn
			Add gg_DUDE_1_READY

		ELSE
			IF gg_DUDE_1_IS_DEAD && gg_DUDE_1_READY

				RemoveC PUZZLE_DUDE_1

				Remove gg_PuzzleDude1
				Remove gg_DUDE_1_READY
				Remove gg_DUDE_1_IS_DEAD

				ResetStats PUZZLE_DUDE_1

			ENDIF
		ENDIF
	ENDIF

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

	IF gg_PuzzleDude2 && !gg_DUDE_2_IS_DEAD && ONMAP-PUZZLE_DUDE_2 && ISDEAD-PUZZLE_DUDE_2

		Add gg_DUDE_2_IS_DEAD

	ELSE
		IF gg_DUDE_2_IS_DEAD && !gg_DUDE_2_READY

			SamplesOff
			FX_Invisible PUZZLE_DUDE_2
			SamplesOn
			Add gg_DUDE_2_READY

		ELSE
			IF gg_DUDE_2_IS_DEAD && gg_DUDE_2_READY

				RemoveC PUZZLE_DUDE_2

				Remove gg_PuzzleDude2
				Remove gg_DUDE_2_READY
				Remove gg_DUDE_2_IS_DEAD

				ResetStats PUZZLE_DUDE_2

			ENDIF
		ENDIF
	ENDIF

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

END

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

VIG MonitorPuzzleBurnPlayer HALFSEC && gg_P1=2 && gg_P2=2 && gg_P3=2 && gg_P4=2 && INAREA-P-burn && !ISDEAD-P

	FX_BurnPerson P
	FireDamage P 50

END

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

VIG MonitorPuzzleBurnDude1 HALFSEC && gg_P1=2 && gg_P2=2 && gg_P3=2 && gg_P4=2 && INAREA-PUZZLE_DUDE_1-burn && !ISDEAD-PUZZLE_DUDE_1

	FX_BurnPerson PUZZLE_DUDE_1
	FireDamage PUZZLE_DUDE_1 50

END

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

VIG MonitorPuzzleBurnDude2 HALFSEC && gg_P1=2 && gg_P2=2 && gg_P3=2 && gg_P4=2 && INAREA-PUZZLE_DUDE_2-burn && !ISDEAD-PUZZLE_DUDE_2

	FX_BurnPerson PUZZLE_DUDE_2
	FireDamage PUZZLE_DUDE_2 50

END

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

VIG MonitorPuzzleBurnGargos HALFSEC && gg_P1=2 && gg_P2=2 && gg_P3=2 && gg_P4=2 && INAREA-GARGOS-burn && !ISDEAD-GARGOS

	FX_BurnPerson GARGOS
	FireDamage GARGOS 50

END

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

VIG MonitorPuzzleFreezePlayer HALFSEC && gg_P1=3 && gg_P2=3 && gg_P3=3 && gg_P4=3 && INAREA-P-burn && !ISDEAD-P

	FX_BlueFire P
	WaterDamage P 50

END

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

VIG MonitorPuzzleFreezeDude1 HALFSEC && gg_P1=3 && gg_P2=3 && gg_P3=3 && gg_P4=3 && INAREA-PUZZLE_DUDE_1-burn && !ISDEAD-PUZZLE_DUDE_1

	FX_BlueFire PUZZLE_DUDE_1
	WaterDamage PUZZLE_DUDE_1 50

END

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

VIG MonitorPuzzleFreezeDude2 HALFSEC && gg_P1=3 && gg_P2=3 && gg_P3=3 && gg_P4=3 && INAREA-PUZZLE_DUDE_2-burn && !ISDEAD-PUZZLE_DUDE_2

	FX_BlueFire PUZZLE_DUDE_2
	WaterDamage PUZZLE_DUDE_2 50

END

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

VIG MonitorPuzzleFreezeGargos HALFSEC && gg_P1=3 && gg_P2=3 && gg_P3=3 && gg_P4=3 && INAREA-GARGOS-burn && !ISDEAD-GARGOS

	FX_BlueFire GARGOS
	WaterDamage GARGOS 50

END

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

VIG PuzzleTouchPillar1 MSG-iP1

	MoveCDir P p1
	AddControl P SetScriptFlagControl gg_GOT_TO_PILLAR1

END

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

VIG PuzzleSwitchPillar1 gg_GOT_TO_PILLAR1

	Remove gg_GOT_TO_PILLAR1
	LookAtTurn P p1
	Capture P cM_POINT

	AddTo gg_P1	1
	IF gg_P1>3
		Set gg_P1 1
	ENDIF

	SWITCH FLAG-gg_P1
		CASE 1
			FX_PuzzleManifest p1A
			FX_PuzzleManifest p1B
			FX_PuzzleManifest p1C
			FX_PuzzleManifest p1D
		CASE 2
			FX_PuzzleBurn p1A
			FX_PuzzleBurn p1B
			FX_PuzzleBurn p1C
			FX_PuzzleBurn p1D
		CASE 3
			FX_PuzzleFreeze p1A
			FX_PuzzleFreeze p1B
			FX_PuzzleFreeze p1C
			FX_PuzzleFreeze p1D
	ENDSWITCH

	RunS ActivationEffect
END

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

VIG PuzzleTouchPillar2 MSG-iP2

	MoveCDir P p2
	AddControl P SetScriptFlagControl gg_GOT_TO_PILLAR2

END

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

VIG PuzzleSwitchPillar2 gg_GOT_TO_PILLAR2

	Remove gg_GOT_TO_PILLAR2
	LookAtTurn P p2
	Capture P cM_POINT

	AddTo gg_P2	1
	IF gg_P2>3
		Set gg_P2 1
	ENDIF

	SWITCH FLAG-gg_P2
		CASE 1
			FX_PuzzleManifest p2A
			FX_PuzzleManifest p2B
			FX_PuzzleManifest p2C
			FX_PuzzleManifest p2D
		CASE 2
			FX_PuzzleBurn p2A
			FX_PuzzleBurn p2B
			FX_PuzzleBurn p2C
			FX_PuzzleBurn p2D
		CASE 3
			FX_PuzzleFreeze p2A
			FX_PuzzleFreeze p2B
			FX_PuzzleFreeze p2C
			FX_PuzzleFreeze p2D
	ENDSWITCH

	RunS ActivationEffect
END

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

VIG PuzzleTouchPillar3 MSG-iP3

	MoveCDir P p3
	AddControl P SetScriptFlagControl gg_GOT_TO_PILLAR3

END

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

VIG PuzzleSwitchPillar3 gg_GOT_TO_PILLAR3

	Remove gg_GOT_TO_PILLAR3
	LookAtTurn P p3
	Capture P cM_POINT

	AddTo gg_P3	1
	IF gg_P3>3
		Set gg_P3 1
	ENDIF

	SWITCH FLAG-gg_P3
		CASE 1
			FX_PuzzleManifest p3A
			FX_PuzzleManifest p3B
			FX_PuzzleManifest p3C
			FX_PuzzleManifest p3D
		CASE 2
			FX_PuzzleBurn p3A
			FX_PuzzleBurn p3B
			FX_PuzzleBurn p3C
			FX_PuzzleBurn p3D
		CASE 3
			FX_PuzzleFreeze p3A
			FX_PuzzleFreeze p3B
			FX_PuzzleFreeze p3C
			FX_PuzzleFreeze p3D
	ENDSWITCH

	RunS ActivationEffect
END

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

VIG PuzzleTouchPillar4 MSG-iP4

	MoveCDir P p4
	AddControl P SetScriptFlagControl gg_GOT_TO_PILLAR4

END

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

VIG PuzzleSwitchPillar4 gg_GOT_TO_PILLAR4

	Remove gg_GOT_TO_PILLAR4
	LookAtTurn P p4
	Capture P cM_POINT

	AddTo gg_P4	1
	IF gg_P4>3
		Set gg_P4 1
	ENDIF

	SWITCH FLAG-gg_P4
		CASE 1
			FX_PuzzleManifest p4A
			FX_PuzzleManifest p4B
			FX_PuzzleManifest p4C
			FX_PuzzleManifest p4D
		CASE 2
			FX_PuzzleBurn p4A
			FX_PuzzleBurn p4B
			FX_PuzzleBurn p4C
			FX_PuzzleBurn p4D
		CASE 3
			FX_PuzzleFreeze p4A
			FX_PuzzleFreeze p4B
			FX_PuzzleFreeze p4C
			FX_PuzzleFreeze p4D
	ENDSWITCH

	RunS ActivationEffect
END

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

VIG LavaSpit TENTHSEC
	logoff
	SWITCH RAND-100
		CASE 0
			FX_Lava a 321
		CASE 1
			FX_Lava b 321
		CASE 2
			FX_Lava c 321
		CASE 3
			FX_Lava d 321
		CASE 4
			FX_Lava e 321
		CASE 5
			FX_Lava f 321
		CASE 6
			FX_Lava g 321
		CASE 7
			FX_Lava h 321
		CASE 8
			FX_Lava i 321
		CASE 9
			FX_Lava j 321
		CASE 10
			FX_Lava k 321
		CASE 11
			FX_Lava l 321
		CASE 12
			FX_Lava m 321
		CASE 13
			FX_Lava n 321
		CASE 14
			FX_Lava o 321
		CASE 15
			FX_Lava p 321
		CASE 16
			FX_Lava q 321
		CASE 17
			FX_Lava r 321
		CASE 18
			FX_Lava s 321
		CASE 19
			FX_Lava t 321
		CASE 20
			FX_Lava u 321
		CASE 21
			FX_Lava v 321
		CASE 22
			FX_Lava w 321
		CASE 23
			FX_Lava x 321
		CASE 24
			FX_Lava y 321
		CASE 25
			FX_Lava z 321
	ENDSWITCH
	logon
END

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

VIG ActivationEffect FALSE

	IF gg_P1=2 && gg_P2=2 && gg_P3=2 && gg_P4=2
		FX_YellowFire 24814 3790
	ENDIF

	IF gg_P1=3 && gg_P2=3 && gg_P3=3 && gg_P4=3
		FX_BlueFire 24814 3790
	ENDIF

END

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

VIG DoDeathEffectGargos ONESEC && gg_FX_GARGOS_DEATH && gg_FX_GARGOS_DEATH<4
	AddTo gg_FX_GARGOS_DEATH 1

	IF gg_FX_GARGOS_DEATH=4
		FX_RevSpiritToPosid GARGOS BI_MAIN_IN 0
		AwardEP xp_DEFEAT_GARGOS_1
	ENDIF
END

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

VIG TeleAppear gg_TELE_INVIS
	Remove gg_TELE_INVIS
	FX_Visible P
END

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

VIG Tele1 INAREA-P-Tele1
	FX_Invisible P
	StopC P
	Wait 2000
	PostMsg m_BI_ANVIL
	Add gg_TELE_INVIS
END

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

VIG Tele2 INAREA-P-Tele2
	FX_Invisible P
	StopC P
	Wait 2000
	PostMsg m_BI_TELEPORT
	Add gg_TELE_INVIS
END

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