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

(public
	Room73 0
)

(local
	newView
)
(procedure (localproc_0402 param1)
	(if param1
		((= newView (View new:))
			view: 800
			loop: 1
			posn: 108 132
			init:
			setPri: 15
			stopUpd:
		)
	else
		(newView dispose:)
		(= newView 0)
	)
)

(instance Room73 of Rm
	(properties
		picture 73
		style $0010
	)
	
	(method (init)
		(Load rsVIEW 800)
		(Load rsVIEW 904)
		(Load rsVIEW 950)
		(super init:)
		(self setRegions: 605)
		(= global101 1)
		(= south 76)
		(gEgo view: 904 xStep: 4 yStep: 1)
		(if (!= gPrevRoomNum 77)
			(gEgo
				posn: 138 179
				init:
				priority: (CoordPri (gEgo y?))
			)
			(proc0_10 605 1)
		else
			(gEgo view: 950 posn: 290 163 init:)
			(if (not (proc0_20)) (localproc_0402 1))
			(= global126 0)
			(gEgo setScript: crawl)
		)
	)
	
	(method (doit)
		(super doit:)
		(if
			(and
				(& (gEgo onControl:) $0002)
				(< (gEgo heading?) 180)
				(!= (gEgo script?) crawl)
			)
			(gEgo setScript: crawl)
		)
		(cond 
			((and newView (proc0_20)) (localproc_0402 0))
			((and (not newView) (not (proc0_20))) (localproc_0402 1))
		)
	)
	
	(method (handleEvent pEvent)
		(return
			(cond 
				((pEvent claimed?) (return 1))
				((== (pEvent type?) evSAID)
					(cond 
						(
						(or (Said 'crawl,exit/cave') (Said 'crawl[/!*]'))
							(if (not (& (gEgo onControl:) $0002))
								(Print 800 1)
							)
						)
						((Said 'look,find/exit,exit') (Print 73 0))
						((Said 'look<out') (Print 73 1))
						((or (Said 'look/sky') (Said 'look<up[/!*]')) (if global100 (Print 73 2) else (Print 73 3)))
					)
				)
			)
		)
	)
	
	(method (newRoom newRoomNumber)
		(if (== newRoomNumber 77)
			((ScriptID 605) keep: 0)
			(= global189 0)
		)
		(super newRoom: newRoomNumber)
	)
)

(instance crawl of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(proc0_8)
				(gEgo illegalBits: 0)
				(if (> (gEgo heading?) 180)
					(self changeState: 10)
				else
					(self changeState: 20)
				)
			)
			(10
				(gEgo
					view: 950
					setLoop: 3
					xStep: 2
					setCycle: Walk
					setMotion: MoveTo 255 164 self
				)
			)
			(11
				(gEgo cel: 5 setLoop: 1 cycleSpeed: 1 setCycle: Beg self)
			)
			(12
				(gEgo
					view: 904
					setLoop: -1
					xStep: 4
					cycleSpeed: 0
					setCycle: Walk
					illegalBits: -32768
				)
				(proc0_9)
				(client setScript: 0)
				(if (proc0_20) (proc0_10 605 3))
			)
			(20
				(if (proc0_20) (proc0_10 605 2))
				(gEgo
					view: 950
					setLoop: 0
					cel: 255
					xStep: 2
					setCycle: End self
				)
			)
			(21
				(gEgo
					illegalBits: 0
					setLoop: 2
					setCycle: Walk
					setMotion: MoveTo (gEgo x?) 164 self
				)
			)
			(22
				(gEgo setMotion: MoveTo 296 164 self)
			)
			(23
				(gEgo illegalBits: -32768)
				(= global205 1)
				(= global204 0)
				(gRoom newRoom: 77)
			)
		)
	)
)
