**************************
***Prate Install Script***
**************************
*OV00 Direction
*OV01 Age
*OV02 Energy
new: simp 2 15 64862 "prate" 14 0 4001
attr 198
bhvr 32
elas 30
fric 95
accg 2
aero 1
perm 60
mvsf rand 3420 3670 5340
setv ov01 0
setv ov02 90
setv ov00 rand 0 1
doif ov00 eq 0
	base 0
	anim [0 1 0]
	setv velx 5
	setv vely rand 7 12
else
	base 0
	anim [7 8 7]
	setv velx -5
	setv vely rand 7 12
endi
	tick 15
************************
***Prate Timer Script***
************************
scrp 2 15 64862 9
	inst
***age and reduce energy
	addv ov01 1
	subv ov02 1

***die if old or out of energy
	doif ov01 gt 500 or ov02 le 0
		gsub die
	endi

***if in water
	doif rtyp room targ eq 8 or rtyp room targ eq 9
		subv ov02 rand 1 4
		doif ov00 eq 0
			setv velx -7
			setv vely rand -5 -15
			anim [0 1 0]
		else
			setv velx 7
			setv vely rand -5 -15
			anim [7 8 7]
		endi

***check if old enough to lay egg
		doif ov01 eq 200 or ov01 eq 320 or ov01 eq 450
			doif rtyp room targ ne 8 or rtyp room targ ne 9
				gsub egg
			endi
		endi

***look if youre by food
		etch 2 3 0
			doif targ ne null
				doif ov00 eq 0
					anim [0 2 3 2 0]
				else
					anim [7 9 10 9 7]
				endi
				kill targ
				targ ownr
				addv ov02 rand 2 5
			endi
		next

***decide on movement action
		setv va01 rand 1 8
		doif va01 le 4
***lets move right
			base 0
			anim [0 1 0]
			setv velx 5
			setv vely rand 7 12
		else
***if not moving right, we must go left
			base 0
			anim [7 8 7]
			setv velx -5
			setv vely rand 7 12
		endi

***death routine
	subr die
		doif ov00 eq 0
			base 0
			anim [0 4 5 6]
			wait 15
			kill ownr
		else
			base 0
			anim [7 11 12 13]
			wait 15
			kill ownr
		endi
		altr room targ 3 0.8
	retn

***lay eggs routine
	subr egg
		reps rand 1 2
			setv va03 posl
			setv va04 post
			subv va03 20
			subv va04 22
			new: simp 2 18 64862 "prategg" 6 0 rand 4001 4003
			attr 195
			bhvr 32
			elas 30
			fric rand 70 90
			accg 3
			perm rand 50 70
			tick rand 100 120
			doif tmvt va03 va04 eq 1
				mvto va03 va04
			else
				mvsf va03 va04
			endi
		repe
	retn
endi

endm

****************************
***Prate Collision Script***
****************************
scrp 2 15 64862 6
	doif wall eq rght
		pose 7
		setv ov00 1
	elif wall eq left
		pose 0
		setv ov00 0
	endi
endm

****************************
***Prate Egg Timer Script***
****************************
scrp 2 18 64862 9
	doif pose le 4
		setv va00 pose
		addv va00 1
		pose va00
	else
		inst
		setv va01 pose
		addv va01 1
		pose va01
		setv va02 posl
		setv va03 post
		new: simp 2 15 64862 "prate" 14 0 4001
		attr 198
		bhvr 32
		elas 30
		fric 95
		accg 2
		aero 1
		perm 60
		mvsf va02 va03
		setv ov01 0
		setv ov02 90
		setv ov00 rand 0 1
		doif ov00 eq 0
			base 0
			pose 0
		else
			base 0
			pose 7
		endi
		tick 15
		targ ownr
		wait 10
		kill ownr
	endi
endm