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

(public
	Room90 0
)

(local
	local0
)
(instance fallMusic of Sound
	(properties
		number 51
	)
)

(instance Room90 of Rm
	(properties
		picture 90
		style $0010
	)
	
	(method (init)
		(Load rsSCRIPT 991)
		(Load rsVIEW 634)
		(Load rsVIEW 512)
		(Load rsSOUND 51)
		(self setRegions: 604)
		(super init:)
		(proc0_10 604 0)
		((View new:)
			view: 634
			loop: 1
			cel: 1
			posn: 209 77
			setPri: 4
			init:
			addToPic:
		)
		((Prop new:)
			view: 512
			loop: 0
			posn: 209 65
			setPri: 3
			init:
			setCycle: Fwd
		)
		(if (or (== gPrevRoomNum 91) (== gPrevRoomNum 0))
			(gEgo
				posn: 255 134
				baseSetter: 0
				view: 4
				setStep: 4 2
				illegalBits: -16384
				init:
			)
			(= local0 0)
			(if global175
				(Print 90 0 67 -1 10 33 gSmallFont)
				(= global175 0)
			)
		)
		(if (== gPrevRoomNum 85)
			(gEgo
				posn: 104 38
				baseSetter: (ScriptID 0 1)
				view: 4
				setStep: 4 2
				illegalBits: -32768
				setPri: 12
				init:
			)
			(= local0 1)
		)
	)
	
	(method (doit)
		(if (& (gEgo onControl: 0) $0040)
			(gEgo setPri: -1 illegalBits: -32768 baseSetter: 0)
			(gRoom newRoom: 91)
		)
		(if (& (gEgo onControl: 0) $0020)
			(gEgo setPri: -1 illegalBits: -32768 baseSetter: 0)
			(gRoom newRoom: 85)
		)
		(if
			(and
				(!= (self script?) fallingToDeath)
				(!= (self script?) fallingDown)
			)
			(if local0
				(cond 
					((& (gEgo onControl:) $0004) (self setScript: fallingToDeath))
					((& (gEgo onControl:) $0100) (self setScript: fallingDown))
				)
			)
			(if (& (gEgo onControl: 1) $0002)
				(if
				(and (< (gEgo heading?) 180) (> (gEgo heading?) 0))
					(gEgo
						baseSetter: (ScriptID 0 1)
						setPri: -1
						illegalBits: -16384
					)
					(= local0 0)
				else
					(gEgo baseSetter: 0 illegalBits: -32768 setPri: 12)
					(= local0 1)
				)
			)
		)
		(super doit:)
	)
	
	(method (dispose)
		(DisposeScript 991)
		(super dispose:)
	)
	
	(method (handleEvent pEvent)
		(return
			(cond 
				((pEvent claimed?) (return 1))
				(
				(and (== (pEvent type?) evSAID) (Said 'look>'))
					(cond 
						((or (Said '/dirt') (Said '<down')) (Print 90 1))
						((Said '/wall') (Print 90 2))
						((or (Said '/sky') (Said '<up')) (Print 90 3))
						((Said '/stair') (Print 90 4))
						((Said '/stair') (Print 90 5))
						((Said '/door') (Print 90 6))
						((Said '/door') (Print 90 7))
						(
						(or (Said '[<around][/room]') (Said '/castle,tower')) (Print 90 8))
						(else (pEvent claimed: 0))
					)
				)
			)
		)
	)
)

(instance fallingDown of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(User canInput: 0 canControl: 0)
				(gEgo
					view: 44
					loop: 0
					illegalBits: 0
					setPri: 9
					setCycle: End
					setMotion:
						((Jump new:)
							y: 145
							gx: 2
							gy: (if (>= (gEgo y?) 145) -5 else 5)
						)
						self
				)
				(fallMusic play:)
			)
			(1
				(gEgo view: 41 loop: 0 cel: 255 setCycle: End self)
			)
			(2
				(gEgo
					view: 4
					baseSetter: 0
					illegalBits: -16384
					setPri: -1
					setCycle: Walk
				)
				(= local0 0)
				(fallMusic dispose:)
				(User canInput: 1 canControl: 1)
				(client setScript: 0)
				(= state -1)
			)
		)
	)
)

(instance fallingToDeath of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(User canInput: 0 canControl: 0)
				(= global105 16)
				(gEgo
					view: 44
					loop: 2
					illegalBits: 0
					setPri: 9
					setMotion: ((Jump new:) y: 145 gx: 2 gy: 5) self
				)
				(fallMusic play:)
			)
			(1
				(gEgo view: 42)
				(proc0_18)
				(ShakeScreen 5)
				(= seconds 2)
			)
			(2
				(gSounds eachElementDo: #stop 0)
				(= global127 1)
				(client setScript: 0)
			)
		)
	)
)
