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

(public
	Room53 0
)
(synonyms
	(room bedroom cottage)
)

(local
	newView_18
	newView_19
	newView_20
	newView_21
	newView_22
	newView_23
	newView_24
	newView
	newView_2
	newView_3
	newView_4
	newView_5
	newView_6
	newView_7
	newView_8
	newView_9
	newView_10
	newView_11
	newView_12
	newView_13
	newView_14
	newView_15
	newView_16
	newView_17
	[local24 2]
	newAct
	local27
)
(instance Room53 of Rm
	(properties
		picture 53
		style $0010
	)
	
	(method (init)
		(Load rsVIEW 676)
		(Load rsVIEW 290)
		(self setRegions: 601)
		(= global189 1)
		(super init:)
		((View new:)
			view: 676
			loop: 3
			cel: 0
			posn: 230 76
			setPri: 4
			addToPic:
		)
		((View new:)
			view: 676
			loop: 3
			cel: 1
			posn: 42 87
			setPri: 10
			addToPic:
		)
		(if (or (== gPrevRoomNum 54) (== gPrevRoomNum 0))
			(gEgo
				posn: 72 131
				view: 4
				setStep: 4 2
				illegalBits: -32768
				init:
			)
		)
		(if global115 (self setScript: cleanBedroom))
		(if (not global102)
			(Load rsVIEW 675)
			(Load rsVIEW 676)
			(Load rsVIEW 63)
			(Load rsVIEW 678)
			(Load rsSOUND 62)
			((= newAct (Act new:))
				view: 290
				illegalBits: 0
				loop: 0
				setCycle: Walk
				posn: 72 1131
				illegalBits: 0
				ignoreActors: 1
				setCycle: Walk
				setScript: chaseEgo
				init:
			)
			((= newView (View new:))
				view: 676
				loop: 0
				cel: 0
				posn: 102 88
				ignoreActors: 1
				stopUpd:
				init:
			)
			((= newView_2 (View new:))
				view: 676
				loop: 0
				cel: 1
				posn: 261 124
				ignoreActors: 1
				stopUpd:
				init:
			)
			((= newView_3 (View new:))
				view: 676
				loop: 0
				cel: 2
				posn: 246 135
				ignoreActors: 1
				stopUpd:
				init:
			)
			((= newView_4 (View new:))
				view: 676
				loop: 0
				cel: 3
				posn: 101 111
				ignoreActors: 1
				stopUpd:
				init:
			)
			((= newView_5 (View new:))
				view: 676
				loop: 0
				cel: 4
				posn: 198 106
				ignoreActors: 1
				stopUpd:
				init:
			)
			((= newView_6 (View new:))
				view: 676
				loop: 0
				cel: 5
				posn: 97 149
				ignoreActors: 1
				stopUpd:
				init:
			)
			((= newView_7 (View new:))
				view: 676
				loop: 0
				cel: 6
				posn: 174 146
				ignoreActors: 1
				setPri: 13
				stopUpd:
				init:
			)
			((= newView_8 (View new:))
				view: 676
				loop: 1
				cel: 0
				posn: 275 149
				ignoreActors: 1
				setPri: 11
				stopUpd:
				init:
			)
			((= newView_9 (View new:))
				view: 676
				loop: 1
				cel: 1
				posn: 255 146
				ignoreActors: 1
				setPri: 11
				stopUpd:
				init:
			)
			((= newView_10 (View new:))
				view: 676
				loop: 1
				cel: 2
				posn: 201 146
				ignoreActors: 1
				setPri: 13
				stopUpd:
				init:
			)
			((= newView_11 (View new:))
				view: 676
				loop: 1
				cel: 3
				posn: 195 83
				ignoreActors: 1
				stopUpd:
				init:
			)
			((= newView_12 (View new:))
				view: 676
				loop: 2
				cel: 0
				posn: 182 125
				ignoreActors: 1
				stopUpd:
				init:
			)
			((= newView_13 (View new:))
				view: 676
				loop: 2
				cel: 1
				posn: 17 146
				ignoreActors: 1
				stopUpd:
				init:
			)
			((= newView_14 (View new:))
				view: 676
				loop: 2
				cel: 2
				posn: 24 136
				ignoreActors: 1
				stopUpd:
				init:
			)
			((= newView_15 (View new:))
				view: 676
				loop: 2
				cel: 3
				posn: 292 139
				ignoreActors: 1
				stopUpd:
				init:
			)
			((= newView_16 (View new:))
				view: 676
				loop: 2
				cel: 4
				posn: 264 133
				ignoreActors: 1
				stopUpd:
				init:
			)
			((= newView_17 (View new:))
				view: 676
				loop: 2
				cel: 5
				posn: 270 135
				ignoreActors: 1
				stopUpd:
				init:
			)
			((= newView_18 (View new:))
				view: 675
				loop: 0
				cel: 0
				posn: 128 92
				ignoreActors: 1
				stopUpd:
				init:
			)
			((= newView_19 (View new:))
				view: 675
				loop: 0
				cel: 1
				posn: 178 91
				ignoreActors: 1
				stopUpd:
				init:
			)
			((= newView_20 (View new:))
				view: 675
				loop: 0
				cel: 2
				posn: 130 117
				ignoreActors: 1
				stopUpd:
				init:
			)
			((= newView_21 (View new:))
				view: 675
				loop: 0
				cel: 3
				posn: 177 120
				ignoreActors: 1
				stopUpd:
				init:
			)
			((= newView_22 (View new:))
				view: 675
				loop: 0
				cel: 4
				posn: 237 120
				ignoreActors: 1
				stopUpd:
				init:
			)
			((= newView_23 (View new:))
				view: 675
				loop: 0
				cel: 5
				posn: 132 156
				ignoreActors: 1
				setPri: 13
				stopUpd:
				init:
			)
			((= newView_24 (View new:))
				view: 675
				loop: 0
				cel: 6
				posn: 173 156
				ignoreActors: 1
				setPri: 13
				stopUpd:
				init:
			)
		)
	)
	
	(method (doit)
		(super doit:)
		(if (& (gEgo onControl: 0) $0040)
			(gRoom newRoom: 54)
		)
	)
	
	(method (handleEvent pEvent)
		(super handleEvent: pEvent)
		(if
		(or (!= (pEvent type?) evSAID) (pEvent claimed?))
			(return)
		)
		(cond 
			((or (Said 'clean/room') (Said 'clean[/!*]'))
				(if (!= global102 1)
					(self setScript: cleanBedroom)
				else
					(Print 53 0)
				)
			)
			((Said 'look>')
				(cond 
					((Said '/bed') (Print 53 1))
					((Said '/stair') (Print 53 2))
					((Said '<under/bed') (Print 53 3))
					((Said '/window')
						(if (gEgo inRect: 211 125 271 146)
							(Print 53 4)
						else
							(Print 800 1)
						)
					)
					((Said '<in/chest,dresser,drawer') (Print 53 5))
					((Said '/chest,dresser') (Print 53 6))
					((Said '/mirror')
						(if (gEgo inRect: 217 142 295 161)
							(Print 53 7)
						else
							(proc0_13)
						)
					)
					((Said '/shelf') (Print 53 8))
					((Said '/wall') (Print 53 9))
					((or (Said '/dirt') (Said '<down')) (Print 53 10))
					((Said '/carpet,carpet') (Print 53 11))
					((Said 'look[<around][/room]')
						(Print
							(Format
								@global228
								53
								12
								(if (not global102)
									{My goodness, these dwarfs are sloppy!}
								else
									{_}
								)
							)
						)
					)
				)
			)
			(
				(or
					(Said 'create/bed')
					(Said 'dust,sweep[/room,dirt,furniture]')
				)
				(if global102 (Print 53 0) else (Print 53 13))
			)
			((Said 'close,close/drawer,dresser,chest') (Print 53 14))
			((Said 'open/chest,dresser,drawer') (Print 53 5))
			(
				(or
					(Said 'get<in,on/bed')
					(Said 'sleep,lay[<down,on,in]')
				)
				(Print 53 15)
			)
		)
	)
)

(instance cleanBedroom of Script
	(properties)
	
	(method (init param1)
		(super init: param1)
		(gEgo
			illegalBits: 0
			ignoreActors: 1
			setCycle: Walk
			setLoop: -1
		)
	)
	
	(method (changeState newState)
		(super changeState: newState)
		(switch (= state newState)
			(0
				(proc0_8)
				(= global205 1)
				(if (not global115) (proc0_10 601 1) (= global115 1))
				(gEgo setCycle: Walk setMotion: MoveTo 137 131 self)
			)
			(1
				(gEgo setMotion: MoveTo 130 145 self)
			)
			(2
				(gEgo view: 63 setCycle: Fwd)
				(= seconds 2)
			)
			(3
				(newView_23 dispose:)
				(newView_6 dispose:)
				(gEgo view: 4 setMotion: MoveTo 185 145 self)
			)
			(4
				(gEgo view: 63 loop: 2 setCycle: Fwd)
				(= seconds 2)
			)
			(5
				(newView_24 dispose:)
				(newView_7 dispose:)
				(newView_10 dispose:)
				(gEgo view: 4 setMotion: MoveTo 231 145 self)
			)
			(6 (self cue:))
			(7
				(gEgo view: 4 setMotion: MoveTo 237 157 self)
			)
			(8
				(gEgo view: 63 loop: 0 setCycle: Fwd)
				(= seconds 2)
			)
			(9
				(newView_17 dispose:)
				(newView_16 dispose:)
				(newView_15 dispose:)
				(newView_9 dispose:)
				(newView_8 dispose:)
				(gEgo view: 4 setMotion: MoveTo 232 130 self)
			)
			(10
				(gEgo view: 63 loop: 0 setCycle: Fwd)
				(= seconds 2)
			)
			(11
				(newView_22 dispose:)
				(newView_2 dispose:)
				(newView_3 dispose:)
				(gEgo view: 4 setMotion: MoveTo 187 126 self)
			)
			(12
				(gEgo view: 63 loop: 3 setCycle: Fwd)
				(= seconds 2)
			)
			(13
				(newView_19 dispose:)
				(newView_21 dispose:)
				(newView_5 dispose:)
				(newView_11 dispose:)
				(newView_12 dispose:)
				(gEgo view: 4 setMotion: MoveTo 115 126 self)
			)
			(14
				(gEgo view: 63 loop: 3 setCycle: Fwd)
				(= seconds 2)
			)
			(15
				(newView_18 dispose:)
				(newView_20 dispose:)
				(newView dispose:)
				(newView_4 dispose:)
				(gEgo view: 4 setMotion: MoveTo 41 151 self)
			)
			(16
				(gEgo view: 63 loop: 1 setCycle: Fwd)
				(= seconds 2)
			)
			(17
				(newView_13 dispose:)
				(newView_14 dispose:)
				(gEgo view: 4 setLoop: -1 setMotion: MoveTo 91 133 self)
			)
			(18
				(= global204 0)
				(gEgo setMotion: MoveTo 71 133 self)
			)
			(19 (gRoom newRoom: 54))
		)
	)
)

(instance chaseEgo of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0 (= seconds 60))
			(1
				(if
					(or
						global115
						global122
						global204
						global102
						(not (gEgo inRect: 95 127 241 145))
					)
					(-- state)
					(= seconds 5)
				else
					(newAct
						setAvoider: Avoid
						posn: 55 130
						setMotion: MoveTo 78 131 self
					)
					(proc0_8)
					(= global204 0)
					(= global205 1)
					(= global122 1)
				)
			)
			(2
				(Print 53 16)
				(gEgo
					illegalBits: 0
					setAvoider: Avoid
					setMotion: MoveTo 75 135 self
				)
			)
			(3
				(newAct setMotion: Follow gEgo 20)
				(gEgo setMotion: MoveTo 10 135 self)
			)
		)
	)
)
