dofile('data/Scripts/Scenes/Common.lua');
dofile('data/Scripts/Scenes/Animations/13_TribeLeaderHut_Animations.lua');

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

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

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

							 'actZoneBox',
							 'actZoneChest',

							 'amulet',
							 'bananas',
							 'basket',
							 'boat',
							 'box',
							 'brush',
							 'bug',
							 'butterfly',
							 'cactus',
							 'cayenne',
							 'chicken',
							 'coinNecklace',
							 'curl',
							 'disk',
							 'emerald',
							 'fork',
							 'handbell',
							 'helmet',
							 'iron',
							 'jar',
							 'jug',
							 'key',
							 'oilBottle',
							 'panther',
							 'pipe',
							 'plateWithCoins',
							 'pumpkin',
							 'rhino',
							 'ring',
							 'rug',
							 'scissors',
							 'shield',
							 'skull',
							 'squirrel',
							 'stone',
							 'sun',
							 'tomehowk',
							 'vase',
							 'vessel',
							 'yellowCrystal',

							 'backpackClosed',
							 'backpackOpened',
							 'boxPadlock',
							 'chestPadlock',
							 'LayerOverBananas',
							 'LayerOverBoat',
							 'LayerOverCactus',
							 'LayerOverChicken',
							 'LayerOverCoinNecklace',
							 'LayerOverEmerald',
							 'LayerOverJug',
							 'LayerOverLens',
							 'LayerOverMechFlowerAnim',
							 'LayerOverShield',
							 'LayerOverTomehowk',
							 'LayerOverVase',
							 'LayerOverWoodenDoor',
							 'mechanicFlowerAnim',
							 'woodenDoor',
							 'woodenShield',

							 'actZoneMinigame',
							 'actZoneLens',
							 'actZoneSkullKey',
							 'actZoneBackpack',

							 'actZoneRubyRoot',

							 'Hatchet',
							 'Key',
							 'Ruby',
							 'SkullKey',
							 'Lens_onPlace',
							 'SkullKey_onPlace'},
							 
							{'backpackClosed'},

							{'light',
							 'LaserRay1',
							 'LaserRay2',
							 'LaserGlow0',
							 'LaserGlow1',
							 'LaserGlow2',
							 'LaserGlow3'});

    BoxZoomZone = CreateZoomZone('BoxZoomZone', RootZoomZone, 
                                   'actZoneBox', 0.0, 
                                   nil, 0.0,
							{'ZoomBoxBackground',
							 'Bag'},

							{});

    ChestZoomZone = CreateZoomZone('ChestZoomZone', RootZoomZone, 
                                   'actZoneChest', 0.0, 
                                   nil, 0.0,
							{'ZoomChestBackground',
							 'Lens'},

							{});

if (restoringFromSave == false) then
    AddRandomTasks(true, MISC_TASK_COUNT_24,
		CreateTask('amulet'),
		CreateTask('bananas'),
		CreateTask('basket'),
		CreateTask('boat'),
		CreateTask('box'),
		CreateTask('brush'),
		CreateTask('bug'),
		CreateTask('butterfly'),
		CreateTask('cactus'),
		CreateTask('cayenne'),
		CreateTask('chicken'),
		CreateTask('coinNecklace'),
		CreateTask('curl'),
		CreateTask('disk'),
		CreateTask('emerald'),
		CreateTask('fork'),
		CreateTask('handbell'),
		CreateTask('helmet'),
		CreateTask('iron'),
		CreateTask('jar'),
		CreateTask('jug'),
		CreateTask('key'),
		CreateTask('oilBottle'),
		CreateTask('panther'),
		CreateTask('pipe'),
		CreateTask('plateWithCoins'),
		CreateTask('pumpkin'),
		CreateTask('rhino'),
		CreateTask('ring'),
		CreateTask('rug'),
		CreateTask('scissors'),
		CreateTask('shield'),
		CreateTask('skull'),
		CreateTask('squirrel'),
		CreateTask('stone'),
		CreateTask('sun'),
		CreateTask('tomehowk'),
		CreateTask('vase'),
		CreateTask('vessel'),
		CreateTask('yellowCrystal')
	);

    playField:GetLevelScreen():AddTaskSafe(CreateTask('Ruby'));
    playField:GetLevelScreen():AddTaskSafe(CreateTask('Lens'));
    playField:GetLevelScreen():AddTaskSafe(CreateTask('Bag'));
    playField:GetLevelScreen():AddTaskSafe(CreateTask('Key'));
    playField:GetLevelScreen():AddTaskSafe(CreateTask('Hatchet'));
    playField:GetLevelScreen():AddTaskSafe(CreateTask('SkullKey'));
end

	CreateToolMap(	{'Ruby', 		'actZoneBackpack'},
					{'Lens',   		'actZoneLens'},
					{'Bag',			'actZoneMinigame'},
					{'Key',   		'actZoneChest'},
					{'Hatchet',  	'actZoneBox'},
					{'SkullKey',	'actZoneSkullKey'});

	SetIconForGameObject(playField:GetObject('amulet'),		'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/amulet_icon.png');
	SetIconForGameObject(playField:GetObject('bananas'),	'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/bananas_icon.png');
	SetIconForGameObject(playField:GetObject('basket'),		'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/basket_icon.png');
	SetIconForGameObject(playField:GetObject('boat'),		'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/boat_icon.png');
	SetIconForGameObject(playField:GetObject('box'),		'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/box_icon.png');
	SetIconForGameObject(playField:GetObject('brush'),		'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/brush_icon.png');
	SetIconForGameObject(playField:GetObject('bug'),		'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/bug_icon.png');
	SetIconForGameObject(playField:GetObject('butterfly'),	'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/butterfly_icon.png');
	SetIconForGameObject(playField:GetObject('cactus'),		'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/cactus_icon.png');
	SetIconForGameObject(playField:GetObject('cayenne'),	'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/cayenne_icon.png');
	SetIconForGameObject(playField:GetObject('chicken'),	'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/chicken_icon.png');
	SetIconForGameObject(playField:GetObject('coinNecklace'),'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/coinNecklace_icon.png');
	SetIconForGameObject(playField:GetObject('curl'),		'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/curl_icon.png');
	SetIconForGameObject(playField:GetObject('disk'),		'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/disk_icon.png');
	SetIconForGameObject(playField:GetObject('emerald'),	'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/emerald_icon.png');
	SetIconForGameObject(playField:GetObject('fork'),		'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/fork_icon.png');
	SetIconForGameObject(playField:GetObject('handbell'),	'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/handbell_icon.png');
	SetIconForGameObject(playField:GetObject('helmet'),		'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/helmet_icon.png');
	SetIconForGameObject(playField:GetObject('iron'),		'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/iron_icon.png');
	SetIconForGameObject(playField:GetObject('jar'),		'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/jar_icon.png');
	SetIconForGameObject(playField:GetObject('jug'),		'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/jug_icon.png');
	SetIconForGameObject(playField:GetObject('key'),		'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/key_icon.png');
	SetIconForGameObject(playField:GetObject('oilBottle'),	'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/oilBottle_icon.png');
	SetIconForGameObject(playField:GetObject('panther'),	'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/panther_icon.png');
	SetIconForGameObject(playField:GetObject('pipe'),		'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/pipe_icon.png');
	SetIconForGameObject(playField:GetObject('plateWithCoins'),'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/plateWithCoins_icon.png');
	SetIconForGameObject(playField:GetObject('pumpkin'),	'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/pumpkin_icon.png');
	SetIconForGameObject(playField:GetObject('rhino'),		'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/rhino_icon.png');
	SetIconForGameObject(playField:GetObject('ring'),		'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/ring_icon.png');
	SetIconForGameObject(playField:GetObject('rug'),		'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/rug_icon.png');
	SetIconForGameObject(playField:GetObject('scissors'),	'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/scissors_icon.png');
	SetIconForGameObject(playField:GetObject('shield'),		'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/shield_icon.png');
	SetIconForGameObject(playField:GetObject('skull'),		'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/skull_icon.png');
	SetIconForGameObject(playField:GetObject('squirrel'),	'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/squirrel_icon.png');
	SetIconForGameObject(playField:GetObject('stone'),		'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/stone_icon.png');
	SetIconForGameObject(playField:GetObject('sun'),		'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/sun_icon.png');
	SetIconForGameObject(playField:GetObject('tomehowk'),	'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/tomehowk_icon.png');
	SetIconForGameObject(playField:GetObject('vase'),		'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/vase_icon.png');
	SetIconForGameObject(playField:GetObject('vessel'),		'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/vessel_icon.png');
	SetIconForGameObject(playField:GetObject('yellowCrystal'),'data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/yellowCrystal_icon.png');

	SetIconForGameObject(playField:GetObject('Ruby'),		'data/Texture/Scenes/13_TribeLeaderHut/Items/Ruby_icon.png');
	SetIconForGameObject(playField:GetObject('Lens'),		'data/Texture/Scenes/13_TribeLeaderHut/Items/Lens_icon.png');
	SetIconForGameObject(playField:GetObject('Bag'),		'data/Texture/Scenes/13_TribeLeaderHut/Items/Bag_icon.png');
	SetIconForGameObject(playField:GetObject('Key'),		'data/Texture/Scenes/13_TribeLeaderHut/Items/Key_icon.png');
	SetIconForGameObject(playField:GetObject('Hatchet'),	'data/Texture/Scenes/13_TribeLeaderHut/Items/Hatchet_icon.png');
	SetIconForGameObject(playField:GetObject('SkullKey'),	'data/Texture/Scenes/13_TribeLeaderHut/Items/SkullKey_icon.png');


if (restoringFromSave == false) then
	gameState.rubyRootInitPosY = playField:GetObject('actZoneRubyRoot'):GetY();
	gameState.rubyRootMoveDistance = -45.0;
	gameState.woodenDoorInitPosY = playField:GetObject('woodenDoor'):GetY();
	gameState.woodenDoorMoveDistance = 110.0;
	gameState.woodenShieldInitPosX = playField:GetObject('woodenShield'):GetX();
	gameState.woodenShieldMoveDistance = -45.0;
	gameState.boxPadlockInitPosY = playField:GetObject('boxPadlock'):GetY();
	gameState.boxPadlockMoveDistance = 50.0;
	gameState.chestPadlockInitPosY = playField:GetObject('chestPadlock'):GetY();
	gameState.chestPadlockMoveDistance = 50.0;

	gameState.rubyOnPlace = false;
	gameState.lensOnPlace = false;
	gameState.bagUsed = false;
	gameState.keyUsed = false;
	gameState.hatchetUsed = false;
	gameState.skullKeyUsed = false;

	gameState.woodenShieldMoved = false
	gameState.woodenShieldIsMoving = false;
	gameState.rubyRootIsMoving = false;
	gameState.woodenDoorIsMoving = false;
	gameState.boxPadlockIsMoving = false;
	gameState.chestPadlockIsMoving = false;
	gameState.blueRayDelayActive = false;

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

	AssignActiveZonesGlow({function() return gameState.rubyOnPlace; end,	'actZoneBackpack',	'Ruby_ghost'},
						  {function() return gameState.lensOnPlace; end,	'actZoneLens',		'Lens_ghost'},
					      {function() return gameState.bagUsed; end,		'actZoneMinigame',	'Bag_ghost'},
						  {function() return gameState.keyUsed; end,		'actZoneChest',		'Key_ghost'},
						  {function() return gameState.hatchetUsed; end,	'actZoneBox',		'Hatchet_ghost'},
						  {function() return gameState.skullKeyUsed; end,	'actZoneSkullKey',	'SkullKey_ghost'});

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

	auxSceneInit(restoringFromSave);
	auxProcessToolObjectStateAnCursorType();
end

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

    StopSound('L13S10');
    StopSound('L13S11');
    StopSound('L13S12');
end

--// Local auxiliary functions - - - - - - - - - - - - - - - - - - - - - - - -
function auxSceneInit(restoringFromSave)
    local initialActions = function()
		ShowLevelIntro(13);
    end
	local regularActions = function()
	    playField:IgnoreOnTestPoint('light');
		playField:GetObject('light'):SetZ(10);
		auxSetFibrillationEffector(playField:GetObject('light'), 0.62, 4.5);

	    playField:IgnoreOnTestPoint('LaserRay1');
	    playField:IgnoreOnTestPoint('LaserRay2');
	    playField:IgnoreOnTestPoint('LaserGlow0');
	    playField:IgnoreOnTestPoint('LaserGlow1');
	    playField:IgnoreOnTestPoint('LaserGlow2');
	    playField:IgnoreOnTestPoint('LaserGlow3');
		auxSetFibrillationEffector(playField:GetObject('LaserRay1'),  0.32, 0.25);
		auxSetFibrillationEffector(playField:GetObject('LaserRay2'),  0.32, 0.25);
		auxSetFibrillationEffector(playField:GetObject('LaserGlow0'), 0.32, 0.25);
		auxSetFibrillationEffector(playField:GetObject('LaserGlow1'), 0.32, 0.25);
		auxSetFibrillationEffector(playField:GetObject('LaserGlow2'), 0.32, 0.25);
		auxSetFibrillationEffector(playField:GetObject('LaserGlow3'), 0.32, 0.25);

		auxStopAnimation('mechanicFlowerAnim', HGEANIM_FWD + HGEANIM_NOLOOP);
		if (playField:HasObject('Ruby')) then
			auxAttachInPlace(playField:GetObject('Ruby'), playField:GetObject('actZoneRubyRoot'));
		end

--	    gameState.customCursors['actZoneBox'] = {'CursorZoom'};
--	    gameState.customCursors['actZoneChest'] = {'CursorZoom'};

	    playField:IgnoreOnTestPoint('LayerOverShield');

		auxCreateTribeLeaderHutAnimations(playField:GetObject('RootBackground'));
		auxPlayTribeLeaderHutAnimation('Fly1');
		auxPlayTribeLeaderHutAnimation('EnvTop');
		auxPlayTribeLeaderHutAnimation('TorchesFire');
--		auxPlayTribeLeaderHutAnimation('Fly2');

		gameState.nextAnimationDelay = 0;

		gameState.woodenShieldIsMoving = false;
		gameState.rubyRootIsMoving = false;
		gameState.woodenDoorIsMoving = false;
		gameState.boxPadlockIsMoving = false;
		gameState.chestPadlockIsMoving = false;
		gameState.blueRayDelayActive = 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.rubyOnPlace ~= nil and
			gameState.lensOnPlace ~= nil and
			gameState.bagUsed ~= nil and
			gameState.keyUsed ~= nil and
			gameState.hatchetUsed ~= nil and
			gameState.skullKeyUsed ~= nil);

	if (gameState.rubyRootIsMoving == false) then
		if (gameState.rubyOnPlace == true) then
			RootZoomZone.UnhideObject('backpackClosed');
			RootZoomZone.HideObject('backpackOpened');
			gameState.customCursors['actZoneBackpack'] = nil;
		else
			RootZoomZone.HideObject('backpackClosed');
			RootZoomZone.UnhideObject('backpackOpened');
			gameState.customCursors['actZoneBackpack'] = {'CursorArms'};
		end
	end

	if (gameState.lensOnPlace == true) then
		RootZoomZone.UnhideObject('Lens_onPlace');
		gameState.customCursors['actZoneLens'] = nil;
	else
		RootZoomZone.HideObject('Lens_onPlace');
		gameState.customCursors['actZoneLens'] = {'CursorArms'};
	end
	playField:GetObject('LaserRay1'):SetVisible(gameState.bagUsed == true and not gameState.blueRayDelayActive);
	playField:GetObject('LaserRay1'):SetScaleX(gameState.lensOnPlace == true and 1.0 or 1.15);
	playField:GetObject('LaserRay2'):SetVisible(gameState.bagUsed == true and gameState.lensOnPlace == true and not gameState.blueRayDelayActive);
	playField:GetObject('LaserGlow0'):SetVisible(gameState.bagUsed == true and not gameState.blueRayDelayActive);
	playField:GetObject('LaserGlow1'):SetVisible(gameState.bagUsed == true and gameState.lensOnPlace == false and not gameState.blueRayDelayActive);
	playField:GetObject('LaserGlow2'):SetVisible(gameState.bagUsed == true and gameState.lensOnPlace == true and not gameState.blueRayDelayActive);
	playField:GetObject('LaserGlow3'):SetVisible(gameState.bagUsed == true and gameState.lensOnPlace == true and not gameState.blueRayDelayActive);
	if (gameState.bagUsed == true) then
		gameState.customCursors['actZoneMinigame'] = nil;
	else
		gameState.customCursors['actZoneMinigame'] = {'CursorArms'};
	end

	if (gameState.chestPadlockIsMoving == false) then
		if (gameState.keyUsed == true) then
			playField:GetObject('chestPadlock'):SetY(gameState.chestPadlockInitPosY + gameState.chestPadlockMoveDistance);
			if (playField:HasObject('Lens') == true) then
				gameState.lockedObjects['actZoneChest'] = nil;
				gameState.customCursors['actZoneChest'] = {'CursorZoom'};
			end
		else
			playField:GetObject('chestPadlock'):SetY(gameState.chestPadlockInitPosY);
			gameState.lockedObjects['actZoneChest'] = true;
			gameState.customCursors['actZoneChest'] = {'CursorArms'};
		end
	end

	if (gameState.boxPadlockIsMoving == false) then
		if (gameState.hatchetUsed == true) then
			playField:GetObject('boxPadlock'):SetY(gameState.boxPadlockInitPosY + gameState.boxPadlockMoveDistance);
			if (playField:HasObject('Bag') == true) then
				gameState.lockedObjects['actZoneBox'] = nil;
				gameState.customCursors['actZoneBox'] = {'CursorZoom'};
			end
		else
			playField:GetObject('boxPadlock'):SetY(gameState.boxPadlockInitPosY);
			gameState.lockedObjects['actZoneBox'] = true;
			gameState.customCursors['actZoneBox'] = {'CursorArms'};
		end
	end

	if (gameState.woodenDoorIsMoving == false) then
		if (gameState.skullKeyUsed == true) then
			RootZoomZone.UnhideObject('SkullKey_onPlace');
			gameState.lockedObjects['Hatchet'] = nil;
			playField:GetObject('woodenDoor'):SetY(gameState.woodenDoorInitPosY + gameState.woodenDoorMoveDistance);
			gameState.customCursors['actZoneSkullKey'] = nil;
		else
			RootZoomZone.HideObject('SkullKey_onPlace');
			gameState.lockedObjects['Hatchet'] = true;
			playField:GetObject('woodenDoor'):SetY(gameState.woodenDoorInitPosY);
			gameState.customCursors['actZoneSkullKey'] = {'CursorArms'};
		end
	end

	if (gameState.woodenShieldIsMoving == false) then
		if (gameState.woodenShieldMoved == true) then
			playField:GetObject('woodenShield'):SetX(gameState.woodenShieldInitPosX + gameState.woodenShieldMoveDistance);
			gameState.customCursors['woodenShield'] = nil;
		else
			playField:GetObject('woodenShield'):SetX(gameState.woodenShieldInitPosX);
			gameState.customCursors['woodenShield'] = {'CursorArms'};
		end
	end

	if (gameState.rubyRootIsMoving == false) then
		local anim = playField:GetObject('mechanicFlowerAnim'):GetAnimation();
		local objRubyRoot = playField:GetObject('actZoneRubyRoot');

		anim:Stop();
		if (gameState.bagUsed == true and gameState.lensOnPlace == true) then
			anim:SetFrame(anim:GetFrames() - 1);
			objRubyRoot:SetY(gameState.rubyRootInitPosY + gameState.rubyRootMoveDistance);
		else
			anim:SetFrame(0);
			objRubyRoot:SetY(gameState.rubyRootInitPosY);
		end
	end
end

--// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function auxDisableStateFlag(flagName, additinalAction)
	assert(gameState[flagName] ~= nil);
	gameState[flagName] = false;
	if (additinalAction ~= nil) then
		additinalAction();
	end
end
function auxMoveWoodenShield()
	local duration = 1.0;

	PlaySound('L13S12');
	gameState.woodenShieldMoved = true;
	gameState.woodenShieldIsMoving = true;
	TimerDoString('auxDisableStateFlag(\'woodenShieldIsMoving\');', duration, playField:GetTimer());

	local objShield = playField:GetObject('woodenShield');
	objShield:SetX(gameState.woodenShieldInitPosX);
	objShield:Move(gameState.woodenShieldMoveDistance, 0.0, duration);
	gameState.customCursors['woodenShield'] = nil;
end
function auxUnlockChest()
	local duration = 0.25;

	gameState.keyUsed = true;
	gameState.chestPadlockIsMoving = true;
	TimerDoString('auxDisableStateFlag(\'chestPadlockIsMoving\');', duration, playField:GetTimer());

	local objPadlock = playField:GetObject('chestPadlock');
	objPadlock:SetY(gameState.chestPadlockInitPosY);
	objPadlock:Move(0.0, gameState.chestPadlockMoveDistance, duration);	

	gameState.lockedObjects['actZoneChest'] = nil;
	gameState.customCursors['actZoneChest'] = {'CursorZoom'};
end
function auxUnlockBox()
	local duration = 0.25;

	gameState.keyUsed = true;
	gameState.boxPadlockIsMoving = true;
	TimerDoString('auxDisableStateFlag(\'boxPadlockIsMoving\');', duration, playField:GetTimer());

	local objPadlock = playField:GetObject('boxPadlock');
	objPadlock:SetY(gameState.boxPadlockInitPosY);
	objPadlock:Move(0.0, gameState.boxPadlockMoveDistance, duration);	

	gameState.lockedObjects['actZoneBox'] = nil;
	gameState.customCursors['actZoneBox'] = {'CursorZoom'};
end
function auxPlaceSkullKey()
	local duration = 1.0;

	PlaySound('L13S10');
	gameState.skullKeyUsed = true;
	gameState.woodenDoorIsMoving = true;
	TimerDoString('auxDisableStateFlag(\'woodenDoorIsMoving\');', duration, playField:GetTimer());

	local objDoor = playField:GetObject('woodenDoor');
	objDoor:SetY(gameState.woodenDoorInitPosY);
	objDoor:Move(0.0, gameState.woodenDoorMoveDistance, duration);	

	RootZoomZone.UnhideObject('SkullKey_onPlace');
	gameState.lockedObjects['Hatchet'] = nil;
	gameState.customCursors['actZoneSkullKey'] = nil;
end
function auxOpenMechanicFlower()
	local duration = 1.0;
	local anim = playField:GetObject('mechanicFlowerAnim'):GetAnimation();
	local objRubyRoot = playField:GetObject('actZoneRubyRoot');

	PlaySound('L13S11');
	gameState.rubyRootIsMoving = true;
	TimerDoString('auxDisableStateFlag(\'rubyRootIsMoving\');', duration, playField:GetTimer());

	anim:Play();
	objRubyRoot:SetY(gameState.rubyRootInitPosY);
	objRubyRoot:Move(0.0, gameState.rubyRootMoveDistance, duration);
end

function auxActivateBlueRay()
	local duration = 2.0;

	gameState.blueRayDelayActive = true;
	TimerDoString('auxDisableStateFlag(\'blueRayDelayActive\');', duration, playField:GetTimer());
	TimerDoString('auxProcessToolObjectStateAnCursorType();', 1.1 * duration, playField:GetTimer());
end

--// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function auxUpdatePeriodicAnimations(dt)
	if (gameState.nextAnimationDelay == 0.0) then
		local animations = {};

		for compositionName, composition in pairs(tribeLeaderHutCompositions) do
			if (composition:IsCyclic() == false) then
				table.insert(animations, composition:GetName());
			end
		end

		local animName = animations[math.random(1, table.getn(animations))];
		if (animName ~= nil) then
			local composition = auxGetTribeLeaderHutAnimation(animName);

            if (composition ~= nil and composition:IsPaused() == true) then
				auxPlayTribeLeaderHutAnimation(animName);
			end
		end
		gameState.nextAnimationDelay = math.random(4, 11);
	else
		gameState.nextAnimationDelay = (gameState.nextAnimationDelay - dt >= 0.0 and gameState.nextAnimationDelay - dt or 0.0);
	end
end

--// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function auxTestLevelCompleteCondition()
	if (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);

	auxUpdatePeriodicAnimations(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 == 'woodenShield' and gameState.woodenShieldMoved == false) then
				gameState.woodenShieldMoved = true;
				auxMoveWoodenShield();
                isWrongClick = false;
			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 == 'actZoneChest' and gameState.keyUsed == false) then
	    playField:GetLevelScreen():ShowTip(GetTextString('LEVEL13_KEY_TIP1'));
	elseif (objectName == 'actZoneSkullKey' and gameState.skullKeyUsed == false) then
	    playField:GetLevelScreen():ShowTip(GetTextString('LEVEL13_SKULLKEY_TIP1'));
	elseif (objectName == 'actZoneBox' and gameState.hatchetUsed == false) then
	    playField:GetLevelScreen():ShowTip(GetTextString('LEVEL13_HATCHET_TIP1'));
	elseif (objectName == 'actZoneMinigame' and gameState.bagUsed == false) then
	    playField:GetLevelScreen():ShowTip(GetTextString('LEVEL13_BAG_TIP1'));
	elseif (objectName == 'actZoneLens' and gameState.lensOnPlace == false) then
	    playField:GetLevelScreen():ShowTip(GetTextString('LEVEL13_LENS_TIP1'));
	elseif (objectName == 'actZoneBackpack' and gameState.rubyOnPlace == false) then
	    playField:GetLevelScreen():ShowTip(GetTextString('LEVEL13_RUBY_TIP1'));
	elseif (objectName == 'mechanicFlowerAnim' and not gameState.allToolsApplied) then
	    playField:GetLevelScreen():ShowTip(GetTextString('LEVEL13_MECH_FLOWER_TIP1'));
	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();
	-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    --// automatic zoom-zone hiding and blocking
	do
	    assert(gameState.activeZone ~= nil);
	    if ((gameState.activeZone == ChestZoomZone and objectName == 'Lens') or
			(gameState.activeZone == BoxZoomZone and objectName == 'Bag')) then
			CloseAndBlockActiveZone();
	    end
	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 or ((toolName == 'Key' or toolName == 'Hatchet') and objName == gameState.toolMap[toolName]);
end

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

	-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	if (toolName == 'Ruby' and objName == gameState.toolMap[toolName]) then
		gameState.rubyOnPlace = true;
		toolApplied = true;
	end
	if (toolName == 'Lens' and objName == gameState.toolMap[toolName]) then
		gameState.lensOnPlace = true;
		toolApplied = true;
	end
	if (toolName == 'Bag' and objName == gameState.toolMap[toolName]) then
		gameState.bagUsed = true;
		toolApplied = true;
		auxActivateBlueRay();
		playField:GetLevelScreen():RunMiniGame('data/Scripts/Minigames/Ballance.lua');
	end
	if (toolName == 'Key' and objName == gameState.toolMap[toolName]) then
		gameState.keyUsed = true;
		toolApplied = true;
		auxUnlockChest();
	end
	if (toolName == 'Hatchet' and objName == gameState.toolMap[toolName]) then
		gameState.hatchetUsed = true;
		toolApplied = true;
		auxUnlockBox();
	end
	if (toolName == 'SkullKey' and objName == gameState.toolMap[toolName]) then
		gameState.skullKeyUsed = true;
		toolApplied = true;
		auxPlaceSkullKey();
	end
	if (not toolApplied) then
	    playField:GetLevelScreen():ShowTip(GetTextString('WRONG_ITEM_APPLIED_TIP1'),
										   GetTextString('WRONG_ITEM_APPLIED_TIP2'));
	end

	if ((toolName == 'Bag' or toolName == 'Lens') and gameState.bagUsed == true and gameState.lensOnPlace == true) then
		local delay = 2.5;
		gameState.rubyRootIsMoving = true;
		TimerDoString('auxOpenMechanicFlower();', delay, playField:GetTimer());
	end

	if (gameState.rubyOnPlace == true and
		gameState.lensOnPlace == true and
		gameState.bagUsed == true and
		gameState.keyUsed == true and
		gameState.hatchetUsed == true and
		gameState.skullKeyUsed == 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/13_TribeLeaderHut/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/13_TribeLeaderHut/Items/Misc/amulet.png',0,0,70,104,1,0)
	anim:SetHotSpot(35,52)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('amulet',anim,948,150,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/bananas.png',0,0,78,67,1,0)
	anim:SetHotSpot(39,33)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('bananas',anim,181,601,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/basket.png',0,0,126,66,1,0)
	anim:SetHotSpot(63,33)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('basket',anim,464,641,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/boat.png',0,0,62,126,1,0)
	anim:SetHotSpot(31,63)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('boat',anim,743,500,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/box.png',0,0,102,74,1,0)
	anim:SetHotSpot(51,37)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('box',anim,296,620,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/brush.png',0,0,90,117,1,0)
	anim:SetHotSpot(45,58)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('brush',anim,979,635,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/bug.png',0,0,59,82,1,0)
	anim:SetHotSpot(29,41)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('bug',anim,991,414,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/butterfly.png',0,0,75,74,1,0)
	anim:SetHotSpot(37,37)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('butterfly',anim,937,43,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/cactus.png',0,0,67,77,1,0)
	anim:SetHotSpot(33,38)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('cactus',anim,711,313,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/cayenne.png',0,0,31,77,1,0)
	anim:SetHotSpot(15,38)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('cayenne',anim,667,433,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/chicken.png',0,0,83,80,1,0)
	anim:SetHotSpot(41,40)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('chicken',anim,690,567,102,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/coinNecklace.png',0,0,77,102,1,0)
	anim:SetHotSpot(38,51)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('coinNecklace',anim,288,49,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/curl.png',0,0,52,71,1,0)
	anim:SetHotSpot(26,35)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('curl',anim,604,464,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/disk.png',0,0,89,48,1,0)
	anim:SetHotSpot(44,24)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('disk',anim,430,59,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/emerald.png',0,0,45,45,1,0)
	anim:SetHotSpot(22,22)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('emerald',anim,202,293,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/fork.png',0,0,36,89,1,0)
	anim:SetHotSpot(18,44)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('fork',anim,517,419,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/handbell.png',0,0,75,52,1,0)
	anim:SetHotSpot(37,26)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('handbell',anim,923,616,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/helmet.png',0,0,104,82,1,0)
	anim:SetHotSpot(52,41)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('helmet',anim,893,300,103,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/iron.png',0,0,75,74,1,0)
	anim:SetHotSpot(37,37)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('iron',anim,644,633,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/jar.png',0,0,103,98,1,0)
	anim:SetHotSpot(51,49)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('jar',anim,914,708,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/jug.png',0,0,61,52,1,0)
	anim:SetHotSpot(30,26)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('jug',anim,318,323,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/key.png',0,0,109,45,1,0)
	anim:SetHotSpot(54,22)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('key',anim,508,750,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/oilBottle.png',0,0,75,102,1,0)
	anim:SetHotSpot(37,51)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('oilBottle',anim,263,578,103,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/panther.png',0,0,149,97,1,0)
	anim:SetHotSpot(74,48)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('panther',anim,524,568,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/pipe.png',0,0,130,37,1,0)
	anim:SetHotSpot(65,18)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('pipe',anim,585,9,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/plateWithCoins.png',0,0,111,56,1,0)
	anim:SetHotSpot(55,28)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('plateWithCoins',anim,313,746,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/pumpkin.png',0,0,106,116,1,0)
	anim:SetHotSpot(53,58)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('pumpkin',anim,940,728,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/rhino.png',0,0,95,79,1,0)
	anim:SetHotSpot(47,39)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('rhino',anim,673,172,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/ring.png',0,0,59,42,1,0)
	anim:SetHotSpot(29,21)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('ring',anim,244,710,103,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/rug.png',0,0,134,60,1,0)
	anim:SetHotSpot(67,30)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('rug',anim,644,687,107,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/scissors.png',0,0,145,47,1,0)
	anim:SetHotSpot(72,23)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('scissors',anim,789,739,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/shield.png',0,0,118,67,1,0)
	anim:SetHotSpot(59,33)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('shield',anim,800,51,103,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/skull.png',0,0,108,88,1,0)
	anim:SetHotSpot(54,44)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('skull',anim,195,713,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/squirrel.png',0,0,79,84,1,0)
	anim:SetHotSpot(39,42)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('squirrel',anim,137,153,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/stone.png',0,0,78,48,1,0)
	anim:SetHotSpot(39,24)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('stone',anim,372,706,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/sun.png',0,0,76,73,1,0)
	anim:SetHotSpot(38,36)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('sun',anim,290,169,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/tomehowk.png',0,0,96,101,1,0)
	anim:SetHotSpot(48,50)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('tomehowk',anim,163,70,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/vase.png',0,0,72,126,1,0)
	anim:SetHotSpot(36,63)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('vase',anim,972,582,103,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/vessel.png',0,0,63,78,1,0)
	anim:SetHotSpot(31,39)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('vessel',anim,397,510,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Misc/yellowCrystal.png',0,0,42,78,1,0)
	anim:SetHotSpot(21,39)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('yellowCrystal',anim,523,298,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Layers/backpackClosed.png',0,0,114,95,1,0)
	anim:SetHotSpot(57,47)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('backpackClosed',anim,738,636,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Layers/backpackOpened.png',0,0,114,95,1,0)
	anim:SetHotSpot(57,47)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('backpackOpened',anim,738,636,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Layers/boxPadlock.png',0,0,13,21,1,0)
	anim:SetHotSpot(6,10)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('boxPadlock',anim,245,516,103,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Layers/chestPadlock.png',0,0,13,22,1,0)
	anim:SetHotSpot(6,11)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('chestPadlock',anim,847,538,103,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Layers/LayerOverBananas.png',0,0,46,87,1,0)
	anim:SetHotSpot(23,43)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverBananas',anim,154,594,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Layers/LayerOverBoat.png',0,0,47,101,1,0)
	anim:SetHotSpot(23,50)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverBoat',anim,761,524,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Layers/LayerOverCactus.png',0,0,50,31,1,0)
	anim:SetHotSpot(25,15)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverCactus',anim,714,343,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Layers/LayerOverChicken.png',0,0,92,70,1,0)
	anim:SetHotSpot(46,35)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverChicken',anim,714,585,103,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Layers/LayerOverCoinNecklace.png',0,0,54,56,1,0)
	anim:SetHotSpot(27,28)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverCoinNecklace',anim,303,21,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Layers/LayerOverEmerald.png',0,0,53,60,1,0)
	anim:SetHotSpot(26,30)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverEmerald',anim,204,295,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Layers/LayerOverJug.png',0,0,55,39,1,0)
	anim:SetHotSpot(27,19)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverJug',anim,327,345,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Layers/LayerOverLens.png',0,0,16,18,1,0)
	anim:SetHotSpot(8,9)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverLens',anim,765,317,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Layers/LayerOverMechFlowerAnim.png',0,0,64,30,1,0)
	anim:SetHotSpot(32,15)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverMechFlowerAnim',anim,522,244,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Layers/LayerOverShield.png',0,0,108,48,1,0)
	anim:SetHotSpot(54,24)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverShield',anim,788,72,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Layers/LayerOverTomehowk.png',0,0,89,73,1,0)
	anim:SetHotSpot(44,36)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverTomehowk',anim,146,94,105,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Layers/LayerOverVase.png',0,0,60,136,1,0)
	anim:SetHotSpot(30,68)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverVase',anim,987,569,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Layers/LayerOverWoodenDoor.png',0,0,64,148,1,0)
	anim:SetHotSpot(32,74)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('LayerOverWoodenDoor',anim,940,547,102,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Layers/light.png',0,0,311,757,1,0)
	anim:SetHotSpot(155,378)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('light',anim,551,431,99,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Layers/mechanicFlowerAnim.png',0,0,128,70,16,12)
	anim:SetHotSpot(64,35)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('mechanicFlowerAnim',anim,518,216,102,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Layers/woodenDoor.png',0,0,55,131,1,0)
	anim:SetHotSpot(27,65)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('woodenDoor',anim,942,426,101,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Layers/woodenShield.png',0,0,80,150,1,0)
	anim:SetHotSpot(40,75)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('woodenShield',anim,444,442,103,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('actZoneMinigame',anim,301,431,104,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('actZoneLens',anim,776,282,104,0,0.6,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('actZoneSkullKey',anim,881,431,104,0,0.7,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('actZoneBackpack',anim,716,632,106,0,0.7,0.9)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Hatchet.png',0,0,64,120,1,0)
	anim:SetHotSpot(32,60)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Hatchet',anim,948,428,100,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Key.png',0,0,80,43,1,0)
	anim:SetHotSpot(40,21)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Key',anim,314,675,104,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Ruby.png',0,0,90,90,1,0)
	anim:SetHotSpot(45,45)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Ruby',anim,518,226,101,0,0.6,0.6)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/SkullKey.png',0,0,46,89,1,0)
	anim:SetHotSpot(23,44)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('SkullKey',anim,444,439,102,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Lens_onPlace.png',0,0,34,40,1,0)
	anim:SetHotSpot(17,20)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Lens_onPlace',anim,769,303,103,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/SkullKey_onPlace.png',0,0,42,64,1,0)
	anim:SetHotSpot(21,32)
	anim:SetBlendMode(2)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('SkullKey_onPlace',anim,868,457,103,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Layers/LaserRay.png',0,0,512,64,1,0)
	anim:SetHotSpot(20,20)
	anim:SetBlendMode(0)
	anim:SetColor('0xFF4066FF')
	play_field:CreateObject('LaserRay1',anim,299,390,104,-12,1.15,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Layers/LaserRay.png',0,0,512,64,1,0)
	anim:SetHotSpot(20,20)
	anim:SetBlendMode(0)
	anim:SetColor('0xFF4066FF')
	play_field:CreateObject('LaserRay2',anim,763,312,104,-160,0.54,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('0xFF0066FF')
	play_field:CreateObject('LaserGlow0',anim,296,393,104,0,1.6,1.6)
	local anim = CreateAnimation('data/Texture/Scenes/Common/radialGlow.png',0,0,97,99,1,0)
	anim:SetHotSpot(48,48)
	anim:SetBlendMode(0)
	anim:SetColor('0xFF0066FF')
	play_field:CreateObject('LaserGlow1',anim,827,287,104,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('0xFF0066FF')
	play_field:CreateObject('LaserGlow2',anim,764,293,104,0,1.6,1.6)
	local anim = CreateAnimation('data/Texture/Scenes/Common/radialGlow.png',0,0,97,99,1,0)
	anim:SetHotSpot(48,48)
	anim:SetBlendMode(0)
	anim:SetColor('0xFF0066FF')
	play_field:CreateObject('LaserGlow3',anim,520,213,104,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('actZoneRubyRoot',anim,519,215,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('actZoneBox',anim,223,507,104,0,1,0.7)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Zones/Box/Layers/background.jpg',0,0,640,480,1,0)
	anim:SetHotSpot(320,240)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	play_field:CreateObject('ZoomBoxBackground',anim,493,400,200,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Bag.png',0,0,139,176,1,0)
	anim:SetHotSpot(69,88)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	play_field:CreateObject('Bag',anim,458,519,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('actZoneChest',anim,872,526,104,5,1.6,0.7)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Zones/Chest/Layers/background.jpg',0,0,640,480,1,0)
	anim:SetHotSpot(320,240)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	play_field:CreateObject('ZoomChestBackground',anim,587,348,200,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Lens.png',0,0,66,82,1,0)
	anim:SetHotSpot(33,41)
	anim:SetBlendMode(2)
	anim:SetColor('0x00FFFFFF')
	play_field:CreateObject('Lens',anim,645,331,204,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Bag_ghost.png',0,0,100,100,1,0)
	anim:SetHotSpot(50,50)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Bag_ghost',anim,289,411,110,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Hatchet_ghost.png',0,0,90,140,1,0)
	anim:SetHotSpot(45,45)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Hatchet_ghost',anim,229,486,110,50,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Key_ghost.png',0,0,90,90,1,0)
	anim:SetHotSpot(45,45)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Key_ghost',anim,820,505,110,-140,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Lens_ghost.png',0,0,42,56,1,0)
	anim:SetHotSpot(21,28)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Lens_ghost',anim,768,303,110,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/Ruby_ghost.png',0,0,90,90,1,0)
	anim:SetHotSpot(45,45)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('Ruby_ghost',anim,715,631,110,0,1,1)
	local anim = CreateAnimation('data/Texture/Scenes/13_TribeLeaderHut/Items/SkullKey_ghost.png',0,0,64,72,1,0)
	anim:SetHotSpot(32,36)
	anim:SetBlendMode(0)
	anim:SetColor('0xFFFFFFFF')
	play_field:CreateObject('SkullKey_ghost',anim,869,456,110,0,1,1)
end

function FreeData()
end
-- CLEAR_ON_SAVE_END
