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

(public
	Room91 0
)

(local
	newAct
)
(instance theMusic of Sound
	(properties)
)

(instance Room91 of Rm
	(properties
		picture 91
		style $0010
	)
	
	(method (init)
		(Load rsVIEW 141)
		(Load rsVIEW 636)
		(self setRegions: 604)
		(super init:)
		(proc0_10 604 0)
		((Prop new:)
			isExtra: 1
			view: 636
			loop: 0
			posn: 133 60
			setPri: 15
			init:
			setCycle: Fwd
		)
		(if (or (== gPrevRoomNum 92) (== gPrevRoomNum 0))
			(gEgo posn: 291 152 view: 4 setStep: 4 2 init:)
			(if global175
				(gEgo x: 275)
				((= newAct (Act new:))
					view: 141
					posn: (+ (gEgo x?) 25) (gEgo y?)
					illegalBits: 0
					setStep: 6 4
					setCycle: Walk
					init:
					setScript: henchChase
				)
			)
		)
		(if (== gPrevRoomNum 89)
			(gEgo posn: 253 123 view: 4 xStep: 4 yStep: 2 init:)
		)
		(if (== gPrevRoomNum 90)
			(gEgo posn: 27 153 view: 4 setStep: 4 2 init:)
			(if global175
				((= newAct (Act new:))
					view: 141
					posn: (- (gEgo x?) 30) (gEgo y?)
					illegalBits: 0
					setStep: 6 4
					setCycle: Walk
					init:
					setScript: henchChase
				)
			)
		)
	)
	
	(method (doit)
		(super doit:)
		(if (& (gEgo onControl: 0) $0040)
			(gRoom newRoom: 90)
		)
		(if (& (gEgo onControl: 0) $0020)
			(gRoom newRoom: 92)
		)
		(if (& (gEgo onControl: 0) $0010)
			(gRoom newRoom: 89)
		)
	)
	
	(method (handleEvent pEvent)
		(return
			(cond 
				((pEvent claimed?) (return 1))
				((== (pEvent type?) evSAID)
					(cond 
						(
							(or
								(Said 'look[/!*]')
								(Said 'look[<around][/room,castle]')
							)
							(Print 91 0)
						)
						((Said 'look>')
							(cond 
								((Said '<under/table') (Print 91 1))
								((Said '/table') (Print 91 2))
								((Said '<behind,under/tapestries') (Print 91 3))
								((Said '/tapestries,painting') (Print 91 4))
								((Said '/chandelier,candle,candelabra') (Print 91 5))
								((Said '/door') (Print 91 6))
								((Said '/wall') (Print 91 7))
								((or (Said '/dirt') (Said '<down')) (Print 91 8))
								(else (pEvent claimed: 0))
							)
						)
						((Said 'sit>') (Print 91 9) (pEvent claimed: 1))
					)
				)
			)
		)
	)
	
	(method (newRoom newRoomNumber)
		(if
		(or (>= (henchChase state?) 1) (== newRoomNumber 81))
			(= global175 1)
			(= newRoomNumber 81)
		else
			(= global175 0)
			(User canControl: 1 canInput: 1)
		)
		(henchChase seconds: 0)
		(super newRoom: newRoomNumber)
	)
)

(instance henchChase of Script
	(properties)
	
	(method (init param1)
		(super init: param1)
	)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(theMusic number: 41 play:)
				(client setMotion: Chase gEgo 15 self)
				(= global175 1)
			)
			(1
				(if (== gCurRoomNum gNewRoomNumber_2)
					(= global205 1)
					(User canControl: 0 canInput: 0)
					(gEgo moveSpeed: 0 setMotion: 0)
					(theMusic number: 42 play:)
					(= seconds 4)
				)
			)
			(2
				(if (== gCurRoomNum gNewRoomNumber_2)
					(gRoom newRoom: 81)
				else
					(User canControl: 1 canInput: 1)
					(= global205 0)
				)
			)
		)
	)
)
