
------------------------------------------------------ Funcions Generiques de tots els inici i Fi de CutScene
function StartCutScene( )
	activateInput(false);
	enableCinematicBlackBands( true );
return 0;
end

function EndCutScene( )
	activateInput(true);
	saveStateOfAllGameInstances();
	enableCinematicBlackBands( false );
return 0;
end

------------------------------------------------------ Cut Scene01: Player arriba amb el barril

function StartCutScene01( )

	-- Events de musica
	startBarrelCutSceneMusic( );

	local functionOrder;
	
	setInstanceValidObjectValue( "barrelIntro", true );
	
	playAmbient( "Music/ambient_ocean" );
	
	functionOrder = "StartCutScene()";
	addOrderToSequencer ( functionOrder, 0.0 );

	-- Coloquem la camera
	functionOrder = "setCameraModeBlendInfo( 6, \"rock19\", \"trackerCamera_CutScene01_01\", 0.0, 0.0, 0.0 )";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "setEntityValidByName(\"BarrelIntro\", true )";
	addOrderToSequencer ( functionOrder, 0.2 );

	functionOrder = "setCameraMode( 2, \"barrelIntro\", \"trackerCamera_CutScene01_01\", 3.0 )";
	addOrderToSequencer ( functionOrder, 3.0 );
	
	functionOrder = "setFOV( 35, 5.0 )";
	addOrderToSequencer ( functionOrder, 4.0 );
	
	functionOrder = "setCameraMode( 6, \"barrelIntro\", \"trackerCamera_CutScene01_02\", 0.0 )";
	addOrderToSequencer ( functionOrder, 4.0 );
	
	functionOrder = "setFOV( 45, 2.0 )";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "EndCutScene()";
	addOrderToSequencer ( functionOrder, 0.0 );
	
return 0;
end

function EndCutScene01( )

	local functionOrder;
	
	--setEntityValidByName("platform_vertical_27", true );
    --setEntityVisibleByName("platform_vertical_27", false );
	
	functionOrder = "setCameraMode( 4, \"\", \"trackerCamera_checkPointStart\", 20.0 )";
	addOrderToSequencer ( functionOrder, 2.0 );
	
	functionOrder = "activateInput(true)";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "start_Lvl1()";
	addOrderToSequencer ( functionOrder, 1.0 );
	
	functionOrder = "saveStateOfAllGameInstances()";
	addOrderToSequencer ( functionOrder, 0.0 );
	
return 0;
end

------------------------------------------------------ Cut Scene02: Player meets FirstSeaUrchin

function StartCutScene02_first( )
	
	local functionOrder;
	
	activateInput(false);
	
	setInstanceValidObjectValue( "seaUrchinNPC", true );
	setEntityVisibleByName( "seaUrchinNPC", false );
	setEntityShadowCastByName( "seaUrchinNPC", false );

    functionOrder = "startNPCDialog(\"seaUrchinNPC\")";
	addOrderToSequencerWithId ( 2, functionOrder, 1.5 );

	-- Coloquem la camera
	functionOrder = "playSound( \"Animated_entities/SeaUrchin/attention\", getEntityPosition(\"seaUrchinNPC\") )";
	addOrderToSequencer ( functionOrder, 0.3 );
	
	functionOrder = "setCameraModeBlendInfo( 6, \"mediumrock02\", \"trackerCamera_CutScene02_01\", 0.0, 0.0, 0.7 )";
	addOrderToSequencer ( functionOrder, 0.2 );
	
	functionOrder = "playSound( \"Animated_entities/SeaUrchin/attention\", getEntityPosition(\"seaUrchinNPC\") )";
	addOrderToSequencer ( functionOrder, 1.0 );
	
	functionOrder = "setCameraModeBlendInfo( 6, \"littleRock02\", \"trackerCamera_CutScene02_01\", 0.0, 0.0, 0.7 )";
	addOrderToSequencer ( functionOrder, 0.2 );
	
	functionOrder = "playSound( \"Animated_entities/SeaUrchin/attention\", getEntityPosition(\"seaUrchinNPC\") )";
	addOrderToSequencer ( functionOrder, 0.5 );
	
	functionOrder = "playSound( \"Animated_entities/SeaUrchin/attention\", getEntityPosition(\"seaUrchinNPC\") )";
	addOrderToSequencer ( functionOrder, 0.3 );
	
	functionOrder = "setCameraModeBlendInfo( 6, \"tracker_lvl1_NPC_Camera\", \"trackerCamera_CutScene02_01\", 0.0, 0.0, 0.7 )";
	addOrderToSequencer ( functionOrder, 0.2 );
	
	functionOrder = "landingAtack_grass( getEntityPosition(\"seaUrchinNPC\"), NULL )";
	addOrderToSequencer ( functionOrder, 0.2 );
	
	functionOrder = "setEntityVisibleByName( \"seaUrchinNPC\", true )";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "setEntityShadowCastByName( \"seaUrchinNPC\", true )";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "landingAtack_grass( getEntityPosition(\"seaUrchinNPC\"), NULL )";
	addOrderToSequencer ( functionOrder, 0.3 );
	
	functionOrder = "landingAtack_grass( getEntityPosition(\"seaUrchinNPC\"), NULL )";
	addOrderToSequencer ( functionOrder, 0.3 );
	
	functionOrder = "setFOV( 25, 1.5 )";
	addOrderToSequencer ( functionOrder, 1.0 );
	
return 0;
end

function StartCutScene02_answer( )

	local functionOrder;

	functionOrder = "setCameraModeBlendInfo( 5, \"\", \"trackerCamera_CutScene02_02\", 0.0, 0.0, 0.7 )";
	addOrderToSequencer ( functionOrder, 0.2 );

return 0;
end

function StartCutScene02_second( )

	local functionOrder;
	
	functionOrder = "setCameraModeBlendInfo( 6, \"Mag_PowerUp01\", \"trackerCamera_CutScene02_01\", 0.0, 0.0, 0.7 )";
	addOrderToSequencer ( functionOrder, 0.2 );
	
	functionOrder = "unHideItem( \"Mag_PowerUp01\" )";
	addOrderToSequencer ( functionOrder, 1.0 );
	
	functionOrder = "setFOV( 25, 1.5 )";
	addOrderToSequencer ( functionOrder, 2.0 );
	
	functionOrder = "setCameraModeBlendInfo( 6, \"seaUrchinNPC\", \"trackerCamera_CutScene02_01\", 0.0, 0.0, 0.7 )";
	addOrderToSequencer ( functionOrder, 2.0 );
	
return 0;
end

function StartCutScene02_final( )

	local functionOrder;
	
	functionOrder = "setFOV( 45, 3.0 )";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "landingAtack_grass( getEntityPosition(\"seaUrchinNPC\"), NULL )";
	addOrderToSequencer ( functionOrder, 0.5 );
	
	functionOrder = "setInstanceValidObjectValue( \"seaUrchinNPC\", false )";
	addOrderToSequencer ( functionOrder, 0.2 );
	
	functionOrder = "landingAtack_grass( getEntityPosition(\"seaUrchinNPC\"), NULL )";
	addOrderToSequencer ( functionOrder, 0.3 );
	
	functionOrder = "activateInput(true)";
	addOrderToSequencer ( functionOrder, 1.0 );
	
	functionOrder = "setCameraMode( 0, \"\", \"\", 0.0 )";
	addOrderToSequencer ( functionOrder, 0.0 );
	
return 0;
end

------------------------------------------------------ Cut Scene03: Player meets Shark

function StartCutScene03( )
	
	local functionOrder;
	
	functionOrder = "middle_Lvl1()";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	StartCutScene();
	
	-- Coloquem la camera
	functionOrder = "setCameraModeBlendInfo( 2, \"Shark11\", \"trackerCamera_CutScene03_01\", 50.0, 0.9, 0.0 )";
	addOrderToSequencer ( functionOrder, 0.0 );

	functionOrder = "setCameraModeBlendInfo( 6, \"Chest06\", \"trackerCamera_CutScene03_01\", 2.0, 0.9, 0.7 )";
	addOrderToSequencer ( functionOrder, 5.0 );
	
	functionOrder = "setFOV( 20, 1.5 )";
	addOrderToSequencer ( functionOrder, 1.0 );
	
	functionOrder = "setFOV( 45, 1.0 )";
	addOrderToSequencer ( functionOrder, 1.5 );
	
	functionOrder = "setCameraModeBlendInfo( 6, \"Cage01\", \"trackerCamera_CutScene03_01\", 2.0, 0.9, 0.7 )";
	addOrderToSequencer ( functionOrder, 1.0 );
	
	functionOrder = "setCameraModeBlendInfo( 4, \"\", \"trackerCamera_CutScene03_02\", 50.0, 0.9, 0.95 )";
	addOrderToSequencer ( functionOrder, 2.0 );
	
	functionOrder = "EndCutScene()";
	addOrderToSequencer ( functionOrder, 1.0 );
	
return 0;
end

------------------------------------------------------ Cut Scene04: Player meets lake SeaUrchin

function StartCutScene04( )

	local functionOrder;
	
	StartCutScene();

	-- Coloquem la camera
	functionOrder = "setCameraModeBlendInfo( 2, \"Cage02\", \"trackerCamera_checkPoint05\", 100.0, 0.98, 0.95 )";
	addOrderToSequencer ( functionOrder, 0.5 );
	
	functionOrder = "setFOV( 8, 3.0 )";
	addOrderToSequencer ( functionOrder, 1.0 );
	
	functionOrder = "setFOV( 45, 2.0 )";
	addOrderToSequencer ( functionOrder, 3.0 );
	
	-- Throw Line Player
	functionOrder = "playSound( \"Animated_entities/Player/Lines/enterLvl2\", getPlayerPosition() );";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "setCameraModeBlendInfo( 4, \"\", \"trackerCamera_checkPoint05\", 40.0, 0.9, 0.95 )";
	addOrderToSequencer ( functionOrder, 0.5 );
	
	functionOrder = "EndCutScene()";
	addOrderToSequencer ( functionOrder, 0.5 );
	
	functionOrder = "start_Lvl2()";
	addOrderToSequencer ( functionOrder, 0.7 );
	
return 0;
end

------------------------------------------------------ Cut Scene05: Sharks takes lake SeaUrchin to staticPlatform02

function StartCutScene05( )

	local functionOrder;
	
	StartCutScene();
	
	functionOrder = "setTrackerEntity( \"Cage02\", \"trackerCage_02\", 1, 4.0 )";
	addOrderToSequencer ( functionOrder, 1.5 );
	
	functionOrder = "setTrackerEntity( \"trackerPlatform_translate_13\", \"trackerCageSuport_02\", 1, 4.0 )";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "setThrowParticlesPlatform(\"trackerPlatform_translate_13\", true )";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "setEntityValidByName(\"hideShark16\", true)";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "setEntityValidByName(\"hideShark17\", true)";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "setEntityValidByName(\"hideShark18\", true)";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "throwParticles( \"water_fall\", getEntityPosition(\"hideShark16\"), NULL );";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "throwParticles( \"water_fall\", getEntityPosition(\"hideShark17\"), NULL );";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "throwParticles( \"water_fall\", getEntityPosition(\"hideShark18\"), NULL );";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	-- Coloquem la camera
	
	functionOrder = "setCameraModeBlendInfo( 6, \"hideShark16\", \"trackerCamera_15\", 0.0, 0.9, 0.95 )";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "setFOV( 20, 5.0 )";
	addOrderToSequencer ( functionOrder, 2.0 );
	
	functionOrder = "setCameraModeBlendInfo( 2, \"Cage02\", \"trackerCamera_15\", 0.0, 0.9, 0.95 )";
	addOrderToSequencer ( functionOrder, 2.0 );
	
	functionOrder = "setFOV( 45, 2.0 )";
	addOrderToSequencer ( functionOrder, 3.0 );
	
	-- Amagem les aletes de tauró
	
	functionOrder = "throwParticles( \"water_fall\", getEntityPosition(\"hideShark16\"), NULL );";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "setEntityValidByName(\"hideShark16\", false)";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "throwParticles( \"water_fall\", getEntityPosition(\"hideShark17\"), NULL );";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "setEntityValidByName(\"hideShark17\", false)";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "throwParticles( \"water_fall\", getEntityPosition(\"hideShark18\"), NULL );";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "setEntityValidByName(\"hideShark18\", false)";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "setThrowParticlesPlatform(\"trackerPlatform_translate_13\", false )";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	--------
	
	functionOrder = "setCameraModeBlendInfo( 2, \"Mag_PowerUp02\", \"trackerCamera_15\", 0.0, 0.9, 0.95 )";
	addOrderToSequencer ( functionOrder, 0.5 );
	
	functionOrder = "unHideItem( \"Mag_PowerUp02\" )";
	addOrderToSequencer ( functionOrder, 0.5 );
	
	functionOrder = "unHideItem( \"Mag_PowerUp03\" )";
	addOrderToSequencer ( functionOrder, 0.3 );
	
	functionOrder = "unHideItem( \"Mag_PowerUp04\" )";
	addOrderToSequencer ( functionOrder, 0.3 );
	
	unlockPathToStaticPlatform02();
	
	functionOrder = "setCameraModeBlendInfo( 0, \"\", \"\", 0.0, 0.9, 0.95 )";
	addOrderToSequencer ( functionOrder, 0.5 );
	
	functionOrder = "EndCutScene()";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "activateGUIDialog( \"NPC1_Dialog_PowerUp\", true )";
	addOrderToSequencer ( functionOrder, 1.0 );
	
	functionOrder = "activateGUIDialog( \"NPC1_Dialog_PowerUp\", false )";
	addOrderToSequencer ( functionOrder, 5.0 );
	
	-- Aquesta part cal posar-ho en una altre funció un cop alliberat el eriçó
	-- Aquest event fa que es desbloqueji el camí
	
return 0;
end

------------------------------------------------------ Cut Scene03: Unlock path to rescure lake seaUrchin, sam

function StartCutScene05_v2( )

	local functionOrder;
	
	StartCutScene();
	
	functionOrder = "setCameraMode( 2, \"trackerPlatform_circular_02\", \"trackerCamera_12\", 30.0 )";
	addOrderToSequencer ( functionOrder, 2.0 );
	
	functionOrder = "unHidePlatform(\"trackerPlatform_circular_01\")";
	addOrderToSequencer ( functionOrder, 0.2 );

	functionOrder = "unHidePlatform(\"trackerPlatform_circular_02\")";
	addOrderToSequencer ( functionOrder, 0.0 );

	functionOrder = "setCameraMode( 2, \"Switch02\", \"trackerCamera_12\", 30.0 )";
	addOrderToSequencer ( functionOrder, 2.0 );
	
	-- Activem les plataformes cap al switch02
	functionOrder = "unHidePlatform(\"trackerPlatform_hidde_02\")";
	addOrderToSequencer ( functionOrder, 0.5 );
	
	functionOrder = "unHidePlatform(\"trackerPlatform_hidde_04\")";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "setFOV( 20, 3.0 )";
	addOrderToSequencer ( functionOrder, 1.0 );
	
	functionOrder = "setFOV( 45, 1.0 )";
	addOrderToSequencer ( functionOrder, 2.0 );
	
	functionOrder = "setCameraMode( 4, \"\", \"trackerCamera_16\", 4.0 )";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "EndCutScene()";
	addOrderToSequencer ( functionOrder, 0.0 );
	
return 0;
end

-----------------------------------------------------------------------------------------------------

function StartCutScene05_old( )

	local functionOrder;
	
	--StartCutScene();

	-- Coloquem la camera
	functionOrder = "setCameraModeBlendInfo( 6, \"Cage02\", \"trackerCamera_18\", 0.0, 0.9, 0.95 )";
	addOrderToSequencer ( functionOrder, 2.0 );
	
	functionOrder = "setFOV( 30, 2.0 )";
	addOrderToSequencer ( functionOrder, 2.0 );
	
	functionOrder = "setFOV( 45, 2.0 )";
	addOrderToSequencer ( functionOrder, 3.0 );
	
	functionOrder = "setCameraModeBlendInfo( 2, \"Mag_PowerUp02\", \"trackerCamera_18\", 0.0, 0.9, 0.95 )";
	addOrderToSequencer ( functionOrder, 0.5 );
	
	functionOrder = "unHideItem( \"Mag_PowerUp02\" )";
	addOrderToSequencer ( functionOrder, 0.5 );
	
	functionOrder = "setCameraModeBlendInfo( 0, \"\", \"\", 0.0, 0.9, 0.95 )";
	addOrderToSequencer ( functionOrder, 0.5 );
	
	functionOrder = "EndCutScene()";
	addOrderToSequencer ( functionOrder, 0.0 );
	
return 0;
end

------------------------------------------------------ Cut Scene03: Player knows KingPaul

function StartCutScene06( )
	
return 0;
end

------------------------------------------------------ Cut Scene07: KingPaul defated

function StartCutScene07( )

	local functionOrder;
	
	StartCutScene();
	
	unHideCage("Cage03", "trackerEndCage_03");
	
	functionOrder = "setCameraModeBlendInfo( 2, \"Cage03\", \"trackerCamera_17\", 0.0, 0.9, 0.95 )";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "setFOV( 25, 2.0 )";
	addOrderToSequencer ( functionOrder, 2.0 );
	
	functionOrder = "setFOV( 45, 2.0 )";
	addOrderToSequencer ( functionOrder, 3.0 );
	
	functionOrder = "setCameraMode( 4, \"\", \"trackerCamera_17\", 4.0 )";
	addOrderToSequencer ( functionOrder, 1.0 );
	
	functionOrder = "EndCutScene()";
	addOrderToSequencer ( functionOrder, 1.0 );
	
return 0;
end

------------------------------------------------------ Cut Scene08: Introduction to cage04

function startCutScene08( )

	local functionOrder;
	
	-- Activem la musica de batalla curta
	functionOrder = "start_shortBattleSeq_Lvl2()";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	StartCutScene();
	
	functionOrder = "setCameraModeBlendInfo( 2, \"Cage04\", \"trackerCamera_15\", 0.0, 0.9, 0.95 )";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "setFOV( 25, 2.0 )";
	addOrderToSequencer ( functionOrder, 2.0 );
	
	functionOrder = "setTrackerEntity( \"Cage04\", \"trackerCage_04\", 1, 4.0 )";
	addOrderToSequencer ( functionOrder, 1.0 );
	
	functionOrder = "throwParticles( \"picat_ground\", getEntityPosition( \"Cage04\" ), NULL )";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	-- Ensenyem els pops que tenen cautiva la cage
	functionOrder = "unHideEnemy( \"Octopus29\" )";
	addOrderToSequencer ( functionOrder, 0.5 );
	
	functionOrder = "unHideEnemy( \"Octopus30\" )";
	addOrderToSequencer ( functionOrder, 0.1 );
	
	functionOrder = "unHideEnemy( \"Octopus31\" )";
	addOrderToSequencer ( functionOrder, 0.2 );
	
	functionOrder = "unHideEnemy( \"Octopus32\" )";
	addOrderToSequencer ( functionOrder, 0.3 );
	
	functionOrder = "setFOV( 45, 2.0 )";
	addOrderToSequencer ( functionOrder, 1.5 );
	
	functionOrder = "setCameraMode( 0, \"\", \"\", 0.0 )";
	addOrderToSequencer ( functionOrder, 1.0 );
	
	functionOrder = "EndCutScene()";
	addOrderToSequencer ( functionOrder, 1.0 );
	
	functionOrder = "setEntityValidByName( \"Cage04\", false )";
	addOrderToSequencer ( functionOrder, 3.0 );
	
	-- Guardem l'estat
	functionOrder = "saveStateOfAllGameInstances()";
	addOrderToSequencer ( functionOrder, 0.0 );
	
return 0;
end

------------------------------------------------------ Cut Scene08: Introduction unearth cage04

function startCutScene09( )
	
	local functionOrder;
	
	StartCutScene();
	
	setEntityValidByName( "hiden_cage01", true );
	
	-- No vull que es vegin les pedres que acompanyen a aquest tipus de interrupor
	setEntityVisibleByName( "hiden_cage01", false );
	
	functionOrder = "setCameraModeBlendInfo( 6, \"hiden_cage01\", \"trackerCamera_28\", 0.0, 0.9, 0.95 )";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	--functionOrder = "setFOV( 30, 2.0 )";
	--addOrderToSequencer ( functionOrder, 3.0 );
	
	--functionOrder = "setFOV( 45, 2.0 )";
	--addOrderToSequencer ( functionOrder, 2.0 );
	
	functionOrder = "setCameraMode( 0, \"\", \"\", 0.0 )";
	addOrderToSequencer ( functionOrder, 3.0 );
	
	functionOrder = "EndCutScene()";
	addOrderToSequencer ( functionOrder, 1.0 );
	
	if( areActionsWithKeyBoard() ) then
		functionOrder = "setComicDialog( getMainPlayer(), \"info_picat\")";
	elseif( areActionsWithPad() ) then
		functionOrder = "setComicDialog( getMainPlayer(), \"info_picat_pad\")";
	else
		functionOrder = "setComicDialog( getMainPlayer(), \"info_picat_mouse\")";
	end
	
	addOrderToSequencer ( functionOrder, 1.0 );
	
	-- Guardem l'estat
	functionOrder = "saveStateOfAllGameInstances()";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	-- desactivem la musica de batalla curta
	functionOrder = "end_shortBattleSeq_Lvl2()";
	addOrderToSequencer ( functionOrder, 0.0 );

return 0;
end

------------------------------------------------------ Cut Scene08: Cage04 is rescured!

function startCutScene10( )

	local functionOrder;
	
	StartCutScene();
	
	setVisiblityComicDialog( getMainPlayer(), false );
	unHideCage("Cage04", "trackerEndCage_04");
	
	-- Treiem el tracker al que estava associat el cofre
	setTrackerEntity( "Cage04", "", 0, 0.0 );
	
	functionOrder = "setCameraModeBlendInfo( 6, \"Cage04\", \"trackerCamera_28\", 0.0, 0.9, 0.95 )";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	--functionOrder = "setFOV( 30, 2.0 )";
	--addOrderToSequencer ( functionOrder, 3.0 );
	
	--functionOrder = "setFOV( 45, 2.0 )";
	--addOrderToSequencer ( functionOrder, 2.0 );
	
	functionOrder = "setCameraMode( 0, \"\", \"\", 0.0 )";
	addOrderToSequencer ( functionOrder, 4.0 );
	
	functionOrder = "EndCutScene()";
	addOrderToSequencer ( functionOrder, 1.0 );
	
	functionOrder = "isTrigger_FollowPath05_enabled = true";
	addOrderToSequencer ( functionOrder, 2.0 );
	
	-- Deixem silenci
	functionOrder = "stopCurrentMusic( false )";
	addOrderToSequencer ( functionOrder, 0.0 );

return 0;
end

------------------------------------------------------ Cut Scene11: Player discover shark's base

function startCutScene11( )

	local functionOrder;
	
	StartCutScene();
	
	functionOrder = "incrementWptScriptedPlatform(\"trackerPlatform_scriptedLake_01\")";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "setCameraModeBlendInfo( 2, \"JawShark\", \"trackerCamera_05\", 200.0, 0.9, 0.95 )";
	addOrderToSequencer ( functionOrder, 1.0 );
	
	functionOrder = "Unlock_Achivement_DiscoverTemple()";
	addOrderToSequencer ( functionOrder, 10.0 );
	
    -- Activem els sistemes de particules que es veuran a la cinematica
	
    --functionOrder = "setEntityValidByName(\"PsEmiter_water_impact08\", true )";
	--addOrderToSequencer ( functionOrder, 0.0 );
	--functionOrder = "setEntityValidByName(\"PsEmiter_water_impact09\", true )";
	--addOrderToSequencer ( functionOrder, 0.0 );
	--functionOrder = "setEntityValidByName(\"PsEmiter_water_impact10\", true )";
	--addOrderToSequencer ( functionOrder, 0.0 );
	--functionOrder = "setEntityValidByName(\"PsEmiter_water_impact11\", true )";
	--addOrderToSequencer ( functionOrder, 0.0 );
	--functionOrder = "setEntityValidByName(\"PsEmiter_water_impact12\", true )";
	--addOrderToSequencer ( functionOrder, 0.0 );
	--functionOrder = "setEntityValidByName(\"PsEmiter_water_impact13\", true )";
	--addOrderToSequencer ( functionOrder, 0.0 );
	--functionOrder = "setEntityValidByName(\"PsEmiter_water_impact14\", true )";
	--addOrderToSequencer ( functionOrder, 0.0 );
	
	------------------------------------------------------------------
	
	-- Parem el so de l'aigua baixant
	functionOrder = "stopSound(\"Game_situations/platformBoss_Down\")";
	addOrderToSequencer ( functionOrder, 0.0);

	functionOrder = "setCameraModeBlendInfo( 2, \"JawShark\", \"trackerCamera_07\", 200.0, 0.9, 0.95 )";
	addOrderToSequencer ( functionOrder, 5.0 );

	functionOrder = "setCameraMode( 4, \"\", \"trackerCamera_21\", 4.0 )";
	addOrderToSequencer ( functionOrder, 10.0 );
	
	-- Throw Line Player
	functionOrder = "playSound( \"Animated_entities/Player/Lines/discoverPiratesBase\", getPlayerPosition() );";
	addOrderToSequencer ( functionOrder, 0.5 );
	
	functionOrder = "EndCutScene()";
	addOrderToSequencer ( functionOrder, 1.0 );

return 0;
end

------------------------------------------------------ Cut Scene12: Presentation of finalBattle gameplay

function StartCutScene12( )
	
	local functionOrder;
	
	functionOrder = "start_finalBattleSeq_Lvl2()";
	addOrderToSequencer ( functionOrder, 2.0 );
	
	StartCutScene();
	
	functionOrder = "setCameraMode( 4, \"\", \"trackerCamera_22\", 100.0 )";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	-- Appear Cages
	
	functionOrder = "appearItem(\"Cage05\")";
	addOrderToSequencer ( functionOrder, 0.2 );

	functionOrder = "appearItem(\"Cage06\")";
	addOrderToSequencer ( functionOrder, 0.5 );
	
	functionOrder = "appearItem(\"Cage07\")";
	addOrderToSequencer ( functionOrder, 0.5 );
	
	functionOrder = "appearItem(\"Cage08\")";
	addOrderToSequencer ( functionOrder, 0.5 );
	
	-- Hide Cages
	
	functionOrder = "hideItem(\"Cage05\")";
	addOrderToSequencer ( functionOrder, 2.0 );

	functionOrder = "hideItem(\"Cage06\")";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "hideItem(\"Cage07\")";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "hideItem(\"Cage08\")";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	-- Invalidem les instancies un cop mostrades
	
	functionOrder = "setEntityValidByName( \"Cage05\", false )";
	addOrderToSequencer ( functionOrder, 0.5 );
	
	functionOrder = "setEntityValidByName( \"Cage06\", false )";
	addOrderToSequencer ( functionOrder, 0.5 );
	
	functionOrder = "setEntityValidByName( \"Cage07\", false )";
	addOrderToSequencer ( functionOrder, 0.5 );
	
	functionOrder = "setEntityValidByName( \"Cage08\", false )";
	addOrderToSequencer ( functionOrder, 0.5 );
	
	--------------------------------------------
	
	functionOrder = "EndCutScene()";
	addOrderToSequencer ( functionOrder, 2.0 );
	
	functionOrder = "startFinalBattle()";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "setChangeFOV( true )";
	addOrderToSequencer ( functionOrder, 0.0 );
	
return 0;
end

------------------------------------------------------ Cut Scene12: Show path to the final boss

function StartCutScene13( )
	
	local functionOrder;
	
	functionOrder = "end_finalBattleSeq_Lvl2()";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	StartCutScene();
	
	functionOrder = "setCameraModeBlendInfo( 6, \"JawShark\", \"trackerCamera_31\", 0.0, 0.0, 0.0 )";
	addOrderToSequencer ( functionOrder, 1.0 );

	functionOrder = "setPlayerVisible( false )";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	unlockPathToFinalBoss();
	
	functionOrder = "EndCutScene()";
	addOrderToSequencer ( functionOrder, 2.0 );
	
    functionOrder = "setCameraModeBlendInfo( 6, \"JawShark\", \"trackerCamera_24\", 0.0, 0.0, 0.0 )";
    addOrderToSequencer ( functionOrder, 0.5 );
    
    functionOrder = "setPlayerVisible( true )";
	addOrderToSequencer ( functionOrder, 0.0 );
    
    functionOrder = "setCameraMode( 0, \"\", \"\", 0.0)";
    addOrderToSequencer ( functionOrder, 0.5 );
	
return 0;
end

------------------------------------------------------ Cut Scene: Introducing FinalBoss

function StartCutScene_FinalBoss_StartStage0( )
	
	local functionOrder;
	local idShark = getEntityID( "MegaWhiteShark" );
	
	StartCutScene();
	
	-- Mostrem una el temple amb un traveling
    functionOrder = "setCameraModeBlendInfo( 6, \"rockLake77\", \"trackerCamera_RingFinalBoss_Stage0_Central\", 0.0, 0.0, 0.0 )";
    addOrderToSequencer ( functionOrder, 1.0 );
    
    functionOrder = "setCameraModeBlendInfo( 6, \"plant_red79\", \"trackerCamera_RingFinalBoss_Stage0_Central\", 0.0, 0.0, 0.98 )";
    addOrderToSequencer ( functionOrder, 0.5 );
    
    functionOrder = "setCameraModeBlendInfo( 6, \"JawShark\", \"trackerCamera_RingFinalBoss_Stage0_Central\", 0.0, 0.0, 0.96 )";
    addOrderToSequencer ( functionOrder, 3.5 );
    
    functionOrder = "setCameraModeBlendInfo( 2, \"MegaWhiteShark\", \"trackerCamera_RingFinalBoss_Stage0_NearBoss\", 100.0, 0.95, 0.96 )";
    addOrderToSequencer ( functionOrder, 0.5 );
	
    functionOrder = "setFOV( 35, 5.0 )";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	-- Obrim la boca del temple
	sendMessage( 5.5, idShark, idShark, Telegram.Play_Animation_Open, NULL );
	
    -- Riure del boss
	sendMessage( 6.0, idShark, idShark, Telegram.Play_Animation_Laught, NULL );
	
	-- Restablim el idle del boss
	sendMessage( 8.5, idShark, idShark, Telegram.Play_Animation_Idle, NULL );

	-- Salt del jaw Shark cap amunt
	sendMessage( 9.5, idShark, idShark, Telegram.Play_Animation_Appear, NULL );
	
	-- Ensenyem la debilitat
	functionOrder = "setCameraModeBlendInfo( 6, \"rockLakemini89\", \"trackerCamera_RingFinalBoss_Stage2_End\", 2.0, 0.0, 0.0 )";
    addOrderToSequencer ( functionOrder, 5.0 );
    
    --functionOrder = "setFOV( 30, 5.0 )";
	--addOrderToSequencer ( functionOrder, 0.0 );
    
    sendMessage( 12.0, idShark, idShark, Telegram.Play_Animation_Landing, NULL );
    
    functionOrder = "setCameraModeBlendInfo( 2, \"MegaWhiteShark\", \"trackerCamera_RingFinalBoss_Stage0_NearBoss\", 80.0, 0.95, 0.96 )";
    addOrderToSequencer ( functionOrder, 2.0 );
    
    sendMessage( 13.0, idShark, idShark, Telegram.Play_Animation_Idle, NULL );
	
	functionOrder = "setFOV( 45, 1.0 )";
	addOrderToSequencer ( functionOrder, 5.0 );

    -- Restablim la camera general del final battle	
	functionOrder = "setCameraModeBlendInfo( 6, \"MegaWhiteShark\", \"trackerCamera_RingFinalBoss_Stage1_01\", 0.0, 0.0, 0.0 )";
    addOrderToSequencer ( functionOrder, 0.0 );

    functionOrder = "setCameraMode( 4, \"\", \"trackerCamera_RingFinalBoss_Stage1_01\", 4.0 )";
    addOrderToSequencer ( functionOrder, 0.5 );
    
    -- Aparició a la plataforma central
	sendMessage( 16.0, idShark, idShark, Telegram.Change_Idle_State, NULL );
	
	-- Acabem cinematica
	functionOrder = "EndCutScene()";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	-- Activem la musica de la primera ronda
	functionOrder = "start_finalBoss_stage1()";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	-- Ensenyem el GUI del final Boss
	functionOrder = "appearGUILifeBoss()";
	addOrderToSequencer ( functionOrder, 1.0 );
	
return 0;
end

------------------------------------------------------ Cut Scene: Final Stage1 - Start Stage2 - FinalBoss

function StartCutScene_FinalBoss_StartStage2( )
	
	local functionOrder;
	
	StartCutScene();
	
	-- Cinematica que mostra com el boss canvia de plataforma
	local functionOrder = "setCameraModeBlendInfo( 6, \"MegaWhiteShark\", \"trackerCamera_RingFinalBoss_Stage2_Right\", 4.0, 0.0, 0.95 )";
	addOrderToSequencer ( functionOrder, 0.2 );
    
	-- Enfoquem la plataforma dreta
	functionOrder = "setCameraMode( 2, \"Octopus41_BraveLongRange\", \"trackerCamera_RingFinalBoss_Stage2_Right\", 0.0 )";
	addOrderToSequencer ( functionOrder, 1.5 );
	
	-- Es la camera segons la plataforma per la que començi el tauro. (dreta)
	functionOrder = "setCameraMode( 4, \"\", \"trackerCamera_RingFinalBoss_Stage2_Right\", 0.0 )";
	addOrderToSequencer ( functionOrder, 2.5 );
	
	-- Acabem cinematica
	functionOrder = "EndCutScene()";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	-- Triggers of the second stage2 activation
	functionOrder = "isTrigger_trigger_finalBossStage2_Right_enabled = true";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "restartTriggers()";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	-- Guardem l'estat de la nova configuració
	functionOrder = "saveStateOfAllGameInstances()";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	-- Activem la musica de la segonda ronda
	functionOrder = "start_finalBoss_stage2()";
	addOrderToSequencer ( functionOrder, 0.0 );
	
return 0;
end


------------------------------------------------------ Cut Scene: FinalBoss_EndStage2

function StartCutScene_FinalBoss_EndStage2( )
	
	local functionOrder;
	local idShark = getEntityID( "MegaWhiteShark" );
	
	-- Triggers of the second stage2 desactivation
	isTrigger_trigger_finalBossStage2_Left_enabled = false;
	isTrigger_trigger_finalBossStage2_Right_enabled = false;
	
	-- Cancel active seaUrchins in the finalBoss platform
	cancelSeaUrchinBattalion_finalBoss();
	
	-- Stablish a recover point when phase2 ended
	is_in_EndStage2_finalBoss = true;
	
	-- So de terratremol de la plataforma
	playSound( "Game_situations/earthQuake", Vector3(0.0, 0.0, 0.0 ) )
	
	StartCutScene();
	
	-- Tremolor de camera
	functionOrder = "setHitCameraMode( true, 1.5 )";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "setCameraModeBlendInfo( 6, \"tracker_FinalBoss_CenterPlat\", \"trackerCamera_RingFinalBoss_Stage2_MegaPicat\", 0.0, 0.0, 0.0 )";
	addOrderToSequencer ( functionOrder, 0.0 );
	
    -- Activem la sequencia de accions que fan el ultim megapicat
	--sendMessage( 0.0, idShark, idShark, Telegram.Do_MegaPicat_In_CentralPlatform, NULL );
	
	functionOrder = "setCameraModeBlendInfo( 4, \"\", \"trackerCamera_RingFinalBoss_Stage2_End\", 40.0, 0.0, 0.0 )";
	addOrderToSequencer ( functionOrder, 3.0 );
	
	-- Activem el sistema de particles destrucció de la plataforma
	functionOrder = "activate_psEmiters_EndStage2_finalBoss( 14.0 )";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "setCameraMode( 2, \"trackerPlatform_translate_21\", \"trackerCamera_RingFinalBoss_Stage2_End\", 0.0 )";
	addOrderToSequencer ( functionOrder, 2.0 );
	
	-- Mostrem la via de escapada amb les lakePlants
	functionOrder = "unHidePlatform(\"trackerPlatform_translate_20\")";
	addOrderToSequencer ( functionOrder, 0.2 );
	functionOrder = "unHidePlatform(\"trackerPlatform_translate_21\")";
	addOrderToSequencer ( functionOrder, 0.3 );
	functionOrder = "unHidePlatform(\"trackerPlatform_translate_22\")";
	addOrderToSequencer ( functionOrder, 0.4 );
	
	-- Afegim blink a les plataformes, per reforçar el feedback
	functionOrder = "setBlinkerByName( \"trackerPlatform_translate_20\", ColorRGBA(0.8,0.8,0.8,0.8), 10, 3 )";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "setBlinkerByName( \"trackerPlatform_translate_21\", ColorRGBA(0.8,0.8,0.8,0.8), 10, 3 )";
	addOrderToSequencer ( functionOrder, 0.0 );

    functionOrder = "setBlinkerByName( \"trackerPlatform_translate_22\", ColorRGBA(0.8,0.8,0.8,0.8), 10, 3 )";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "setCameraMode( 4, \"\", \"trackerCamera_RingFinalBoss_Stage2_End\", 40.0 )";
	addOrderToSequencer ( functionOrder, 1.5 );
	
	-- Baixem 2 posicions la plataforma central i les colisions
	functionOrder = "incrementEntityScriptedTracker(\"ringFinalBattle\")";
	addOrderToSequencer ( functionOrder, 0.5 );
	
	functionOrder = "incrementEntityScriptedTracker(\"platform_vertical_2_35\")";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "incrementEntityScriptedTracker(\"platform_horitzontal_2_60_rock\")";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "incrementEntityScriptedTracker(\"ringFinalBattle\")";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "incrementEntityScriptedTracker(\"platform_vertical_2_35\")";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "incrementEntityScriptedTracker(\"platform_horitzontal_2_60_rock\")";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	-- Acabem cinematica
	functionOrder = "EndCutScene()";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	--functionOrder = "setChangeFOV( true )";
	--addOrderToSequencer ( functionOrder, 0.0 );
	
	-- Guardem l'estat de la nova configuració
	functionOrder = "saveStateOfAllGameInstances()";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	-- Activem la musica de la tercera ronda
	functionOrder = "start_finalBoss_stage3()";
	addOrderToSequencer ( functionOrder, 0.0 );
	
return 0;
end

------------------------------------------------------ 

function StartCutScene_FinalBoss_StartStage3( )
	
	local functionOrder;
	
	-- parem el so de terratremol
	stopSound( "Game_situations/earthQuake" );
	
    -- Cal afegir el tauro donant voltes per el escenari
	StartCutScene();
	
	desactivate_psEmiters_EndStage2_finalBoss( 0.0 );
	
	-- Associem nous trackers a les plataformes
	setTrackerEntity( "trackerPlatform_translate_22", "tracker_translate_22", 3, 6.0 );
	setTrackerEntity( "trackerPlatform_translate_21", "tracker_translate_21", 3, 6.0 );
	setTrackerEntity( "trackerPlatform_translate_20", "tracker_translate_20", 3, 6.0 );
	
	-- Activem el particleEmiter de les lakePlants
	setThrowParticlesPlatform("trackerPlatform_translate_22", true );
	setThrowParticlesPlatform("trackerPlatform_translate_21", true );
	setThrowParticlesPlatform("trackerPlatform_translate_20", true );	
	
	functionOrder = "setHitCameraMode( false, 1.0 )";
	addOrderToSequencer ( functionOrder, 0.2 );
	
	functionOrder = "setCameraMode( 4, \"\", \"trackerCamera_RingFinalBoss_Stage3\", 40.0 )";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "Unlock_FinalBoss_Lakeplants_Stage03( )";
	addOrderToSequencer ( functionOrder, 2.0 );
	
	-- Activem la ia del boss al stage3
	functionOrder = "changeEntityState(getEntityID(\"MegaWhiteShark\"), \"MegaWhiteShark_Phase3_Init\")";
	addOrderToSequencer ( functionOrder, 1.0 );
	
	-- Guradem estat per la ultima fase
	functionOrder = "is_in_Stage3_finalBoss = true";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	-- Acabem cinematica
	functionOrder = "EndCutScene()";
	addOrderToSequencer ( functionOrder, 1.0 );
	
	functionOrder = "setCameraModeBlendInfo( 2, \"trackerCamera_Target_Stage03\", \"trackerCamera_44\", 50.0, 0.9, 0.95 );";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	-- Parem el particleEmiter de les lakePlants
	functionOrder = "setThrowParticlesPlatform(\"trackerPlatform_translate_22\", false )";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "setThrowParticlesPlatform(\"trackerPlatform_translate_21\", false )";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	functionOrder = "setThrowParticlesPlatform(\"trackerPlatform_translate_20\", false )";
	addOrderToSequencer ( functionOrder, 0.0 );
	
	-- Guardem la nova posició de aparició del player
	functionOrder = "setPlayerLastCheckPoint(\"trigger_posSave12\");";
	addOrderToSequencer ( functionOrder, 0.0 );
	
return 0;
end

------------------------------------------------------ 

function StartCutScene_FinalBoss_EndHitCinematic( )
	
	local functionOrder;
	
	StartCutScene();
	
    functionOrder = "setPlayerLastCheckPoint(\"trigger_posSave13\")";
	addOrderToSequencerWithId ( 3, functionOrder, 0.0 );
	
	functionOrder = "setCameraMode( 4, \"\", \"trackerCamera_LastHit_Hit\", 50.0)";
	addOrderToSequencerWithId ( 3, functionOrder, 0.2 );
	
	functionOrder = "setSlowMotion( true )";
	addOrderToSequencerWithId ( 3, functionOrder, 0.0 );
	
	--functionOrder = "forcePlayerToStopLandingAttack()";
	--addOrderToSequencerWithId ( 3, functionOrder, 0.0 );
	
    functionOrder = "throwAreaParticles( \"enemy_die\", getEntityPositionByID(getEntityID(\"MegaWhiteShark\")), 1, 2 )"
    addOrderToSequencerWithId ( 3, functionOrder, 1.0 );
    
    functionOrder = "setCameraMode( 2, \"MegaWhiteShark\", \"trackerCamera_LastHit_Hit\", 50.0)";
	addOrderToSequencerWithId ( 3, functionOrder, 0.5 );
	
	functionOrder = "throwAreaParticles( \"unhide_water_big\", getEntityPositionByID(getEntityID(\"MegaWhiteShark\")), 2, 6 );";
	addOrderToSequencerWithId ( 3, functionOrder, 1.0 );
	
    functionOrder = "setSlowMotion( false )";
    addOrderToSequencerWithId ( 3, functionOrder, 2.0 );
    
	functionOrder = "unHidePlatform(\"trackerPlatform_static_03\")";
	addOrderToSequencerWithId ( 3, functionOrder, 0.0 );
	
	functionOrder = "setEntityValidByName(\"platform_horitzontal_stopPicat\", false)";
	addOrderToSequencerWithId ( 3, functionOrder, 1.0 );
	
    functionOrder = "forcePlayerLand()";
	addOrderToSequencerWithId ( 3, functionOrder, 0.1 );
	  
	-- Acabem cinematica
	functionOrder = "EndCutScene()";
	addOrderToSequencerWithId ( 3, functionOrder, 1.0 );
	
	-- Throw Line Player
    functionOrder = "playSound( \"Animated_entities/Player/Lines/defeatFinalBoss\", getPlayerPosition() );";
    addOrderToSequencer ( functionOrder, 2.0 );
	
return 0;
end


