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

(public
	Room28 0
)

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

(instance Room28 of Rm
	(properties
		picture 28
	)
	
	(method (init)
		(= north 22)
		(= south 4)
		(= east 29)
		(= west 27)
		(= horizon 126)
		(= global101 0)
		(proc0_9)
		(gEgo edgeHit: 0 illegalBits: -32768)
		(super init:)
		(if global100 (gRoom overlay: 128))
		(self setRegions: 508)
		(Load rsVIEW 17)
		(Load rsVIEW 21)
		(Load rsSOUND 51)
		(= newView (View new:))
		(if global100
			(newView
				view: 600
				loop: 0
				cel: 0
				setPri: 9
				posn: 289 137
				ignoreActors:
				init:
				stopUpd:
			)
			(gEgo observeControl: 16384)
		else
			(newView
				view: 600
				loop: 1
				cel: 0
				ignoreActors: 1
				setPri: 9
				posn: 284 131
				init:
				stopUpd:
			)
		)
		(switch gPrevRoomNum
			(22 (gEgo posn: 82 128))
			(27
				(if (<= (gEgo y?) horizon)
					(gEgo posn: 2 (+ horizon 2))
				else
					(gEgo posn: 2 (gEgo y?))
				)
			)
			(29
				(if (<= (gEgo y?) 156)
					(gEgo x: 318 y: 149)
				else
					(gEgo posn: 317 187)
				)
			)
			(4 (gEgo posn: 158 187))
			(55 (gEgo x: 290 y: 134))
			(0 (gEgo x: 88 y: 160))
		)
		(gEgo view: 2 xStep: 3 yStep: 2 init:)
		(gEgo y: (| (gEgo y?) $0001))
	)
	
	(method (doit)
		(super doit:)
		(if (& (= gEgoOnControl (gEgo onControl:)) $0040)
			(gRoom newRoom: 55)
		)
		(if
			(and
				(!= gEgoOnControl theGEgoOnControl)
				(== (gRoom script?) 0)
				(== gCurRoomNum gNewRoomNumber_2)
			)
			(= theGEgoOnControl gEgoOnControl)
			(if (& gEgoOnControl $0004)
				(self setScript: fallSouth)
				(gRoom east: 0)
			)
		)
	)
	
	(method (handleEvent pEvent)
		(if (pEvent claimed?) (return 1))
		(return
			(if (== (pEvent type?) evSAID)
				(if (not global100)
					(if (Said 'look>')
						(cond 
							((Said '/door') (Print 28 0))
							((Said '<in[/mine]')
								(if (gEgo inRect: 269 135 295 142)
									(Print 28 1)
								else
									(Print 800 1)
								)
							)
							((Said '/mine,hill') (Print 28 2))
							((Said '[<around][/room]') (Print 28 3))
						)
					)
					(if (Said '/door>')
						(cond 
							((Said 'close,close') (Print 28 4))
							((Said 'open,bang') (Print 28 5))
						)
					)
				else
					(if (Said '/door,padlock,latch>')
						(cond 
							((Said 'break/door') (Print 28 6))
							((Said 'bang/door')
								(if (gEgo inRect: 276 131 298 143)
									(Print 28 7)
								else
									(Print 800 1)
								)
							)
							((Said 'open/door') (Print 28 8))
							((Said 'unlatch,detach,get') (Print 28 9))
						)
					)
					(if (Said 'look>')
						(cond 
							((Said '/door') (Print 28 10))
							((Said '/mine,hill') (Print 28 11))
							((Said '[<around][/room]') (Print 28 3))
						)
					)
				)
			else
				0
			)
		)
	)
	
	(method (newRoom newRoomNumber)
		(super newRoom: newRoomNumber)
	)
)

(instance fallSouth of Script
	(properties)
	
	(method (init)
		(gEgo viewer: 0)
		(super init:)
	)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(proc0_8)
				(fallSound play:)
				(if (< (gEgo x?) 265)
					(= local2 20)
				else
					(= local2 30)
				)
				(if (> (+ (gEgo y?) local2) 188)
					(= local1 188)
				else
					(= local1 (+ (gEgo y?) local2))
				)
				(gEgo
					view: 17
					setStep: 6 6
					illegalBits: 0
					loop: (& (gEgo loop?) $0001)
					setCel: 0
					setCycle: End
					setMotion: MoveTo (gEgo x?) local1 self
				)
			)
			(1
				(gEgo
					xStep: 3
					yStep: 2
					view: 21
					loop: 2
					setCycle: CT 4 1 self
				)
			)
			(2
				(gEgo view: 21 loop: 2 setCycle: Beg self)
			)
			(3
				(gRoom setScript: 0)
				(gEgo illegalBits: -32768 setCycle: Walk view: 2)
				(if global100 (gEgo observeControl: 16384))
				(gRoom east: 29)
				(proc0_9)
			)
		)
	)
)
