;;; Sierra Script 1.0 - (do not remove this comment)
(script# 86)
(include sci.sh)
(use Main)
(use Class_255_0)
(use Sound)
(use Cycle)
(use Game)
(use User)
(use Feature)
(use Obj)

(public
	Room86 0
)

(local
	newAct
	newAct_2
	newProp_2
	newProp_3
	newProp_4
	newProp
)
(instance theMusic of Sound
	(properties)
)

(instance doorOpenMusic of Sound
	(properties
		number 300
	)
)

(instance Room86 of Rm
	(properties
		picture 86
		style $0010
	)
	
	(method (init)
		(Load rsVIEW 81)
		(Load rsVIEW 82)
		(Load rsVIEW 147)
		(Load rsVIEW 607)
		(Load rsVIEW 141)
		(Load rsVIEW 633)
		(super init:)
		(self setRegions: 604)
		((= newProp (Prop new:))
			view: 607
			posn: 173 117
			init:
			stopUpd:
		)
		((= newProp_2 (Prop new:))
			posn: 281 64
			view: 633
			cel: 2
			init:
			setCycle: Fwd
		)
		((= newProp_3 (Prop new:))
			posn: 289 75
			view: 633
			cel: 0
			init:
			setCycle: Fwd
		)
		((= newProp_4 (Prop new:))
			posn: 296 64
			view: 633
			cel: 1
			init:
			setCycle: Fwd
		)
		(if (or (== gPrevRoomNum 87) (== gPrevRoomNum 0))
			(gEgo posn: 303 141 view: 4 xStep: 4 yStep: 2 init:)
			(if global175
				((= newAct (Act new:))
					view: 141
					posn: (+ (gEgo x?) 40) (gEgo y?)
					setCycle: Walk
					illegalBits: 0
					init:
					setScript: henchChase
				)
				(theMusic number: 41 loop: 1 init:)
			)
		)
		(if (== gPrevRoomNum 83)
			(if (== global109 0)
				(User canControl: 0 canInput: 0)
				(gEgo
					view: 81
					loop: 2
					posn: 190 120
					init:
					setCycle: Walk
					setScript: toThrone
				)
			else
				(gEgo posn: 190 120 view: 4 setStep: 4 2 init:)
			)
		)
		(if (== gPrevRoomNum 92)
			(gEgo
				view: 81
				loop: 1
				posn: 293 141
				setStep: 4 2
				init:
				setCycle: Walk
			)
			(User canControl: 0 canInput: 0)
			(self setScript: intoDungeon)
		)
	)
	
	(method (doit)
		(super doit:)
		(if
		(and (& (gEgo onControl:) $0040) (!= global109 0))
			(gRoom newRoom: 87)
		)
	)
	
	(method (handleEvent pEvent)
		(return
			(cond 
				((pEvent claimed?) (return 1))
				((== (pEvent type?) evSAID)
					(cond 
						(
							(or
								(Said 'look[<around][/!*]')
								(Said 'look/room,castle,hall')
							)
							(Print
								(Format
									@global228
									86
									0
									(if (== (newProp cel?) 0) {a closed} else {an open})
								)
							)
						)
						((Said 'look>')
							(cond 
								((Said '/door') (Print 86 1))
								((Said '/table') (Print 86 2))
								((Said '/candelabra,candle') (Print 86 3))
								((Said '/chair') (Print 86 4))
								((Said '/wall') (Print 86 5))
								((or (Said '/dirt') (Said '<down')) (Print 86 6))
							)
						)
						((Said 'bang/door')
							(if (gEgo inRect: 171 115 204 122)
								(Print 86 7)
							else
								(Print 800 1)
							)
						)
						((Said 'open/door')
							(if (not (gEgo inRect: 171 115 204 122))
								(Print 800 1)
							else
								(Print 86 8)
							)
						)
						((Said 'close/door') (Print 86 9))
						((Said 'unlatch/door')
							(if (gEgo inRect: 171 115 204 122)
								(Print 86 8)
							else
								(Print 800 1)
							)
						)
						((Said 'sit/chair') (Print 86 10))
						((Said 'get/candelabra') (Print 86 11))
					)
				)
			)
		)
	)
)

(instance openDoor of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(proc0_8)
				(newProp setCycle: End self)
				(newProp ignoreActors: 1)
				(doorOpenMusic play:)
			)
			(1
				(proc0_9)
				(gRoom newRoom: 83)
			)
		)
	)
)

(instance intoDungeon of Script
	(properties)
	
	(method (init param1)
		(super init: param1)
	)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(gEgo setMotion: MoveTo 187 122 self)
			)
			(1
				(gEgo view: 82 loop: 0)
				(self cue:)
			)
			(2
				((= newAct (Act new:))
					view: 147
					loop: 3
					posn: (- (gEgo x?) 15) (gEgo y?)
					init:
					moveSpeed: 1
					setCycle: End
				)
				((= newAct_2 (Act new:))
					view: 147
					loop: 4
					posn: (+ (gEgo x?) 15) (gEgo y?)
					setPri: (+ (gEgo priority?) 1)
					init:
					moveSpeed: 1
					setCycle: End
				)
				(newProp setCycle: End self)
			)
			(3
				(gEgo cel: 255 loop: 1 setCycle: End self)
			)
			(4
				(User canControl: 1 canInput: 1)
				(gEgo setLoop: -1)
				(gRoom newRoom: 83)
			)
		)
	)
)

(instance toThrone of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(gEgo setMotion: MoveTo 329 130 self)
				(newProp cel: 4)
			)
			(1
				(= global205 1)
				(gRoom newRoom: 92)
			)
		)
	)
)

(instance henchChase of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(theMusic number: 41 loop: 10 play:)
				(client setMotion: Chase gEgo 15 self)
			)
			(1
				(User canControl: 0 canInput: 0)
				(gEgo moveSpeed: 0 setMotion: 0)
				(theMusic number: 42 loop: 1 play:)
				(= seconds 3)
			)
			(2
				(= global205 1)
				(gRoom newRoom: 81)
			)
		)
	)
)
