
inst
reps 30

	new: simp 2 3 10 "fungi" 7 110 rand 300 1800

	attr 195
	bhvr 48
	elas 0
	fric 100
	anim [0 1 2 3 255]
	perm rand 30 70
	mvto 1500 1700
	velo rand -10 10 rand -10 0
	tick rand 300 600



	setv ov72 rand 10 40

	setv ov80 1

	setv ov82 1

	setv ov87 0

repe


scrp 2 3 10 4
	anim []
endm

scrp 2 3 10 5
	anim [0 1 2 3 255]
endm

scrp 2 3 10 6
	doif wall eq down
		anim []
	endi
endm

scrp 2 3 10 12
	stim writ from 77 1
	kill ownr
endm


scrp 2 3 10 9
	lock
	rnge 100
	setv va66 0
	esee 1 1 5817
		addv va66 1
	next
	targ ownr
	doif va66 ge 1
		doif room targ ne -1 and carr eq null
			altr room targ 3 0.005
			altr room targ 4 0.01
			kill ownr
		else

			kill ownr
		endi
	endi
	unlk


	doif fall eq 0 and carr eq null
		doif rtyp room targ eq 8 or rtyp room targ eq 9
			kill ownr
		endi

		gsub envi

		gsub dorm
	endi


	subr envi
		doif prop room targ 1 le ov80
			setv va00 1
		else
			setv va00 0
		endi

		doif prop room targ 2 le ov82 and prop room targ 2 ge 0.1
			setv va01 1
		else
			setv va01 0
		endi
		doif prop room targ 3 ge 0.1
			setv va02 1
		else
			setv va02 0
		endi
		rnge 125
		esee 2 4 0
			addv va05 1
		next
		targ ownr
		esee 2 5 0
			doif spcs ne 1
				addv va05 1
			endi
		next
		targ ownr
		esee 2 6 0
			addv va05 1
		next
		targ ownr
		doif va05 ge 1
			setv va03 1
		endi


		doif va00 eq 1 and va01 eq 1 and va02 eq 1 and va03 eq 1
			gsub sprout
		endi
	retn


	subr sprout
		setv va90 perm
		setv va00 posl
		setv va01 post
		subv va00 76
		subv va01 12
		new: simp 1 1 5817 "fungi" 1 117 rand 400 1700
		attr 192
		bhvr 0
		perm va90
		accg 2
		fric 100
		elas 0
		aero 0
		setv ov00 0
		setv ov01 0
		setv ov02 5
		setv ov99 0
		doif tmvt va00 va01 ne 1
			kill targ
			kill ownr
		else
			mvto va00 va01
			tick rand 300 450
		endi
		kill ownr
	retn


	subr dorm
		doif pose lt 4

			attr 16
			anim [4 5 6]
			over
		endi

		subv ov72 1

		doif ov72 le 0
			doif room targ ne -1
				altr room targ 3 0.005
				altr room targ 4 0.01
				kill ownr
			else
				kill ownr
			endi
		endi
	retn
endm
scrp 1 1 5817 9
	addv ov01 1
	subv ov02 1
	doif ov02 le 0
		setv ov00 99
	endi
	doif ov00 eq 0
		gsub grow
	endi
	doif ov00 eq 99
		gsub die
	endi
	subr grow
		etch 2 4 0
			doif targ ne null
				doif ov02 ge 1
					doif ov02 ge mv02
						subv ov02 5
						addv mv02 5
					elif ov02 lt mv02
						addv ov02 3
						subv mv02 3
					endi
				endi
			endi
		next
		targ ownr
		etch 2 5 0
			doif targ ne null
				doif ov02 ge 1
					doif ov02 ge mv02
						subv ov02 5
						addv mv02 5
					elif ov02 lt mv02
						addv ov02 1
						subv mv02 1
					endi
				endi
			endi
		next
		targ ownr
		etch 2 6 0
			doif targ ne null
				doif ov02 ge 1
					doif ov02 ge mv02
						subv ov02 5
						addv mv02 5
					elif ov02 lt mv02
						addv ov02 2
						subv mv02 2
					endi
				endi
			endi
		next
		targ ownr
		altr room targ 4 0.005
		doif ov01 ge 15
			gsub fruit
			setv ov01 0
		endi
	retn
	subr fruit
		doif ov99 lt 3
			setv va90 perm
			setv va00 posl
			setv va01 post
			setv va02 posr
			subv va00 16
			subv va01 14
			subv va02 16
			reps rand 3 5

				setv va03 rand va00 va02
				setv va99 rand 0 4
				mulv va99 22
				new: simp 2 8 5 "fungi" 22 va99 rand 400 1700
				attr 195
				bhvr 48
				elas 0
				fric 100
				perm va90
				accg 2
				setv ov00 0
				setv ov01 0
				seta ov16 ownr
				doif tmvt va03 va01 eq 1
					mvto va03 va01
				elif tmvt va03 va01 ne 1
					kill targ
					targ ownr
				endi
				tick rand 600 900
			repe
			targ ownr
			addv ov99 1
		else
			setv ov00 99
		endi
	retn
	subr die
		doif room targ ne -1
			altr room targ 3 0.05
			altr room targ 4 0.1
			kill ownr
		else
			kill ownr
		endi
	retn
endm

scrp 2 8 5 9







	addv ov01 1
	doif ov00 eq 0
		doif ov16 ne null
			targ ov16
			doif ov00 eq 99
				targ ownr
				setv ov00 2
			endi
		else
			setv ov00 2
		endi
	endi
	targ ownr
	doif ov00 eq 0
		doif pose lt 3
			setv va00 pose
			addv va00 1
			pose va00
		else

			doif ov01 ge 20
				setv ov00 1
				stop
			endi
		endi
	endi


	doif ov00 eq 1
		doif pose lt 7
			setv va00 pose
			addv va00 1
			pose va00
		else

			inst
			setv va00 posl
			setv va01 post
			reps rand 2 4
				new: simp 2 3 10 "fungi" 7 110 rand 300 1800

				attr 195
				bhvr 48
				elas 0
				fric 100
				anim [0 1 2 3 255]
				perm rand 40 70
				doif tmvt va00 va01 <> 1
					kill targ
					targ ownr
					setv ov00 2
					stop
				endi
				mvto va00 va01
				velo rand -10 10 rand -10 0
				tick rand 300 600


				setv ov72 rand 10 40

				setv ov80 1

				setv ov82 1

				setv ov87 0
			repe
			targ ownr
			setv ov00 2
		endi
	endi


	doif ov00 eq 2
		doif pose lt 11
			setv va00 pose
			addv va00 1
			pose va00
		else
			altr room targ 3 0.1
			altr room targ 4 0.15
			kill ownr
		endi
	endi



	doif ov00 eq 3

		doif carr eq null and fall eq 0
			doif ov99 eq -1
				doif pose lt 21
					setv va00 pose
					addv va00 1
					pose va00
				else
					altr room targ 3 0.1
					altr room targ 4 0.15
					kill ownr
				endi
			endi
		endi
	elif ov99 eq 1
		doif pose lt 16
			setv va00 pose
			addv va00 1
			pose va00
		else
			altr room targ 3 0.1
			altr room targ 4 0.15
			kill ownr
		endi
	endi
endm


scrp 2 8 5 4



	setv ov00 3
	doif ov99 eq 0
		setv ov99 rand 0 1
		doif ov99 eq 0
			setv ov99 -1
		endi
	endi

	doif ov99 eq -1
		doif pose lt 17
			pose 17
		endi
	endi
	doif ov99 eq 1
		doif pose lt 12
			pose 12
		endi
	endi
endm


scrp 2 8 5 12
	inst

	setv va00 posl
	setv va01 post
	stim writ from 78 1
	reps rand 2 4
		new: simp 2 3 10 "fungi" 7 110 rand 300 1800

		attr 195
		bhvr 48
		elas 0
		fric 100
		anim [0 1 2 3 255]
		perm rand 30 70
		setv ov72 rand 10 40

		setv ov80 1

		setv ov82 1

		setv ov87 0
		doif tmvt va00 va01 eq 1
			mvto va00 va01




		else
			mvsf va00 va01
		endi
		velo rand -10 10 rand -10 0
		tick rand 300 600
	repe
	kill ownr
endm



rscr
enum 2 3 10
	kill targ
next
enum 2 8 5
	kill targ
next
enum 1 1 5817
	kill targ
next
scrx 2 3 10 4
scrx 2 3 10 5
scrx 2 3 10 6
scrx 2 3 10 9
scrx 2 3 10 12
scrx 1 1 5817 9
scrx 2 8 5 4
scrx 2 8 5 9
scrx 2 8 5 12