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

(public
	Room54 0
)
(synonyms
	(sink counter)
	(cottage room)
)

(local
	newProp
	newProp_2
	local2
	[newView 8]
	local11
	newAct
	local13
	newView_3
	newView_4
	newView_5
	newView_6
	newView_7
	newView_8
	newView_9
	newView_10
	newView_11
	newView_12
	newView_2
	local25
)
(instance Room54 of Rm
	(properties
		picture 54
		style $0010
	)
	
	(method (init)
		(Load rsVIEW 677)
		(Load rsVIEW 678)
		(Load rsVIEW 630)
		(Load rsVIEW 290)
		(Load rsVIEW 500)
		(Load rsVIEW 533)
		(self setRegions: 601)
		(if (== gPrevRoomNum 654) (gRoom style: 6))
		(super init:)
		((View new:)
			view: 533
			loop: 1
			cel: 0
			posn: 295 106
			setPri: 9
			addToPic:
		)
		((= newAct (Act new:))
			view: 290
			loop: 3
			illegalBits: 0
			ignoreActors: 0
			setCycle: Walk
			setScript: bounceBitchScript
			init:
			hide:
		)
		(= global101 1)
		(proc0_7)
		(gEgo view: 4 observeControl: 4 setStep: 4 2)
		(cond 
			((== gPrevRoomNum 53)
				(if (== global122 1)
					(newAct posn: 253 86 setMotion: Follow gEgo show:)
					(gEgo posn: 205 104 loop: 1 init:)
					(bounceBitchScript changeState: 6)
				else
					(newAct posn: 147 1194 show:)
					(gEgo posn: 222 87 init:)
					(if global115
						(Load rsVIEW 61)
						(Load rsVIEW 62)
						(gEgo setScript: cleanKitchen)
					)
				)
			)
			((== gPrevRoomNum 654) (gEgo posn: 270 135 loop: 2 init:))
			(else
				(newAct posn: 147 1194 show:)
				(gEgo posn: 147 157 loop: 3 init:)
				(= global115 0)
			)
		)
		(if (not global177)
			(= local11 7)
			(while (>= local11 0)
				((= [newView local11] (View new:))
					view: 500
					loop: 1
					cel: 2
					ignoreActors: 1
					setPri: 12
					posn:
						(switch local11
							(0 189)
							(1 193)
							(2 218)
							(3 228)
							(4 240)
							(5 262)
							(6 270)
							(7 295)
						)
						(switch local11
							(0 136)
							(1 133)
							(2 133)
							(3 136)
							(4 133)
							(5 136)
							(6 133)
							(7 136)
						)
					init:
					stopUpd:
				)
				(-- local11)
			)
		else
			((= [newView 0] (View new:))
				view: 677
				posn: 78 102
				loop: 3
				cel: 0
				init:
				stopUpd:
			)
		)
		(if (== ((gInv at: 1) owner?) 54)
			((= newView_2 (View new:))
				view: 500
				ignoreActors: 1
				loop: 0
				cel: 0
				setPri: 12
				posn: 236 134
				init:
				stopUpd:
			)
		)
		(if (not global102)
			((= newView_3 (View new:))
				view: 677
				loop: 0
				cel: 0
				posn: 100 98
				init:
				stopUpd:
			)
			((= newView_4 (View new:))
				view: 677
				loop: 0
				cel: 1
				posn: 110 98
				init:
				stopUpd:
			)
			((= newView_5 (View new:))
				view: 677
				loop: 0
				cel: 2
				posn: 120 98
				init:
				stopUpd:
			)
			((= newView_6 (View new:))
				view: 677
				loop: 1
				cel: 0
				posn: 130 98
				init:
				stopUpd:
			)
			((= newView_7 (View new:))
				view: 677
				loop: 1
				cel: 1
				posn: 140 98
				init:
				stopUpd:
			)
			((= newView_8 (View new:))
				view: 677
				loop: 1
				cel: 2
				posn: 150 98
				init:
				stopUpd:
			)
			((= newView_9 (View new:))
				view: 678
				loop: 0
				cel: 0
				posn: 160 98
				init:
				stopUpd:
			)
			((= newView_10 (View new:))
				view: 678
				loop: 0
				cel: 1
				posn: 170 98
				init:
				stopUpd:
			)
			((= newView_11 (View new:))
				view: 678
				loop: 0
				cel: 2
				posn: 180 98
				init:
				stopUpd:
			)
			((= newView_12 (View new:))
				view: 677
				loop: 0
				cel: 3
				posn: 107 96
				init:
				stopUpd:
			)
		)
		(= global176 0)
		((= newProp (Prop new:))
			view: 630
			posn: 83 124
			cycleSpeed: 0
			setCycle: Fwd
			init:
		)
		(if (not global223) (newProp addToPic:))
		((= newProp_2 (Prop new:))
			view: 677
			setLoop: 2
			cel: 3
			setPri: 9
			posn: 56 137
			ignoreActors: 1
			init:
			stopUpd:
		)
	)
	
	(method (doit)
		(super doit:)
		(if (and (== local25 0) (== (gEgo script?) 0))
			(cond 
				((& (gEgo onControl:) $0020) (gRoom newRoom: 53))
				((& (gEgo onControl:) $0200) (gEgo setScript: useSteps) (useSteps changeState: 1))
				((& (gEgo onControl:) $1000) (gEgo setScript: useSteps) (useSteps changeState: 4))
				((& (gEgo onControl:) $0040)
					(gEgo illegalBits: -32768 ignoreActors: 0 loop: 2)
					(gRoom newRoom: 22)
				)
			)
		)
	)
	
	(method (handleEvent pEvent)
		(super handleEvent: pEvent)
		(if
		(or (!= (pEvent type?) evSAID) (pEvent claimed?))
			(return)
		)
		(cond 
			((or (Said 'is<how<time') (Said '[!*]/time')) (Print 54 0))
			((Said 'open,(look<in)/cabinet') (Print 54 1))
			((Said 'close/cabinet')
				(if (not global102)
					(Print 54 2)
				else
					(Print 54 3)
				)
			)
			((Said 'open/door,closet,pantry')
				(cond 
					((== (newProp_2 cel?) 0) (Print 54 4))
					((gEgo inRect: 40 137 70 150) (newProp_2 setScript: doorOpen))
					(else (Print 800 1))
				)
			)
			((Said 'close/door,closet,pantry')
				(cond 
					((> (newProp_2 cel?) 0) (Print 54 3))
					((gEgo inRect: 0 137 70 145) (newProp_2 setScript: doorClose))
					(else (Print 800 1))
				)
			)
			((Said 'sit') (Print 54 5))
			((Said 'clean[/cottage]')
				(if (== global122 1) (Print 54 5) (return))
				(cond 
					((& (gEgo onControl:) $0004) (Print 54 6))
					((== global102 0) (gEgo setScript: startClean))
					((not global177) (gEgo setScript: cleanTable))
					(else (Print 54 7))
				)
			)
			((Said 'clean,scrub/table,dish')
				(cond 
					((and global102 (not global177)) (gEgo setScript: cleanTable))
					((and global102 global177) (Print 54 8))
					(else (Print 54 2))
				)
			)
			(
			(Said 'clean,do,scrub,sweep,dust[/dish,dirt,furniture]') (if global102 (Print 54 9) else (Print 54 2)))
			((Said 'chew,drink,chew/soup')
				(if (not global176)
					(Print 54 5)
				else
					(Print 54 10)
				)
			)
			((Said 'get>')
				(cond 
					((Said '/dish[<dirty]')
						(if (or (not global102) (not global177))
							(Print 54 11)
						else
							(Print 54 12)
						)
					)
					((Said '/broom')
						(if (& (gEgo onControl: 1) $0004)
							(Print 54 13)
						else
							(Print 54 14)
						)
					)
					((Said '/caldron') (Print 54 15))
					((Said '/bowl') (Print 54 16))
					((Said '/soup') (if global176 (Print 54 17) else (Print 54 18)))
					((Said '/pouch,diamond')
						(cond 
							((gEgo has: 1) (pEvent claimed: 0))
							((== ((gInv at: 1) owner?) gCurRoomNum)
								(if (gEgo inRect: 200 140 276 164)
									(gEgo get: 1)
									(= global182 1)
									(gGame changeScore: 2)
									(newView_2 dispose:)
								else
									(Print 800 1)
								)
							)
							(else (Print 54 19))
						)
					)
				)
			)
			((Said 'look>')
				(cond 
					((and (== global176 1) (Said '/soup')) (Print 54 20))
					(
					(and ((Inv at: 1) ownedBy: 54) (Said '/pouch,diamond')) (Print 54 21))
					((Said '/window')
						(if (gEgo inRect: 124 117 197 130)
							(Print 54 22)
						else
							(Print 800 1)
						)
					)
					((Said '/mantel,mantel')
						(if
							(and
								(gCast contains: [newView 0])
								(== ([newView 0] view?) 677)
							)
							(Print 54 23)
						else
							(Print 54 24)
						)
					)
					((Said '<under/table') (Print 54 25))
					((Said '/table')
						(if global177
							(Print 54 26)
							(if (== ((gInv at: 1) owner?) 54) (Print 54 27))
						else
							(Print 54 28)
							(if (== ((gInv at: 1) owner?) gCurRoomNum)
								(Print 54 27)
							)
						)
					)
					((Said '/stair') (Print 54 29))
					((Said '/cabinet') (Print 54 30))
					((Said '<in/cabinet') (Print 54 1))
					((Said '/wall') (Print 54 31))
					((or (Said '/dirt') (Said '<down')) (Print 54 32))
					((Said '/bowl') (if global177 (Print 54 33) else (Print 54 34)))
					((Said '/caldron,soup') (Print 54 35))
					((Said '/fire,fireplace') (Print 54 36))
					((Said '/carpet') (Print 54 37))
					((Said '/sink') (if global102 (Print 54 38) else (Print 54 39)))
					((Said '/dish[<dirty]')
						(if (or (not global102) (not global177))
							(Print 54 40)
						else
							(Print 54 41)
						)
					)
					((Said '/clock[<cuckoo]') (Print 54 42))
					((Said '/time') (Print 54 43))
					((Said '<in/closet')
						(cond 
							((& (gEgo onControl: 1) $0004) (Print 54 44))
							((> (newProp_2 cel?) 0) (Print 54 45))
							(else (Print 800 1))
						)
					)
					((Said '/closet')
						(if (& (gEgo onControl: 1) $0004)
							(Print 54 46)
						else
							(Print 54 47)
						)
					)
					((Said '/broom')
						(if (& (gEgo onControl: 1) $0004)
							(Print 54 48)
						else
							(Print 54 49)
						)
					)
					((Said '[<around][/cottage,kitchen]')
						(Print 54 50)
						(if (== global102 0) (Print 54 51))
					)
				)
			)
		)
	)
	
	(method (newRoom newRoomNumber)
		(if (== newRoomNumber 22) ((ScriptID 601) keep: 0))
		(= global189 0)
		(super newRoom: newRoomNumber)
	)
)

(instance startClean of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(proc0_8)
				(= local25 1)
				(= global204 0)
				(= global205 1)
				(= global115 1)
				(gEgo illegalBits: 0 setAvoider: Avoid)
				(proc0_10 601 1)
				(gEgo setMotion: MoveTo 135 (gEgo y?) self)
			)
			(1
				(gEgo setMotion: MoveTo 135 130 self)
			)
			(2
				(gEgo setMotion: MoveTo 192 123 self)
			)
			(3
				(gEgo setLoop: 0 setMotion: MoveTo 232 88 self)
			)
			(4
				(gEgo setMotion: MoveTo 243 90 self)
			)
			(5 (gRoom newRoom: 53))
		)
	)
)

(instance cleanKitchen of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(proc0_8)
				(= local25 1)
				(gEgo
					illegalBits: 0
					setAvoider: Avoid
					loop: 1
					setMotion: MoveTo 194 123 self
				)
			)
			(1 (cleanTable cue:))
			(2
				(gEgo setLoop: -1 setMotion: MoveTo 103 120 self)
			)
			(3
				(newView_3 dispose:)
				(gEgo setMotion: MoveTo 110 (gEgo y?) self)
			)
			(4
				(newView_4 dispose:)
				(newView_12 dispose:)
				(gEgo setMotion: MoveTo 120 (gEgo y?) self)
			)
			(5
				(newView_5 dispose:)
				(gEgo setMotion: MoveTo 130 (gEgo y?) self)
			)
			(6
				(newView_6 dispose:)
				(gEgo setMotion: MoveTo 140 (gEgo y?) self)
			)
			(7
				(newView_7 dispose:)
				(gEgo setMotion: MoveTo 150 (gEgo y?) self)
			)
			(8
				(newView_8 dispose:)
				(gEgo setMotion: MoveTo 160 (gEgo y?) self)
			)
			(9
				(newView_9 dispose:)
				(gEgo setMotion: MoveTo 170 (gEgo y?) self)
			)
			(10
				(newView_10 dispose:)
				(newView_11 dispose:)
				(gEgo setMotion: MoveTo 180 (gEgo y?) self)
			)
			(11
				(gEgo setMotion: MoveTo 160 (gEgo y?) self)
			)
			(12
				(dishDust init:)
				(gEgo view: 62 loop: 3 setCycle: Fwd)
				(= seconds 5)
			)
			(13
				(dishDust dispose:)
				(gEgo view: 4 setLoop: -1 setMotion: MoveTo 83 134 self)
			)
			(14
				((= [newView 0] (View new:))
					view: 677
					posn: 78 102
					loop: 3
					cel: 0
					init:
				)
				(newProp_2 setPri: 6 ignoreActors: 1 setCycle: Beg)
				(gEgo setMotion: MoveTo 65 140 self)
			)
			(15
				(gEgo setMotion: MoveTo 45 140 self)
			)
			(16
				(gEgo view: 61 setMotion: MoveTo 150 145 self)
			)
			(17
				(sweepDust init:)
				(gEgo setLoop: 2 setMotion: MoveTo 170 122 self)
			)
			(18
				(gEgo setMotion: MoveTo 120 155 self)
			)
			(19
				(gEgo setMotion: MoveTo 45 140 self)
			)
			(20
				(sweepDust dispose:)
				(newProp_2 setCycle: End setPri: 6)
				(gEgo
					view: 4
					setLoop: -1
					illegalBits: -32768
					setMotion: MoveTo 140 155 self
				)
			)
			(21
				(gEgo setMotion: MoveTo 150 125 self)
			)
			(22
				(= global204 0)
				(= local25 0)
				(= global115 0)
				(proc0_10 601 0)
				(= global205 1)
				(= global102 1)
				(gEgo loop: 2 forceUpd:)
				(newProp_2 dispose:)
				(gGame changeScore: 5)
				(gRoom newRoom: 654)
			)
		)
	)
)

(instance dishDust of Prop
	(properties
		view 678
	)
	
	(method (init)
		(super init:)
		(self
			loop: 1
			setCycle: Fwd
			ignoreActors:
			posn: (gEgo x?) (- (gEgo y?) 20)
			setPri: (- (gEgo priority?) 1)
		)
	)
	
	(method (doit)
		(super doit:)
		(self
			posn: (gEgo x?) (- (gEgo y?) 20)
			setPri: (- (gEgo priority?) 1)
		)
	)
)

(instance sweepDust of Prop
	(properties
		view 678
	)
	
	(method (init)
		(super init:)
		(self
			loop: 2
			setCycle: Fwd
			ignoreActors: 1
			posn: (gEgo x?) (gEgo y?)
			setPri: (gEgo priority?)
		)
	)
	
	(method (doit)
		(super doit:)
		(self
			posn: (gEgo x?) (gEgo y?)
			setPri: (gEgo priority?)
		)
	)
)

(instance cleanTable of Script
	(properties)
	
	(method (init param1)
		(Load rsVIEW 63)
		(super init: param1)
	)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(proc0_8)
				(= local25 1)
				(if (not global115) (= global115 1) (proc0_10 601 1))
				(gEgo illegalBits: 0 setAvoider: Avoid setCycle: Walk)
				(if (> (gEgo y?) 145)
					(gEgo setMotion: MoveTo 135 159 self)
				else
					(gEgo setMotion: MoveTo 135 150 self)
				)
			)
			(1
				(= local11 7)
				(gEgo setMotion: MoveTo 290 (gEgo y?) self)
			)
			(2
				([newView local11] dispose:)
				(gEgo
					view: 63
					setLoop: (if (> (gEgo y?) 151) 3 else 2)
					setMotion: MoveTo (+ (* local11 10) 190) (gEgo y?) self
				)
			)
			(3
				(if (> local11 0)
					(-- local11)
					(= state 1)
					(self cue:)
				else
					(gEgo
						view: 4
						setLoop: -1
						setMotion: MoveTo 135 (gEgo y?) self
					)
				)
			)
			(4
				(if (not global102)
					(cleanKitchen cue:)
				else
					(gEgo setMotion: MoveTo 150 120 self)
				)
			)
			(5
				(dishDust init:)
				(gEgo view: 62 loop: 3 setCycle: Fwd)
				(= seconds 5)
			)
			(6
				(dishDust dispose:)
				(gEgo view: 4 setLoop: -1 setMotion: MoveTo 83 134 self)
			)
			(7
				((= [newView 0] (View new:))
					view: 677
					posn: 78 102
					loop: 3
					cel: 0
					init:
				)
				(gEgo
					setAvoider: 0
					setCycle: Walk
					setMotion: MoveTo 123 134 self
				)
			)
			(8
				(= global177 1)
				(= local25 0)
				(= global115 0)
				(proc0_10 601 0)
				(proc0_7)
				(gEgo observeControl: 4)
				(proc0_9)
				(= global189 1)
				(client setScript: 0)
				(Print 54 52)
			)
		)
	)
)

(instance doorOpen of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(proc0_8)
				(gEgo setMotion: MoveTo 64 146 self)
			)
			(1
				(gEgo loop: 1)
				(newProp_2 setCycle: Beg self)
			)
			(2
				(gEgo ignoreControl: 4)
				(proc0_9)
			)
		)
	)
)

(instance doorClose of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(proc0_8)
				(gEgo setMotion: MoveTo 64 144 self)
			)
			(1
				(gEgo loop: 1)
				(newProp_2 setCycle: End self)
			)
			(2
				(proc0_9)
				(gEgo observeControl: 4)
			)
		)
	)
)

(instance useSteps of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(1
				(proc0_8)
				(= local25 1)
				(gEgo ignoreControl: -32768 setMotion: MoveTo 232 88 self)
			)
			(2
				(gEgo setMotion: MoveTo 243 90 self)
			)
			(3
				(proc0_9)
				(= global189 1)
				(gEgo observeControl: -32768 setScript: 0)
				(gRoom newRoom: 53)
			)
			(4
				(proc0_8)
				(= local25 1)
				(gEgo
					ignoreControl: -32768
					setMotion: MoveTo 192 123 self
				)
			)
			(5
				(proc0_9)
				(= local25 0)
				(= global189 1)
				(gEgo observeControl: -32768 setScript: 0)
			)
		)
	)
)

(instance bounceBitchScript of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0 (= seconds 60))
			(1
				(if
					(or
						global115
						global122
						global204
						global102
						(> (gEgo y?) 155)
						(< (gEgo y?) 119)
					)
					(-- state)
					(= seconds 5)
				else
					(Print 54 53)
					(= global122 1)
					(proc0_8)
					(newAct
						posn: 140 221
						setMotion: MoveTo 140 160 self
						setAvoider: Avoid
					)
				)
			)
			(2
				(newAct setMotion: MoveTo 110 160 self)
			)
			(3
				(newAct loop: 0 stopUpd:)
				(= local25 1)
				(gEgo
					illegalBits: 0
					setMotion: MoveTo 140 (gEgo y?) self
				)
			)
			(4
				(gEgo setMotion: MoveTo 140 162 self)
			)
			(5
				(= global102 2)
				(= global122 0)
				(proc0_7)
				(gEgo observeControl: 4)
				(proc0_9)
				(User canInput: 0)
				(gRoom newRoom: 22)
			)
			(6
				(= seconds 0)
				(proc0_8)
				(= local25 1)
				(gEgo setMotion: MoveTo 192 123 self)
			)
			(7
				(gEgo setMotion: MoveTo 140 131 self)
				(= state 3)
			)
		)
	)
)
