* speech bubble factory
* send message 126 to it to create speech bubbles
* _p1_ = string to write
* _p2_ = agent bubble is connected to

new: simp 1 2 10 "blnk" 1 0 0
attr 16

scrp 1 2 10 126
	inst
	doif _p2_ = null
		stop
	endi
	targ _p2_
	* cl's bubbles come from corner on the pointer, and from top on other agents
	doif targ eq pntr
		setv va00 posl
	else
		setv va00 posx
	endi
	setv va01 post
	subv va01 30

	* bubble direction - based on which side of the screen the bubble's on

	setv va80 wndl
	addv va80 wndr
	divv va80 2

	doif va00 < va80
		setv va90 0
	else
		setv va90 1
	endi

	setv va10 plne
	addv va10 10

	new: comp 1 2 9 "speech_bubbles" 2 2 va10
	tick 40
	attr 48
	part 0
	pose va90
	setv va20 2
	loop
		outs "va20: "
		outv va20
		outs "\n"

		doif va20 gt 2
			pat: kill 1
		endi
		pat: fixd 1 "speech_bubbles" va20 0 0 0 "blackontransparentchars"
		part 1
		frmt 12 12 12 5 0 0 0
		pose va90
		ptxt _p1_
		doif va20 eq 2 setv va02 102
		elif va20 eq 4 setv va02 155
		elif va20 eq 6 setv va02 230
		elif va20 eq 8 setv va02 319 endi
		addv va20 2

		outs "npgs: "
		outv npgs
		outs "\n"
	untl va20 ge 8 or npgs le 1

	frel _p2_
	doif va00 >= va80
		subv va00 va02
	endi

	mvto va00 va01
endm

scrp 1 2 9 9
	kill ownr
endm

rscr
enum 1 2 9
	kill targ
next
enum 1 2 10
	kill targ
next

scrx 1 2 9 9
scrx 1 2 10 126
