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

(public
	Room63 0
)

(local
	local0
	newProp
	newView
	newView_2
)
(instance Room63 of Rm
	(properties
		picture 63
		style $0010
	)
	
	(method (init)
		(Load rsPIC 60)
		(Load rsVIEW 44)
		(Load rsVIEW 40)
		(Load rsVIEW 77)
		(Load rsVIEW 42)
		(Load rsVIEW 537)
		(Load rsVIEW 529)
		(Load rsVIEW 648)
		(Load rsSCRIPT 991)
		(Load rsSOUND 52)
		(self setRegions: 603)
		(super init:)
		((View new:)
			view: 648
			loop: 5
			cel: 0
			posn: 280 104
			setPri: 6
			addToPic:
		)
		((Prop new:)
			view: 536
			loop: 1
			cel: 0
			posn: 224 123
			init:
			setPri: 15
			setCycle: Fwd
		)
		((View new:)
			view: 537
			loop: 3
			cel: 0
			posn: 167 125
			addToPic:
		)
		((= newProp (Prop new:))
			view: 537
			loop: 0
			cel: 0
			posn: 167 115
			init:
			stopUpd:
		)
		((View new:)
			view: 537
			loop: 1
			cel: 0
			posn: 165 157
			setPri: 11
			ignoreActors: 1
			addToPic:
		)
		(if (== global134 5) (Load rsVIEW 209))
		(gEgo setScript: climbIn)
		(if
			(and
				(< 0 global134)
				(< global134 255)
				(== global133 gCurRoomNum)
			)
			(proc0_10 603 -1)
		)
	)
	
	(method (doit)
		(super doit:)
		(if
			(and
				(& (gEgo onControl: 1) $0004)
				(not (gEgo script?))
			)
			(gEgo setScript: fallDead)
		)
	)
	
	(method (dispose)
		(DisposeScript 991)
		(super dispose:)
	)
	
	(method (handleEvent pEvent)
		(return
			(cond 
				((pEvent claimed?) (return 1))
				((== (pEvent type?) evSAID)
					(cond 
						((Said '/box') (Print 63 0))
						((Said 'get,open,look/birdcage,birdcage') (Print 63 1))
						((Said 'play/boy,ghost')
							(if (== gCurRoomNum global133)
								(Print 63 2)
							else
								(Print 63 3)
							)
						)
						((Said 'look>')
							(cond 
								((Said '<in/chest')
									(if (gEgo inRect: 141 120 193 129)
										(gEgo setMotion: 0)
										(cond 
											((not local0)
												(if (== global134 5)
													(Print 63 4)
												else
													(Print 63 5)
												)
											)
											((== ((gInv at: 26) owner?) 63)
												(Print 63 6)
												(gEgo get: 26)
												(= global182 1)
												(gGame changeScore: 2)
											)
											(else (Print 63 7))
										)
									else
										(Print 800 1)
									)
								)
								((Said '/chest')
									(if (== global134 5)
										(Print 63 4)
									else
										(Print 63 8)
									)
								)
								((Said '<in/trapdoor')
									(if (gEgo inRect: 135 138 182 148)
										(Print 63 9)
									else
										(Print 63 10)
									)
								)
								((or (Said '/trapdoor') (Said '<down')) (Print 63 11))
								((Said '/ladder') (Print 63 12))
								((Said '/window') (Print 63 13))
								((Said '/junk') (Print 63 14))
								((Said '/wall') (Print 63 15))
								((Said '/dirt') (Print 63 16))
								((Said '/ghost')
									(if (== global133 gCurRoomNum)
										(Print 63 17)
									else
										(Print 63 18)
									)
								)
								((Said '[<around][/room]') (Print 63 19))
							)
						)
						((Said 'climb[/ladder,down]')
							(if (gEgo inRect: 131 138 205 159)
								(gEgo setScript: climbDown)
							else
								(Print 800 1)
							)
						)
						((Said 'close/trapdoor') (Print 63 20))
						((Said 'open/trapdoor') (Print 63 21))
						((Said 'get/chest') (Print 63 22))
						((Said 'get,move,detach/ghost')
							(if (== global133 gCurRoomNum)
								(Print 63 23)
							else
								(Print 63 18)
							)
						)
						((Said 'close/chest')
							(if local0
								(newProp setCycle: Beg)
								(= local0 0)
							else
								(Print 63 24)
							)
						)
						((Said 'open/chest')
							(cond 
								(local0 (Print 63 25))
								((== global134 5) (Print 63 26))
								((gEgo inRect: 141 120 193 129) (gEgo setMotion: 0) (newProp setCycle: End) (= local0 1))
								(else (Print 800 1))
							)
						)
					)
				)
			)
		)
	)
)

(instance climbDown of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(proc0_8)
				(gEgo illegalBits: 0 setMotion: MoveTo 196 149 self)
			)
			(1
				(gEgo
					setMotion: 0
					view: 40
					loop: 1
					cel: 255
					setCycle: End self
				)
			)
			(2
				(gEgo
					view: 77
					loop: 2
					cel: 255
					setPri: 12
					setCycle: End self
				)
			)
			(3
				(= global204 0)
				(= global205 1)
				(gRoom newRoom: 60)
			)
		)
	)
)

(instance climbIn of Script
	(properties)
	
	(method (init param1)
		(super init: param1)
	)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(proc0_8)
				(gEgo
					posn: 196 150
					view: 77
					loop: 2
					setStep: 4 3
					setPri: 12
					setCycle: Beg self
					init:
				)
			)
			(1
				(gEgo
					view: 40
					moveSpeed: 0
					cycleSpeed: 0
					loop: 1
					setStep: 4 2
					setPri: -1
					setCel: 255
					setCycle: Beg self
				)
			)
			(2
				(gEgo view: 4 setCycle: Walk illegalBits: -32768)
				(client setScript: 0)
				(proc0_9)
			)
		)
	)
)

(instance fallSound of Sound
	(properties)
)

(instance fallDead of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(proc0_8)
				(fallSound number: 52 play:)
				(gEgo
					view: 44
					illegalBits: 0
					ignoreActors: 1
					setPri: (if (>= (gEgo priority?) 12) 11 else (gEgo priority?))
					setCycle: Fwd
					setStep: 5 5
					setLoop: (if (> (gEgo x?) 155) 1 else 0)
					setMotion: MoveTo 155 155 self
				)
			)
			(1
				(gEgo
					setLoop: (+ 2 (gEgo loop?))
					setMotion: MoveTo 155 222 self
				)
			)
			(2
				(gAddToPics eachElementDo: #dispose)
				(gCast eachElementDo: #hide)
				(gRoom drawPic: 60 6)
				((= newView (View new:))
					view: 529
					loop: 1
					cel: 0
					posn: 161 137
					ignoreActors: 1
					addToPic:
				)
				((= newView_2 (View new:))
					view: 529
					loop: 0
					cel: 0
					posn: 161 33
					setPri: (- (newView priority?) 1)
					addToPic:
				)
				(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
					)
				)
				(gEgo
					posn: 156 59
					setStep: 1 10
					show:
					setMotion: MoveTo 161 150 self
				)
			)
			(3
				(gEgo view: 40 setLoop: (- 2 (gEgo loop?)) setCel: 2)
				(= cycles 1)
			)
			(4
				(gSounds eachElementDo: #stop 0)
				(gEgo view: 42)
				(proc0_18)
				(ShakeScreen 10)
				(= seconds 5)
			)
			(5 (= global127 1))
		)
	)
)
