* agent help watcher
new: simp 1 2 4 "blnk" 0 1 0
imsk 1
attr 272
seta ov00 null
setv ov01 0
pure 0

* raw key down
scrp 1 2 4 73
	inst
	doif _p1_ = 112
		targ pntr
		doif held ne null
			sndc "buzz"
			stop
		endi
		doif pure = 1
			targ pntr
			pose 0
			rtar 1 2 14
			setv ov00 0
			part 6
			pose 0
			targ ownr
			imsk 1
			doif ov00 <> null
				kill ov00
				seta ov00 null
			endi
			pure 0
		else
			pure 1
			targ hhld
			nohh
			targ pntr
			pose 18
			rtar 1 2 14
			setv ov00 1
			part 6
			pose 1
			targ ownr
			imsk 9
		endi
	endi

endm

* raw mouse down
scrp 1 2 4 76
	inst
	mesg wrt+ ownr 1000 _p1_ hots 0
endm

* launch agent help on specific agent
scrp 1 2 4 1000
	inst
	seta va10 ov00
	seta va05 _p2_
	doif va05 <> null
* left mouse - shout your name
		doif _p1_ = 1
			targ va05
*		set up string with name of object
			setv va98 cata
			sets va99 catx va98

* icons gui
			doif fmly eq 1 and gnus eq 2 and spcs eq 14
*				mesg writ targ 1000
				mesg wrt+ ownr 73 112 0 0
* agent help box
			elif fmly eq 1 and gnus eq 2 and spcs eq 5
*				mesg writ targ 1000
				enum 1 2 5
					mesg wrt+ pntr 2006 targ 0 0
				next
			else
* unclassified (39) things don't say their name
				doif va98 <> -1
* send message to bubble factory to do visuals
					rtar 1 2 10
					mesg wrt+ targ 126 va99 va05 0
* target agent again, and send shout from it
					targ va05
					ordr shou va99
				endi
			endi

* right mouse - bring up help dialogue
		elif _p1_ = 2
* agent help bubble
			targ va05

			doif fmly = 4
				new: comp 1 2 23 "ds_creature_history" 32 0 8520
				mesg wrt+ targ 1000 va05 1001 0
				rtar 1 2 4
				mesg wrt+ targ 73 112 0 0
				stop
			else
				doif va10 = null
					new: comp 1 2 5 "useful_screen" 1 0 9050
					attr 304
* the description text
					pat: fixd 1 "useful_screen" 1 25 59 1 "WhiteOnTransparentChars"
					part 1
					frmt 8 8 8 18 3 0 0
* close button
					pat: butt 2 "useful_screen" 2 2 237 24 0 [] 1000 0
* pgdn button
					pat: butt 4 "useful_screen" 9 3 238 302 0 [] 1001 0
* pgup button
					pat: butt 5 "useful_screen" 6 3 20 302 0 [] 1002 0
* page counter
					pat: fixd 6 "useful_screen" 15 119 306 1 "WhiteOnTransparentChars"
					part 6
					frmt 0 0 0 0 3 0 2
* the name of agent text
					pat: fixd 3 "useful_screen" 12 22 22 1 "WhiteOnTransparentChars"
					part 3
					frmt 8 0 37 0 2 0 8
** blueprint button
					pat: butt 7 "useful_screen" 4 2 198 25 1 [] 2000 0
*set ov02 to agent that help is on.
					seta ov02 va05
					setv va90 wndw
					divv va90 2
					setv va91 wndh
					divv va91 2
					setv va92 wdth
					divv va92 2
					setv va93 hght
					divv va93 2

					subv va90 va92
					subv va91 va93

					flto va90 va91

					seta va10 targ
				endi
				targ va05

*				if this is a portal ...
				doif fmly eq 3 and gnus eq 9 and spcs eq 1
*					sets va01 "This warp portal has been identified as: "
					sets va01 read "portal misc" 0
					doif ov01 eq ""
*						adds va01 "<un-named>"
						adds va01 read "portals" 1
					else
						adds va01 ov01
					endi

					adds va01 "\n\n"
				else
					sets va01 ""
				endi


				sets va00 wild fmly gnus spcs "Agent Help" 0
				adds va01 wild fmly gnus spcs "Agent Help" 1



				doif va01 = "***"
					sets va01 read "Agent Help Something" 0
					adds va01 vtos fmly
					adds va01 " "
					adds va01 vtos gnus
					adds va01 " "
					adds va01 vtos spcs
				endi

				targ va10
				part 3
				ptxt va00
				part 1
				ptxt va01

* set page counter
				targ ownr
				seta ov00 va10
				mesg writ ov00 1003
			endi
		endi
	endi
	targ ownr
	seta ov00 va10
endm
***close text box
scrp 1 2 5 1000
	part 2
	anim [0 1]
	rtar 1 2 4
	seta ov00 null
	wait 10
	kill ownr
endm
*********
*********
***page down
scrp 1 2 5 1001
	part 1
	setv va99 page
	setv va06 npgs
	addv va99 1

	doif va99 < npgs
		part 4
		anim [ 2 2 2 ]
		over
		part 1
		page va99
	endi

* set page counter
	mesg writ ownr 1003
endm
*********
***page up
scrp 1 2 5 1002
	part 1
	setv va99 page

	doif va99 > 0
		part 5
		anim [ 2 2 2 ]
		over
		part 1
		subv va99 1
		page va99
	endi

* set page counter
	mesg writ ownr 1003
endm

* set page counter
scrp 1 2 5 1003
	inst

* get number of pages and current page
	part 1
	setv va06 npgs
	setv va07 page
	addv va07 1

* set page number text
	sets va08 vtos va07
	adds va08 "/"
	adds va08 vtos va06
	part 6
	ptxt va08

* set pgup button
	part 5
	doif va07 = 1
		anim [0]
	else
		anim [1]
	endi

* set pgdn button
	part 4
	doif va07 = va06
		anim [0]
	else
		anim [1]
	endi
endm

*********

* This is a pointer script and should

*make a blue print agent
scrp 1 2 5 2000
	inst
	lock
	part 7
	anim [0 1]
	sets va90 ""
	doif ov02 <> null
		econ ov02
			addv va66 1
		next
	endi
	part 1
	doif ov02 <> null
		seta va49 ov02
		sets va67 ptxt
		setv va89 strl va67
		sets va90 subs va67 va89 1
	endi
	doif va66 > 1 and va90 <> "-" and ov02 <> null
		targ ov02
		setv va50 posl
		setv va51 post
		targ ownr
		new: simp 1 1 100 "pick-ups" 0 0 5000
		attr 199
		perm 60
		elas 10
		fric 90
		accg 2
		sets ov98 ""
		setv ov61 1
		doif tmvt va50 va51 <> 1
*			dbg: outs "oh dear, this is going to be a pain."
			subv va51 20
			doif tmvt va50 va51 <> 1
*				mvsf va50 va51
				kill targ
			else
				mvto va50 va51
				setv va88 1
				mesg wrt+ targ 1000 va49 0 0
			endi
			targ ownr
		else
			mvto va50 va51
			setv va88 1
			mesg wrt+ targ 1000 va49 0 0
		endi

	else

	endi
	targ ownr
	part 7
	over
	anim [1 0]
	doif va88 = 1 and ov02 <> null
		part 1
		sets va67 ptxt
		setv va89 strl va67
		sets va90 subs va67 va89 1
		doif va90 <> "-"
			adds va67 read "Blueprint" 4
		endi
		ptxt va67
	else
		part 1
		sets va67 ptxt
		setv va89 strl va67
		sets va90 subs va67 va89 1
		doif va90 <> "-"
			adds va67 read "Blueprint" 5
		endi
		ptxt va67
	endi
endm


rscr
enum 1 2 4
	kill targ
next
enum 1 2 5
	kill targ
next
enum 1 2 23
	kill targ
next
scrx 1 2 4 76
scrx 1 2 5 1000