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

(public
	Room5 0
)

(local
	[newProp 9]
	local9
	newProp_2
	local11
	newProp_3
)
(instance gMusic of Sound
	(properties
		number 65
	)
)

(instance walkingMusic of Sound
	(properties
		number 64
	)
)

(instance Room5 of Rm
	(properties
		picture 5
	)
	
	(method (init)
		(= north 29)
		(= south 11)
		(= east 6)
		(= west 4)
		(= horizon 86)
		(= global101 0)
		(Load rsSOUND 65)
		(gEgo edgeHit: 0)
		(self setRegions: 509)
		(super init:)
		(if global100 (gRoom overlay: 105))
		(= local9 1)
		(while (<= local9 7)
			(= [newProp local9] (Prop new:))
			(++ local9)
		)
		([newProp 1]
			view: 690
			loop: 0
			cel: 0
			cycleSpeed: 1
			ignoreActors:
			posn: 270 81
			setPri: 15
			init:
			stopUpd:
		)
		([newProp 2]
			view: 690
			loop: 1
			cel: 0
			cycleSpeed: 1
			ignoreActors:
			posn: 270 81
			setPri: 15
			init:
			stopUpd:
		)
		([newProp 3]
			view: 690
			loop: 2
			cel: 0
			cycleSpeed: 1
			ignoreActors:
			posn: 291 78
			setPri: 8
			init:
			stopUpd:
		)
		([newProp 4]
			view: 690
			loop: 3
			cel: 0
			cycleSpeed: 1
			ignoreActors:
			posn: 311 150
			setPri: 7
			init:
			stopUpd:
		)
		([newProp 5]
			view: 690
			loop: 3
			cel: 0
			cycleSpeed: 1
			ignoreActors:
			posn: 269 89
			setPri: 2
			init:
			stopUpd:
		)
		([newProp 6]
			view: 691
			loop: 0
			cel: 0
			cycleSpeed: 1
			ignoreActors:
			posn: 115 76
			setPri: 8
			init:
			stopUpd:
		)
		([newProp 7]
			view: 691
			loop: 1
			cel: 0
			cycleSpeed: 1
			ignoreActors:
			posn: 235 162
			setPri: 15
			init:
			stopUpd:
		)
		(= newProp_2 (Prop new:))
		(= newProp_3 (Prop new:))
		(newProp_2
			isExtra: 1
			view: 689
			loop: 0
			cel: 3
			ignoreActors:
			posn: 208 57
			setPri: 15
			setCycle: Fwd
			cycleSpeed: 4
			init:
		)
		(newProp_3
			isExtra: 1
			view: 689
			loop: 1
			cel: 0
			ignoreActors:
			posn: 233 44
			setPri: 15
			setCycle: Fwd
			cycleSpeed: 3
			init:
		)
		(switch gPrevRoomNum
			(4
				(if (<= (gEgo y?) 135)
					(gEgo posn: 1 120)
				else
					(gEgo posn: 1 (gEgo y?))
				)
			)
			(6
				(if (< (gEgo y?) 133)
					(gEgo posn: 318 133)
				else
					(gEgo posn: 318 (gEgo y?))
				)
			)
			(11
				(if (> (gEgo x?) 207)
					(gEgo posn: 207 187)
				else
					(gEgo posn: (gEgo x?) 187)
				)
			)
			(29
				(if (> (gEgo x?) 272) (gEgo x: 258))
				(gEgo posn: (gEgo x?) (+ horizon (gEgo yStep?)))
			)
			(0 (gEgo x: 290 y: 161))
		)
		(walkingMusic play:)
		(gEgo view: 2 init:)
	)
	
	(method (doit)
		(super doit:)
		(if
		(and (not global112) (== (gRoom script?) 0))
			(cond 
				((& (gEgo onControl: 0) $0040) (= local11 3) (= local9 1) (gRoom setScript: grabbed))
				((& (gEgo onControl: 0) $0020) (= local11 3) (= local9 2) (gRoom setScript: grabbed))
				((& (gEgo onControl: 0) $0010) (= local11 3) (= local9 3) (gRoom setScript: grabbed))
				((& (gEgo onControl: 0) $0004) (= local11 1) (= local9 7) (gRoom setScript: grabbed))
				((& (gEgo onControl: 0) $0400) (= local11 1) (= local9 4) (gRoom setScript: grabbed))
				((& (gEgo onControl: 0) $0200) (= local11 1) (= local9 5) (gRoom setScript: grabbed))
				((& (gEgo onControl: 0) $0002) (= local11 2) (= local9 6) (gRoom setScript: grabbed))
			)
		)
	)
	
	(method (handleEvent pEvent)
		(if (pEvent claimed?) (return 1))
		(return
			(if (== (pEvent type?) evSAID)
				(cond 
					(
						(or
							(Said 'look/room')
							(Said 'look/around')
							(Said 'look[<around][/!*]')
						)
						(Print 5 0)
					)
					((Said 'look/cottage') (Print 5 1))
					((Said 'look/door') (Print 5 2))
					((Said 'look/window')
						(if (gEgo inRect: 0 130 32 138)
							(Print 5 3)
						else
							(Print 5 4)
						)
					)
					((Said 'break/window') (Print 5 5))
					((Said 'open/window') (Print 5 6))
				)
			else
				0
			)
		)
	)
)

(instance grabbed of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(walkingMusic dispose:)
				(gMusic play:)
				(proc0_8)
				([newProp local9] startUpd: setCycle: CT local11 1 self)
			)
			(1
				(gEgo dispose:)
				([newProp local9] setCycle: End self)
			)
			(2
				(switch (Random 1 6)
					(1 (Print 5 7))
					(2 (Print 5 8))
					(3 (Print 5 9))
					(4 (Print 5 10))
					(5 (Print 5 11))
					(6 (Print 5 12))
				)
				(= seconds 5)
			)
			(3 (= global127 1))
		)
	)
)
