dofile('data/Scripts/Scenes/Common.lua');
dofile('data/Scripts/Scenes/Animations/17_CandleCave_Animations.lua');
dofile('data/Scripts/Scenes/Animations/17_CandleCaveAltarZoom_Animations.lua');

------------------------------------------------------------------------------
--
function OnSceneLoad(restoringFromSave)
	InitGameState();

	play_field = playField;
    LoadData();
	play_field = nil;

    RootZoomZone = CreateZoomZone('RootZoomZone', nil, 
                                   nil, 0.0, 
                                   nil, 0.0,
							{'RootBackground',
							 'actZoneAltar',
							 'actZoneGates',

							 'axe',
							 'bird',
							 'bracelet',
							 'brooch',
							 'bullHead',
							 'cayenne',
							 'crossbow',
							 'cup',
							 'drum',
							 'drums',
							 'eagleHead',
							 'eggplants',
							 'grapes',
							 'grasshopper',
							 'jug',
							 'lime',
							 'lizard',
							 'mace',
							 'magnolia',
							 'oldFnife',
							 'onions',
							 'pelican',
							 'pendant',
							 'plate',
							 'pterodactyl',
							 'pumpkin',
							 'sabre',
							 'scroll',
							 'seagull',
							 'shield',
							 'skull',
							 'soldierStatuette',
							 'statuette1',
							 'statuette2',
							 'statuette3',
							 'stoneIdol',
							 'tambourine',
							 'torch',
							 'vessel1',
							 'vessel2',

							 'actZonePyramidRoot',
							 'actZoneFlame',
							 'actZoneStone',
							 'actZoneSphere',

							 'ArtifactWithRune',
							 'Bucket',
							 'Handle',
							 'Sphere',
							 'Sphere_onPlace',
							 'Stone',
							 'Stone_onPlace',
							 'LayerOverStone',
							 'LayerOverStoneOnPlace'},

							{},

							{'flameOnStairs1',
							 'flameOnStairs2',
							 'flameOnStairs3',
							 'flameOnStairsGlow'});

    AltarZoomZone = CreateZoomZone('AltarZoomZone', RootZoomZone, 
                                   'actZoneAltar', 0.0, 
                                   nil, 0.0,
							{'ZoomAltarBackground',
							 'LayerOverRunnedCrystal',
							 'LayerOverWithChain',
							 'PyramidBottom',
							 'PyramidTop',

							 'actZoneArtifact',

							 'ArtifactWithRune_onPlace',
							 'VCrystal'},

							{});

    GatesZoomZone = CreateZoomZone('GatesZoomZone', RootZoomZone, 
                                   'actZoneGates', 0.0, 
                                   nil, 0.0,
							{'ZoomGatesBackground',
							 'gateGridLeft',
							 'gateGridRight',
							 'LayerOverGateGridRight',
							 'LayerOverGateGridLeft',

							 'Handle_onPlace',
							 'VCrystal_onPlace',

							 'actZoneHandle',
							 'actZoneVCrystal'},

							{},

							{'vCrystal_onPlaceGlow'});

if (restoringFromSave == false) then
    AddRandomTasks(true, MISC_TASK_COUNT_24,
		CreateTask('axe'),
		CreateTask('bird'),
		CreateTask('bracelet'),
		CreateTask('brooch'),
		CreateTask('bullHead'),
		CreateTask('cayenne'),
		CreateTask('crossbow'),
		CreateTask('cup'),
		CreateTask('drum'),
		CreateTask('drums'),
		CreateTask('eagleHead'),
		CreateTask('eggplants'),
		CreateTask('grapes'),
		CreateTask('grasshopper'),
		CreateTask('jug'),
		CreateTask('lime'),
		CreateTask('lizard'),
		CreateTask('mace'),
		CreateTask('magnolia'),
		CreateTask('oldFnife'),
		CreateTask('onions'),
		CreateTask('pelican'),
		CreateTask('pendant'),
		CreateTask('plate'),
		CreateTask('pterodactyl'),
		CreateTask('pumpkin'),
		CreateTask('sabre'),
		CreateTask('scroll'),
		CreateTask('seagull'),
		CreateTask('shield'),
		CreateTask('skull'),
		CreateTask('soldierStatuette'),
		CreateTask('statuette1'),
		CreateTask('statuette2'),
		CreateTask('statuette3'),
		CreateTask('stoneIdol'),
		CreateTask('tambourine'),
		CreateTask('torch'),
		CreateTask('vessel1'),
		CreateTask('vessel2')
	);

    playField:GetLevelScreen():AddTaskSafe(CreateTask('ArtifactWithRune'));
    playField:GetLevelScreen():AddTaskSafe(CreateTask('Bucket'));
    playField:GetLevelScreen():AddTaskSafe(CreateTask('Handle'));
    playField:GetLevelScreen():AddTaskSafe(CreateTask('Sphere'));
    playField:GetLevelScreen():AddTaskSafe(CreateTask('Stone'));
    playField:GetLevelScreen():AddTaskSafe(CreateTask('VCrystal'));
end

	CreateToolMap(	{'ArtifactWithRune','actZoneArtifact'},
					{'Bucket',			'actZoneFlame'},
					{'Handle',			'actZoneHandle'},
					{'Sphere',   		'actZoneSphere'},
					{'Stone',  			'actZoneStone'},
					{'VCrystal',		'actZoneVCrystal'});

	SetIconForGameObject(playField:GetObject('axe'),		'data/Texture/Scenes/17_CandleCave/Items/Misc/axe_icon.png');
	SetIconForGameObject(playField:GetObject('bird'),		'data/Texture/Scenes/17_CandleCave/Items/Misc/bird_icon.png');
	SetIconForGameObject(playField:GetObject('bracelet'),	'data/Texture/Scenes/17_CandleCave/Items/Misc/bracelet_icon.png');
	SetIconForGameObject(playField:GetObject('brooch'),		'data/Texture/Scenes/17_CandleCave/Items/Misc/brooch_icon.png');
	SetIconForGameObject(playField:GetObject('bullHead'),	'data/Texture/Scenes/17_CandleCave/Items/Misc/bullHead_icon.png');
	SetIconForGameObject(playField:GetObject('cayenne'),	'data/Texture/Scenes/17_CandleCave/Items/Misc/cayenne_icon.png');
	SetIconForGameObject(playField:GetObject('crossbow'),	'data/Texture/Scenes/17_CandleCave/Items/Misc/crossbow_icon.png');
	SetIconForGameObject(playField:GetObject('cup'),		'data/Texture/Scenes/17_CandleCave/Items/Misc/cup_icon.png');
	SetIconForGameObject(playField:GetObject('drum'),		'data/Texture/Scenes/17_CandleCave/Items/Misc/drum_icon.png');
	SetIconForGameObject(playField:GetObject('drums'),		'data/Texture/Scenes/17_CandleCave/Items/Misc/drums_icon.png');
	SetIconForGameObject(playField:GetObject('eagleHead'),	'data/Texture/Scenes/17_CandleCave/Items/Misc/eagleHead_icon.png');
	SetIconForGameObject(playField:GetObject('eggplants'),	'data/Texture/Scenes/17_CandleCave/Items/Misc/eggplants_icon.png');
	SetIconForGameObject(playField:GetObject('grapes'),		'data/Texture/Scenes/17_CandleCave/Items/Misc/grapes_icon.png');
	SetIconForGameObject(playField:GetObject('grasshopper'),'data/Texture/Scenes/17_CandleCave/Items/Misc/grasshopper_icon.png');
	SetIconForGameObject(playField:GetObject('jug'),		'data/Texture/Scenes/17_CandleCave/Items/Misc/jug_icon.png');
	SetIconForGameObject(playField:GetObject('lime'),		'data/Texture/Scenes/17_CandleCave/Items/Misc/lime_icon.png');
	SetIconForGameObject(playField:GetObject('lizard'),		'data/Texture/Scenes/17_CandleCave/Items/Misc/lizard_icon.png');
	SetIconForGameObject(playField:GetObject('mace'),		'data/Texture/Scenes/17_CandleCave/Items/Misc/mace_icon.png');
	SetIconForGameObject(playField:GetObject('magnolia'),	'data/Texture/Scenes/17_CandleCave/Items/Misc/magnolia_icon.png');
	SetIconForGameObject(playField:GetObject('oldFnife'),	'data/Texture/Scenes/17_CandleCave/Items/Misc/oldFnife_icon.png');
	SetIconForGameObject(playField:GetObject('onions'),		'data/Texture/Scenes/17_CandleCave/Items/Misc/onions_icon.png');
	SetIconForGameObject(playField:GetObject('pelican'),	'data/Texture/Scenes/17_CandleCave/Items/Misc/pelican_icon.png');
	SetIconForGameObject(playField:GetObject('pendant'),	'data/Texture/Scenes/17_CandleCave/Items/Misc/pendant_icon.png');
	SetIconForGameObject(playField:GetObject('plate'),		'data/Texture/Scenes/17_CandleCave/Items/Misc/plate_icon.png');
	SetIconForGameObject(playField:GetObject('pterodactyl'),'data/Texture/Scenes/17_CandleCave/Items/Misc/pterodactyl_icon.png');
	SetIconForGameObject(playField:GetObject('pumpkin'),	'data/Texture/Scenes/17_CandleCave/Items/Misc/pumpkin_icon.png');
	SetIconForGameObject(playField:GetObject('sabre'),		'data/Texture/Scenes/17_CandleCave/Items/Misc/sabre_icon.png');
	SetIconForGameObject(playField:GetObject('scroll'),		'data/Texture/Scenes/17_CandleCave/Items/Misc/scroll_icon.png');
	SetIconForGameObject(playField:GetObject('seagull'),	'data/Texture/Scenes/17_CandleCave/Items/Misc/seagull_icon.png');
	SetIconForGameObject(playField:GetObject('shield'),		'data/Texture/Scenes/17_CandleCave/Items/Misc/shield_icon.png');
	SetIconForGameObject(playField:GetObject('skull'),		'data/Texture/Scenes/17_CandleCave/Items/Misc/skull_icon.png');
	SetIconForGameObject(playField:GetObject('soldierStatuette'),'data/Texture/Scenes/17_CandleCave/Items/Misc/soldierStatuette_icon.png');
	SetIconForGameObject(playField:GetObject('statuette1'),	'data/Texture/Scenes/17_CandleCave/Items/Misc/statuette1_icon.png');
	SetIconForGameObject(playField:GetObject('statuette2'),	'data/Texture/Scenes/17_CandleCave/Items/Misc/statuette2_icon.png');
	SetIconForGameObject(playField:GetObject('statuette3'),	'data/Texture/Scenes/17_CandleCave/Items/Misc/statuette3_icon.png');
	SetIconForGameObject(playField:GetObject('stoneIdol'),	'data/Texture/Scenes/17_CandleCave/Items/Misc/stoneIdol_icon.png');
	SetIconForGameObject(playField:GetObject('tambourine'),	'data/Texture/Scenes/17_CandleCave/Items/Misc/tambourine_icon.png');
	SetIconForGameObject(playField:GetObject('torch'),		'data/Texture/Scenes/17_CandleCave/Items/Misc/torch_icon.png');
	SetIconForGameObject(playField:GetObject('vessel1'),	'data/Texture/Scenes/17_CandleCave/Items/Misc/vessel1_icon.png');
	SetIconForGameObject(playField:GetObject('vessel2'),	'data/Texture/Scenes/17_CandleCave/Items/Misc/vessel2_icon.png');

	SetIconForGameObject(playField:GetObject('ArtifactWithRune'),'data/Texture/Scenes/17_CandleCave/Items/ArtifactWithRune_icon.png');
	SetIconForGameObject(playField:GetObject('Bucket'),		'data/Texture/Scenes/17_CandleCave/Items/Bucket_icon.png');
	SetIconForGameObject(playField:GetObject('Handle'),		'data/Texture/Scenes/17_CandleCave/Items/Handle_icon.png');
	SetIconForGameObject(playField:GetObject('Sphere'),		'data/Texture/Scenes/17_CandleCave/Items/Sphere_icon.png');
	SetIconForGameObject(playField:GetObject('Stone'),		'data/Texture/Scenes/17_CandleCave/Items/Stone_icon.png');
	SetIconForGameObject(playField:GetObject('VCrystal'),	'data/Texture/Scenes/17_CandleCave/Items/VCrystal_icon.png');


if (restoringFromSave == false) then
	gameState.finalZoomInPos = {playField:GetObject('actZoneGates'):GetScrX(), playField:GetObject('actZoneGates'):GetScrY()};

	gameState.artifactOnPlace = false;
	gameState.bucketUsed = false;
	gameState.handleOnPlace = false;
	gameState.sphereOnPlace = false;
	gameState.stoneOnPlace = false;
	gameState.vcrystalOnPlace = false;

	gameState.platformIsMovingDown = false;
	gameState.pyramidCapIsMoving = false;
	gameState.gatesAreOpening = false;
	gameState.handleTurned = false;

	gameState.allToolsApplied = false;
	gameState.levelCompleted = false;
end

	AssignActiveZonesGlow({function() return gameState.artifactOnPlace or
											 not gameState.stoneOnPlace; end,	'actZoneArtifact',	'ArtifactWithRune_ghost'},
						  {function() return gameState.bucketUsed; end,			'actZoneFlame',		'Bucket_ghost'},
					      {function() return gameState.handleOnPlace; end,		'actZoneHandle',	'Handle_ghost'},
						  {function() return gameState.sphereOnPlace; end,		'actZoneSphere',	'Sphere_ghost'},
						  {function() return gameState.stoneOnPlace; end,		'actZoneStone',		'Stone_ghost'},
						  {function() return gameState.vcrystalOnPlace; end,	'actZoneVCrystal',	'VCrystal_ghost'});


    ApplyLevelDump(restoringFromSave);
	SetZoneVisible(RootZoomZone, true, false);

	auxSceneInit(restoringFromSave);
	auxProcessToolObjectStateAnCursorType();
end

------------------------------------------------------------------------------
--
function OnSceneFree()
    FreeData()

	StopSound('L17S10');
	StopSound('L17S11');
	StopSound('L17S12');
	StopSound('L17S13');
	StopSound('L17S14');
	StopSound('L17S15');
end

--// Local auxiliary functions - - - - - - - - - - - - - - - - - - - - - - - -
function auxSceneInit(restoringFromSave)
    local initialActions = function()
		ShowLevelIntro(17);
    end
	local regularActions = function()
		if (gameState.bucketUsed) then
			StopSound('L17S10');
		else
			PlaySound('L17S10', true);
		end
		if (gameState.sphereOnPlace) then
			StopSound('L17S15');
		else
			PlaySound('L17S15', true);
		end

		gameState.customCursors['actZoneAltar'] = {'CursorZoom'};
		gameState.customCursors['actZoneGates'] = {'CursorZoom'};

		playField:IgnoreOnTestPoint('LayerOverPyramidalArtefact');

		playField:IgnoreOnTestPoint('flameOnStairs1');
		playField:IgnoreOnTestPoint('flameOnStairs2');
		playField:IgnoreOnTestPoint('flameOnStairs3');
		playField:IgnoreOnTestPoint('flameOnStairsGlow');
		auxSetFibrillationEffector(playField:GetObject('flameOnStairsGlow'), 0.24);

		auxAttachInPlace(playField:GetObject('vCrystal_onPlaceGlow'), playField:GetObject('VCrystal_onPlace'));

		auxCreateCandleCaveAnimations(playField:GetObject('RootBackground'));
		auxPlayCandleCaveAnimation('FrontEnv');
		auxPlayCandleCaveAnimation('FrontForceField');
		auxPlayCandleCaveAnimation('BackEnv');
		auxPlayCandleCaveAnimation('BackForceField');

		auxCreateCandleCaveAltarZoomAnimations(playField:GetObject('ZoomAltarBackground'));
		auxPlayCandleCaveAltarZoomAnimation('ForceField');

		auxAttachInPlace(playField:GetObject('pyramidalArtefactTop'), playField:GetObject('pyramidalArtefactBottom'), false);
		auxAttachInPlace(playField:GetObject('pyramidalArtefactBottom'), playField:GetObject('actZonePyramidRoot'));
		auxSetLevitationEffector(playField:GetObject('actZonePyramidRoot'), {0.0, 7.0}, {0.0, 2.35});

		if (playField:HasObject('VCrystal')) then
			auxAttachInPlace(playField:GetObject('VCrystal'), playField:GetObject('PyramidBottom'));
		end
		auxAttachInPlace(playField:GetObject('LayerOverRunnedCrystal'), playField:GetObject('PyramidBottom'));
		auxAttachInPlace(playField:GetObject('PyramidTop'), playField:GetObject('PyramidBottom'));
		auxAttachInPlace(playField:GetObject('ArtifactWithRune_onPlace'), playField:GetObject('PyramidTop'));

		auxAttachInPlace(playField:GetObject('Stone_ghost'), playField:GetObject('platform'));
		auxAttachInPlace(playField:GetObject('Stone_onPlace'), playField:GetObject('platform'));
		auxAttachInPlace(playField:GetObject('LayerOverStoneOnPlace'), playField:GetObject('platform'));
		auxSetLevitationEffector(playField:GetObject('platform'), {5.0, 0.0}, {3.0, 0.0});

		gameState.platformInitPosY = playField:GetObject('platform'):GetY();
		gameState.platformShift	= 10.0;
		gameState.pyramidInitScrPosY = playField:GetObject('pyramidalArtefactBottom'):GetScrY();
		gameState.pyramidFallDistance = 106;
		gameState.pyramidCapGenInitPosY = playField:GetObject('pyramidalArtefactTop'):GetY();
		gameState.pyramidCapGenShift = -20;
		gameState.pyramidCapInitPosY = playField:GetObject('PyramidTop'):GetY();
		gameState.pyramidCapShift = -100;
		gameState.gatesLeftPartInitPosX = playField:GetObject('gateGridLeft'):GetX();
		gameState.gatesRightPartInitPosX = playField:GetObject('gateGridRight'):GetX();
		gameState.gatesPartShift = 100;

		gameState.pyramidCapIsMoving = false;
		gameState.gatesAreOpening = false;
	end

    if (restoringFromSave == false) then
        initialActions();
	else
    end	
    regularActions();

	if (gameState.levelCompleted == true) then
		gameState.levelCompleted = false;
		auxTestLevelCompleteCondition();
	end
end


function auxProcessToolObjectStateAnCursorType()
    assert(	gameState.artifactOnPlace ~= nil and
			gameState.bucketUsed ~= nil and
			gameState.handleOnPlace ~= nil and
			gameState.sphereOnPlace ~= nil and
			gameState.stoneOnPlace ~= nil and
			gameState.vcrystalOnPlace ~= nil);

	if (gameState.artifactOnPlace == true) then
		AltarZoomZone.UnhideObject('ArtifactWithRune_onPlace');
		gameState.customCursors['actZoneArtifact'] = nil;
		playField:GetObject('actZoneArtifact'):SetVisible(false);
	else
		AltarZoomZone.HideObject('ArtifactWithRune_onPlace');
		gameState.customCursors['actZoneArtifact'] = (gameState.stoneOnPlace == true and {'CursorArms'} or nil);
		playField:GetObject('actZoneArtifact'):SetVisible(true);
	end
	auxUpdatePyramidTopPosition(not gameState.artifactOnPlace);

	if (gameState.bucketUsed == true) then
		gameState.customCursors['actZoneFlame'] = nil;
	else
		gameState.customCursors['actZoneFlame'] = {'CursorArms'};
	end
	playField:GetObject('flameOnStairs1'):SetVisible(not gameState.bucketUsed);
	playField:GetObject('flameOnStairs2'):SetVisible(not gameState.bucketUsed);
	playField:GetObject('flameOnStairs3'):SetVisible(not gameState.bucketUsed);
	playField:GetObject('flameOnStairsGlow'):SetVisible(not gameState.bucketUsed);

	if (gameState.handleOnPlace == true) then
		GatesZoomZone.UnhideObject('Handle_onPlace');
		gameState.customCursors['actZoneHandle'] = (gameState.handleTurned == true and nil or {'CursorArms'});
		auxUpdateGatesState(gameState.handleTurned);
	else
		GatesZoomZone.HideObject('Handle_onPlace');
		gameState.customCursors['actZoneHandle'] = {'CursorArms'};
	end

	if (gameState.sphereOnPlace == true) then
		RootZoomZone.UnhideObject('Sphere_onPlace');
		gameState.customCursors['actZoneSphere'] = nil;
		if (auxGetCandleCaveAltarZoomAnimation('ForceField'):IsVisible() == true) then
			auxHideCandleCaveAltarZoomAnimation('ForceField');
		end
		if (auxGetCandleCaveAnimation('BackForceField'):IsVisible() == true) then
			auxHideCandleCaveAnimation('BackForceField');
			auxHideCandleCaveAnimation('FrontForceField');
		end
	else
		RootZoomZone.HideObject('Sphere_onPlace');
		gameState.customCursors['actZoneSphere'] = {'CursorArms'};
		if (auxGetCandleCaveAltarZoomAnimation('ForceField'):IsVisible() == false) then
			auxPlayCandleCaveAltarZoomAnimation('ForceField');
		end
		if (auxGetCandleCaveAnimation('BackForceField'):IsVisible() == false) then
			auxPlayCandleCaveAnimation('BackForceField');
			auxPlayCandleCaveAnimation('FrontForceField');
		end
	end

	if (gameState.stoneOnPlace == true) then
		RootZoomZone.UnhideObject('Stone_onPlace');
		AltarZoomZone.UnhideObject('PyramidBottom');
		gameState.customCursors['actZoneStone'] = nil;
	else
		RootZoomZone.HideObject('Stone_onPlace');
		AltarZoomZone.HideObject('PyramidBottom');
		gameState.customCursors['actZoneStone'] = {'CursorArms'};
	end
	auxUpdatePlatformPosition(not gameState.stoneOnPlace);

	if (gameState.vcrystalOnPlace == true) then
		GatesZoomZone.UnhideObject('VCrystal_onPlace');
		gameState.customCursors['actZoneVCrystal'] = nil;
	else
		GatesZoomZone.HideObject('VCrystal_onPlace');
		gameState.customCursors['actZoneVCrystal'] = {'CursorArms'};
	end

	-- zoom-zones blocking
	if (playField:HasObject('VCrystal') == false) then
		gameState.customCursors['actZoneAltar'] = nil;
		gameState.lockedObjects['actZoneAltar'] = true;
	else
		gameState.customCursors['actZoneAltar'] = {'CursorZoom'};
		gameState.lockedObjects['actZoneAltar'] = nil;
	end
end

--// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function auxMovePlatform()
	local duration = 0.25;

	PlaySound('L17S14');
	gameState.platformIsMovingDown = true;
	TimerDoString('SetGameStateParameter(\'platformIsMovingDown\', false);', duration, playField:GetTimer());

	local objPlatform = playField:GetObject('platform');
	local objPyramid = playField:GetObject('pyramidalArtefactBottom');

	objPlatform:SetY(gameState.platformInitPosY);
	objPlatform:Move(0.0, gameState.platformShift, duration);

	auxAttachInPlace(objPyramid, playField);
	objPyramid:SetScrY(gameState.pyramidInitScrPosY);
	objPyramid:Move(0.0, gameState.pyramidFallDistance, duration);
end
function auxUpdatePlatformPosition(itIsInAir)
	if (gameState.platformIsMovingDown == true) then
		return;
	end

	local objPlatform = playField:GetObject('platform');
	local objPyramid = playField:GetObject('pyramidalArtefactBottom');

	if (itIsInAir == true) then
		objPyramid:SetScrY(gameState.pyramidInitScrPosY);
		auxAttachInPlace(objPyramid, playField:GetObject('actZonePyramidRoot'));
	else
		objPyramid:SetScrY(gameState.pyramidInitScrPosY + gameState.pyramidFallDistance);
		auxAttachInPlace(objPyramid, playField);
	end
end

function auxLiftUpPyramidTop()
	local duration = 0.75;

	PlaySound('L17S13');
	gameState.pyramidCapIsMoving = true;
	TimerDoString('SetGameStateParameter(\'pyramidCapIsMoving\', false);', duration, playField:GetTimer());

	local objPyramidTop = playField:GetObject('PyramidTop');
	local objPyramidTopGen = playField:GetObject('pyramidalArtefactTop');

	objPyramidTop:SetY(gameState.pyramidCapInitPosY);
	objPyramidTop:Move(0.0, gameState.pyramidCapShift, duration);

	objPyramidTopGen:SetY(gameState.pyramidCapGenInitPosY);
	objPyramidTopGen:Move(0.0, gameState.pyramidCapGenShift, duration);
end
function auxUpdatePyramidTopPosition(closed)
	if (gameState.pyramidCapIsMoving == true) then
		return;
	end

	local objPyramidTop = playField:GetObject('PyramidTop');
	local objPyramidTopGen = playField:GetObject('pyramidalArtefactTop');

	if (closed) then
		objPyramidTop:SetY(gameState.pyramidCapInitPosY);
		objPyramidTopGen:SetY(gameState.pyramidCapGenInitPosY);
	else
		objPyramidTop:SetY(gameState.pyramidCapInitPosY + gameState.pyramidCapShift);
		objPyramidTopGen:SetY(gameState.pyramidCapGenInitPosY + gameState.pyramidCapGenShift);
	end
end

function auxOpenGates()
	local duration = 1.0;

	PlaySound('L17S12');
	gameState.gatesAreOpening = true;
	TimerDoString('SetGameStateParameter(\'gatesAreOpening\', false);', duration, playField:GetTimer());

	local objGatesLeftPart = playField:GetObject('gateGridLeft');
	local objGatesRightPart = playField:GetObject('gateGridRight');

	objGatesLeftPart:SetX(gameState.gatesLeftPartInitPosX);
	objGatesRightPart:SetX(gameState.gatesRightPartInitPosX);

	objGatesLeftPart:Move(-gameState.gatesPartShift, 0.0, duration);
	objGatesRightPart:Move(gameState.gatesPartShift, 0.0, duration);
end
function auxUpdateGatesState(opened)
	if (gatesAreOpening == false) then
		local objGatesLeftPart = playField:GetObject('gateGridLeft');
		local objGatesRightPart = playField:GetObject('gateGridRight');

		objGatesLeftPart:SetX(opened == true and gameState.gatesLeftPartInitPosX - gameState.gatesPartShift or gameState.gatesLeftPartInitPosX);
		objGatesRightPart:SetX(opened == true and gameState.gatesRightPartInitPosX + gameState.gatesPartShift or gameState.gatesRightPartInitPosX);	
	end
end

--// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function auxTestLevelCompleteCondition()
	if (gameState.handleTurned == true and

		gameState.allToolsApplied == true and
		gameState.levelCompleted == false and
		playField:GetLevelScreen():HasUncompletedTask() == false) then

		gameState.levelCompleted = true;
		TimerDoString('OnWin();', 2.0, playField:GetTimer());
	end
end
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

------------------------------------------------------------------------------
--
function OnDialogButtonPress(name, param)
end

------------------------------------------------------------------------------
--
function OnUpdate(dt)
    DefaultOnUpdate(dt);
end

------------------------------------------------------------------------------
--
function OnWin()
	DefaultOnWin();
end

------------------------------------------------------------------------------
--
function OnObjectMouseEnter(object)
    local objectName = object:GetName();

    DefaultOnObjectMouseEnter(object);
	ActivateActiveZoneGlow(objectName);
end

------------------------------------------------------------------------------
--
function OnObjectMouseLeave(object)
    local objectName = object:GetName();

    DefaultOnObjectMouseLeave(object);
    DeactivateActiveZoneGlow(objectName);
end

------------------------------------------------------------------------------
--
function OnObjectMouseDown(object)
    local objectName = object:GetName();
    local isWrongClick = true;

	assert(gameState.activeZone ~= nil and gameState.locker:GetNReferences() > 0);

    if (gameState.lockedObjects[objectName] ~= true) then
        if (gameState.activeZone.HasObject(objectName)) then
            isWrongClick = DefaultOnZoomZoneActiveObjectClick(objectName);

			--// ...
			if (objectName == 'actZoneHandle' and gameState.handleTurned == false) then
				if (gameState.handleOnPlace == true and gameState.vcrystalOnPlace == true) then
					gameState.handleTurned = true;
					auxOpenGates();
					auxTestLevelCompleteCondition();

				    assert(gameState.activeZone ~= nil);
				    if (gameState.activeZone == GatesZoomZone) then
						CloseAndBlockActiveZone();
				    end
				else
					playField:GetLevelScreen():ShowTip(GetTextString('LEVEL17_UNLOCKGATES_TIP1'));
				end
			end

	        if (isWrongClick == true and playField:GetLevelScreen():IsTaskObject(objectName)) then
	            auxAttachInPlace(object, playField);
				object:ResetClippingRect();
				--// remove object from zoom-zone which contents it
				assert(gameState.activeZone.objects[objectName] ~= nil);
				gameState.activeZone.objects[objectName] = nil;

                playField:OnObjectFound(object);
                isWrongClick = false;
            end
        else
--			assert(gameState.activeZone ~= RootZoomZone and 
--				   gameState.locker:GetNReferences() > 1 and
--				   'Attempt to close root scene - you have clicked on an object which hasn`t been added to any zoom-zone');
            if (gameState.activeZone ~= RootZoomZone and gameState.locker:GetNReferences() > 1) then
                if (gameState.lockedObjects[gameState.activeZone.activeObject] == nil) then
                    SetZoneVisible(gameState.activeZone, false);
                end
            else
                Log('Lua: OnObjectMouseDown(\''..objectName..'\'): Was made click on object which hasn`t been attached to any zoom-zone');
            end
        end --// if (gameState.activeZone.HasObject(...
    end --// if (gameState.lockedObjects[...

	--// Tips - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
	if (objectName == 'actZoneFlame' and gameState.bucketUsed == false) then
	    playField:GetLevelScreen():ShowTip(GetTextString('LEVEL17_FIRE_TIP1'));
	elseif (objectName == 'actZoneArtifact' and gameState.artifactOnPlace == false) then
		if (gameState.sphereOnPlace == false) then
		    playField:GetLevelScreen():ShowTip(GetTextString('LEVEL17_FORSE_FIELD_TIP1'));
		else
		    playField:GetLevelScreen():ShowTip(GetTextString('LEVEL17_VCRYSTAL_TIP1'), 
											   GetTextString('LEVEL17_VCRYSTAL_TIP2'));
		end
	elseif (objectName == 'actZoneSphere' and gameState.sphereOnPlace == false) then
	    playField:GetLevelScreen():ShowTip(GetTextString('LEVEL17_SPHERE_TIP1'));
	elseif (objectName == 'actZoneStone' and gameState.stoneOnPlace == false) then
	    playField:GetLevelScreen():ShowTip(GetTextString('LEVEL17_STONE_TIP1'));
	elseif (objectName == 'actZoneHandle' and gameState.handleOnPlace == false) then
	    playField:GetLevelScreen():ShowTip(GetTextString('LEVEL17_LEVER_TIP1'));
	elseif (objectName == 'actZoneVCrystal' and gameState.vcrystalOnPlace == false) then
	    playField:GetLevelScreen():ShowTip(GetTextString('LEVEL17_VCRYSTAL_TIP1'), 
										   GetTextString('LEVEL17_VCRYSTAL_TIP2'));
	else
	    playField:GetLevelScreen():HideTip();
	end
	--//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

    DefaultOnObjectClick(object, isWrongClick, not playField:GetLevelScreen():IsTipShown());
    DefaultOnObjectMouseEnter(object);
end

------------------------------------------------------------------------------
--
function OnObjectMouseUp(object)
end

------------------------------------------------------------------------------
--
function OnObjectFound(object)
    local objectName = object:GetName();
	-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    assert(gameState.activeZone ~= nil);
    if (gameState.activeZone == AltarZoomZone and objectName == 'VCrystal') then
		CloseAndBlockActiveZone();
    end
	-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	local objectMustBeHighlighted = DefaultOnObjectFound(object);
	return objectMustBeHighlighted;
end

------------------------------------------------------------------------------
--
function OnToolFound(tool)
end

------------------------------------------------------------------------------
--
function CanToolBeApplied(tool, object)
	local toolName = tool:GetName();
	local objName = object:GetName();
    local canToolBeApplied = true;
	-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	canToolBeApplied = DefaultCanToolBeApplied(tool, object);
	return canToolBeApplied;
end

------------------------------------------------------------------------------
--
function OnToolApply(tool, object)
	local toolName = tool:GetName();
	local objName = object:GetName();
    local toolApplied = false;

	-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	if (toolName == 'ArtifactWithRune' and objName == gameState.toolMap[toolName]) then
		if (gameState.stoneOnPlace == true) then
			if (gameState.sphereOnPlace == true) then
				gameState.artifactOnPlace = true;
				toolApplied = true;
        		auxLiftUpPyramidTop();
			else
			    playField:GetLevelScreen():ShowTip(GetTextString('CANNT_USE_ITEM_YET_TIP1'),
												   GetTextString('CANNT_USE_ITEM_YET_TIP2'));
				toolApplied = false;
				return toolApplied;
			end
		end
	end
	if (toolName == 'Bucket' and objName == gameState.toolMap[toolName]) then
		gameState.bucketUsed = true;
		toolApplied = true;
		StopSound('L17S10');
		PlaySound('L17S11');
	end
	if (toolName == 'Handle' and objName == gameState.toolMap[toolName]) then
		gameState.handleOnPlace = true;
		toolApplied = true;
	end
	if (toolName == 'Sphere' and objName == gameState.toolMap[toolName]) then
		gameState.sphereOnPlace = true;
		toolApplied = true;
		StopSound('L17S15');
	end
	if (toolName == 'Stone' and objName == gameState.toolMap[toolName]) then
		gameState.stoneOnPlace = true;
		toolApplied = true;
		auxMovePlatform();
	end
	if (toolName == 'VCrystal' and objName == gameState.toolMap[toolName]) then
		gameState.vcrystalOnPlace = true;
		toolApplied = true;
	end
	if (not toolApplied) then
	    playField:GetLevelScreen():ShowTip(GetTextString('WRONG_ITEM_APPLIED_TIP1'),
										   GetTextString('WRONG_ITEM_APPLIED_TIP2'));
	end


	if (gameState.artifactOnPlace == true and
		gameState.bucketUsed == true and
		gameState.handleOnPlace == true and
		gameState.sphereOnPlace == true and
		gameState.stoneOnPlace == true and
		gameState.vcrystalOnPlace == true and
		gameState.allToolsApplied == false) then

		gameState.allToolsApplied = true;
		if (playField:GetLevelScreen():HasUncompletedTask() == true) then
		    playField:GetLevelScreen():ShowTip(GetTextString('HAVE_TO_FIND_ITEMS_MSG1'),
											   GetTextString('HAVE_TO_FIND_ITEMS_MSG2'));
		else
			auxTestLevelCompleteCondition();
		end
	end

	auxProcessToolObjectStateAnCursorType();
	-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    DefaultOnObjectMouseEnter(object);
	if (toolApplied == true) then
	    DeactivateActiveZoneDeactivatedGlow(object:GetName());
	end
	return toolApplied;
end

------------------------------------------------------------------------------
--
function OnObjectReachPanel(object)
    local objectName = object:GetName();
	-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	auxTestLevelCompleteCondition();
end

------------------------------------------------------------------------------
--
function OnButtonPress(zoneName)
    DefaultOnButtonPress(zoneName);
end

------------------------------------------------------------------------------
--
function OnMouseMove(prevMousePos, currentMousePos)
end

------------------------------------------------------------------------------
--
function OnSetTool(tool)
end

------------------------------------------------------------------------------
-- CLEAR_ON_SAVE_BEGIN
-- Do not edit code listed below (generated by the editor on each save)
function LoadData()
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Layers/background.jpg',0,0,1024,768,1,0)
	anim:SetHotSpot(512,384)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('RootBackground',anim,512,384,98,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/axe.png',0,0,76,42,1,0)
	anim:SetHotSpot(38,21)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('axe',anim,690,681,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/bird.png',0,0,69,54,1,0)
	anim:SetHotSpot(34,27)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('bird',anim,928,417,102,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/bracelet.png',0,0,67,78,1,0)
	anim:SetHotSpot(33,39)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('bracelet',anim,617,710,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/brooch.png',0,0,89,56,1,0)
	anim:SetHotSpot(44,28)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('brooch',anim,403,204,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/bullHead.png',0,0,68,75,1,0)
	anim:SetHotSpot(34,37)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('bullHead',anim,774,366,102,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/cayenne.png',0,0,94,29,1,0)
	anim:SetHotSpot(47,14)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('cayenne',anim,672,751,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/crossbow.png',0,0,165,86,1,0)
	anim:SetHotSpot(82,43)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('crossbow',anim,294,670,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/cup.png',0,0,86,87,1,0)
	anim:SetHotSpot(43,43)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('cup',anim,420,590,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/drum.png',0,0,67,61,1,0)
	anim:SetHotSpot(33,30)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('drum',anim,399,370,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/drums.png',0,0,61,69,1,0)
	anim:SetHotSpot(30,34)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('drums',anim,700,547,102,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/eagleHead.png',0,0,67,66,1,0)
	anim:SetHotSpot(33,33)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('eagleHead',anim,609,389,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/eggplants.png',0,0,64,69,1,0)
	anim:SetHotSpot(32,34)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('eggplants',anim,279,522,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/grapes.png',0,0,59,36,1,0)
	anim:SetHotSpot(29,18)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('grapes',anim,349,523,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/grasshopper.png',0,0,97,76,1,0)
	anim:SetHotSpot(48,38)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('grasshopper',anim,321,717,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/jug.png',0,0,115,102,1,0)
	anim:SetHotSpot(57,51)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('jug',anim,523,346,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/lime.png',0,0,42,42,1,0)
	anim:SetHotSpot(21,21)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('lime',anim,491,741,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/lizard.png',0,0,31,103,1,0)
	anim:SetHotSpot(15,51)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('lizard',anim,247,334,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/mace.png',0,0,63,53,1,0)
	anim:SetHotSpot(31,26)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('mace',anim,723,711,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/magnolia.png',0,0,53,47,1,0)
	anim:SetHotSpot(26,23)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('magnolia',anim,554,315,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/oldFnife.png',0,0,63,97,1,0)
	anim:SetHotSpot(31,48)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('oldFnife',anim,180,485,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/onions.png',0,0,106,68,1,0)
	anim:SetHotSpot(53,34)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('onions',anim,294,585,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/pelican.png',0,0,73,130,1,0)
	anim:SetHotSpot(36,65)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('pelican',anim,509,614,103,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/pendant.png',0,0,30,45,1,0)
	anim:SetHotSpot(15,22)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('pendant',anim,421,303,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/plate.png',0,0,63,52,1,0)
	anim:SetHotSpot(31,26)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('plate',anim,381,551,102,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/pterodactyl.png',0,0,57,77,1,0)
	anim:SetHotSpot(28,38)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('pterodactyl',anim,935,229,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/pumpkin.png',0,0,90,88,1,0)
	anim:SetHotSpot(45,44)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('pumpkin',anim,396,727,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/sabre.png',0,0,55,158,1,0)
	anim:SetHotSpot(27,79)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('sabre',anim,430,508,103,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/scroll.png',0,0,53,67,1,0)
	anim:SetHotSpot(26,33)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('scroll',anim,822,627,102,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/seagull.png',0,0,82,48,1,0)
	anim:SetHotSpot(41,24)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('seagull',anim,423,117,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/shield.png',0,0,60,59,1,0)
	anim:SetHotSpot(30,29)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('shield',anim,642,532,102,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/skull.png',0,0,117,98,1,0)
	anim:SetHotSpot(58,49)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('skull',anim,542,694,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/soldierStatuette.png',0,0,90,124,1,0)
	anim:SetHotSpot(45,62)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('soldierStatuette',anim,905,523,102,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/statuette1.png',0,0,42,117,1,0)
	anim:SetHotSpot(21,58)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('statuette1',anim,582,513,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/statuette2.png',0,0,73,92,1,0)
	anim:SetHotSpot(36,46)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('statuette2',anim,327,358,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/statuette3.png',0,0,67,80,1,0)
	anim:SetHotSpot(33,40)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('statuette3',anim,139,190,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/stoneIdol.png',0,0,53,112,1,0)
	anim:SetHotSpot(26,56)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('stoneIdol',anim,819,469,102,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/tambourine.png',0,0,53,61,1,0)
	anim:SetHotSpot(26,30)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('tambourine',anim,248,550,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/torch.png',0,0,49,103,1,0)
	anim:SetHotSpot(24,51)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('torch',anim,735,481,102,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/vessel1.png',0,0,68,72,1,0)
	anim:SetHotSpot(34,36)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('vessel1',anim,225,599,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Misc/vessel2.png',0,0,77,69,1,0)
	anim:SetHotSpot(38,34)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('vessel2',anim,754,651,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Layers/LayerOverOldKnife.png',0,0,59,30,1,0)
	anim:SetHotSpot(29,15)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverOldKnife',anim,182,452,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Layers/LayerOverPyramidalArtefact.png',0,0,290,255,1,0)
	anim:SetHotSpot(145,127)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverPyramidalArtefact',anim,673,124,106,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Layers/LayerOverStoneIdol.png',0,0,27,110,1,0)
	anim:SetHotSpot(13,55)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverStoneIdol',anim,837,467,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Layers/platform.png',0,0,180,172,1,0)
	anim:SetHotSpot(90,86)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('platform',anim,927,67,102,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Layers/pyramidalArtefactBottom.png',0,0,95,56,1,0)
	anim:SetHotSpot(47,28)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('pyramidalArtefactBottom',anim,676,80,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Layers/pyramidalArtefactTop.png',0,0,96,65,1,0)
	anim:SetHotSpot(48,32)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('pyramidalArtefactTop',anim,676,42,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/actZoneC.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	play_field:CreateObject('actZonePyramidRoot',anim,678,60,99,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/fire1.png',0,0,86,128,31,9)
	anim:SetHotSpot(43,64)
	anim:SetBlendMode(0)
	anim:SetColor('0xDDFFBBFF')
	play_field:CreateObject('flameOnStairs1',anim,333,396,105,0,1.6,1.6)
	local anim = CreateAnimation('data/Texture/Scenes/Common/fire1.png',0,0,86,128,31,12)
	anim:SetHotSpot(43,64)
	anim:SetBlendMode(0)
	anim:SetColor('0xDDFFBBFF')
	play_field:CreateObject('flameOnStairs2',anim,386,404,105,0,-1.5,1.6)
	local anim = CreateAnimation('data/Texture/Scenes/Common/fire1.png',0,0,86,128,31,12)
	anim:SetHotSpot(43,64)
	anim:SetBlendMode(0)
	anim:SetColor('0xDDFFBBFF')
	play_field:CreateObject('flameOnStairs3',anim,355,430,106,0,-1.3,1.2)
	local anim = CreateAnimation('data/Texture/Scenes/Common/radialGlow.png',0,0,97,99,1,0)
	anim:SetHotSpot(48,48)
	anim:SetBlendMode(0)
	anim:SetColor('0xEEFFAA00')
	play_field:CreateObject('flameOnStairsGlow',anim,346,384,107,0,4,5)
	local anim = CreateAnimation('data/Texture/Scenes/Common/actZoneC.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	play_field:CreateObject('actZoneFlame',anim,355,451,104,0,1.3,0.8)
	local anim = CreateAnimation('data/Texture/Scenes/Common/actZoneC.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	play_field:CreateObject('actZoneStone',anim,922,85,105,0,1.2,0.9)
	local anim = CreateAnimation('data/Texture/Scenes/Common/actZoneC.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	play_field:CreateObject('actZoneSphere',anim,921,650,104,0,1,0.9)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/ArtifactWithRune.png',0,0,46,59,1,0)
	anim:SetHotSpot(23,29)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('ArtifactWithRune',anim,823,319,102,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Bucket.png',0,0,81,80,1,0)
	anim:SetHotSpot(40,40)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Bucket',anim,459,667,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Handle.png',0,0,100,51,1,0)
	anim:SetHotSpot(50,25)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Handle',anim,640,574,102,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Sphere.png',0,0,51,46,1,0)
	anim:SetHotSpot(25,23)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Sphere',anim,197,196,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Sphere_ghost.png',0,0,72,72,1,0)
	anim:SetHotSpot(36,36)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Sphere_ghost',anim,926,648,110,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Sphere_onPlace.png',0,0,51,46,1,0)
	anim:SetHotSpot(25,23)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Sphere_onPlace',anim,925,648,103,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Stone.png',0,0,75,65,1,0)
	anim:SetHotSpot(37,32)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Stone',anim,543,161,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Stone_ghost.png',0,0,100,100,1,0)
	anim:SetHotSpot(50,50)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Stone_ghost',anim,906,94,110,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Stone_onPlace.png',0,0,80,60,1,0)
	anim:SetHotSpot(40,30)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Stone_onPlace',anim,906,94,103,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Layers/LayerOverStone.png',0,0,87,67,1,0)
	anim:SetHotSpot(43,33)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverStone',anim,542,162,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Layers/LayerOverStoneOnPlace.png',0,0,82,31,1,0)
	anim:SetHotSpot(41,15)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverStoneOnPlace',anim,906,119,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/actZoneC.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	play_field:CreateObject('actZoneGates',anim,278,109,104,0,1,1.4)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Zones/Gates/Layers/background.jpg',0,0,640,480,1,0)
	anim:SetHotSpot(320,240)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	play_field:CreateObject('ZoomGatesBackground',anim,506,315,200,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Zones/Gates/Layers/gateGridLeft.png',0,0,58,119,1,0)
	anim:SetHotSpot(29,59)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	play_field:CreateObject('gateGridLeft',anim,529,407,202,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Zones/Gates/Layers/gateGridRight.png',0,0,71,120,1,0)
	anim:SetHotSpot(35,60)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	play_field:CreateObject('gateGridRight',anim,586,408,202,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Zones/Gates/Layers/LayerOverGateGridRight.png',0,0,122,143,1,0)
	anim:SetHotSpot(61,71)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	play_field:CreateObject('LayerOverGateGridRight',anim,676,417,203,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Zones/Gates/Layers/LayerOverGateGridLeft.png',0,0,160,144,1,0)
	anim:SetHotSpot(80,72)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	play_field:CreateObject('LayerOverGateGridLeft',anim,431,416,203,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Handle_onPlace.png',0,0,47,59,1,0)
	anim:SetHotSpot(20,11)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	play_field:CreateObject('Handle_onPlace',anim,478,391,204,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/VCrystal_onPlace.png',0,0,49,44,1,0)
	anim:SetHotSpot(24,22)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	play_field:CreateObject('VCrystal_onPlace',anim,569,274,202,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/radialGlow.png',0,0,97,99,1,0)
	anim:SetHotSpot(48,48)
	anim:SetBlendMode(0)
	anim:SetColor('0xFF0040FF')
	play_field:CreateObject('vCrystal_onPlaceGlow',anim,563,267,203,0,2,2)
	local anim = CreateAnimation('data/Texture/Scenes/Common/actZoneC.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	play_field:CreateObject('actZoneHandle',anim,471,405,205,0,0.8,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/actZoneC.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	play_field:CreateObject('actZoneVCrystal',anim,567,275,204,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/actZoneC.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	play_field:CreateObject('actZoneAltar',anim,693,191,107,0,2,1.3)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Zones/Altar/Layers/background.jpg',0,0,640,480,1,0)
	anim:SetHotSpot(320,240)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	play_field:CreateObject('ZoomAltarBackground',anim,635,346,200,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Zones/Altar/Layers/LayerOverRunnedCrystal.png',0,0,114,86,1,0)
	anim:SetHotSpot(57,43)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	play_field:CreateObject('LayerOverRunnedCrystal',anim,622,457,203,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Zones/Altar/Layers/LayerOverWithChain.png',0,0,114,484,1,0)
	anim:SetHotSpot(57,242)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	play_field:CreateObject('LayerOverWithChain',anim,775,346,204,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Zones/Altar/Layers/PyramidBottom.png',0,0,241,179,1,0)
	anim:SetHotSpot(120,89)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	play_field:CreateObject('PyramidBottom',anim,630,453,201,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Zones/Altar/Layers/PyramidTop.png',0,0,233,168,1,0)
	anim:SetHotSpot(116,84)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	play_field:CreateObject('PyramidTop',anim,634,354,204,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/Common/actZoneC.png',0,0,128,128,1,0)
	anim:SetHotSpot(64,64)
	anim:SetBlendMode(2)
	anim:SetColor('0x01FFFFFF')
	play_field:CreateObject('actZoneArtifact',anim,587,372,206,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/ArtifactWithRune_onPlace.png',0,0,45,52,1,0)
	anim:SetHotSpot(22,26)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	play_field:CreateObject('ArtifactWithRune_onPlace',anim,584,358,205,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/ArtifactWithRune_ghost.PNG',0,0,64,72,1,0)
	anim:SetHotSpot(32,36)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('ArtifactWithRune_ghost',anim,584,359,210,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/VCrystal.png',0,0,80,68,1,0)
	anim:SetHotSpot(40,34)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	play_field:CreateObject('VCrystal',anim,629,415,202,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Handle_ghost.png',0,0,64,72,1,0)
	anim:SetHotSpot(32,36)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Handle_ghost',anim,482,411,210,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/VCrystal_ghost.png',0,0,64,64,1,0)
	anim:SetHotSpot(32,32)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('VCrystal_ghost',anim,569,272,210,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/17_CandleCave/Items/Bucket_ghost.png',0,0,100,112,1,0)
	anim:SetHotSpot(50,50)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Bucket_ghost',anim,379,420,110,0,1,1)
end

function FreeData()
end
-- CLEAR_ON_SAVE_END
