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

(public
	Room11 0
)

(local
	[newProp 12]
	local12
	local13
	newProp_2
	newProp_3
	newProp_4
	newProp_5
	newProp_6
	newBlk
)
(instance walkingMusic of Sound
	(properties
		number 64
	)
)

(instance caughtMusic of Sound
	(properties
		number 65
	)
)

(instance Room11 of Rm
	(properties
		picture 11
	)
	
	(method (init)
		(= north 5)
		(= south 17)
		(= east 12)
		(= west 10)
		(= horizon 86)
		(= global101 0)
		(Load rsSOUND 65)
		(gEgo edgeHit: 0)
		(super init:)
		(if global100 (gRoom overlay: 111))
		(self setRegions: 509)
		(= local12 1)
		(while (<= local12 11)
			(= [newProp local12] (Prop new:))
			(++ local12)
		)
		([newProp 1]
			view: 692
			loop: 0
			cel: 0
			posn: 145 76
			setPri: 4
			cycleSpeed: 1
			ignoreActors:
			init:
			stopUpd:
		)
		([newProp 2]
			view: 692
			loop: 1
			cel: 0
			posn: 152 83
			setPri: 7
			cycleSpeed: 1
			ignoreActors:
			init:
			stopUpd:
		)
		([newProp 3]
			view: 692
			loop: 2
			cel: 0
			posn: 167 83
			setPri: 7
			cycleSpeed: 1
			ignoreActors:
			init:
			stopUpd:
		)
		([newProp 4]
			view: 692
			loop: 3
			cel: 0
			posn: 196 70
			setPri: 7
			cycleSpeed: 1
			ignoreActors:
			init:
			stopUpd:
		)
		([newProp 5]
			view: 692
			loop: 4
			cel: 0
			posn: 213 66
			setPri: 7
			cycleSpeed: 1
			ignoreActors:
			init:
			stopUpd:
		)
		([newProp 6]
			view: 692
			loop: 5
			cel: 0
			posn: 258 76
			setPri: 7
			cycleSpeed: 1
			ignoreActors:
			init:
			stopUpd:
		)
		([newProp 7]
			view: 692
			loop: 6
			cel: 0
			posn: 305 70
			setPri: 7
			cycleSpeed: 1
			ignoreActors:
			init:
			stopUpd:
		)
		([newProp 8]
			view: 693
			loop: 0
			cel: 0
			posn: 81 105
			setPri: 11
			cycleSpeed: 1
			ignoreActors:
			init:
			stopUpd:
		)
		([newProp 9]
			view: 693
			loop: 1
			cel: 0
			posn: 242 86
			setPri: 11
			cycleSpeed: 1
			ignoreActors:
			init:
			stopUpd:
		)
		([newProp 10]
			view: 693
			loop: 2
			cel: 0
			posn: 256 85
			setPri: 11
			cycleSpeed: 1
			ignoreActors:
			init:
			stopUpd:
		)
		([newProp 11]
			view: 694
			loop: 0
			cel: 0
			posn: 281 65
			setPri: 11
			cycleSpeed: 1
			ignoreActors:
			init:
			stopUpd:
		)
		(= newProp_2 (Prop new:))
		(= newProp_3 (Prop new:))
		(= newProp_4 (Prop new:))
		(= newProp_5 (Prop new:))
		(= newProp_6 (Prop new:))
		(newProp_2
			isExtra: 1
			view: 689
			loop: 2
			cel: 2
			posn: 105 62
			setPri: 10
			setCycle: Fwd
			cycleSpeed: 2
			ignoreActors:
			init:
		)
		(newProp_3
			isExtra: 1
			view: 689
			loop: 3
			cel: 3
			posn: 160 83
			setPri: 7
			setCycle: Fwd
			cycleSpeed: 2
			ignoreActors:
			init:
		)
		(newProp_4
			isExtra: 1
			view: 689
			loop: 4
			cel: 2
			posn: 249 83
			setPri: 10
			setCycle: Fwd
			cycleSpeed: 2
			ignoreActors:
			init:
		)
		(newProp_5
			isExtra: 1
			view: 689
			loop: 5
			cel: 3
			posn: 280 52
			setPri: 10
			setCycle: Fwd
			cycleSpeed: 2
			ignoreActors:
			init:
		)
		(newProp_6
			isExtra: 1
			view: 689
			loop: 6
			cel: 0
			posn: 314 48
			setPri: 10
			setCycle: Fwd
			cycleSpeed: 2
			ignoreActors:
			init:
		)
		(switch gPrevRoomNum
			(10
				(if (<= (gEgo y?) horizon)
					(gEgo posn: 1 (+ horizon 2))
				else
					(gEgo posn: 1 (gEgo y?))
				)
			)
			(12 (gEgo posn: 318 (gEgo y?)))
			(17
				(cond 
					((>= (gEgo x?) 277) (gEgo x: 277 y: 188))
					((<= (gEgo x?) 103) (gEgo x: 103 y: 188))
					(else (gEgo y: 188))
				)
			)
			(5
				(gEgo posn: 148 (+ horizon 2))
			)
			(0 (gEgo x: 318 y: 160))
		)
		(walkingMusic play:)
		(gEgo view: 2 init:)
		((= newBlk (Blk new:))
			left: 212
			top: 103
			right: 224
			bottom: 106
		)
		(gEgo observeBlocks: newBlk)
	)
	
	(method (doit)
		(super doit:)
		(if
		(and (not global112) (== (gRoom script?) 0))
			(cond 
				((& (gEgo onControl: 0) $0002) (= local12 8) (= local13 3) (gRoom setScript: grabbed))
				((& (gEgo onControl: 0) $0004) (= local12 1) (= local13 1) (gRoom setScript: grabbed))
				((& (gEgo onControl: 0) $0008)
					(= local12 2)
					(gRoom setScript: grabbed)
					(= local13 2)
					(gRoom setScript: grabbed)
				)
				((& (gEgo onControl: 0) $0010) (= local12 3) (= local13 1) (gRoom setScript: grabbed))
				((& (gEgo onControl: 0) $0020) (= local12 4) (= local13 1) (gRoom setScript: grabbed))
				((& (gEgo onControl: 0) $0040) (= local12 5) (= local13 1) (gRoom setScript: grabbed))
				((& (gEgo onControl: 0) $0200) (= local12 9) (= local13 1) (gRoom setScript: grabbed))
				((& (gEgo onControl: 0) $2000) (= local12 6) (= local13 2) (gRoom setScript: grabbed))
				((& (gEgo onControl: 0) $0400)
					(= local12 10)
					(= local13 2)
					(gRoom setScript: grabbed)
				)
				((& (gEgo onControl: 0) $1000)
					(= local12 11)
					(= local13 3)
					(gRoom setScript: grabbed)
				)
				((& (gEgo onControl: 0) $0800) (= local12 7) (= local13 2) (gRoom setScript: grabbed))
			)
		)
	)
	
	(method (handleEvent pEvent)
		(if (pEvent claimed?) (return 1))
		(return
			(if
				(and
					(== (pEvent type?) evSAID)
					(or
						(Said 'look/around')
						(Said 'look/room')
						(Said 'look[<around][/!*]')
					)
				)
				(Print 11 0)
			else
				0
			)
		)
	)
)

(instance grabbed of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(walkingMusic dispose:)
				(caughtMusic play:)
				(proc0_8)
				([newProp local12] startUpd: setCycle: CT local13 1 self)
			)
			(1
				(gEgo dispose:)
				([newProp local12] setCycle: End self)
			)
			(2
				(switch (Random 1 6)
					(1 (Print 11 1))
					(2 (Print 11 2))
					(3 (Print 11 3))
					(4 (Print 11 4))
					(5 (Print 11 5))
					(6 (Print 11 6))
				)
				(= seconds 5)
			)
			(3 (= global127 1))
		)
	)
)
