***DS Favourite places - revamp
** Is this world docked with C3?
doif eame "engine_no_auxiliary_bootstrap_1" = 0
** Kill the old C3 Signposts
	enum 1 1 31
		kill targ
	next
	enum 1 1 32
		kill targ
	next
	enum 1 1 33
		kill targ
	next
	enum 1 1 34
		kill targ
	next
	enum 1 1 35
		kill targ
	next
	enum 1 1 36
		kill targ
	next
	enum 1 1 37
		kill targ
	next
	enum 1 1 107
		kill targ
	next
** Kill any existing favourite place icons
	enum 1 2 38
		kill targ
	next
	enum 1 2 15
		kill targ
	next
	enum 1 2 16
		kill targ
	next
	enum 1 2 17
		kill targ
	next
	enum 1 2 18
		kill targ
	next
	enum 1 2 19
		kill targ
	next
	enum 1 2 20
		kill targ
	next
endi



*****************************************************
* 1 1 225
* ov00 = current fav place # pointing at
*
*****************************************************
* 1 3 x
* OV00 = created corresonding icon
* 0=no, 1=yes
*
*****************************************************
* 1 4 x
* OV00 = off or on
* 0=off, 1=on
* OV01 = metaroom number created in
* OV50 = position in fav places list (from 0 to "ds_favourites"-1)
* OV99 = velocity for initial movement when created
****************************************************




**OV50 of the 1/4/x icons is the postion in the 
**favourites list. Determined by new game variable
setv game "ds_favourites" 0

**fat controller
new: simp 1 1 225 "blnk" 0 0 0
mvto 0 0
imsk 35
tick 1

*fat controller ov00 is which is current place in fav places stack



*************CREATURES 3 SIGNPOSTS
**the desert outpost
new: simp 1 3 3 "fav_place_desert" 1 0 1
attr 272
mvto 5282 608
tick 10
**OV00 is state
*0=not used yet
*1=icon already on display

**the marine outpost
new: simp 1 3 4 "fav_place_marine" 1 0 1
attr 272
mvto 4625 1721
tick 10

**the bridge outpost
new: simp 1 3 6 "fav_place_bridge" 1 0 1
attr 272
*mvto 1298 3226
mvto 2269 3913
tick 10

**the engineering outpost
new: simp 1 3 5 "fav_place_engineering" 1 0 1
attr 272
mvto 5586 3334
tick 10

**the jungle outpost
new: simp 1 3 2 "fav_place_jungle" 1 0 1
attr 272
mvto 426 1745
tick 10

**the norn outpost
new: simp 1 3 1 "fav_place_norn" 1 0 8100
attr 272
*mvto 1109 733
mvto 2972 848
tick 10

**the learning room
new: simp 1 3 7 "fav_place_learning" 1 0 1
attr 272
mvto 8892 145
tick 10

*********************FAT CONTROLLER EVENTS
*****Fat controller timer
scrp 1 1 225 9
	inst
*	CHECK which metaroom you are looking at	
*	clear checking variable
	setv va01 -1

*	check which metaroom the camera is on
	setv va00 meta

*	find which fav place icon should be on
	enum 1 4 0
*		by checking its record of which metaroom it belongs to
		doif va00 eq ov01
			doif spcs eq 5 or spcs eq 6
*			nasty friggy bit to deal with the fact 
*			engineering and bridge are same metaroom
				setv va40 wndl
				setv va41 800
				divv va41 2
				addv va40 va41
				doif va40 lt 3673
*				bridge
					doif spcs eq 6
						doif ov00 eq 0
							setv va01 ov50
						else
							stop
						endi
					endi
				else
*				engineering
					doif spcs eq 5
						doif ov00 eq 0
							setv va01 ov50
						else
							stop
						endi
					endi
				endi
			else
*		is it on already?
				doif ov00 eq 1
*			just stop
					stop
*			otherwise ...
				else
*				get this ones position value
					setv va01 ov50
				endi
			endi

		endi
	next

*	if you found the right icon
	doif va01 ne -1
*		set your own variable to say you are on this positon
		setv ov00 va01
*		send messages to all icons
		enum 1 4 0
			mesg wrt+ targ 1000 va01 0 0
		next
*		give all agents a 'metaroom has changed' message
		enum 0 0 0
			mesg writ targ 900
		next
	else
*	otherwise you are in a room with no icon
		setv ov00 va01
		enum 1 4 0
			pose 0
		next
	endi

endm

****controller key down
scrp 1 1 225 73
	inst
	doif _p1_ eq 36
* home
*	go to position 0
		enum 1 4 0
			doif ov50 eq 0
				mesg writ targ 0
			endi
		next
	elif _p1_ eq 35
* end
*	go to last position
		setv va00 game "ds_favourites"
		subv va00 1
		enum 1 4 0
			doif ov50 eq va00
				mesg writ targ 0
			endi
		next
	elif _p1_ eq 33
* page up
*	get your current position in stack
		setv va01 ov00
*	if current position is 0 then no more room to go up
		doif va01 eq 0
			stop
		endi
*	otherwise, move up list (decrease value of current position)
*	find the one signpost that matches
		subv va01 1
		enum 1 4 0
			doif ov50 eq va01
				mesg writ targ 0
				stop
			endi
		next
	elif _p1_ eq 34
* page down
*	get value of ds_favourites
		setv va00 game "ds_favourites"
		subv va00 1
*	get your current position in stack
		setv va01 ov00
*	if current position same as ds_favourites then no more room to go down
		doif va01 eq va00
			stop
		endi
*	otherwise, move down list (increase value of current position)
*	find the one signpost that matches
		addv va01 1
		enum 1 4 0
			doif ov50 eq va01
				mesg writ targ 0
				stop
			endi
		next
	endi

endm

*	raw mouse wheel
scrp 1 1 225 78
	inst
	doif hhld eq null
		doif _p1_ gt 0
			mesg wrt+ ownr 73 33 0 0
		elif _p1_ lt 0
			mesg wrt+ ownr 73 34 0 0
		endi
	endi
endm

**************************SIGNPOST EVENTS
**********Signpost timer
scrp 1 3 0 9
	inst
*	if on screen
	doif visi 0 eq 1
*	if no icon created yet, make one
		doif ov00 eq 0
*		change state
			setv ov00 1
*		play sfx
			sndc "fp_2"
*		get your spcs number
			setv va10 spcs
*		get your sprite file
			sets va11 gall
*		get your metaroom
			setv va12 gmap posx posy
*		make the icon
			new: simp 1 4 va10 va11 2 1 8505
			tran 0 0
			attr 308
*			store your stack position
			setv ov50 game "ds_favourites"
			addv game "ds_favourites" 1
*			store your metaroom
			setv ov01 va12
			clac 0
*			working out position to float from
			setv va00 wndw
			divv va00 2
			setv va01 wndh
			divv va01 2
*			position it
			flto va00 va01
*			velocity value
			setv ov99 5
*			move it
			velo ov99 -10
*			timer for movement
			tick 2
		endi
	endi
endm

**********************ICON EVENTS
******Icon clicked on
scrp 1 4 0 1
	inst
*	get your species number
	setv va00 spcs
*	find your counterpart signpost
	rtar 1 3 va00
	doif targ eq null
*	no targ, stop
		stop
	endi
*	move camera to them
	cmrt 0
*	give all agents a 'metaroom has changed' message
	enum 0 0 0
		mesg writ targ 900
	next

endm

*************Icon timer
scrp 1 4 0 9
	inst
	setv va01 post
	setv va99 wndt
	subv va01 va99
*	if you're close enough to the top ...
	doif va01 le 30
*		calculate the offset from the left edge
		setv va02 ov50
		mulv va02 50
		addv va02 145
*		this gives you float position	
		flto va02 0
*		set velocity variables to 0
		setv ov99 0
		setv va00 0
*		stop ticking
		tick 0
	else
*		otherwise carry on moving
		setv va00 -10
	endi
	velo ov99 va00
	negv ov99
endm
*******Icon world loaded event
scrp 1 4 0 123
	mesg writ targ 9
endm
*******Icon highlight event
*_p1_ says which one to highlight
scrp 1 4 0 1000
	inst
*	check _p1_ against your ov50 value
	doif _p1_ eq ov50
*		highlight yourself
		pose 1
		setv ov00 1
	else
		pose 0
		setv ov00 0
	endi


endm



*******REMOVAL
rscr
enum 1 3 0
	kill targ
next
enum 1 4 0
	kill targ
next
enum 1 1 225
	kill targ
next