
locations-start

	location
		tags: sewer-easy
		max-rooms: 6
		entry-tags: sewer-entry

		0 value sewerstate
		0 value sewerdir

		: randew rnd5050 if e else w then ;
		: randns rnd5050 if n else s then ;
		
		: setup-sewer
			locseed 3 % 19 loc-ftheme!
			locseed 9 % 14 loc-wtheme!
			door-sewer
			0 to sewerstate
			randew to sewerdir
			// 1 allow-double-doors!
		;

		: yad 1 auto-doors! ; 
		: nad 0 auto-doors! ; 
		: ndx 0 %auto-door-escape ;

		: sewerhall
			rooms-left . "rooms left" print
			
			rooms-left 2 < if then;
			sewerdir dup edge-inc random-edge-door
			"sewer-hall" with-door
		;

		: startsewerhall
			sewerdir dup edge-inc random-edge-door
			"sewer-hall" with-door
		;

		: sewerloot
			rooms-left 2 > if then;
			rooms-left 2 < if then;			
			1 allow-inset-doors!
			randns dup edge-inc random-inset-door
//			random-door
			"treasure" only-with-door
			0 allow-inset-doors!
		;

		: trysewerend
			rooms-left 1 > if then;
			 sewerdir dup edge-inc random-door 
			"sewer-end" with-door
		;
		
		script: setup-sewer
		post-script: 10diff %zombs map{ wetfloor } nad ndx

		room-choice: sewer-entry
			room-weight: 1
			room-count: 1
			room-post-script: startsewerhall

		room-choice: treasure
			room-weight: 1
			room-count: 1
			filter-only

		room-choice: sewer-hall
			room-weight: 1
			room-count: 3
			room-post-script: trysewerend sewerhall sewerloot
			filter-only

		room-choice: sewer-end
			room-weight: 1
			room-count: 1
			filter-only

// Deadlier Sewer
			
	location
		tags: sewer-hard
		max-rooms: 10
		entry-tags: sewer-entry

		0 value sewerstate
		0 value sewerdir

		script: setup-sewer
		post-script: 10diff %zombs map{ wetfloor } nad ndx

		room-choice: sewer-entry
			room-weight: 1
			room-count: 1
			room-post-script: startsewerhall

		room-choice: treasure
			room-weight: 1
			room-count: 1
			filter-only

		room-choice: sewer-hall
			room-weight: 1
			room-count: 7
			room-post-script: trysewerend sewerhall sewerloot
			filter-only

		room-choice: sewer-end
			room-weight: 1
			room-count: 1
			filter-only
			
	location
		tags: factory
		max-rooms: 9
//		max-rooms: 4
		entry-tags: indust-room
		
		: randnes 40 %chance if e else rnd5050 if n else s then then ;
		: randne rnd5050 if n else e then ;
		
		: factory-theme

			floor-industrial
			wall-industrial
			door-industrial
			0 4 rnd to theme-num

		;
		
		: indust-rnd rnd5050 if "indust-hall" else "indust-room" then ;
		
		: nad 0 auto-doors! ; 
		: ndx 0 %auto-door-escape ;
		
		: factoryhall
			rooms-left . "rooms left" print
			rooms-left 2 < if then;
			randnes dup edge-inc random-edge-door
			indust-rnd with-door
		;

		: startfactoryhall
			randne dup edge-inc random-edge-door
			indust-rnd with-door
		;

		: factorylloot
			35 %chance if wrench scatter then
			20 %chance if metal scatter then
			10 %chance if crowbar scatter then
			2 %chance if blowtorch scatter then
		;
		
		: factoryloot
			factorylloot
			rooms-left 4 > if then;
			rooms-left 2 < if then;
			1 allow-inset-doors!
//			s edge-inc s random-inset-door
			random-door
			"treasure" only-with-door
			0 allow-inset-doors!
		;

		: tryfactoryend
			rooms-left 1 > if then;
			random-door "indust-end" with-door
		;
		
		script: factory-theme 
		post-script: 10diff %zombs map{ room-papers 25 %chance if swreckage then 15 %chance if room-garbage then } nad ndx

		room-choice: indust-room
			room-weight: 1
			room-count: 6
			room-post-script: factoryhall tryfactoryend factoryloot
			filter-only

		room-choice: treasure
			room-weight: 1
			room-count: 1
			filter-only

		room-choice: indust-end
			room-weight: 1
			room-count: 1
			filter-only

		room-choice: indust-hall
			room-weight: 1
			room-count: 6
			room-post-script: tryfactoryend factoryhall factoryloot
			filter-only
			
locations-end

