if not GLOBAL.TUNING.LOLGLOBALINIT then
	GLOBAL.TUNING.LOLGLOBALINIT = true
local simn = 0.02
GLOBAL.require("map/tasks")
GLOBAL.require("map/terrain")
GLOBAL.require("constants")
GLOBAL.require("map/rooms/riven_rooms")
modimport 'scripts/tile_riven.lua'
local heherog=true local funrog = function ( ... ) print(GLOBAL.CAPY_DLC) end xTryCatchGetErrorInforog=function() heherog=false end xTryCatchrog=function(funrog) local ret,errMessage=GLOBAL.xpcall(funrog,xTryCatchGetErrorInforog) end xTryCatchrog(funrog) if not heherog then GLOBAL.CAPY_DLC=0 end 
local hehesw=true local funsw = function ( ... ) print(GLOBAL.REIGN_OF_GIANTS) end xTryCatchGetErrorInfosw=function() hehesw=false end xTryCatchsw=function(funsw) local ret,errMessage=GLOBAL.xpcall(funsw,xTryCatchGetErrorInfosw) end xTryCatchsw(funsw) if not hehesw then GLOBAL.REIGN_OF_GIANTS=0 end 

function ranm(task)
	if math.random()<0.5 then
		task.room_choices["RivenSpawn"] = 1
	else
		task.room_choices["RivenSpawn2"] = 1
	end
end

AddTaskPreInit("Battlefield", ranm)
AddTaskPreInit("Beeeees!", ranm)
AddTaskPreInit("Befriend the pigs", ranm)
AddTaskPreInit("Chessworld", ranm)
AddTaskPreInit("Dig that rock", ranm)
AddTaskPreInit("Easy Blocked Dig that rock", ranm)
AddTaskPreInit("For a nice walk", ranm)
AddTaskPreInit("Forest hunters", ranm)
AddTaskPreInit("Frogs and bugs", ranm)
AddTaskPreInit("Great Plains", ranm)
AddTaskPreInit("Greater Plains", ranm)
AddTaskPreInit("Guarded For a nice walk", ranm)
AddTaskPreInit("Guarded Forest hunters", ranm)
AddTaskPreInit("Guarded Squeltch", ranm)
AddTaskPreInit("Guarded Walrus Desolate", ranm)
AddTaskPreInit("Hounded Greater Plains", ranm)
AddTaskPreInit("Hounded Magic meadow", ranm)
AddTaskPreInit("HoundFields", ranm)
AddTaskPreInit("Insanity-Blocked Necronomicon", ranm)
AddTaskPreInit("Kill the spiders", ranm)
AddTaskPreInit("Killer Bees!", ranm)
AddTaskPreInit("Land of Plenty", ranm)
AddTaskPreInit("Lots-o-Chessmonsters", ranm)
AddTaskPreInit("Lots-o-Spiders", ranm)
AddTaskPreInit("Lots-o-Tallbirds", ranm)
AddTaskPreInit("Lots-o-Tentacles", ranm)
AddTaskPreInit("Magic meadow", ranm)
AddTaskPreInit("Make A Beehat", ranm)
AddTaskPreInit("Make a pick", ranm)
AddTaskPreInit("Merms ahoy", ranm)
AddTaskPreInit("Mine Forest", ranm)
AddTaskPreInit("Necronomicon", ranm)
AddTaskPreInit("Pigs in the city", ranm)
AddTaskPreInit("Pretty Rocks Burnt", ranm)
AddTaskPreInit("Resource-rich Tier2", ranm)
AddTaskPreInit("Resource-Rich", ranm)
AddTaskPreInit("Rock-Blocked HoundFields", ranm)
AddTaskPreInit("Sane-Blocked Swamp", ranm)
AddTaskPreInit("Sanity-Blocked Great Plains", ranm)
AddTaskPreInit("Spider swamp", ranm)
AddTaskPreInit("Squeltch", ranm)
AddTaskPreInit("Swamp start", ranm)
AddTaskPreInit("Tentacle-Blocked Spider Swamp", ranm)
AddTaskPreInit("Tentacle-Blocked The Deep Forest", ranm)
AddTaskPreInit("TEST_TASK", ranm)
AddTaskPreInit("TEST_TASK1", ranm)
AddTaskPreInit("The charcoal forest", ranm)
AddTaskPreInit("The Deep Forest", ranm)
AddTaskPreInit("The hunters", ranm)
AddTaskPreInit("The other side", ranm)
AddTaskPreInit("The Pigs are back in town", ranm)
AddTaskPreInit("Trapped Befriend the pigs", ranm)
AddTaskPreInit("Trapped Forest hunters", ranm)
AddTaskPreInit("Walled Kill the spiders", ranm)
AddTaskPreInit("Walrus Desolate", ranm)
AddTaskPreInit("Wasps and Frogs and bugs", ranm)
AddTaskPreInit("Waspy Beeeees!", ranm)
AddTaskPreInit("Waspy The hunters", ranm)

if GLOBAL.IsDLCEnabled(GLOBAL.CAPY_DLC) then
	local function create (name)
		if GLOBAL.terrain.rooms[name]
		and GLOBAL.terrain.rooms[name].contents
		and GLOBAL.terrain.rooms[name].contents.distributeprefabs
		 then
		 	local tot = GLOBAL.terrain.rooms[name].contents.distributeprefabs
		 	local total = 0 
		 	for key, value in pairs(tot) do 
		 		if type(value)=='number' then
		 			total = total + value  
		 		end
		 	end  
	 	   	if total>1 then
	 		  	if math.random()>0.5 then
	 		  		GLOBAL.terrain.rooms[name].contents.distributeprefabs.riventent1 = total*0.01*math.random()
	 		  	else
	 		  		GLOBAL.terrain.rooms[name].contents.distributeprefabs.riventent2 = total*0.01*math.random()
	 		  	end
	 	  	end
		end
	end
			create("BareMangrove")
			create("BeachClear")
			create("BeachCrabTown")
			create("BeachDunes")
			create("BeachFlowers")
			create("BeachGrassy")
			create("BeachGravel")
			create("BeachLimpety")
			create("BeachNoCrabbits")
			create("BeachNoFlowers")
			create("BeachNoLimpets")
			create("BeachPalmCasino")
			create("BeachPalmForest")
			create("BeachPiggy")
			create("BeachRocky")
			create("BeachSand")
			create("BeachSandHome")
			create("BeachSappy")
			create("BeachShells")
			create("BeachSinglePalmTreeHome")
			create("BeachSkull")
			create("BeachSpider")
			create("BeachUnkept")
			create("BeachUnkeptDubloon")
			create("BeachWaspy")
			create("BeesBeach")
			create("BG_Magma")
			create("BG_Mangrove")
			create("BGGrassIsland")
			create("ChessArea")
			create("ChessBarrens")
			create("ChessForest")
			create("ChessMarsh")
			create("DoydoyBeach")
			create("Forest1")
			create("Forest2")
			create("Forest4")
			create("ForestSpiders")
			create("GenericMagmaNoThreat")
			create("Graveyard")
			create("Jungle")
			create("JungleBamboozled")
			create("JungleBees")
			create("JungleClearing")
			create("JungleCritterCrunch")
			create("JungleDense")
			create("JungleDenseBerries")
			create("JungleDenseCritterCrunch")
			create("JungleDenseHome")
			create("JungleDenseMed")
			create("JungleDenseMedHome")
			create("JungleDenseVery")
			create("JungleEvilFlowers")
			create("JungleEyeplant")
			create("JungleFlower")
			create("JungleFrogSanctuary")
			create("JungleGrassy")
			create("JungleMonkeyHell")
			create("JungleMorePalms")
			create("JungleNoBerry")
			create("JungleNoFlowers")
			create("JungleNoMushroom")
			create("JungleNoRock")
			create("JungleParrotSanctuary")
			create("JunglePigGuards")
			create("JunglePigs")
			create("JungleRockyDrop")
			create("JungleSappy")
			create("JungleShroomin")
			create("JungleSkeleton")
			create("JungleSparse")
			create("JungleSparseHome")
			create("JungleSpiderCity")
			create("JungleSpidersDense")
			create("Magma")
			create("MagmaForest")
			create("MagmaGold")
			create("MagmaGoldBoon")
			create("MagmaHome")
			create("MagmaHomeBoon")
			create("MagmaSpiders")
			create("MagmaTallBird")
			create("MagmaVolcano")
			create("Mangrove")
			create("MangroveOxBoon")
			create("MangroveWetlands")
			create("MarbleForest")
			create("MeadowBees")
			create("MeadowCarroty")
			create("MeadowFlowery")
			create("MeadowMandrake")
			create("MeadowOxBoon")
			create("MeadowRocky")
			create("MeadowSappy")
			create("MeadowSpider")
			create("NoOxMangrove")
			create("NoOxMeadow")
			create("OceanCoral")
			create("OceanDeep")
			create("OceanMedium")
			create("OceanMediumSeaweedBed")
			create("OceanMediumShoal")
			create("OceanShallow")
			create("OceanShallowReef")
			create("OceanShallowSeaweedBed")
			create("PirateGraveyard")
			create("RockyBlueMushroom")
			create("RockyFlint")
			create("RockyGold")
			create("RockyGoldBoon")
			create("RockyIsland")
			create("RockySpiders")
			create("RockyTallBird")
			create("SampleRoom")
			create("SW_Graveyard")
			create("TidalMarsh")
			create("TidalMermMarsh")
			create("ToxicTidalMarsh")
			create("Volcano")
			create("VolcanoAltar")
			create("VolcanoAsh")
			create("VolcanoCage")
			create("VolcanoLava")
			create("VolcanoNoise")
			create("VolcanoObsidian")
			create("VolcanoObsidianBench")
			create("VolcanoRock")
			create("VolcanoStart")
			create("WaterAll")
			create("WaterCoral")
			create("WaterDeep")
			create("WaterMangrove")
			create("WaterMedium")
			create("WaterShallow")
			create("WaterShipGraveyard")
	end
	end