
inst
reps 10

	new: simp 2 3 11 "tendril" 10 32 rand 500 1600
	attr 195
	bhvr 16
	elas 30
	fric 100
	anim [0 1 2 3 4 5 255]
	perm rand 30 70
	setv ov72 rand 4 10

	setv ov80 1

	setv ov82 1

	setv ov87 0
	doif tmvt 1800 1700 eq 1
		mvto 1800 1700
		velo rand -15 15 rand -10 0
		tick rand 1200 1800
	else
		kill targ
	endi
repe


reps 10

	new: simp 2 3 11 "tendril" 10 32 rand 500 1600
	attr 195
	bhvr 16
	elas 30
	fric 100
	anim [0 1 2 3 4 5 255]
	perm rand 30 70
	setv ov72 rand 4 10

	setv ov80 1

	setv ov82 1

	setv ov87 0
	doif tmvt 1800 2000 eq 1
		mvto 1800 2000
	else
		kill targ
	endi
	velo rand -5 5 rand -10 0
	tick rand 1200 1800
repe





scrp 2 3 11 4
	anim []
endm

scrp 2 3 11 5
	anim [0 1 2 3 4 5 255]
endm

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

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


scrp 2 3 11 9
	lock
	rnge 50
	setv va66 0
	esee 2 5 4
		addv va66 1
	next
	targ ownr
	doif va66 ge 1
		doif room targ ne -1 and carr eq null
			altr room targ 3 0.01
			altr room targ 4 0.01
			kill ownr
		else
			kill ownr
		endi
	endi
	unlk
	doif rtyp room targ eq 8 or rtyp room targ eq 9
		doif room targ <> -1 and carr = null
			altr room targ 3 0.01
			altr room targ 4 0.01
		endi
		kill ownr
	endi


	doif fall eq 0 and carr eq null

		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 gt 0.2 and prop room targ 2 le ov82
			setv va01 1
		else
			setv va01 0
		endi
		doif prop room targ 3 ge 0.05 and prop room targ 3 le 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 2 4 4
			doif targ ne null
				subv ov02 3
				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
		subv va00 12
		subv va01 37
		setv va90 perm

		setv va99 rand 0 4
		mulv va99 22
		new: simp 2 5 4 "tendril" 32 0 rand 600 1500
		attr 192
		elas 0
		fric 100
		perm va90
		accg 2
		setv ov02 3
		doif tmvt va00 va01 ne 1
			kill targ
			kill ownr
		endi
		mvto va00 va01
		tick rand 600 1200
		kill ownr
	retn


	subr dorm
		doif pose lt 9

			attr 16
			anim [6 7 8 9]
			over
		endi

		subv ov72 1

		doif ov72 le 0
			doif room targ ne -1 and carr = null
				altr room targ 3 0.01
				altr room targ 4 0.01
				kill ownr
			else
				kill ownr
			endi
		endi
	retn
endm



scrp 2 5 4 9







	addv ov01 1
	etch 2 4 4
		doif targ ne null
			subv ov02 3
			addv mv02 3
		endi
	next
	targ ownr
	doif ov00 eq 0

		doif pose lt 8
			setv va00 pose
			addv va00 1
			pose va00
		else


			setv ov00 1
			stop

		endi
	endi


	doif ov00 eq 1
		doif pose lt 13
			setv va00 pose
			addv va00 1
			pose va00
		else
			setv ov00 2
			stop
		endi
	endi


	doif ov00 eq 2
		doif ov02 gt 25
			setv va02 4
		else
			setv va02 1
		endi
		anim [14 15 16 17 18]
		over
		inst
		setv va00 posx
		setv va01 posy
		reps va02
			new: simp 2 3 11 "tendril" 10 32 rand 500 1600
			attr 195
			bhvr 16
			elas 30
			fric 100


			anim [0 1 2 3 4 5 255]
			perm rand 30 70
			doif tmvt va00 va01 <> 1
				kill targ
				targ ownr
				setv ov00 3
				stop
			endi
			mvto va00 va01
			velo rand -10 10 rand -15 0
			tick rand 1200 1800



			setv ov72 rand 4 10

			setv ov80 1

			setv ov82 1

			setv ov87 0
		repe

		targ ownr
		anim [19 20 21 22]
		setv ov00 3
	endi


	doif ov00 eq 3
		doif pose lt 31
			setv va00 pose
			addv va00 1
			pose va00
		else
			doif room targ <> -1 and carr = null
				altr room targ 3 0.15
				altr room targ 4 0.15
			endi
			kill ownr
		endi
	endi

endm






rscr
enum 2 5 4
	kill targ
next
enum 2 3 11
	kill targ
next
scrx 2 3 11 4
scrx 2 3 11 5
scrx 2 3 11 6
scrx 2 3 11 9
scrx 2 3 11 12
scrx 2 5 4 9