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

(public
	Room60 0
)
(synonyms
	(room bedroom)
)

(local
	newView_2
	local1
	newView
)
(instance Room60 of Rm
	(properties
		picture 60
		style $0010
	)
	
	(method (init)
		(Load rsVIEW 648)
		(Load rsVIEW 529)
		(self setRegions: 603)
		(super init:)
		(if global100
			((View new:)
				view: 648
				loop: 1
				posn: 163 90
				setPri: 5
				addToPic:
			)
			((Prop new:)
				view: 536
				loop: 2
				posn: 267 75
				init:
				setPri: 13
				setCycle: Fwd
			)
		)
		(if (> global134 4)
			(Load rsVIEW 529)
			(Load rsVIEW 77)
			((= newView (View new:))
				view: 529
				loop: 1
				cel: 0
				posn: 161 137
				init:
				stopUpd:
			)
			((= newView_2 (View new:))
				view: 529
				loop: 0
				cel: 0
				posn: 161 33
				init:
				stopUpd:
				setPri: (- (newView priority?) 1)
			)
			(= local1 1)
		)
		(if (== gPrevRoomNum 68)
			(gEgo posn: 68 159 view: 4 setStep: 4 2 init:)
		else
			(gEgo posn: 161 59 view: 77 setStep: 4 2 init:)
			(self setScript: climbDown)
		)
		(if
			(and
				(< 0 global134)
				(< global134 255)
				(== global133 gCurRoomNum)
			)
			(proc0_10 603 -1)
		)
	)
	
	(method (doit)
		(super doit:)
		(if (& (gEgo onControl: 0) $0040)
			(gRoom newRoom: 68)
		)
	)
	
	(method (handleEvent pEvent &tmp gInvSaidMe)
		(return
			(cond 
				((pEvent claimed?) (return 1))
				((== (pEvent type?) evSAID)
					(cond 
						(
							(or
								(Said 'look[<around][/!*]')
								(Said 'look[<around]/room')
							)
							(Print 60 0)
							(if (== global134 3) (Print 60 1))
						)
						((Said 'look>')
							(cond 
								((Said '<under/bed') (Print 60 2))
								((Said '/bed') (Print 60 3))
								((Said '/window')
									(if (gEgo inRect: 137 114 191 124)
										(Print 60 4)
									else
										(Print 800 1)
									)
								)
								((Said '/fireplace') (Print 60 5))
								((Said '/carpet,carpet') (Print 60 6))
								((Said '<in/chest,dresser,drawer') (Print 60 7))
								((Said '/chandelier') (Print 60 8))
								((Said '/chest,dresser') (Print 60 9))
								((Said '/wall') (Print 60 10))
								((or (Said '/dirt') (Said '<down')) (Print 60 11))
								((Said '/ceiling') (if local1 (Print 60 12) else (Print 60 13)))
								((Said '<in,up/trapdoor') (if local1 (Print 60 14) else (Print 60 15)))
								((Said '<up') (if local1 (Print 60 16) else (proc0_15)))
								((Said '/ladder') (if local1 (Print 60 17) else (Print 60 18)))
								((Said '/trapdoor') (if local1 (Print 60 19) else (Print 60 20)))
							)
						)
						((Said 'open/trapdoor') (if local1 (Print 60 21) else (Print 60 22)))
						((Said 'close/trapdoor') (if local1 (Print 60 23) else (Print 60 24)))
						((Said 'open/chest,dresser,drawer') (Print 60 7))
						(
							(or
								(Said 'lay,sleep[<in,down,on][/bed]')
								(Said 'get<in,in/bed')
							)
							(Print 60 25)
						)
						((Said 'climb[/ladder]')
							(if local1
								(if (< (gEgo distanceTo: newView) 10)
									(if (>= (gEgo y?) (newView y?))
										(gEgo setScript: climbLadder)
									else
										(Print 60 26)
									)
								else
									(Print 800 1)
								)
							else
								(Print 60 27)
							)
						)
						((Said 'climb') (Print 60 28))
						((Said 'move>') (Print 60 29))
					)
					(if
						(and
							(== global134 3)
							(== global225 1)
							(== (pEvent claimed?) 0)
						)
						(cond 
							((Said 'look/ghost,fishwife,fishwife,fishwife') (Print 60 1))
							((Said 'look/chair') (Print 60 30))
							(
								(or
									(Said 'converse/ghost,fishwife,fishwife,fishwife')
									(Said 'converse[/!*]')
								)
								(Print 60 31)
							)
							((Said 'get/ghost,fishwife,fishwife,fishwife') (Print 60 32))
							(
							(Said 'get,capture/ghost,fishwife,fishwife,fishwife') (Print 60 33))
							((Said 'kill/ghost,fishwife,fishwife,fishwife') (Print 60 34))
							(
								(or
									(Said 'kiss/ghost,fishwife,fishwife,fishwife')
									(Said 'kiss[/!*]')
								)
								(Print 60 35)
							)
							((Said 'help/ghost,fishwife,fishwife,fishwife') (Print 60 36))
							((Said 'deliver>')
								(if (gEgo inRect: 60 118 105 152)
									(cond 
										(
											(and
												(= gInvSaidMe (gInv saidMe:))
												(gEgo has: (gInv indexOf: gInvSaidMe))
											)
											(if (== (gInv indexOf: gInvSaidMe) 28)
												(gEgo put: 28 -1)
												(gGame changeScore: 2)
												(Print 60 37)
												(proc0_10 603 -1)
											else
												(Print 60 38)
											)
										)
										(gInvSaidMe (pEvent claimed: 0))
									)
								else
									(Print 800 1)
									(pEvent claimed: 1)
								)
							)
						)
					)
				)
			)
		)
	)
)

(instance climbLadder of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(proc0_8)
				(gEgo
					ignoreActors: 1
					illegalBits: 0
					setMotion: MoveTo 161 140 self
				)
			)
			(1
				(gEgo view: 77 loop: 0 setStep: 4 3 setCycle: End self)
			)
			(2
				(gEgo
					loop: 1
					cel: 0
					setPri: 12
					setCycle: Walk
					moveSpeed: 2
					cycleSpeed: 2
					setMotion: MoveTo 161 48 self
				)
			)
			(3
				(= global204 0)
				(= global205 1)
				(client setScript: 0)
				(gEgo cycleSpeed: 0 moveSpeed: 0)
				(gRoom newRoom: 63)
			)
		)
	)
)

(instance climbDown of Script
	(properties)
	
	(method (init param1)
		(super init: param1)
	)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(proc0_8)
				(gEgo
					view: 77
					loop: 1
					illegalBits: 0
					setStep: 3 3
					moveSpeed: 2
					cycleSpeed: 2
					setPri: 10
					setCycle: Rev
					setMotion: MoveTo 161 140 self
				)
			)
			(1
				(gEgo
					view: 4
					loop: 3
					illegalBits: -32768
					setCycle: Walk
					cycleSpeed: 0
					moveSpeed: 0
					setPri: -1
					setStep: 4 2
				)
				(proc0_9)
				(= global205 0)
			)
		)
	)
)
