-- LUA donde se guarda la resupesta a todos los eventos

--------------------------------------------------------- Step events
function step( position, entity3D )
return 0;
end

function step_sand( position, entity3D )

	-- Llamar al sistema de particulas
	throwParticles( "run_sand", position, NULL );
	
	-- LLamar al sonido correspondiente
	playSound( "Animated_entities/Common_events/Step/step_sand", position );
	
return 0;
end

function step_grass( position, entity3D )
	throwParticles( "run_grass", position, NULL );
	playSound( "Animated_entities/Common_events/Step/step_grass", position );
return 0;
end

function step_wood( position, entity3D )
	throwParticles( "run_ground", position, NULL );
	playSound( "Animated_entities/Common_events/Step/step_ground", position );
return 0;
end

function step_water( position, entity3D )
	throwParticles( "run_water", position, NULL );
	playSound( "Animated_entities/Common_events/Step/step_water", position );
return 0;
end

function step_rock( position, entity3D)
	throwParticles( "run_ground", position, NULL );
	playSound( "Animated_entities/Common_events/Step/step_ground", position );
return 0;
end

--------------------------------------------------------- bigStep events
function bigStep( position, entity3D )
return 0;
end

function bigStep_sand( position, entity3D )
	-- Llamar al sistema de particulas
	throwParticles( "octopus_appear_sand", position, NULL );
return 0;
end

function bigStep_grass( position, entity3D )
	throwParticles( "octopus_appear_grass", position, NULL );
	-- playSound( "player/run_grass", position );
return 0;
end

function bigStep_wood( position, entity3D )
	throwParticles( "octopus_appear_ground", position, NULL );
return 0;
end

function bigStep_water( position, entity3D )
	throwParticles( "run_water", position, NULL );
	-- playSound( "player/run_water", position );
return 0;
end

function bigStep_rock( position, entity3D)
	throwParticles( "octopus_appear_ground", position, NULL );
return 0;
end

------------------------------------------------------------- Hide events
function hide( position, entity3D )
	--playSound( "Animated_entities/Octopus/hide", position );
return 0;
end

function hide_sand( position, entity3D )
	throwParticles( "octopus_hide_sand", position, NULL );
return 0;
end

function hide_rock( position, entity3D )
	throwParticles( "octopus_hide_ground", position, NULL );
return 0;
end

function hide_grass( position, entity3D )
	throwParticles( "octopus_hide_grass", position, NULL );
return 0;
end

function hide_water( position, entity3D )
	throwParticles( "leaf_diveing", position, NULL );
return 0;
end

------------------------------------------------------------- unHide events
function unhide( position, entity3D )
return 0;
end

function unhide_sand( position, entity3D )
	playSound( "Animated_entities/Octopus/appear_default", position );
	throwParticles( "octopus_appear_sand", position, NULL );
return 0;
end

function unhide_rock( position, entity3D )
	playSound( "Animated_entities/Octopus/appear_default", position );
	throwParticles( "octopus_appear_ground", position, NULL );
return 0;
end

function unhide_grass( position, entity3D )
	playSound( "Animated_entities/Octopus/appear_default", position );
	throwParticles( "octopus_appear_grass", position, NULL );
return 0;
end

function unhide_water( position, entity3D )
	playSound( "Animated_entities/Octopus/appear_water", position );
	throwParticles( "water_fall", position, NULL );
return 0;
end

function unhide_water_blue( position, entity3D )
	playSound( "Animated_entities/Octopus/appear_water", position );
	throwParticles( "water_fall_blue", position, NULL );
return 0;
end

function unhide_water_big( position, entity3D )
	playSound( "Animated_entities/Common_events/Hit_impacts/water_splash", position );
	throwParticles( "unhide_water_big", position, NULL );
return 0;
end

function unhide_default( position, entity3D )
	playSound( "Animated_entities/Octopus/appear_default", position );
	throwParticles( "enemy_die", position, NULL );
return 0;
end

--------------------------------------------------------------- Twister events
function twister( position, entity3D )
	throwParticles( "twister", position, entity3D);
	playSound( "Animated_entities/Player/twister_attack", position );
return 0;
end

function twister_sand( position, entity3D )
	throwParticles( "twister_sand", position, NULL );
return 0;
end

function twister_rock( position, entity3D )
	throwParticles( "twister_ground", position, NULL );
return 0;
end

function twister_grass( position, entity3D )
	throwParticles( "twister_grass", position, NULL );
return 0;
end

--------------------------------------------------------------- MegaTwister event
function megaTwister_voice( position, entity3D )
	playSound( "Animated_entities/Player/megaTwister_attack_voice", position );
return 0;
end

function megaTwister( position, entity3D )
	throwParticles( "megatwister", position, entity3D);
	playSound( "Animated_entities/Player/megaTwister_attack", position );
return 0;
end

function megaTwister_sand( position, entity3D )
	throwParticles( "megatwister_sand", position, NULL );
return 0;
end

function megaTwister_rock( position, entity3D )
	throwParticles( "megatwister_ground", position, NULL );
return 0;
end

function megaTwister_grass( position, entity3D )
	throwParticles( "megatwister_grass", position, NULL );
return 0;
end

function megaTwister_default( position, entity3D )
	throwParticles( "megatwister_default", position, NULL );
return 0;
end

--------------------------------------------------------------- LandingHit events
function landingHit( position, entity3D )
	playSound( "Animated_entities/Player/landing_attack", position );
return 0;
end

function landingHit_sand( position, entity3D )
	throwParticles( "picat_sand", position, NULL );
return 0;
end

function landingHit_rock( position, entity3D )
	throwParticles( "picat_ground", position, NULL );
return 0;
end

function landingHit_grass( position, entity3D )
	throwParticles( "picat_grass", position, NULL );
return 0;
end

function landingHit_water( position, entity3D )
	throwParticles( "picat_sand", position, NULL );
return 0;
end

function landingHit_default( position, entity3D )
	throwParticles( "picat_default", position, NULL );
return 0;
end

--------------------------------------------------------------- LandingAtack events

function landingAtack( position, entity3D )
    landingHit( position, entity3D )
    
    -- Per a que no soni al final del joc
    if( HAS_DESTROYED_FINAL_LAKE_PLANT == false ) then
	    playSound( "Animated_entities/Player/landing_attack_voice", position );
	end
		
return 0;
end

function landingAtack_sand( position, entity3D )
    landingHit_sand( position, entity3D )
return 0;
end

function landingAtack_rock( position, entity3D )
	landingHit_rock( position, entity3D )
return 0;
end

function landingAtack_grass( position, entity3D )
	landingHit_grass( position, NULL );
return 0;
end

function landingAtack_water( position, entity3D )
	landingHit_water( position, NULL );
return 0;
end

function landingAtack_default( position, entity3D )
	landingHit_default( position, NULL );
return 0;
end

--------------------------------------------------------------- Shoot event
function shoot( position, entity3D )
	sendTimeToShootMessage( entity3D, position );
	
	throwParticles( "octopus_shoot", position, entity3D );
	playSound( "Animated_entities/Octopus/big_shoot", position );
	return 0;
end

------------------------------------------------------------- Hit events
function hit( position, entity3D )
    setBlinker( entity3D, ColorRGBA(1,1,1,0.8), 0.5, 1 );
	throwParticles( "hit", position, NULL );
	playSound( "Animated_entities/Common_events/Hit_impacts/hit_scenario_wood", position );
return 0;
end

function player_hited( position, entity3D )
    setBlinker( entity3D, ColorRGBA(1,1,1,0.8), 0.5, 1 );
	throwParticles( "hit", position, NULL );
	playSound( "Gui_Menu/player_hited", position );
	playSound( "Animated_entities/Player/hit", position );
return 0;
end

--------------------------------------------------------------- shark events

function alert_shark( position, entity3D )
	throwParticles( "shark_alert", position, entity3D );
return 0;
end

function shark_hited( position, entity3D )
    setBlinker( entity3D, ColorRGBA(1,1,1,0.8), 0.5, 1 );
	throwParticles( "hit", position, NULL );
	playSound( "Animated_entities/Shark/hit", position );
return 0;
end

function shark_trapped( position, entity3D )
	playSound( "Animated_entities/Shark/trapped", position );
return 0;
end

function shark_directionalAttack( position, entity3D )
	playSound( "Animated_entities/Shark/directional_attack", position );
return 0;
end

function shark_horitzontalAttack( position, entity3D )
	playSound( "Animated_entities/Shark/horitzontal_attack", position );
return 0;
end

function shark_search( position, entity3D )
	--playSound( "Animated_entities/Shark/search", position );
return 0;
end

function shark_appearWater( position, entity3D )
	playSound( "Animated_entities/Shark/appear_water_voice", position );
return 0;
end

function shark_die( position, entity3D )
	playSound( "Animated_entities/Shark/die", position );
return 0;
end

--------------------------------------------------------------- takingOff events
function takingOff( position, entity3D )
    -- Per a que no soni al final del joc
    if( HAS_DESTROYED_FINAL_LAKE_PLANT == false ) then
	    playSound( "Animated_entities/Player/takingOff", position );
	end
return 0;
end

function takingOff_sand( position, entity3D )
	throwParticles( "run_sand", position, NULL );
return 0;
end

function takingOff_rock( position, entity3D )
	throwParticles( "run_ground", position, NULL );
return 0;
end

function takingOff_wood( position, entity3D )
	throwParticles( "run_ground", position, NULL );
return 0;
end

function takingOff_water( position, entity3D )
	throwParticles( "run_water", position, NULL );
return 0;
end

function doubleTakingOff( position, entity3D )
	playSound( "Animated_entities/Player/takingOff", position );
return 0;
end

--------------------------------------------------------------- landing events
function landing( position, entity3D )
return 0;
end

function landing_sand( position, entity3D )
	throwParticles( "run_sand", position, NULL );
return 0;
end

function landing_rock( position, entity3D )
	throwParticles( "run_ground", position, NULL );
return 0;
end

function landing_wood( position, entity3D )
	throwParticles( "run_ground", position, NULL );
return 0;
end

function landing_water( position, entity3D )
	throwParticles( "run_water", position, NULL );
return 0;
end

--------------------------------------------------------------- landing events
function swordTraped( position, entity3D )
	playSound( "Animated_entities/Shark/sword_impact", position );
return 0;
end

function swordTraped_grass( position, entity3D )
	throwParticles( "octopus_appear_grass", position, NULL );
return 0;
end

function swordTraped_sand( position, entity3D )
	throwParticles( "octopus_appear_sand", position, NULL );
return 0;
end

function swordTraped_rock( position, entity3D )
	throwParticles( "octopus_appear_ground", position, NULL );
return 0;
end

function swordTraped_wood( position, entity3D )
	throwParticles( "octopus_appear_ground", position, NULL );
return 0;
end

function swordTraped_water( position, entity3D )
	throwParticles( "run_water", position, NULL );
return 0;
end

--------------------------------------------------------------- player Die event

function playerDieHit( position, entity3D )

  throwParticles( "enemy_die", position, NULL );
  playerDie( position, entity3D );

return 0;
end

function playerDieWater( position, entity3D )

  throwParticles( "water_fall", position, NULL );
  playerDie( position, entity3D );

return 0;
end

function playerDie( position, entity3D )

  disablePlayerPowerUp();
  playerRestartCheckPoint();

return 0;
end

--------------------------------------------------------------- player Respawn event
function playerRespawn( position, entity3D )

  throwParticles( "enemy_die", position, NULL );

return 0;
end

-- Funcion de debug
function DIE( )
--local playerManager = getPlayerManager( );
--local player = playerManager:getMainPlayer( );
--player:setLife( 0 );
return 0;
end

--------------------------------------------------------------- octopusDie event
function octopusUnhide_voice( position, entity3D )
    playSound( "Animated_entities/Octopus/unhide", position );
return 0;
end

function octopusDie_voice( position, entity3D )
	playSound( "Animated_entities/Octopus/die", position );
return 0;
end

function octopusDie( position, entity3D )
	throwParticles( "enemy_die", position, NULL );
	playSound( "Animated_entities/Common_events/Hit_impacts/enemy_die", position );
return 0;
end

function octopusDie_big( position, entity3D )
	throwParticles( "enemy_die_big", position, NULL );
	playSound( "Animated_entities/Common_events/Hit_impacts/water_splash", position );
return 0;
end

function octopus_dig( position, entity3D )
	playSound( "Animated_entities/Octopus/unhide", position );
return 0;
end

--------------------------------------------------------------- Stunned event
function stunned( position, entity3D )
	setBlinker( entity3D, ColorRGBA(1,1,1,0.8), 0.5, 1 );
	throwParticles( "stunned", position, entity3D );
	--playSound( "Animated_entities/Common_events/stunned", position );
return 0;
end

--------------------------------------------------------------- directionalAtack events
function directionalAtack( position, entity3D )
	playSound( "Animated_entities/Player/directional_attack", position );
return 0;
end

--------------------------------------------------------------- Coin events
function coinPickUp( position, entity3D )
	setBlinker( entity3D, ColorRGBA(1,1,1,0.8), 0.5, 1 );
	playSound( "Items/coin_pickup", position );
	throwParticles( "coin_get", position, NULL );
return 0;
end

--------------------------------------------------------------- Gem events
function gemPickUp( position, entity3D )
	setBlinker( entity3D, ColorRGBA(1,1,1,0.8), 0.5, 1 );
	playSound( "Items/gem_pickup", position );
	throwParticles( "coin_get", position, NULL );
return 0;
end

--------------------------------------------------------------- Barrel events
function breakBarrel( position, entity3D )
	playSound( "Items/barrel_break", position );
	throwParticles( "broken_barrel", position, NULL );
	setBlinker( entity3D, ColorRGBA(1,1,1,0.8), 0.5, 1 );
return 0;
end

--------------------------------------------------------------- Trunk events
function trunkDown( position, entity3D )

	end_Lvl1();

	setBlinker( entity3D, ColorRGBA(1,1,1,0.8), 0.5, 1 );
	playSound( "Items/trunk_break", position );
	
	-- Desactivem el comic dialog del player
	local player = getMainPlayer();
	setVisiblityComicDialog( player, false );

return 0;
end

--------------------------------------------------------------- Chest events
function breakChest( position, entity3D )
	playSound( "Items/chest_break", position );
	
	throwParticles( "broken_chest", position, NULL );
	setBlinker( entity3D, ColorRGBA(1,1,1,0.8), 0.5, 1 );
return 0;
end

--------------------------------------------------------------- Fruit events
function fruitPickUp( position, entity3D )
	playSound( "Items/fruit_pickup", position );
	throwParticles( "heal", position, NULL );
	setBlinker( entity3D, ColorRGBA(1,1,1,0.8), 0.5, 1 );
return 0;
end

--------------------------------------------------------------- WhiteShark events
function roar( position, entity3D )
	--playSound( "Animated_entities/Final_Boss/roar", position );
	throwParticles( "roar", position, entity3D );
return 0;
end

function shield( position, entity3D )
	playSound( "Animated_entities/Final_Boss/shield_attack", position );
	-- playSound( "weapons/lightsaber/hit", position );
	throwParticles( "shield", position, entity3D );
return 0;
end

--------------------------------------------------------------- powerUp events
function powerUpPickUp( position, entity3D )
	playSound( "Items/powerup_pickup", position );
	throwParticles( "lightning_player", position, NULL );
	setBlinker( entity3D, ColorRGBA(0.75,0,0,1), 5.0, 20 );
return 0;
end

--------------------------------------------------------------- Proj events
function dieProjectile( position, entity3D )
	playSound( "Items/projectile_dead", position );
	throwParticles( "hit_octopus", position, NULL );
return 0;
end

--------------------------------------------------------------- ScenarioElements events
function impactWood( position, entity3D )
	throwParticles( "hit", position, NULL );
	playSound( "Animated_entities/Common_events/Hit_impacts/hit_scenario_wood", position );
return 0;
end

--------------------------------------------------------------- ScenarioElements events
function impactStone( position, entity3D )
	throwParticles( "hit", position, NULL );
	playSound( "Animated_entities/Common_events/Hit_impacts/hit_scenario_stone", position );
return 0;
end

--------------------------------------------------------------- Trail events
function trailInk( position, entity3D )
	throwParticles( "print_shoot_trail", position, NULL );
	-- playSound( "weapons/lightsaber/hit", position );
return 0;
end

function trailDefault( position, entity3D )
	throwParticles( "baseball_trail", position, NULL );
	-- playSound( "weapons/lightsaber/hit", position );
return 0;
end

function trailWater( position, entity3D )
	throwParticles( "appear_water_trail", position, NULL );
	-- playSound( "weapons/lightsaber/hit", position );
return 0;
end

function waterAmplitude_blue( position, entity3D )
	throwParticles( "water_amplitude_blue", position, NULL );
	-- playSound( "weapons/lightsaber/hit", position );
return 0;
end

function waterAmplitude_sunset( position, entity3D )
	throwParticles( "water_amplitude", position, NULL );
	-- playSound( "weapons/lightsaber/hit", position );
return 0;
end

function waterAmplitude_little_blue( position, entity3D )
	throwParticles( "water_amplitude_little_blue", position, NULL );
	-- playSound( "weapons/lightsaber/hit", position );
return 0;
end

function waterAmplitude_little_sunset( position, entity3D )
	throwParticles( "water_amplitude_little", position, NULL );
	-- playSound( "weapons/lightsaber/hit", position );
return 0;
end

--------------------------------------------------------------- In half of octopus appearWater Animation 
function octopusExpulseWater( position, entity3D )
	throwParticles( "octopus_appear_water", position, NULL );
	playSound( "Animated_entities/Octopus/expulse_water", position );
return 0;
end

function octopusExpulseWater_big( position, entity3D )
	throwParticles( "octopus_appear_water_big", position, NULL );
	playSound( "Animated_entities/Octopus/expulse_water", position );
return 0;
end

--------------------------------------------------------------- Love SeaUrchin
function loveSeaUrchin( position, entity3D )
	throwParticles( "love", position, entity3D );
	playSound( "Animated_entities/SeaUrchin/love", position );
return 0;
end

--------------------------------------------------------------- Player walks under water
function runWaterPowerUp( position, entity3D )
	throwParticles( "run_water_powerup", position, NULL );
	playSound( "Animated_entities/Common_events/Step/step_water", position );
return 0;
end

--------------------------------------------------------------- MegaAirAttack finalBoss impact
function earth_gap( position, entity3D )
	throwParticles( "earth_gap", position, NULL );
	--playSound( "Animated_entities/Common_events/Step/step_water", position );
return 0;
end

--------------------------------------------------------------- GUI events
function gui_saveSeaUrchin()
	playSound( "Gui_Menu/save_seaUrchin", Vector3(0,0,0) );
return 0;
end

function gui_unlockAchivement()
	playSound( "Gui_Menu/unlocked_achivement", Vector3(0,0,0) );
return 0;
end

--------------------------------------------------------------- finalBoss events
---- Events in animation_parameters.xml 
function finalBoss_jumpSteps( position, entity3D )
    throwParticles( "octopus_appear_ground", position, NULL );
return 0;
end

function finalBoss_swordTrapped( position, entity3D )
    throwParticlesInEndSword();
return 0;
end

function finalBoss_trappedStage1( position, entity3D )
    playSound( "Animated_entities/Final_Boss/trapped_stage1", position );
return 0;
end

function finalBoss_End_trappedStage1()
    stopSound( "Animated_entities/Final_Boss/trapped_stage1" );
return 0;
end

function finalBoss_directionalAttack( position, entity3D )
    playSound( "Animated_entities/Final_Boss/directional_attack", position );
return 0;
end

function finalBoss_laught( position, entity3D )
    playSound( "Animated_entities/Final_Boss/laught", position );
return 0;
end

function finalBoss_End_laught()
    stopSound( "Animated_entities/Final_Boss/laught" );
return 0;
end


function finalBoss_roar( position, entity3D )
    playSound( "Animated_entities/Final_Boss/roar", position );
return 0;
end

function finalBoss_End_roar()
	stopSound( "Animated_entities/Final_Boss/roar" );
return 0;
end

---- Events directly in code of machine state 

function finalBoss_hitStage1( position, entity3D )
	throwParticles( "hit", position, NULL );
    playSound( "Animated_entities/Final_Boss/hit_stage1", position );
    setBlinkerByID( entity3D:ID(), ColorRGBA(1.0,1.0,1.0,0.8), 0.5, 1.0 );
return 0;
end

function finalBoss_hitStage2_baseball( position, entity3D )
    setBlinkerByID( entity3D:ID(), ColorRGBA(1.0,1.0,1.0,0.8), 0.5, 1.0 );
	throwParticles( "hit", position, NULL );
    playSound( "Animated_entities/Final_Boss/hit_baseball", position );
return 0;
end

function finalBoss_hitStage2_trapped( position, entity3D )
    setBlinkerByID( entity3D:ID(), ColorRGBA(1.0,1.0,1.0,0.8), 0.5, 1.0 );
	throwParticles( "hit", position, NULL );
    playSound( "Animated_entities/Final_Boss/hit_trapped", position );
return 0;
end

function finalBoss_hitStage3( position, entity3D )
    setBlinkerByID( entity3D:ID(), ColorRGBA(1.0,1.0,1.0,0.8), 0.5, 1.0 );
	throwParticles( "hit", position, NULL );
    playSound( "Animated_entities/Final_Boss/hit_stage3", position );
return 0;
end

function finalBoss_beforeJumpMp( position, entity3D )
    playSound( "Animated_entities/Final_Boss/jump_before_mp", position );
return 0;
end

function finalBoss_duringJumpMp( position, entity3D )
    playSound( "Animated_entities/Final_Boss/jump_during_mp", position );
return 0;
end

function finalBoss_initTrappedStage2( position, entity3D )
    --local position = getPositionEntityBone( entity3D:ID(), "Bip01" );
    -- Com es produeix a la plataforma esta la Y hardcodejada
    throwParticles( "earth_gap", Vector3( position.x, 6.2 , position.z), NULL );
return 0;
end

function finalBoss_trappedStage2( position, entity3D )
    playSound( "Animated_entities/Final_Boss/trapped_stage2", position );
return 0;
end

function finalBoss_appearStage3( position, entity3D )
    playSound( "Animated_entities/Final_Boss/appear_stage3", position );
return 0;
end

function finalBoss_megaPicat( position )
   playSound( "Animated_entities/Common_events/Hit_impacts/megaPicat_impact", position );    
   throwAreaParticles( "octopus_appear_ground", position, 2.0, 6 );
return 0;
end

function finalBoss_eatPlayer( position )
   playSound( "Animated_entities/Final_Boss/eat_player", position );    
return 0;
end

--------------------------------------------------------------- Menu events
function menuYes()
	playSound( "Gui_Menu/menu_yes", position );
return 0;
end

function menuNo()
	playSound( "Gui_Menu/menu_no", position );
return 0;
end

--------------------------------------------------------------- Music events

function startIntroMusic()
	playMusic("Intro/ambient_intro");
	playMusic("Music/main_theme_intro");
return 0;
end

function endIntroMusic()
	stopMusic("Music/main_theme_intro", false);
	stopAmbient( "Intro/ambient_intro" , false);
return 0;
end

function startMenuMusic()
	playMusic("Music/menu");
return 0;
end

function endMenuMusic()
	stopMusic( "Music/menu", false );
    playSound("Game_situations/activate_switch", Vector3(0.0, 0.0, 0.0))
return 0;
end

function startBarrelCutSceneMusic()

return 0;
end


function start_Lvl1()
    playAmbient( "Music/ambient_ocean" );
	playMusic( "Music/beach_start" );
return 0;
end

function middle_Lvl1()
	stopCurrentMusic( false );
	playMusic( "Music/beach_middle" );
	stopAmbient( "Music/ambient_ocean", false );
return 0;
end

function end_Lvl1()
	--stopCurrentMusic( false );
	--playMusic( "Music/main_theme_intro" );
return 0;
end

function start_Lvl2()
	stopCurrentMusic( false );
	playMusic( "Music/lvl2_transition" );
return 0;
end

function start_shortBattleSeq_Lvl2()
	stopCurrentMusic( false );
	playMusic( "Music/long_action_stage" );
return 0;
end

function end_shortBattleSeq_Lvl2()
	stopCurrentMusic( false );
	playMusic( "Music/lvl2_transition" );
return 0;
end

function start_StaticPlatformsBattleSeq_Lvl2()
	stopCurrentMusic( false );
	playMusic( "Music/long_action_stage" );
return 0;
end

function end_StaticPlatformsBattleSeq_Lvl2()
	stopCurrentMusic( false );
	playMusic( "Music/lvl2_transition" );
return 0;
end

function start_BaseballBattleSeq_Lvl2()
	stopCurrentMusic( false );
	playMusic( "Music/long_action_stage" );
return 0;
end

function end_BaseballBattleSeq_Lvl2()
	stopCurrentMusic( false );
	playMusic( "Music/lvl2_transition" );
return 0;
end

function start_finalBattleSeq_Lvl2()
	stopCurrentMusic( false );
	playMusic( "Music/long_action_stage" );
return 0;
end

function end_finalBattleSeq_Lvl2()
	stopCurrentMusic( false );
	playMusic( "Music/lvl2_transition" );
return 0;
end

function start_finalBoss_stage0()
	stopCurrentMusic( false );
	playMusic( "Music/a_pirates_fate_0" );
return 0;
end

function start_finalBoss_stage1()
	stopCurrentMusic( false );
	playMusic( "Music/a_pirates_fate_1" );
return 0;
end

function start_finalBoss_stage2()
	stopCurrentMusic( false );
	playMusic( "Music/a_pirates_fate_2" );
return 0;
end

function start_finalBoss_stage3()
	stopCurrentMusic( false );
	playMusic( "Music/a_pirates_fate_2" );
return 0;
end

function start_credits()
	stopCurrentMusic( false );
	playMusic( "Music/the_last_pirate_main_theme" );
return 0;
end

function end_credits()
	stopCurrentMusic( false );
	activateInput( false );
	
	--stopAmbient("Music/Ambient/under_lakeAmbient", false);
	
    stopAmbient("Music/Ambient/waterFall", false);
	playMusic( "Music/final_boss_end" );
	
	-- Amagem el gui de coins a la sequencia final
	hideGUIBonusCoins();
return 0;
end

function restart_transition_lvl2()
	stopCurrentMusic( false );
	playMusic( "Music/lvl2_transition" );
return 0;
end