**Create leaf manager.
new: simp 1 1 2 "blnk" 1 0 0
tick rand 20 200

**Leaf manager tick script.
scrp 1 1 2 9
	tick rand 20 200
	new: simp 2 6 1 "treehouse" 3 0 0
	attr 16
	frat 4
	tick rand 800 1600
	setv ov00 1
	mvto rand 2571 3430 rand 300 829
	anim [0 1 255]
endm

**Leaf script.
**ov00: Whether it's a cluster or an edible leaf.
scrp 2 6 1 9
	doif ov00 eq 1
		inst
		setv va00 posl
		setv va01 post
		loop
			new: simp 2 6 1 "treehouse" 3 3 rand 500 1000
			bhvr 48
			perm rand 30 70
			attr 194
			elas 0
			**Emit green smell.
			emit 10 0.01
			tick rand 1200 2400
			anim [0 1 255]
			velo rand -10 10 0
			addv va02 1
			mvsf va00 va01
		untl va02 ge rand 2 5
	endi
	kill ownr
endm

**Leaf being eaten.
scrp 2 6 1 12
	doif from ne null
		stim writ from 77 1
	endi
	snde "chwp"
	kill targ
endm

**Leaf hitting ground.
scrp 2 6 1 6
	doif ov00 eq 0
		anim [2]
	endi
endm

**Leaf being picked up.
scrp 2 6 1 4
	anim [0]
endm


**Leaf being dropped.
scrp 2 6 1 5
	anim [0 1 255]
endm

rscr
enum 1 1 2
	kill targ
next

enum 2 6 1
	kill targ
next

scrx 1 1 2 9