inst
reps 9
	new: simp 2 3 5819 "junglefern" 1 0 rand 200 2100
	attr 195
	bhvr 48
	elas 5
	fric 100
	perm rand 20 80
	accg 0.5
	aero 3
	setv ov72 rand 40 80
	setv ov80 1
	setv ov82 1
	setv ov87 0.01
	setv va00 rand 1800 2100
	setv va01 2030
	doif tmvt va00 va01 eq 1
		mvto va00 va01
		tick rand 600 800
		emit 7 0.01
	else
		kill targ
	endi
repe
scrp 2 3 5819 9
	lock
	rnge 100
	setv va66 0
	esee 2 5 5819
		addv va66 1
	next
	targ ownr
	doif va66 ge 1
		doif room targ ne -1 and carr eq null
			altr room targ 3 0.001
			altr room targ 4 0.001
			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 lt ov80 and prop room targ 1 gt 0.02
			setv va00 1
		else
			setv va00 0
		endi
		doif prop room targ 2 lt ov82 and prop room targ 2 gt 0.2
			setv va01 1
		else
			setv va01 0
		endi
		doif prop room targ 3 le 1 and prop room targ 3 gt 0.1
			setv va02 1
		else
			setv va02 0
		endi
		doif prop room targ 4 ge ov87
			setv va03 1
		else
			setv va03 0
		endi
		etch 1 1 5817
			doif targ ne null
				subv ov02 1
				setv va04 1
			else
				setv va04 0
			endi
		next
		targ ownr
		doif va00 eq 1 and va01 eq 1 and va02 eq 1 and va03 eq 1 and va04 eq 1
			gsub grow
		endi
	retn
	subr grow
		setv va00 posl
		setv va01 post
		new: simp 2 5 5819 "junglefern" 11 1 rand 300 2000
		attr 192
		bhvr 0
		elas 0
		fric 100
		perm 80
		accg 1
		aero 0
		setv ov00 0
		setv ov01 0
		setv ov02 5
		subv va00 38
		subv va01 58
		doif tmvt va00 va01 eq 1
			mvto va00 va01
		else
			kill targ
			kill ownr
		endi
		tick rand 300 600
		kill ownr
	retn
	subr dorm
		subv ov72 1
		doif ov72 le 0
			doif room targ ne -1
				altr room targ 3 0.001
				altr room targ 4 0.001
				kill ownr
			else
				kill ownr
			endi
		endi
	retn
endm
scrp 2 5 5819 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 20

	endi
	doif ov02 le 0
		setv ov00 99
	endi
	doif ov00 eq 0
		gsub grow
	elif ov00 eq 1
		gsub spore
	elif ov00 eq 99
		gsub die
	endi
	subr grow
		etch 1 1 5817
			doif targ ne null
				addv ov02 6
			endi
		next
		targ ownr
		doif ov01 ge 3
			doif pose lt 5
				setv va00 pose
				addv va00 1
				pose va00
				subv ov02 4
				setv ov01 0
			elif pose eq 5
				setv ov00 1
			endi
		endi
	retn
	subr spore
		setv va00 posl
		setv va01 post
		addv va01 22
		reps rand 10 20
			new: simp 2 3 5819 "junglefern" 1 0 rand 200 1500
			attr 195
			bhvr 48
			elas 5
			fric 100
			perm rand 20 80
			accg 0.5
			aero 3
			setv ov72 rand 40 80
			setv ov80 1
			setv ov82 1
			setv ov87 0.01
			addv va00 rand -4 4
			addv va01 rand -3 3
			doif tmvt va00 va01 eq 1
				mvto va00 va01
				velo rand -20 20 -10
				tick rand 600 800
				emit 7 0.01
			else
				kill targ
				targ ownr
				setv ov00 99
			endi
		repe
		targ ownr
		setv ov00 99
	retn
	subr die
		doif ov01 ge 3
			doif pose lt 10
				setv va00 pose
				addv va00 1
				pose va00
				setv ov01 0
			elif pose eq 10
				doif room targ ne -1 and carr eq null
					altr room targ 3 0.15
					altr room targ 4 0.15
					kill ownr


				else
					kill ownr
				endi
			endi
		endi
	retn
endm
scrp 2 3 5819 12
	stim writ from 77 0.1
	kill ownr
endm
rscr
enum 2 3 5819
	kill targ
next
enum 2 5 5819
	kill targ
next
scrx 2 3 5819 9
scrx 2 3 5819 12
scrx 2 5 5819 9