inst
reps 10
	new: simp 2 3 5818 "fanplant" 1 0 rand 600 1200
	attr 195
	bhvr 48
	elas 10
	accg 1
	aero 3
	perm 99
	fric 90
	emit 7 0.1
	setv ov72 rand 40 80
	setv ov80 1
	setv ov82 1
	setv ov87 0.0001
	velo rand -20 20 rand -10 10
	tick rand 300 600
	doif tmvt rand 1000 2500 1700 eq 1
		mvto rand 1000 2500 1700

	else
		kill targ
	endi
repe
scrp 2 3 5818 9
	lock
	rnge 100
	setv va66 0
	esee 2 6 5818
		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
		setv va52 posb
		addv va52 2
		doif prop room targ 1 le ov80 and prop room targ 1 ge 0.01
			setv va00 1
		else
			setv va00 0
		endi
		doif prop room targ 4 ge ov87
			setv va01 1
		else
			setv va01 0
		endi
		doif prop room targ 2 le ov82 and prop room targ 2 ge 0.2

			setv va02 1
		else
			setv va02 0
		endi
		doif prop room targ 3 ge 0.05
			setv va03 1
		else
			setv va03 0
		endi
		doif rtyp grap posx va52 eq 1
			setv va04 1
		else
			setv va04 0
		endi
		doif va00 eq 1 and va01 eq 1 and va02 eq 1 and va03 eq 1 and va04 eq 1
			gsub sprout
		endi
	retn
	subr sprout
		setv va00 posl
		setv va01 post
		new: simp 2 6 5818 "fanplant" 11 1 rand 600 1500
		attr 16
		bhvr 0
		setv ov00 0
		setv ov01 0
		setv ov02 8
		subv va00 45
		subv va01 25
		doif tmvt va00 va01 eq 1
			mvto va00 va01
			tick rand 600 800
		else
			kill targ
			kill ownr
		endi
		kill ownr
	retn
	subr dorm
		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 2 6 5818 9
	addv ov01 1
	subv ov02 1
	doif prop room targ 1 ge 0.005 and prop room targ 2 ge 0.2 and prop room targ 3 ge 0.005 and prop room targ 4 ge 0.00001

		addv ov02 10

	endi
	doif ov02 le 0
		setv ov00 99
	endi
	doif ov00 eq 0
		gsub grow
	elif ov00 eq 1
		gsub seed
	elif ov00 eq 99
		gsub die
	endi
	subr grow
		doif ov01 ge 3
			doif pose lt 6
				setv va00 pose
				addv va00 1
				pose va00
				setv ov01 0
			else
				setv ov00 1
			endi
		endi
	retn
	subr seed
		setv va50 posx
		setv va01 post
		subv va01 29
		reps rand 10 15
			new: simp 2 3 5818 "fanplant" 1 0 rand 600 1200
			attr 195
			bhvr 48
			elas 0
			accg 1
			aero 3
			perm 99
			fric 90
			emit 7 0.1
			setv ov72 rand 10 20
			setv ov80 1
			setv ov82 1
			setv ov87 0
			doif tmvt va50 va01 eq 1
				mvto va50 va01
				tick rand 300 600
				velo rand -15 15 rand -10 0
			else
				kill targ
				targ ownr
			endi
		repe
		targ ownr
		setv ov00 99
	retn
	subr die
		doif pose lt 10
			setv va00 pose
			addv va00 1
			pose va00
		else
			doif room targ ne -1 and carr eq null
				altr room targ 3 0.1
				altr room targ 4 0.2
				kill ownr
			else
				kill ownr
			endi
		endi
	retn
endm
scrp 2 3 5818 12
	stim writ from 77 0.5
	kill ownr
endm
rscr
enum 2 3 5818
	kill targ
next
enum 2 6 5818
	kill targ
next
scrx 2 3 5818 9
scrx 2 3 5818 12
scrx 7 3 5818 9