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

(public
	Room17 0
)
(synonyms
	(kiss kiss embrace)
	(ghoul ghoul ghoul man ghoul ghoul)
)

(local
	newAct
)
(instance zTheme of Sound
	(properties
		number 21
	)
)

(instance doorSound of Sound
	(properties)
)

(instance door of Prop
	(properties)
	
	(method (cue)
		(if (!= (door cel?) (door lastCel:))
			(self setCycle: End self)
		else
			(proc0_9)
			(gRoom newRoom: 68)
		)
	)
)

(instance Room17 of Rm
	(properties
		picture 17
	)
	
	(method (init)
		(= north 11)
		(= south 23)
		(= east 18)
		(= west 16)
		(= horizon 100)
		(= global101 0)
		(gEgo edgeHit: 0)
		(self setRegions: 508)
		(super init:)
		(if global100 (gRoom overlay: 117))
		(if (and global100 (not (gEgo has: 7)))
			(Load rsVIEW 270)
			(Load rsVIEW 36)
			(Load rsVIEW 35)
			(= newAct (Act new:))
			(newAct
				view: 270
				cel: 0
				loop: 0
				posn: 146 145
				setPri: 10
				illegalBits: 0
				ignoreActors:
				setScript: z6Actions
				init:
				hide:
			)
		)
		(door
			view: 610
			loop: 0
			cel: 0
			posn: 147 144
			stopUpd:
			init:
		)
		(switch gPrevRoomNum
			(16
				(if (<= (gEgo y?) 120)
					(gEgo x: 1 y: 120)
				else
					(gEgo x: 1)
				)
			)
			(18
				(if (<= (gEgo y?) 120)
					(gEgo x: 318 y: 120)
				else
					(gEgo x: 318)
				)
			)
			(23 (gEgo posn: (gEgo x?) 188))
			(11
				(if (< (gEgo x?) 160)
					(gEgo x: 42 y: (+ horizon (gEgo yStep?) 1))
				else
					(gEgo x: 267 y: (+ horizon (gEgo yStep?) 1))
				)
			)
			(68
				(gEgo loop: 2 x: 161 y: 151)
			)
			(0 (gEgo x: 290 y: 160))
		)
		(gEgo setPri: -1 view: 2 xStep: 3 yStep: 2 init:)
	)
	
	(method (handleEvent pEvent)
		(if (pEvent claimed?) (return 1))
		(return
			(if (== (pEvent type?) evSAID)
				(cond 
					(
						(or
							(Said 'look/around')
							(Said 'look/room')
							(Said 'look[<around][/!*]')
						)
						(Print 17 0)
					)
					((Said 'look>')
						(cond 
							((Said '/grave,gravestone,gravestone') (Print 17 1))
							((Said '/fence,wall') (Print 17 2))
							((Said '/cottage') (Print 17 3))
							((Said '/cemetery') (Print 17 4))
							((Said '/door') (Print 17 5))
							((Said '/window')
								(cond 
									(
										(or
											(gEgo inRect: 96 142 128 148)
											(gEgo inRect: 194 142 229 148)
										)
										(Print 17 6)
									)
									(
										(or
											(gEgo inRect: 70 151 124 157)
											(gEgo inRect: 193 154 260 159)
										)
										(Print 17 7)
									)
									(else (Print 800 1))
								)
							)
							((Said '/stair') (Print 17 8))
							((or (Said 'look/bush') (Said 'look/bush')) (Print 17 9))
						)
					)
					((Said 'break/window') (Print 17 10))
					((Said 'break/door') (Print 17 11))
					((Said 'open/door')
						(if (gEgo inRect: 139 140 173 153)
							(proc0_8)
							(gEgo loop: 3 setPri: 11)
							(doorSound number: 300 loop: 1 play: door)
							(door setCycle: End)
						else
							(Print 800 1)
						)
					)
					((Said 'close/door') (Print 17 12))
					((Said 'open/window') (Print 17 13))
					((Said 'unlatch/door') (Print 17 14))
					((Said 'bang/door')
						(if (gEgo inRect: 139 140 173 153)
							(Print 17 15)
						else
							(Print 800 1)
						)
					)
				)
			else
				0
			)
		)
	)
	
	(method (newRoom newRoomNumber)
		(if (== (gEgo view?) 2)
			(proc0_9)
			(gEgo setPri: -1)
			(super newRoom: newRoomNumber)
		)
	)
)

(instance z6Actions of Script
	(properties)
	
	(method (doit)
		(super doit:)
		(if
		(and (gEgo inRect: 141 146 175 149) (== state 0))
			(proc0_8)
			(z6Actions changeState: 1)
		)
	)
	
	(method (changeState newState)
		(switch (= state newState)
			(1
				(newAct show: setLoop: 0 cel: 255 setCycle: End self)
			)
			(2
				(newAct hide:)
				(zTheme play: self)
				(gEgo view: 35 cel: 255 setCycle: End self)
			)
			(3
				(newAct view: 270 show: cycleSpeed: 1 setCycle: Beg)
				(gEgo view: 36 cel: 255 setMotion: 0 setCycle: End self)
			)
			(4
				(gEgo view: 46 cel: 255 setCycle: End self)
			)
			(5
				(newAct hide:)
				(= global120 (Print 17 16 67 -1 20 88))
				(gEgo
					view: 45
					x: 160
					setCycle: Walk
					setMotion: MoveTo 160 230
				)
			)
			(6 (= global127 1))
		)
	)
)
