**Spawn ten gomato plants in random areas and growth stages.
reps 10
	new: simp 2 4 1 "gomato" 12 8 rand 500 1000
	attr 192
	setv ov00 rand 0 11
	setv ov01 rand 0 10
	setv ov02 rand 0 1
	mira ov02
	pose ov00
	elas 0
	accg 10
	tick rand 600 1200
	mvsf rand 2200 2650 1660
repe

setv va00 0
**On both sides of the bridge.
reps 10
	new: simp 2 4 1 "gomato" 12 8 rand 500 1000
	attr 192
	setv ov00 rand 0 11
	setv ov01 rand 0 10
	setv ov02 rand 0 1
	mira ov02
	pose ov00
	elas 0
	accg 10
	tick rand 600 1200
	mvsf rand 3200 3700 1660
repe

**Plant tick script.
**ov00: Growth stage, from 0 to 11. 0-6 are growth stages, 7-11 are fruit stages.
**ov01: Fruiting cycles until death.
**ov02: Direction.
scrp 2 4 1 9
	tick rand 600 1200
**If it has fruiting cycles left, use growth routine.
	doif ov01 gt 0
**Add 1 to life stage.
		addv ov00 1
**If it's fully grown, drop a fruit, lose a cycle, and revert to stage 6.
		doif ov00 ge 12
			inst
**Calculate position.
			setv va00 posl
			setv va01 post
			doif ov02 eq 0
				addv va00 21
			endi
			addv va01 9
			subv ov01 1
**Spawn the thing.
			new: simp 2 8 1 "gomato" 8 0 rand 500 1000
			velo rand -2 2 0
			emit 6 0.01
			attr 194
			elas 1
			bhvr 48
			perm 60
			tick rand 1200 2400
			mvsf va00 va01
			targ ownr
			setv ov00 6
			pose 6
		else
			pose ov00
		endi
**Else die.
	else
		subv ov00 1
		doif ov00 ge 0
			pose ov00
		else
			kill targ
		endi
	endi
endm

**Fruit scripts.
**ov00: Whether it's half-eaten.
**ov01: Age of fruit.
**Fruit rot script.
scrp 2 8 1 9
	inst
	tick rand 1200 2400
	addv ov01 1
**If it's super old, become detritus.
	doif ov01 ge 2
		setv va00 posl
		setv va01 post
		new: simp 2 10 1 "gomato" 8 0 rand 500 1000
		rnge 50
		pose 2
		attr 194
		elas 0
		bhvr 48
		tick rand 1200 2400
		setv ov01 2
		mvsf va00 va01
		kill ownr
**Else age and pose accordingly.
	else
		setv va00 ov01
		doif ov00 eq 1
			addv va00 4
		endi
		pose va00
	endi
endm

**Fruit eat script.
scrp 2 8 1 12
	snde "chwp"
	doif crea from eq 1
**Give it a fruit eaten stim.
		stim writ from 78 1
**And also a little bit of critter stim because it's a fish tomato. uwu
		stim writ from 80 0.5
	endi
**If it's not half-eaten, become half-eaten. Else be destroyed.
	doif ov00 ne 1
		setv ov00 1
		setv va00 pose
		addv va00 4
		pose va00
	else
		kill targ
	endi
endm

**Detritus scripts.
**ov00: Whether it's half-eaten.
**ov01: Age of fruit.
**Fruit rot script.
scrp 2 10 1 9
	inst
	tick rand 1200 2400
**If it's super old, see if it can grow into a plant.
	doif ov01 eq 3
		setv va00 0
**If the nearby population is reasonable...
		esee 2 4 1
			doif ov01 gt 0
				addv va00 1
			endi
		next
		doif va00 le 1
**And the nutrient, heat, light, and body of water CA levels are appropriate...
**God, that's a long line.
			doif prop room targ 4 ge 0.2 and prop room targ 2 le 0.3 and prop room targ 2 ge 0.1 and prop room targ 1 le 0.2 and prop room targ 5 ge 0.01
**It's safe to grow. Do that.
				setv va00 posl
				setv va01 post
				new: simp 2 4 1 "gomato" 12 8 rand 500 1000
				setv ov02 rand 0 1
				mira ov02
				setv ov01 rand 5 10
				attr 192
				elas 0
				accg 10
				tick rand 600 1200
				mvsf va00 va01
			endi
		endi
**Either way, it's been around too long. Kill it.
		kill ownr
**Else age and pose accordingly.
	else
		addv ov01 1
		setv va00 ov01
		doif ov00 eq 1
			addv va00 4
		endi
		pose va00
	endi
endm

**Detritus eat script.
scrp 2 10 1 12
	snde "chwp"
	doif crea from eq 1
**Give it a detritus stim because it's freaking detritus.
		stim writ from 81 1
	endi
**If it's not half-eaten, become half-eaten. Else be destroyed.
	doif ov00 ne 1
		setv ov00 1
		setv va00 pose
		addv va00 4
		pose va00
	else
		kill targ
	endi
endm




rscr
enum 2 4 1
	kill targ
next
enum 2 8 1
	kill targ
next
enum 2 10 1
	kill targ
next
scrx 2 8 1 12
scrx 2 8 1 9
scrx 2 4 1 9