--[[
locations:
1_BEACH
2_SHPRK
3_LIVNG
4_RUINS
5_BCAVE
6_WTRFL
7_INVEN
8_SCLAB
9_DOCKS
10_TEMPX
11_PLANE
12_TEMPI
13_MPATH
14_UNLAB
15_OFFIC
16_CONDO

modes:
"T" Typical ISpy
"P" Pairs
"G" Group

"F" Finished already in this stage
"D"	Disabled (returned when prerequisites have not yet been met)
"N" Not in stage
--]]



stages = {
	-- Stage 1
	{
		{ location = "1_BEACH", round=1, mode="T" }
	},
	
	-- Stage 2
	{
		{ location = "1_BEACH", round=2, mode="G" },
		{ location = "9_DOCKS", round=1, mode="T" }
	},
	
	-- Stage 3
	{
		{ location = "13_MPATH", round=1, mode="T" },
		{ location = "5_BCAVE", round=1, mode="T" },
		{ location = "9_DOCKS", round=2, mode="G" }
	},

	-- Stage 4
	{
		{ location = "1_BEACH", round=3, mode="P" },
		{ location = "2_SHPRK", round=1, mode="G" },
		{ location = "7_INVEN", round=1, mode="T" }
	},
	
	--Stage 5 (Office Flashback)
	{
		{ location = "15_OFFIC", round=1, mode="T" }
	},
	
	--Stage 6
	{
		{ location = "8_SCLAB", round=1, mode="T" },
		{ location = "5_BCAVE", round=2, mode="P" },
		{ location = "13_MPATH", round=2, mode="G" },
		{ location = "2_SHPRK", round=2, mode="T" }
	},
	
	--Stage 7 (Univ. Lab Flashback)
	{
		{ location = "14_UNLAB", round=1, mode="T" }
	},
	
	--Stage 8
	{
		{ location = "3_LIVNG", round=1, mode="G" },
		{ location = "9_DOCKS", round=3, mode="P" },
		{ location = "7_INVEN", round=2, mode="G" },
		{ location = "6_WTRFL", round=1, mode="T" }
	},
	
	--Stage 9
	{
		{ location = "4_RUINS", round=1, mode="T" },
		{ location = "2_SHPRK", round=3, mode="P" },
		{ location = "13_MPATH", round=3, mode="P" },
		{ location = "8_SCLAB", round=2, mode="G" }
	},
	
	--Stage 10 (Condo Flashback)
	{
		{ location = "16_CONDO", round=1, mode="T" }
	},
	
	--Stage 11
	{
		{ location = "10_TEMPX", round=1, mode="T" },
		{ location = "9_DOCKS", round=4, mode="T" },
		{ location = "6_WTRFL", round=2, mode="G" },
		{ location = "3_LIVNG", round=2, mode="P" }
	},
	
	--Stage 12
	{
		{ location = "11_PLANE", round=1, mode="T" },
		{ location = "4_RUINS", round=2, mode="G" },
		{ location = "7_INVEN", round=3, mode="P" },
		{ location = "8_SCLAB", round=3, mode="P" }
	},
	
	--Stage 13 (Office Flashback)
	{
		{ location = "15_OFFIC", round=2, mode="G" }
	},
	
	--Stage 14
	{
		{ location = "12_TEMPI", round=1, mode="P" },
		{ location = "10_TEMPX", round=2, mode="G" },
		{ location = "6_WTRFL", round=3, mode="P" }
	},
	
	--Stage 15 (Univ. Lab Flashback)
	{
		{ location = "14_UNLAB", round=2, mode="G" }
	},
	
	--Stage 16
	{
		{ location = "10_TEMPX", round=3, mode="P" },
		{ location = "11_PLANE", round=2, mode="P" },
		{ location = "3_LIVNG", round=3, mode="T" },
		{ location = "12_TEMPI", round=2, mode="G" }
	},
	
	--Stage 17
	{
		{ location = "11_PLANE", round=3, mode="G" },
		{ location = "12_TEMPI", round=3, mode="T" },
		{ location = "4_RUINS", round=3, mode="P" },
		{ location = "5_BCAVE", round=3, mode="G" }
	},
}


--[[
Action Items
	earnable: Indicates if Action Item is earnable by finding all I-spy items (as oppsed to findable in the scene)
	requires: a list of Target UIDs which must be triggered before collecting this Action Item
		prompt: ID of string resource to display if Target has not been triggered yet (optional)
		targetTriggered: UID of Target that needs to be triggered before collecting object, also used to display specific text when player clicks on target or silhouette
	Target: This Action Item acts on this thing
	location: where the action item is hidden
	round: number of times player has scene background
	autoGiveActionItem: automatically replaces one object in UI with new object
	storyrevealitem: name of story reveal item when target is triggered,
	builtItem: Needs an action item and does not show item in UI.
	EXAMPLE:  ai["27book"]= { location = "2_SHPRK", round = 1, target = "65postyenote", requires = {{targetTriggered = "12eel", prompt = "STRING_NEED_EEL"},{} } }
	EXAMPLE: target["9drillbit1"] = { location = "7_INVEN",  round = 1, storyrevealitem = "99sortyprintout", stroyrevealID = 1 }
--]]

ai = {}
target = {}



--Stage 1
ai["91actioncrowbar"] = { location = "1_BEACH", round = 1, target = { "14targetburiedcrate" }, uiPos = 1 }
ai["1shovel"] = { location = "1_BEACH", round = 1, target = { "92targetburiedcrate" }, earnable = true, uiPos = 2}
target["92targetburiedcrate"] = { location = "1_BEACH", round = 1, wrongAI = { { AI = "91actioncrowbar", prompt = "TEXT_MID_CROW_CRATE" } } }
target["14targetburiedcrate"] = { location = "1_BEACH", round = 1, requires = { { targetTriggered = "92targetburiedcrate" } }, storyrevealitem = "10journal", storyrevealID = 1 }


--Stage 2
ai["90actionicepick"] = { location = "1_BEACH", round = 2, target = { "75briefcaseclosed" }, uiPos = 1 }
ai["66hook"] = { location = "9_DOCKS", round = 1, target = { "67rope" }, uiPos = 2 }
ai["69ropewithhook"] = { location = "9_DOCKS", round = 1, target = { "7backpack" }, builtItem = true, uiPos = 2 }
ai["22actionelectricaltape"] = { location = "1_BEACH", round = 2, target = { "72exposedwires" } , uiPos = 3, requires = { targetTriggered = "7backpack" } }
ai["65banana"] = { location = "9_DOCKS", round = 1, target = { "5monkey" }, uiPos = 4 }
ai["6passcode"] = { location = "9_DOCKS", round = 1, target = { "129targetcpubriefcaseopen" }, earnable = true, uiPos = 5 }
ai["16actionsolarpanel"] = { location = "1_BEACH", round = 2, target = { "73solarpanel" }, earnable = true, uiPos = 6 }
target["5monkey"] = { location = "1_BEACH", round = 2 }
target["67rope"] = { location = "9_DOCKS", round = 1, autoGiveActionItem = "69ropewithhook" }
target["72exposedwires"] = { location = "9_DOCKS", round = 1, requires = { { targetTriggered = "73solarpanel" } } }
target["75briefcaseclosed"] = { location = "9_DOCKS", round = 1, wrongAI = { { AI = "6passcode", prompt = "TEXT_MID_WRONG_CODE" } } }
target["73solarpanel"] = { location = "9_DOCKS", round = 1 }
target["129targetcpubriefcaseopen"] = { location = "9_DOCKS", round = 1, storyrevealitem = "89boatspecsandlocation", storyrevealID = 2, 
	requires = {{ targetTriggered = "73solarpanel", prompt = "TEXT_MID_NEED_POWER" }, {targetTriggered = "75briefcaseclosed"}, {targetTriggered = "72exposedwires", prompt = "TEXT_MID_NEED_POWER" } } }
target["7backpack"] = { location = "1_BEACH", round = 2, storyrevealitem = "3pictureandname", storyrevealID = 3, wrongAI = { { AI = "66hook", prompt = "TEXT_MID_HOOK_ON_BACKPACK" } }, requires = { { targetTriggered = "5monkey", prompt = "TEXT_MID_HOOK_ON_BACKPACK_7backpack" } } }


--Stage 3
ai["107gearshift"] = { location = "9_DOCKS", round = 2, target = { "8throttle" }, uiPos = 1 }
ai["45antenna"] = { location = "9_DOCKS", round = 2, target = { "58gpswithoutanantenna" }, uiPos = 2 }
ai["15screwdriver"] = { location = "13_MPATH", round = 1, target = { "63ammobox" }, earnable = true, uiPos = 3 }
ai["7gpscoordinates"] = { location = "9_DOCKS", round = 2, target = { "57gpswithoutcoordinates" }, earnable = true, uiPos = 4 }
ai["5key"] = { location = "5_BCAVE", round = 1, target = { "62boatdashboard" }, earnable = true, uiPos = 5 }
target["63ammobox"] = { location = "13_MPATH", round = 1, wrongAI =  { { AI = "5key", prompt = "TEXT_MID_KEYS_ON_AMMOBOX" } } }
target["58gpswithoutanantenna"] = { location = "13_MPATH", round = 1, requires = { { targetTriggered = "63ammobox" } }, wrongAI = { { AI = "7gpscoordinates", prompt = "TEXT_MID_GPS_WITHOUT_ANTENNA" } } }
target["8throttle"] =  { location = "5_BCAVE", round = 1 }
target["62boatdashboard"] =  { location = "5_BCAVE", round = 1 }
target["57gpswithoutcoordinates"] = { location = "13_MPATH", round = 1, requires = { { targetTriggered = "58gpswithoutanantenna" } }, storyrevealitem = "56gpsmap", storyrevealID = 4 }
target["114targetstartbutton"] = { location = "5_BCAVE", round = 1, clickOnly = true, storyrevealitem = "107storydrawingofresourceholderandlogo", storyrevealID = 5, 
	requires = { { targetTriggered = "8throttle", prompt = "TEXT_MID_THROTTLE" } , { targetTriggered = "62boatdashboard", prompt = "TEXT_MID_KEYS" } } }


--Stage 4
ai["117actiondecodedsafecode"] = { location = "7_INVEN", round = 1, target = { "99stickynote1" }, builtItem = true, uiPos = 1 }
ai["79book1"] = { location = "2_SHPRK", round = 1, target = { "102book1" }, uiPos = 1, requires = { targetTriggered = "76eel1", prompt = "TEXT_MID_CLICKTARGET_76eel1" } }
ai["12knife"] = { location = "2_SHPRK", round = 1, target = { "17targetlobstertrap" }, uiPos = 2 }
ai["96emblem1"] = { location = "7_INVEN", round = 1, target = { "97emblem1" }, earnable = true, uiPos = 3 } --97emblem1 is the picture frame
ai["111actiondrillwithbit"] = { location = "7_INVEN", round = 1, target = { "105drill" }, builtItem = true, uiPos = 4 } --105drill is the file cabinet
ai["3drillbit"] = { location = "2_SHPRK", round = 1, target = { "9drillbit1" }, earnable = true, uiPos = 4 } --9drillbit1 is the drill
ai["20actioncamerawithflash"] = { location = "1_BEACH", round = 3, target = { "76eel1" }, builtItem = true, uiPos = 5 }
ai["18actionflash"] = { location = "1_BEACH", round = 3, target = { "19targetcamera" }, earnable = true, uiPos = 5 }
target["17targetlobstertrap"] = { location = "1_BEACH", round = 3, wrongAI = { {  AI = "18actionflash", prompt = "TEXT_MID_FLASH_ON_POT" } } }
target["97emblem1"] = { location = "7_INVEN", round = 1 }
target["9drillbit1"] = { location = "7_INVEN", round = 1, autoGiveActionItem = "111actiondrillwithbit" }
target["19targetcamera"] = { location = "1_BEACH", round = 3, autoGiveActionItem = "20actioncamerawithflash", requires = { { targetTriggered = "17targetlobstertrap" } } }
target["102book1"] = { location = "7_INVEN", round = 1, autoGiveActionItem = "117actiondecodedsafecode", requires = { { targetTriggered = "105drill" } } }
target["76eel1"] = { location = "2_SHPRK", round = 1, storyrevealitem = "80grandopening", storyrevealID = 6, wrongAI = {{ AI = "12knife", prompt = "TEXT_MID_KNIFE_ON_EEL" }, { AI = "18actionflash", prompt = "TEXT_MID_FLASH_ON_EEL"}} }
target["105drill"] = { location = "7_INVEN", round = 1, storyrevealitem = "116storyenergyrubbing", storyrevealID = 7, wrongAI = { { AI = "12knife", prompt = "TEXT_MID_KNIFE_ON_FILECABINET" } } }
target["99stickynote1"] = { location = "7_INVEN", round = 1, storyrevealitem = "104files", storyrevealID = 8, requires = { { targetTriggered = "97emblem1" } }, wrongAI = { { AI = "111actiondrillwithbit", prompt = "TEXT_MID_DRILL_ON_SAFE" }, { AI = "3drillbit", prompt = "TEXT_MID_DRILLBIT_ON_SAFE" }, { AI = "79book1", prompt = "TEXT_MID_BOOK_ON_SAFE" } } }


--Stage 5 (Office Flashback)
ai["102actionscissors"] = { location = "15_OFFIC", round = 1, target = { "89paperream" }, uiPos = 1 }
ai["97actionblankpieceofpaper"] = { location = "15_OFFIC", round = 1, target = { "98targetprinter" }, builtItem = true, uiPos = 1 }
ai["95actionscrewdriver"] = { location = "15_OFFIC", round = 1, target = { "92targetmailbox" }, uiPos = 2, requires = { targetTriggered = "87targetdrawer" } }
ai["101storykeys"] = { location = "15_OFFIC", round = 1, target = { "87targetdrawer" }, earnable = true, uiPos = 3 }
target["87targetdrawer"] = { location = "15_OFFIC", round = 1 }
target["89paperream"] = { location = "15_OFFIC", round = 1, autoGiveActionItem = "97actionblankpieceofpaper" }
target["92targetmailbox"] = { location = "15_OFFIC", round = 1, storyrevealitem = "103storyinvitation", storyrevealID = 9, wrongAI = { { AI = "101storykeys", prompt = "TEXT_MID_KEYS_ON_MAILBOX" } } }
target["98targetprinter"] = { location = "15_OFFIC", round = 1, storyrevealitem = "99storyprintout", storyrevealID = 10, wrongAI = { { AI = "95actionscrewdriver", prompt = "TEXT_MID_SCREWDRIVER_ON_PRINTER" } } }


--Stage 6 (5)
ai["9fishnet"] = { location = "2_SHPRK", round = 2, target = { "85film" }, uiPos = 1 }
ai["106actionfilm"] = { location = "5_BCAVE", round = 2, target = { "39developertraywithdeveloper" }, builtItem = true, uiPos = 1 }
ai["37partiallydevelopedfilm"] = { location = "8_SCLAB", round = 1, target = { "66h2obeaker" }, builtItem = true, uiPos = 1 }
ai["42developer"] = { location = "8_SCLAB", round = 1, target = { "40developertray" }, uiPos = 2 }
ai["63gloves"] = { location = "8_SCLAB", round = 1, target = { "51canistervalveclosed", "50canistervalveopen1" }, uiPos = 3 }
ai["52audiotape"] = { location = "2_SHPRK", round = 2, target = { "32boomboxeject" }, builtItem = true, uiPos = 4 }
ai["14pencil"] = { location = "13_MPATH", round = 2, target = { "54unwoundtape", "53tapeafterpencil1" }, earnable = true, uiPos = 4 }
ai["6pole"] = { location = "5_BCAVE", round = 2, target = { "66stone" }, earnable = true, uiPos = 5 }
ai["1pressurereleasevalve"] = { location = "8_SCLAB", round = 1, target = { "52canisternovalve" }, earnable = true, uiPos = 6 }
ai["2ejectbutton"] = { location = "2_SHPRK", round = 2, target = { "31boombox" }, earnable = true, uiPos = 7 }
target["54unwoundtape"] = { location = "2_SHPRK", round = 2,  wrongAI = { { AI = "6pole", prompt = "TEXT_MID_POLE_ON_TAPE" } } }
target["53tapeafterpencil1"] = { location = "2_SHPRK", round = 2, autoGiveActionItem = "52audiotape", requires = { { targetTriggered = "54unwoundtape" } } }
target["85film"] = { location = "5_BCAVE", round = 2, autoGiveActionItem = "106actionfilm" }
target["31boombox"] = { location = "5_BCAVE", round = 2, wrongAI = { { AI = "52audiotape", prompt = "TEXT_MID_TAPE_ON_BOOMBOX" } } }
target["40developertray"] = { location = "8_SCLAB", round = 1 }
target["39developertraywithdeveloper"] = { location = "8_SCLAB", round = 1, autoGiveActionItem = "37partiallydevelopedfilm", requires = { { targetTriggered = "49lightswitchoff", prompt = "TEXT_MID_NEED_RED_LIGHT" } } }
target["52canisternovalve"] = { location = "8_SCLAB", round = 1 }
target["51canistervalveclosed"] = { location = "8_SCLAB", round = 1, requires = { { targetTriggered = "52canisternovalve" } } }
target["49lightswitchoff"] = { location = "8_SCLAB", clickOnly = true, round = 1, requires = { { targetTriggered = "85film", prompt = "TEXT_MID_REDLIGHT_ON" } } }
target["66h2obeaker"] = { location = "8_SCLAB", round = 1, storyrevealitem = "47disasteratwaterfall", storyrevealID = 11 }
target["32boomboxeject"] = { location = "5_BCAVE", round = 2, requires = { { targetTriggered = "31boombox" } }, storyrevealitem = "127storyboombox", storyrevealID = 12 }
target["50canistervalveopen1"] = { location = "8_SCLAB", round = 1, storyrevealitem = "56resourcefragments", storyrevealID = 13, requires = { { targetTriggered = "51canistervalveclosed" } } }
target["66stone"] = { location = "13_MPATH", round = 2, storyrevealitem = "67letter", storyrevealID = 14 }


--Stage 7 (Univ. Lab Flashback)
ai["28pencil"] = { location = "14_UNLAB", round = 1, target = { "38tracingpaper" }, uiPos = 1 }
ai["26brush"] = { location = "14_UNLAB", round = 1, target = { "42spray", "40brush1" }, uiPos = 2 }
ai["36emptyspraybottle"] = { location = "14_UNLAB", round = 1, target = { "95faucet" }, uiPos = 3 }
ai["37fullspraybottle"] = { location = "14_UNLAB", round = 1, target = { "44chisel3" }, builtItem = true, uiPos = 3 }
ai["65chisel"] = { location = "14_UNLAB", round = 1, target = { "50artifact1", "48chisel1", "46chisel2" }, uiPos = 4 }
ai["134actionsponge"] = { location = "14_UNLAB", round = 1, target = { "133targetwipe" }, uiPos = 5 }
ai["25tracingpaper"] = { location = "14_UNLAB", round = 1, target = { "39brush2" }, earnable = true, uiPos = 6 }
target["95faucet"] = { location = "14_UNLAB", round = 1, autoGiveActionItem = "37fullspraybottle" }
target["50artifact1"] = { location = "14_UNLAB", round = 1, wrongAI = { { AI = "36emptyspraybottle", prompt = "TEXT_MID_EMPTYSPRAYBOTTLE" } } }
target["48chisel1"] = { location = "14_UNLAB", round = 1, wrongAI = { { AI = "36emptyspraybottle", prompt = "TEXT_MID_EMPTYSPRAYBOTTLE" } } }
target["46chisel2"] = { location = "14_UNLAB", round = 1, wrongAI = { { AI = "36emptyspraybottle", prompt = "TEXT_MID_EMPTYSPRAYBOTTLE" } }, requires = { { targetTriggered = "50artifact1" }, { targetTriggered = "48chisel1" } } }
target["44chisel3"] = { location = "14_UNLAB", round = 1, requires = { { targetTriggered = "40brush1" } }, wrongAI = { { AI = "36emptyspraybottle", prompt = "TEXT_MID_EMPTYSPRAYBOTTLE" }, { AI = "25tracingpaper", prompt = "TEXT_MID_PAPER_ON_DIRTY_TABLET" } } }
target["42spray"] = { location = "14_UNLAB", round = 1, requires = { { targetTriggered = "46chisel2" } }, wrongAI = { { AI = "36emptyspraybottle", prompt = "TEXT_MID_EMPTYSPRAYBOTTLE" }, { AI = "25tracingpaper", prompt = "TEXT_MID_PAPER_ON_DIRTY_TABLET" } } }
target["40brush1"] = { location = "14_UNLAB", round = 1, requires = { { targetTriggered = "42spray" } }, wrongAI = { { AI = "36emptyspraybottle", prompt = "TEXT_MID_EMPTYSPRAYBOTTLE" }, { AI = "25tracingpaper", prompt = "TEXT_MID_PAPER_ON_DIRTY_TABLET" } } }
target["133targetwipe"]  = { location = "14_UNLAB", requires = { { targetTriggered = "44chisel3" } }, wrongAI = { { AI = "25tracingpaper", prompt = "TEXT_MID_PAPER_ON_DIRTY_TABLET" } }, round = 1 }
target["39brush2"] = { location = "14_UNLAB", requires = { { targetTriggered = "133targetwipe" } }, round = 1 }
target["38tracingpaper"] = { location = "14_UNLAB", round = 1, requires = { { targetTriggered = "39brush2" } }, storyrevealitem = "126storyenergytabletandtracing", storyrevealID = 15 }


--Stage 8 (6)
ai["87actionbarcodereader"] = { location = "3_LIVNG", round = 1, target = { "8poweredcomputer" }, uiPos = 1, requires = { targetTriggered = "21padlockclosed" } }
ai["19keys"] = { location = "3_LIVNG", round = 1, target = { "21padlockclosed" }, uiPos = 2, requires = { targetTriggered = "18flagmarker" } }
ai["66crank"] = { location = "6_WTRFL", round = 1, target = { "76well" }, uiPos = 3 }
ai["50rope"] = { location = "6_WTRFL", round = 1, target = { "75well2" }, uiPos = 4 }
ai["72barcode"] = { location = "6_WTRFL", round = 1, target = { "10barcodereader" }, uiPos = 5, requires = { targetTriggered = "74well3" } }
ai["83powercord"] = { location = "9_DOCKS", round = 3, target = { "9computer" }, uiPos = 6, requires = { targetTriggered = "78nailandboard", prompt = "TEXT_MID_POWERCORD" } }
ai["4metaldetector"] = { location = "9_DOCKS", round = 3, target = { "85targetsand" }, earnable = true, uiPos = 7 }
ai["0magnet"] = { location = "7_INVEN", round = 2, target = { "78nailandboard" }, earnable = true, uiPos = 8 }
ai["54bucket"] = { location = "6_WTRFL", round = 1, target = { "74well3" }, earnable = true, uiPos = 9 }
ai["0shovel"] = { location = "3_LIVNG", round = 1, target = { "18flagmarker" }, earnable = true, uiPos = 10 }
target["78nailandboard"] = { location = "9_DOCKS", round = 3 }
target["9computer"] = { location = "7_INVEN", round = 2, wrongAI = { { AI = "72barcode", prompt = "TEXT_MID_BARCODE" } } }
target["8poweredcomputer"] = { location = "7_INVEN", round = 2, requires = { { targetTriggered = "9computer" } }, wrongAI = { { AI = "72barcode", prompt = "TEXT_MID_BARCODE_ON_COMPUTER" } } }
target["76well"] = { location = "6_WTRFL", round = 1 }
target["75well2"] = { location = "6_WTRFL", round = 1, requires = { { targetTriggered = "76well" } } }
target["18flagmarker"] = { location = "3_LIVNG", round = 1, requires = { { targetTriggered = "85targetsand" } } }
target["85targetsand"] = { location = "3_LIVNG", round = 1, wrongAI = { { AI = "0shovel", prompt = "TEXT_MID_SHOVEL_ON_SAND" } } }
target["21padlockclosed"] = { location = "3_LIVNG", round = 1, storyrevealitem = "88storyidcards", storyrevealID = 16 }
target["74well3"] = { location = "6_WTRFL", round = 1, requires = { { targetTriggered = "75well2" } }, storyrevealitem = "0fragmentofcanister", storyrevealID = 17 }
target["10barcodereader"] = { location = "7_INVEN", round = 2, storyrevealitem = "6email", storyrevealID = 18, requires = { { targetTriggered = "8poweredcomputer" } } }


--Stage 9 (7)
ai["0resourcestand"] = { location = "2_SHPRK", round = 3, target = { "67baseopen" }, uiPos = 1 }
ai["27batteryacid"] = { location = "2_SHPRK", round = 3, target = { "83groundvines", "85groundvines1" }, uiPos = 2, requires = { targetTriggered = "29boxclosed" } }
ai["35clearresource"] = { location = "8_SCLAB", round = 2, target = { "64resourcestand" }, uiPos = 3, requires = { targetTriggered = "89centrifugeopen" } }
ai["87wirebrush"] = { location = "13_MPATH", round = 3, target = { "66corrodedtablet", "64corrodedtablet1" }, uiPos = 4, requires = { targetTriggered = "85groundvines1" } }
ai["16vial"] = { location = "13_MPATH", round = 3, target = { "89centrifugeopen" }, earnable = true, uiPos = 5 }
ai["2lockpick"] = { location = "8_SCLAB", round = 2, target = { "29boxclosed" }, earnable = true, uiPos = 6 }
ai["3statuehead"] = { location = "4_RUINS", round = 1, target = { "70statuebody" }, earnable = true, uiPos = 7 }
ai["1statuebody"] = { location = "2_SHPRK", round = 3, target = { "71baseclosed" }, earnable = true, uiPos = 8 }
target["71baseclosed"] = { location = "4_RUINS", round = 1, wrongAI = { { AI = "3statuehead", prompt = "TEXT_MID_STONEHEAD" } } }
target["70statuebody"] = { location = "4_RUINS", requires = { { targetTriggered = "71baseclosed" } }, round = 1 }
target["67baseopen"] = { location = "4_RUINS", requires = { { targetTriggered = "70statuebody" } }, round = 1 }
target["29boxclosed"] = { location = "2_SHPRK", round = 3 }
target["83groundvines"] = { location = "13_MPATH", round = 3, wrongAI = { { AI = "16vial", prompt = "TEXT_MID_TESTTUBE_ON_VINES" } } }
target["85groundvines1"] = { location = "13_MPATH", round = 3, requires = { { targetTriggered = "83groundvines" } } }
target["66corrodedtablet"] = { location = "2_SHPRK", round = 3, wrongAI = { { AI = "16vial", prompt = "TEXT_MID_TESTTUBE_ON_VINES" } } }
target["64corrodedtablet1"] = { location = "2_SHPRK", round = 3, storyrevealitem = "63lighttablet", storyrevealID = 19, requires = { { targetTriggered = "66corrodedtablet" } }, wrongAI = { { AI = "16vial", prompt = "TEXT_MID_TESTTUBE_ON_VINES" } } }
target["64resourcestand"] = { location = "4_RUINS", round = 1, requires = { { targetTriggered = "67baseopen" } }, storyrevealitem = "61yellowresourceforlight", storyrevealID = 20 }
target["89centrifugeopen"] = { location = "8_SCLAB", round = 2, storyrevealitem = "25photoofstonecarvings", storyrevealID = 21 }


--Stage 10 (Condo Flashback)
ai["9businesscard"] = { location = "16_CONDO", round = 1, target = { "4landline" }, uiPos = 1, requires = { targetTriggered = "40thermostat", prompt = "TEXT_MID_BUSINESS_CARD" } }
ai["39fireextinguisher"] = { location = "16_CONDO", round = 1, target = { "40thermostat" }, earnable = true, uiPos = 2 }
target["40thermostat"] = { location = "16_CONDO", round = 1 }
target["4landline"] = { location = "16_CONDO", round = 1 }
target["1cellphone"] = { location = "16_CONDO", round = 1, storyrevealitem = "56cellphone", clickOnly = true, storyrevealID = 22 }


--Stage 11 (8)
ai["86lighter"] = { location = "6_WTRFL", round = 2, target = { "30firewoodsoaked" }, uiPos = 1 }
ai["47fullwaterjug"] = { location = "6_WTRFL", round = 2, target = { "25dogwaterbowlfull" }, builtItem = true, uiPos = 2 }
ai["79emptybucket"] = { location = "9_DOCKS", round = 4, target = { "111targetwellwater" }, uiPos = 2 }
ai["108oillamp"] = { location = "9_DOCKS", round = 4, target = { "29firewood" }, uiPos = 3 }
ai["88weatherforecast"] = { location = "9_DOCKS", round = 4, target = { "67fullislandweatherposter" }, uiPos = 4, requires = { targetTriggered = "85lockbox" } } 
ai["117hammer"] = { location = "10_TEMPX", round = 1, target = { "82bentkey" }, uiPos = 5, requires = { targetTriggered = "80statueheadpiece1" } }
ai["94actionhotkey"] = { location = "3_LIVNG", round = 2, target = { "83anvil" }, requires = { targetTriggered = "31firewoodlighted" }, builtItem = true, uiPos = 6 }
ai["79straightkey"] = { location = "6_WTRFL", round = 2, target = { "85lockbox" }, builtItem = true, uiPos = 6 }
ai["5"] = { location = "9_DOCKS", round = 4, target = { "31firewoodlighted" }, earnable = true, uiPos = 6 } --5 is the bent key
ai["88firewood"] = { location = "10_TEMPX", round = 1, target = { "32bbq" }, earnable = true, uiPos = 7 }
ai["48statueheadpiece"] = { location = "6_WTRFL", round = 2, target = { "80statueheadpiece1" }, earnable = true, uiPos = 8 }
ai["90actionhalfweatherposter"] = { location = "3_LIVNG", round = 2, target = { "65halfislandweatherposter" }, earnable = true, uiPos = 9 }
target["80statueheadpiece1"] = { location = "10_TEMPX", round = 1 }
target["65halfislandweatherposter"] = { location = "10_TEMPX", round = 1 }
target["83anvil"] = { location = "6_WTRFL", round = 2, wrongAI = { { AI = "5", prompt = "TEXT_MID_BENTKEY_ON_ANVIL" } } }
target["82bentkey"] = { location = "6_WTRFL", round = 2, requires = { { targetTriggered = "83anvil" } }, autoGiveActionItem = "79straightkey" }
target["111targetwellwater"] = { location = "6_WTRFL", round = 2, autoGiveActionItem = "47fullwaterjug" }
target["32bbq"] = { location = "3_LIVNG", round = 2 }
target["29firewood"] = { location = "3_LIVNG", round = 2, requires = { { targetTriggered = "32bbq" } }, wrongAI = { { AI = "86lighter", prompt = "TEXT_MID_LIGHER_ON_WOOD" } } }
target["30firewoodsoaked"] = { location = "3_LIVNG", round = 2, requires = { { targetTriggered = "29firewood" } } }
target["31firewoodlighted"] = { location = "3_LIVNG", round = 2, requires = { { targetTriggered = "30firewoodsoaked" } }, autoGiveActionItem = "94actionhotkey" }
target["25dogwaterbowlfull"] = { location = "3_LIVNG", round = 2, storyrevealitem = "89storycookschedule", storyrevealID = 23 }
target["85lockbox"] = { location = "9_DOCKS", round = 4, storyrevealitem = "112fooddropoffschedule", storyrevealID = 24, wrongAI = { { AI = "5", prompt = "TEXT_MID_KEY_ON_BOX" }, { AI = "117hammer", prompt = "TEXT_MID_HAMMER_ON_BOX" } } }
target["67fullislandweatherposter"] = { location = "10_TEMPX", round = 1, storyrevealitem = "127storytwoforecasts", storyrevealID = 25 }


--Stage 12 (9)
ai["16serialcable"] = { location = "7_INVEN", round = 3, target = { "7computerch9" }, uiPos = 1, requires = { targetTriggered = "13closetdoor1", prompt = "TEXT_MID_SERIAL_CABLE" } }
ai["33blackbox"] = { location = "11_PLANE", round = 1, target = { "5serialcable" }, uiPos = 2, requires = { targetTriggered = "31smallhole3" } }
ai["34vialwithchemicalformula"] = { location = "11_PLANE", round = 1, target = { "107researchbinder" }, uiPos = 3 }
ai["35vialdropperwserialnumbertag"] = { location = "11_PLANE", round = 1, target = { "83checkoutlog" }, uiPos = 4 }
ai["28axe"] = { location = "11_PLANE", round = 1, target = { "12closetdoor", "13closetdoor1" }, earnable = true, uiPos = 5 }
ai["3tincutters"] = { location = "8_SCLAB", round = 3, target = { "29smallhole1", "30smallhole2", "31smallhole3" }, earnable = true, uiPos = 6 }
ai["1wire"] = { location = "7_INVEN", round = 3, target = { "113brokenwires" }, earnable = true, uiPos = 7 }
ai["4clockhands"] = { location = "4_RUINS", round = 2, target = { "110clockwithouthands" }, earnable = true, uiPos = 8 }
target["29smallhole1"] = { location = "11_PLANE", round = 1, wrongAI = { { AI = "28axe", prompt = "TEXT_MID_AXE_ON_PLANE" } } }
target["30smallhole2"] = { location = "11_PLANE", round = 1, requires = { { targetTriggered = "29smallhole1" } } }
target["31smallhole3"] = { location = "11_PLANE", round = 1, requires = { { targetTriggered = "30smallhole2" } } }
target["113brokenwires"] = { location = "8_SCLAB", round = 3 }
target["110clockwithouthands"] = { location = "8_SCLAB", round = 3 }
target["12closetdoor"] = { location = "7_INVEN", round = 3 }
target["13closetdoor1"] = { location = "7_INVEN", round = 3, requires = { { targetTriggered = "12closetdoor" } } }
target["7computerch9"] = { location = "7_INVEN", round = 3 }
target["5serialcable"] = { location = "7_INVEN", round = 3, requires = { { targetTriggered = "7computerch9" } }, storyrevealitem = "122flightrecorder", storyrevealID = 26 }
target["107researchbinder"] = { location = "8_SCLAB", round = 3, storyrevealitem = "106vialchemistry", requires = { { targetTriggered = "110clockwithouthands" }, { targetTriggered = "113brokenwires" } }, storyrevealID = 27 }
target["83checkoutlog"] = { location = "8_SCLAB", round = 3, storyrevealitem = "82vialcheckoutinfo", storyrevealID = 28 }


--Stage 13 (University Office)
ai["120sodabottle"] = { location = "15_OFFIC", round = 2, target = { "124targetrecyclebin" }, uiPos = 1, requires = { targetTriggered = "111targetchairmissingonewheel", prompt = "TEXT_MID_CHAIR_BLOCK_SODA" } }
ai["49glasses"] = { location = "15_OFFIC", round = 2, target = { "123targetnewspaper" }, uiPos = 2 }
ai["106actionbatteries"] = { location = "15_OFFIC", round = 2, target = { "108targetbatterycharger" }, uiPos = 3 }
ai["107actionchargedbatteries"] = { location = "15_OFFIC", round = 2, target = { "116mousetarget" }, builtItem = true, uiPos = 3 }
ai["126actionchairwheel"] = { location = "15_OFFIC", round = 2, target = { "111targetchairmissingonewheel" }, earnable = true, uiPos = 4 }
target["111targetchairmissingonewheel"] = { location = "15_OFFIC", round = 2 }
target["124targetrecyclebin"] = { location = "15_OFFIC", round = 2, requires = { { targetTriggered = "111targetchairmissingonewheel" } } }
target["108targetbatterycharger"] = { location = "15_OFFIC", round = 2, autoGiveActionItem = "107actionchargedbatteries" }
target["123targetnewspaper"] = { location = "15_OFFIC", round = 2, requires = { { targetTriggered = "124targetrecyclebin" } }, storyrevealitem = "125storynewspaper", storyrevealID = 29 }
target["116mousetarget"] = { location = "15_OFFIC", round = 2, storyrevealitem = "119Emailfromdean", storyrevealID = 30, wrongAI = { { AI = "106actionbatteries", prompt = "TEXT_MID_BATTERIES_ON_MOUSE" } } }


--Stage 14 (10)
ai["68walkietalkie"] = { location = "6_WTRFL", round = 3, target = { "44hamradiowiresstripped" }, uiPos = 1 }
ai["112actionleakypipe"] = { location = "6_WTRFL", round = 3, target = { "30rightwaterport" }, uiPos = 2 }
ai["52ducttape"] = { location = "6_WTRFL", round = 3, target = { "27leakypipe" }, uiPos = 3 }
ai["68stonelever"] = { location = "10_TEMPX", round = 2, target = { "5pillarswitch" }, uiPos = 4 }
ai["72leverswitch"] = { location = "10_TEMPX", round = 2, target = { "101statue2" }, uiPos = 5, requires = { targetTriggered = "79statueheadpiece 2" } }
ai["6brick"] = { location = "12_TEMPI", round = 1, target = { "67potwithsnake" }, uiPos = 6 }
ai["71rightarmofsmallstatue"] = { location = "12_TEMPI", round = 1, target = { "98statue3" }, uiPos = 7, requires = { targetTriggered = "67potwithsnake" } }
ai["94actionstatuedoorpiece"] = { location = "12_TEMPI", round = 1, target = { "79statueheadpiece 2" }, earnable = true, uiPos = 8 }
ai["0machete"] = { location = "10_TEMPX", round = 2, target = { "91foliage1", "90foliage2", "89foliage3" }, earnable = true, uiPos = 9 }
ai["51wirestripper"] = { location = "6_WTRFL", round = 3, target = { "43hamradiowires" }, earnable = true, uiPos = 10 }
target["67potwithsnake"] = { location = "12_TEMPI", round = 1 }
target["5pillarswitch"] = { location = "12_TEMPI", round = 1 }
target["30rightwaterport"] = { location = "12_TEMPI", requires = { { targetTriggered = "5pillarswitch" } }, round = 1 }
target["79statueheadpiece 2"] = { location = "10_TEMPX", round = 2 }
target["43hamradiowires"] = { location = "10_TEMPX", round = 2 }
target["91foliage1"] = { location = "6_WTRFL", round = 3 }
target["90foliage2"] = { location = "6_WTRFL", round = 3 }
target["89foliage3"] = { location = "6_WTRFL", round = 3, requires = { { targetTriggered = "91foliage1" }, { targetTriggered = "90foliage2" } } }
target["98statue3"] = { location = "6_WTRFL", round = 3, requires = { { targetTriggered = "89foliage3" } } }
target["101statue2"] = { location = "6_WTRFL", round = 3, requires = { { targetTriggered = "89foliage3" } } }
target["100button1"] = { location = "6_WTRFL", round = 3, storyrevealitem = "105pillars", storyrevealID = 31, clickOnly = true, requires = { { targetTriggered = "98statue3", prompt = "TEXT_MID_STONE_MISSING_ON_STATUE" }, { targetTriggered = "101statue2", prompt = "TEXT_MID_STONE_MISSING_ON_STATUE" } } }
target["44hamradiowiresstripped"] = { location = "10_TEMPX", round = 2, requires = { { targetTriggered = "43hamradiowires" } }, storyrevealitem = "138walkietalkieaudio", storyrevealID = 32 }
target["27leakypipe"] = { location = "12_TEMPI", round = 1, requires = { { targetTriggered = "30rightwaterport" } }, storyrevealitem = "98storyemptycache", storyrevealID = 33 }


--Stage 15 (University Lab)
ai["18drawerhandle"] = { location = "14_UNLAB", round = 2, target = { "112drawer" }, uiPos = 1 }
ai["108magnifiedglass"] = { location = "14_UNLAB", round = 2, target = { "125targetparchment" }, uiPos = 2, requires = { targetTriggered = "112drawer" } }
ai["19smallbrush"] = { location = "14_UNLAB", round = 2, target = { "34beaker1" }, earnable = true, uiPos = 3 }
target["34beaker1"] = { location = "14_UNLAB", round = 2 }
target["112drawer"] = { location = "14_UNLAB", round = 2 }
target["125targetparchment"] = { location = "14_UNLAB", round = 2, requires = { { targetTriggered = "34beaker1" } }, storyrevealitem = "127storyresourceusedforinvisibility", storyrevealID = 34 }


--Stage 16 (11)
ai["83actioncoathanger"] = { location = "3_LIVNG", round = 3, target = { "89closeddoor" }, uiPos = 1, requires = { targetTriggered = "57doorclosed" } }
ai["84actionhacksawfixed"] = { location = "3_LIVNG", round = 3, target = { "81pontoon1", "82pontoon2", "84pontoon3" }, builtItem = true, uiPos = 6 }
ai["2hacksawblade"] = { location = "12_TEMPI", round = 2, target = { "71hacksaw" }, earnable = true, uiPos = 6 }
ai["51handdrill"] = { location = "11_PLANE", round = 2, target = { "69rainbarrelup" }, uiPos = 2 }
ai["55statuedoorpiece"] = { location = "12_TEMPI", round = 2, target = { "78statueheadpiece3" }, uiPos = 3 }
ai["78suitcase"] = { location = "12_TEMPI", round = 2, target = { "100statuemouth" }, uiPos = 4, requires = { targetTriggered = "76chain", prompt = "TEXT_MID_CHAIN_SUITCASE" } }
ai["123actionsledgehammer"] = { location = "11_PLANE", round = 2, target = { "113rainbarrelhole" }, uiPos = 5 }
ai["25lever"] = { location = "11_PLANE", round = 2, target = { "90dash" }, earnable = true, uiPos = 7 }
ai["1housekey"] = { location = "10_TEMPX", round = 3, target = { "57doorclosed" }, earnable = true, uiPos = 8 }
ai["1liquidnitrogen"] = { location = "3_LIVNG", round = 3, target = { "76chain" }, earnable = true, uiPos = 9 }
target["76chain"] = { location = "12_TEMPI", round = 2, wrongAI = { { AI = "84actionhacksawfixed", prompt = "TEXT_MID_HACKSAW_ON_CHAIN" }, { AI = "1housekey", prompt = "TEXT_MID_KEY_ON_CHAIN" } } }
target["89closeddoor"] = { location = "11_PLANE", round = 2, wrongAI = { { AI = "1housekey", prompt = "TEXT_MID_KEY_PLANEDOOR" }, {AI = "84actionhacksawfixed", prompt = "TEXT_MID_HACKSAW_ON_PLANE" } } }
target["90dash"] = { location = "11_PLANE", requires = { { targetTriggered = "89closeddoor" } }, round = 2 }
target["81pontoon1"] = { location = "11_PLANE", round = 2, requires = { { targetTriggered = "90dash" } }, wrongAI = { { AI = "1liquidnitrogen", prompt = "TEXT_MID_NITROGEN_ON_PLANE" } } }
target["82pontoon2"] = { location = "11_PLANE", round = 2, requires = { { targetTriggered = "81pontoon1" } } }
target["100statuemouth"] = { location = "10_TEMPX", round = 3 }
target["113rainbarrelhole"] = { location = "3_LIVNG", requires = { { targetTriggered = "69rainbarrelup" } }, round = 3 }
target["57doorclosed"] = { location = "3_LIVNG", round = 3 }
target["69rainbarrelup"] = { location = "3_LIVNG", round = 3, wrongAI = { { AI = "123actionsledgehammer", prompt = "TEXT_MID_HAMMER_ON_BARREL" } } }
target["71hacksaw"] = { location = "3_LIVNG", round = 3, autoGiveActionItem = "84actionhacksawfixed", requires = { { targetTriggered = "113rainbarrelhole" } } }
target["78statueheadpiece3"] = { location = "10_TEMPX", round = 3, storyrevealitem = "95documentsfrombetasite", storyrevealID = 35, requires = { { targetTriggered = "100statuemouth", prompt = "TEXT_MID_CASE_BEFORE_STONE" } } }
target["84pontoon3"] = { location = "11_PLANE", round = 2, storyrevealitem = "87rvsnotebook", storyrevealID = 36, requires = { {targetTriggered = "82pontoon2" } } }


--Stage 17 (12)
ai["63yellowresource"] = { location = "4_RUINS", round = 3, target = { "27pyramidtip" }, uiPos = 1 }
ai["130greenresource"] = { location = "4_RUINS", round = 3, builtItem = true, target = { "40openhatch" }, uiPos = 1, requires = { targetTriggered = "11middleofpyramid" } }
ai["54redcrystaleyes"] = { location = "4_RUINS", round = 3, target = { "96targeteyes" }, uiPos = 2 }
ai["66clearresource"] = { location = "11_PLANE", round = 3, target = { "11middleofpyramid" }, uiPos = 3, requires = { targetTriggered = "119targetclosedcrate1" } }
ai["1charcoal"] = { location = "12_TEMPI", round = 3, target = { "24tracingpaper", "14tracingpapercharcoal1" }, earnable = true, uiPos = 4 }
ai["26tracingpaper"] = { location = "11_PLANE", round = 3, target = { "25nativepyramiddrawings" }, earnable = true, uiPos = 5 }
ai["7hammer"] = { location = "5_BCAVE", round = 3, target = { "55closedcrate", "119targetclosedcrate1" }, earnable = true, uiPos = 6 }
ai["2icepick"] = { location = "4_RUINS", round = 3, target = { "53targetmoss" }, earnable = true, uiPos = 7 }
target["53targetmoss"] = { location = "12_TEMPI", round = 3, wrongAI = { { AI = "54redcrystaleyes", prompt = "TEXT_MID_GEMS_ON_MOSSY_EYES" } } }
target["96targeteyes"] = { location = "12_TEMPI", round = 3, requires = { { targetTriggered = "53targetmoss" } } }
target["55closedcrate"] = { location = "11_PLANE", round = 3 }
target["119targetclosedcrate1"] = { location = "11_PLANE", round = 3, requires = { { targetTriggered = "55closedcrate" } } }
target["27pyramidtip"] = { location = "4_RUINS", round = 3 }
target["25nativepyramiddrawings"] = { location = "4_RUINS", requires = { { targetTriggered = "27pyramidtip" } }, round = 3 }
target["24tracingpaper"] = { location = "4_RUINS", requires = { { targetTriggered = "25nativepyramiddrawings" } }, round = 3 }
target["11middleofpyramid"] = { location = "4_RUINS", round = 3, autoGiveActionItem = "130greenresource", requires = { { targetTriggered = "14tracingpapercharcoal1", prompt = "TEXT_MID_RESOURCE_ON_PYRAMID" }, { targetTriggered = "96targeteyes" } } }
target["40openhatch"] = { location = "5_BCAVE", round = 3 }
target["14tracingpapercharcoal1"] = { location = "4_RUINS", requires = { { targetTriggered = "24tracingpaper" } }, round = 3, storyrevealitem = "13finalpartoftablet", storyrevealID = 37 }



function isEnabled(aStage, aLocation)
	local	theStage = stages[aStage]
	local	i, location
	for i, location in ipairs(theStage) do
		if location.location == aLocation then
			if location.requires == nil then
				if isCompleted(aStage, aLocation) then
					return "F"					-- Finished already
				else
					return location.mode		-- no prerequisites, return play mode
				end
			else
				-- Iterate all required ones
				local	j, prereq
				for j, prereq in ipairs(location.requires) do
					if not isCompleted(aStage, prereq) then
						return "D"				-- Disabled
					end
				end
				return location.mode			-- met all prerequisites, return play mode
			end
		end
	end
	return "N"									-- Not in stage
end

function getPlayMode(aStage, aLocation)
	local	theStage = stages[aStage]
	local	i, location
	for i, location in ipairs(theStage) do
		if location.location == aLocation then
			return location.mode				-- return play mode
		end
	end
	return "N"									-- Not in stage
end

function locationInStage(aStage, aLocation)
	local	theStage = stages[aStage]
	local	i, location
	for i, location in ipairs(theStage) do
		if location.location == aLocation then
			return location
		end
	end
	return nil
end

function roundOfLocationInStage(aStage, aLocation)
	local	theRound = locationInStage(aStage, aLocation)
	if theRound ~= nil then
		return theRound.round
	end
	return nil
end

function stageFromLocationAndRound(aRound, aLocation)
	-- go through each stage and get the table with locations in that stage
	for i, stageData in ipairs(stages) do
		if stageData ~= nil then
			-- now go through this table -- do we have the round and location here?
			for j, locData in ipairs(stageData) do
				if locData.location == aLocation and locData.round == aRound then
					return i
				end
			end
		end
	end
	
	return 0
end

function isCompleted(aStage, aLocation)
	local	roundNum = roundOfLocationInStage(aStage, aLocation)
	if roundNum ~= nil then
		local	done = scene:isDone(aLocation, roundNum)		-- query player save game
		return done
	end
	return false
end

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

if ghf.SceneMarooned == nil then
	ghf.SceneMarooned = {superclass = ghf.Dialog}
end

if ghf.SceneGame == nil then
	ghf.SceneGame = {superclass = ghf.SceneMarooned}
end
