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

(public
	Room66 0
)

(local
	newView
	local1
	local2
	local3
)
(instance fallSound of Sound
	(properties
		number 51
	)
)

(instance Room66 of Rm
	(properties
		picture 66
		style $0010
	)
	
	(method (init)
		(Load rsVIEW 512)
		(Load rsVIEW 44)
		(Load rsVIEW 42)
		(Load rsVIEW 41)
		(Load rsVIEW 4)
		(Load rsSCRIPT 991)
		(self setRegions: 603)
		(super init:)
		((View new:)
			view: 512
			loop: 1
			cel: 0
			posn: 208 79
			setPri: 4
			addToPic:
		)
		((Prop new:)
			view: 512
			loop: 0
			posn: 206 64
			setPri: 3
			init:
			setCycle: Fwd
		)
		(if (== ((gInv at: 15) owner?) 66)
			((= newView (View new:))
				view: 512
				loop: 2
				cel: 0
				posn: 194 122
				init:
				stopUpd:
			)
		)
		(if (or (== gPrevRoomNum 67) (== gPrevRoomNum 0))
			(gEgo
				illegalBits: -16384
				posn: 240 127
				view: 4
				xStep: 4
				yStep: 2
				init:
				setPri: -1
			)
			(= local1 1)
			(gEgo observeBlocks: stair1)
		)
		(if (== gPrevRoomNum 61)
			(gEgo
				illegalBits: -32768
				view: 4
				xStep: 4
				setPri: 7
				yStep: 1
				posn: 102 37
				baseSetter: (ScriptID 0 1)
				init:
			)
			(= local1 0)
		)
		(gEgo observeBlocks: stair2)
	)
	
	(method (doit)
		(super doit:)
		(if (!= (self script?) stairTrip)
			(if (& (gEgo onControl: 0) $0040)
				(gRoom newRoom: 67)
			)
			(if (& (gEgo onControl: 0) $0020)
				(gRoom newRoom: 61)
			)
			(if
			(and (& (gEgo onControl: 0) $0004) (not local1))
				(self setScript: stairTrip)
			)
			(if (& (gEgo onControl: 1) $0800)
				(if (> (gEgo heading?) 180)
					(= local1 0)
					(if (gEgo blocks?) (gEgo ignoreBlocks: stair1))
					(gEgo
						illegalBits: -32768
						baseSetter: (ScriptID 0 1)
						setPri: 12
					)
				else
					(= local1 1)
					(gEgo
						observeBlocks: stair1
						illegalBits: -16384
						baseSetter: 0
						setPri: -1
					)
				)
			)
		)
		(cond 
			(
				(and
					(gEgo inRect: 183 150 205 168)
					(& (gEgo onControl:) $0800)
					local1
				)
				(gEgo setPri: 12)
			)
			(
				(and
					local1
					(not (gEgo inRect: 183 150 205 168))
					(== (gEgo priority?) 12)
				)
				(gEgo setPri: -1)
			)
		)
		(if
			(and
				(!= (self script?) stairTrip)
				(or
					(gEgo inRect: 92 14 128 36)
					(gEgo inRect: 74 13 112 48)
				)
			)
			(gEgo setPri: 7)
		)
		(if (& (gEgo onControl: 1) $0400)
			(if
			(or (< (gEgo heading?) 90) (> (gEgo heading?) 270))
				(gEgo setPri: 7)
			else
				(gEgo setPri: 12)
			)
		)
		(if
			(and
				(> (gEgo y?) 60)
				(< (gEgo y?) 116)
				(!= (gEgo script?) stairTrip)
			)
			(gEgo setPri: 12)
		)
	)
	
	(method (dispose)
		(DisposeScript 991)
		(super dispose:)
	)
	
	(method (handleEvent pEvent)
		(return
			(cond 
				((pEvent claimed?) (return 1))
				((== (pEvent type?) evSAID)
					(cond 
						((Said 'look>')
							(cond 
								((Said '/stair') (Print 66 0))
								((Said '/door') (Print 66 1))
								((or (Said '/dirt') (Said '<down')) (Print 66 2))
								((Said '/wall') (Print 66 3))
								((Said '/torch') (Print 66 4))
								((Said '<up') (Print 66 5))
								((Said '[<around][/room,tower]')
									(Print
										(Format
											@global228
											66
											6
											(if (== ((gInv at: 15) owner?) 66)
												{You notice a shovel leaning against the wall.}
											else
												{_}
											)
										)
									)
								)
								(else (pEvent claimed: 0))
							)
						)
						((Said '*/stair') (Print 66 7))
						((Said 'get/shovel')
							(if
								(and
									(== ((gInv at: 15) owner?) 66)
									(gCast contains: newView)
								)
								(if (< (gEgo distanceTo: newView) 15)
									(gEgo get: 15)
									(= global182 1)
									(gGame changeScore: 2)
									(newView dispose:)
								else
									(Print 800 1)
								)
							else
								(Print 66 8)
							)
						)
						((Said 'get/torch') (Print 66 9))
						((Said 'close/door') (Print 66 10))
						((Said 'open/door') (Print 66 11))
					)
				)
			)
		)
	)
)

(instance stairTrip of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(proc0_8)
				(gEgo illegalBits: 0 ignoreActors: 1)
				(if (< (gEgo y?) 90) (= local2 1))
				(self cue:)
			)
			(1
				(gEgo
					view: 44
					moveSpeed: 0
					setMotion: 0
					setLoop: 0
					setCycle: End self
				)
				(fallSound play:)
			)
			(2
				(gEgo setPri: 11)
				(proc0_18)
				(gEgo
					setStep: 10 10
					setLoop: 2
					setCycle: Fwd
					setMotion: JumpTo 185 142 self
				)
			)
			(3
				(if local2
					(gEgo view: 42 loop: 0 cel: 0 setPri: 8)
					((ScriptID 0 4) setCycle: self 2)
				else
					(= local1 1)
					(gEgo observeBlocks: stair1)
					(gEgo
						view: 41
						setPri: -1
						cel: 255
						setLoop: 0
						setCycle: End self
					)
				)
			)
			(4
				(if local2
					(ShakeScreen 10)
					(= seconds 3)
				else
					(gEgo
						view: 4
						xStep: 4
						yStep: 2
						setCycle: Walk
						setLoop: -1
						setPri: -1
						illegalBits: -16384
						baseSetter: 0
						ignoreActors: 0
					)
					(= state -1)
					(proc0_9)
					(client setScript: 0)
				)
			)
			(5 (= global127 1))
		)
	)
)

(instance stair1 of Blk
	(properties
		top 116
		left 147
		bottom 117
		right 159
	)
)

(instance stair2 of Blk
	(properties
		top 194
		left 198
		bottom 149
		right 151
	)
)
