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

(public
	Room80 0
)

(local
	newProp
)
(instance doorSound of Sound
	(properties
		number 300
	)
)

(instance fallMusic of Sound
	(properties
		number 52
	)
)

(instance Room80 of Rm
	(properties
		picture 80
	)
	
	(method (init)
		(Load rsVIEW 603)
		(Load rsSOUND 52)
		(super init:)
		(= global101 0)
		((= newProp (Prop new:))
			view: 603
			posn: 288 116
			init:
			stopUpd:
		)
		(if (or (== gPrevRoomNum 79) (== gPrevRoomNum 0))
			(gEgo posn: 279 166 view: 2 xStep: 3 yStep: 2 init:)
		)
		(if (== gPrevRoomNum 92)
			(gEgo view: 2 posn: 266 122 xStep: 3 yStep: 2 init:)
		)
		(if (== gPrevRoomNum 94)
			(gEgo view: 2 posn: 185 134 xStep: 3 yStep: 2 init:)
		)
		(doorSound init:)
	)
	
	(method (doit)
		(super doit:)
		(if (& (gEgo onControl:) $0010)
			(gEgo loop: 1)
			(proc0_18)
			(gRoom newRoom: 94)
		)
		(if (& (gEgo onControl:) $1000) (gRoom newRoom: 79))
		(if (& (gEgo onControl: 1) $0004)
			(self setScript: falling)
		)
	)
	
	(method (handleEvent pEvent)
		(return
			(cond 
				((pEvent claimed?) (return 1))
				((== (pEvent type?) evSAID)
					(cond 
						((Said 'open/door')
							(if (< (gEgo distanceTo: newProp) 25)
								(proc0_8)
								(gEgo setMotion: 0)
								(newProp ignoreActors: 1 setCycle: End)
								(doorSound play: doDoor)
							else
								(Print 800 1)
							)
						)
						((Said 'look>')
							(cond 
								(
									(or
										(Said '/room')
										(Said '/around')
										(Said '[<around][/!*]')
									)
									(Print 80 0)
								)
								((Said '/boulder') (Print 80 1))
								((Said '/castle') (Print 80 2))
								((Said '/barn') (Print 80 3))
								((Said '/cliff') (Print 80 4))
								((Said '/path') (Print 80 5))
								((Said '/door') (Print 80 6))
							)
						)
					)
				)
			)
		)
	)
)

(instance doDoor of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(if (!= (newProp cel?) (newProp lastCel:))
					(-- state)
					(newProp setCycle: End self)
				else
					(proc0_9)
					(gRoom newRoom: 92)
				)
			)
		)
	)
)

(instance falling of Script
	(properties)
	
	(method (init param1)
		(super init: param1)
	)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(User canControl: 0 canInput: 0)
				(gEgo
					view: 17
					setStep: 5 6
					setLoop: 3
					setMotion: MoveTo (- (gEgo x?) 15) 230 self
				)
				(fallMusic play:)
			)
			(1 (= seconds 3))
			(2
				(fallMusic dispose:)
				(ShakeScreen 6)
				(= seconds 3)
			)
			(3 (= global127 1))
		)
	)
)
