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

(public
	Room42 0
)
(synonyms
	(room cottage)
	(shelf cabinet)
	(fisherman man)
	(fishwife fishwife)
)

(local
	newAct_4
	[local1 3]
	newAct
	newAct_2
	newAct_3
	newView
	newProp
	local9
)
(instance Room42 of Rm
	(properties
		picture 42
		style $0010
	)
	
	(method (init)
		(Load rsVIEW 513)
		(if (gEgo has: 1)
			(Load rsVIEW 243)
			(Load rsVIEW 242)
			(Load rsVIEW 240)
			(Load rsVIEW 241)
		)
		(super init:)
		(= global101 1)
		(if (gEgo has: 1) (= local9 1))
		(gEgo
			view: 4
			loop: 0
			setStep: 4 2
			illegalBits: -32768
			setPri: -1
			posn: 63 125
			init:
		)
		((= newProp (Prop new:))
			view: 513
			posn: 133 84
			setLoop: 2
			ignoreActors: 1
			init:
			cycleSpeed: 1
			setCycle: Fwd
		)
		(if (gEgo has: 1)
			((View new:)
				view: 513
				loop: 0
				cel: 2
				posn: 181 93
				addToPic:
			)
			((= newAct (Act new:))
				view: 241
				loop: 0
				setCycle: Fwd
				x: 200
				y: 117
				illegalBits: 0
				init:
				setScript: doBread
			)
			((View new:)
				view: 513
				loop: 3
				cel: 0
				posn: 82 154
				addToPic:
			)
		else
			(if
			(and (== global116 3) (!= ((gInv at: 1) owner?) 42))
				((= newAct (Act new:))
					view: 240
					illegalBits: 0
					loop: 2
					posn: 84 132
					ignoreActors: 1
					init:
					setPri: 12
					setScript: wifeTalk
				)
			else
				((= newAct (Act new:))
					view: 240
					loop: 3
					illegalBits: 0
					posn: 84 132
					ignoreActors: 1
					init:
					setPri: 12
					setScript: wifeTalk
				)
			)
			((= newAct_2 (Act new:))
				view: 240
				loop: 4
				cel: 1
				illegalBits: 0
				posn: 84 153
				init:
				setPri: 12
			)
			(chairBlock
				top: (- (newAct_2 y?) 5)
				bottom: (+ (newAct_2 y?) 5)
				left: (- (newAct_2 x?) 13)
				right: (+ (newAct_2 x?) 15)
				init:
			)
			(gEgo observeBlocks: chairBlock)
		)
		(if (== global116 3)
			((View new:)
				view: 513
				loop: 0
				cel: 2
				posn: 181 93
				addToPic:
			)
			((= newAct_3 (Act new:))
				view: 235
				loop: 0
				cel: 0
				ignoreActors: 1
				illegalBits: 0
				posn: 130 135
				init:
				setPri: 12
				setScript: fishermanSit
			)
			((= newView (View new:))
				view: 235
				loop: 2
				cel: 0
				posn: 129 157
				init:
				stopUpd:
				setPri: 12
			)
			(if (== ((gInv at: 17) owner?) 204)
				((= newAct_4 (Act new:))
					view: 513
					loop: 1
					cel: 0
					illegalBits: 0
					posn: 223 115
					init:
					stopUpd:
					ignoreActors: 1
				)
			)
		else
			((View new:)
				view: 513
				loop: 3
				cel: 1
				posn: 138 161
				addToPic:
			)
		)
	)
	
	(method (doit)
		(if (& (gEgo onControl: 0) $0040)
			(gEgo loop: 1)
			(Animate (gCast elements?) 0)
			(gRoom newRoom: 7)
		)
		(super doit:)
	)
	
	(method (handleEvent pEvent &tmp gInvSaidMe)
		(if (pEvent claimed?) (return 1))
		(return
			(if (== (pEvent type?) evSAID)
				(cond 
					((Said 'look[<around][/room,room,place]')
						(if local9
							(Print
								(Format
									@global228
									42
									0
									(cond 
										((not (gCast contains: newAct_3))
											{You see a tired-looking woman kneading bread at the counter.}
										)
										((not (gEgo has: 17))
											{You see the old fisherman at the table, and his wife kneading bread at the counter. The fisherman's fishing pole has been set in the corner.}
										)
										((not (gEgo has: 1))
											{You see the old fisherman at the table, and his wife kneading bread at the counter. Since your generous gift of the diamonds, however, her grouchy look has been replaced by one of contentment.}
										)
										(else {_})
									)
								)
							)
						else
							(Print
								(Format
									@global228
									42
									0
									(cond 
										((not (gCast contains: newAct_3)) {You see a tired-looking woman knitting at the table.})
										((not (gEgo has: 17))
											{The fisherman's worn and tattered wife sits at the table with her husband, talking. The fisherman's pole has been set into the corner.}
										)
										((not (gEgo has: 1))
											{The fisherman's worn and tattered wife sits at the table with her husband, talking. Since your generous gift of the diamonds, however, her grouchy look has been replaced by one of contentment.}
										)
										(else {_})
									)
								)
							)
						)
					)
					(
					(and (gCast contains: newAct_3) (Said '/person')) (Print 42 1))
					((Said '/people')
						(if (gCast contains: newAct_3)
							(Print 42 1)
						else
							(Print 42 2)
						)
					)
					((Said 'look>')
						(cond 
							((Said '/fishwife,person')
								(cond 
									(local9
										(cond 
											((not (gEgo has: 17)) (Print 42 3))
											((not (gEgo has: 1)) (Print 42 4))
										)
									)
									((!= global116 3) (Print 42 5))
									((== ((gInv at: 1) owner?) 42) (Print 42 6))
									(else (Print 42 7))
								)
							)
							((Said '/dough[<bread]') (Print 42 8))
							((Said '<under/table') (Print 42 9))
							((Said '/table') (Print 42 10))
							((Said '/chair') (Print 42 11))
							((Said '<under/bed') (Print 42 12))
							((Said '/bed') (Print 42 13))
							((Said '/stove') (Print 42 14))
							((Said '/window')
								(cond 
									(
										(or
											(gEgo inRect: 14 127 52 140)
											(gEgo inRect: 66 110 88 119)
										)
										(Print 42 15)
									)
									((gEgo inRect: 236 118 261 139) (Print 42 16))
									(else (Print 800 1))
								)
							)
							((Said '/door') (Print 42 17))
							((Said '/wall') (Print 42 18))
							((or (Said '/dirt') (Said '<down')) (Print 42 19))
							((Said '/pole')
								(cond 
									(
									(and (== global116 3) (== ((gInv at: 17) owner?) 204)) (Print 42 20))
									((gEgo has: 17) (pEvent claimed: 0))
									(else (Print 42 21))
								)
							)
							((Said '/fisherman')
								(cond 
									((!= global116 3) (Print 42 22))
									((not local9) (Print 42 23))
									((== ((gInv at: 1) owner?) 42) (Print 42 24))
									(else (Print 42 25))
								)
							)
							((Said '/caldron,kettle,coffee') (Print 42 26))
							((Said '/fish')
								(if (not (gEgo has: 24))
									(Print 42 27)
								else
									(pEvent claimed: 0)
								)
							)
							((Said '/shelf') (Print 42 28))
							((Said '/can') (Print 42 29))
							((Said '/knitting,knitting')
								(if
								(and (== (newAct view?) 240) (== (newAct loop?) 3))
									(Print 42 30)
								else
									(Print 42 31)
								)
							)
						)
					)
					((Said 'chew/dough') (Print 42 32))
					((Said 'rob/pole')
						(cond 
							(
							(and (== ((gInv at: 17) owner?) 204) (== global116 3)) (Print 42 33))
							(((gInv at: 17) ownedBy: gEgo) (Print 800 0))
							(else (Print 42 21))
						)
					)
					((Said 'kiss>')
						(cond 
							((Said '[/!*]')
								(if (== global116 3)
									(Print 42 34)
								else
									(Print 42 35)
								)
							)
							((Said '/fishwife,person') (Print 42 35))
							((Said '/fisherman')
								(if (== global116 3)
									(Print 42 36)
								else
									(Print 42 37)
								)
							)
						)
					)
					((Said 'help') (Print 42 38))
					(
						(or
							(Said 'converse/fishwife,person')
							(and
								(< (gEgo distanceTo: newAct) 50)
								(Said 'converse[/!*]')
							)
						)
						(cond 
							((== ((gInv at: 1) owner?) 42) (wifeTacoDoco2 cue:))
							((gCast contains: newAct_3) (wifeTacoDoco1 cue:))
							(else (wifeTacoDoco cue:))
						)
					)
					(
						(or
							(Said 'converse/fisherman')
							(and
								(gCast contains: newAct_3)
								(< (gEgo distanceTo: newAct_3) 50)
								(Said 'converse[/!*]')
							)
						)
						(if (== global116 3)
							(if (== ((gInv at: 1) owner?) 42)
								(fishermanTacoDoco1 cue:)
							else
								(fishermanTacoDoco2 cue:)
							)
						else
							(Print 42 39)
						)
					)
					((Said 'converse[/!*]')
						(cond 
							((gCast contains: newAct_3) (Print 42 40))
							((== ((gInv at: 1) owner?) 42) (wifeTacoDoco2 cue:))
							((gCast contains: newAct_3) (wifeTacoDoco1 cue:))
							(else (wifeTacoDoco cue:))
						)
					)
					((Said 'close,open/door') (Print 42 41))
					((Said 'sit') (Print 42 42))
					(
						(or
							(Said 'lay,sleep[<down,on,in]')
							(Said 'get<in,on,in/bed')
						)
						(Print 42 13)
					)
					((Said 'drink,get/coffee,cup') (Print 42 43))
					((Said 'deliver>')
						(if
							(or
								(< (gEgo distanceTo: newAct) 20)
								(and
									(gCast contains: newAct_3)
									(< (gEgo distanceTo: newView) 30)
								)
							)
							(if
								(and
									(= gInvSaidMe (gInv saidMe:))
									(gEgo has: (gInv indexOf: gInvSaidMe))
								)
								(cond 
									(
										(and
											(== (gInv indexOf: gInvSaidMe) 1)
											(== global116 3)
										)
										(if (< (gEgo distanceTo: newAct) 25)
											(Print 42 44)
										else
											(Print 42 45)
										)
										(gEgo put: 1 42)
										(newAct setScript: givePole)
									)
									((== global116 3) (Print 42 46))
									(else (Print 42 47))
								)
							else
								(if gInvSaidMe (Print 800 2) else (Print 42 48))
								(pEvent claimed: 1)
							)
						else
							(Print 800 1)
							(pEvent claimed: 1)
						)
					)
					((Said 'get,rob>')
						(cond 
							((Said '/knitting') (Print 42 49))
							((Said '/pole')
								(cond 
									(
									(and (== ((gInv at: 17) owner?) 204) (== global116 3)) (Print 42 50))
									(((gInv at: 17) ownedBy: gEgo) (Print 42 51))
									(else (Print 42 21))
								)
							)
							((Said '/dough') (Print 42 52))
							((Said '/fishwife,person') (Print 42 53))
							((Said '/fisherman') (if (== global116 3) (Print 42 54)))
							((Said '/caldron') (Print 42 55))
							((Said '/can') (Print 42 56))
							((Said '/fish') (Print 42 57))
						)
					)
					((Said 'create/bed') (Print 42 58))
				)
			else
				0
			)
		)
	)
	
	(method (newRoom newRoomNumber)
		(super newRoom: newRoomNumber)
	)
)

(instance doBread of Script
	(properties)
	
	(method (init param1)
		(super init: param1)
	)
	
	(method (changeState newState)
		(switch (= state newState)
			(0 (Timer setReal: self 5))
			(1
				(newAct setLoop: 1)
				(Timer setReal: self 3)
			)
			(2
				(newAct setLoop: 0)
				(= state -1)
				(self cue:)
			)
		)
	)
)

(instance givePole of Script
	(properties)
	
	(method (init param1)
		(super init: param1)
	)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(gEgo setMotion: 0)
				(proc0_8)
				(if (gEgo inRect: 185 115 239 124)
					(gEgo setMotion: MoveTo (gEgo x?) 125)
				)
				(newAct
					view: 242
					loop: 0
					cel: 0
					setAvoider: (Avoid new:)
					setCycle: Walk
					setMotion: MoveTo 223 118 self
				)
			)
			(1
				(proc0_3 gEgo newAct)
				(newAct_4 dispose:)
				(newAct
					view: 243
					setLoop: -1
					cel: 0
					setMotion: Chase gEgo 20 self
				)
			)
			(2
				(gEgo get: 17)
				(gGame changeScore: 3)
				(= global182 1)
				(newAct
					view: 242
					loop: 0
					cel: 0
					setMotion: MoveTo 200 118 self
				)
			)
			(3
				(proc0_9)
				(newAct
					view: 241
					setAvoider: 0
					loop: 0
					setCycle: Fwd
					setScript: doBread
				)
			)
		)
	)
)

(instance wifeTalk of Script
	(properties)
	
	(method (init param1)
		(super init: param1)
		(client cycleSpeed: 1)
	)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(client setCycle: Fwd)
				((ScriptID 0 4) setReal: self 2)
			)
			(1
				(= state -1)
				(client cel: 0 setCycle: 0)
				(if (== (client loop?) 3)
					((ScriptID 0 4) setReal: self 1)
				else
					((ScriptID 0 4) setReal: self 5)
				)
			)
		)
	)
)

(instance fishermanSit of Script
	(properties)
	
	(method (init param1)
		(super init: param1)
		(client cycleSpeed: 2)
	)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(client loop: 0 cel: 0 setCycle: Fwd)
				(Timer setReal: self 3)
			)
			(1
				(client loop: 1 cel: 255 setCycle: End self)
			)
			(2 (Timer setReal: self 2))
			(3
				(= state -1)
				(client setCycle: Beg)
				(Timer setReal: self 10)
			)
		)
	)
)

(instance wifeTacoDoco of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(if global206 (self cue:) (return))
				(Print 42 59)
				(= global206 1)
			)
			(1
				(if (> global206 1) (self cue:) (return))
				(Print 42 60)
				(= global206 2)
			)
			(2
				(= state 1)
				(Print 42 61)
			)
		)
	)
)

(instance wifeTacoDoco1 of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(if global206 (self cue:) (return))
				(Print 42 62)
				(= global206 1)
			)
			(1
				(= state 0)
				(Print 42 63)
			)
		)
	)
)

(instance wifeTacoDoco2 of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(if (< global206 0) (self cue:) (return))
				(= global206 -1)
				(Print 42 64)
			)
			(1
				(= state 0)
				(Print
					(Format
						@global228
						42
						65
						(if (== (newAct view?) 241)
							{kneading the bread}
						else
							{knitting}
						)
					)
				)
			)
		)
	)
)

(instance fishermanTacoDoco1 of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0 (Print 42 66))
			(1
				(= state 0)
				(Print 42 67)
			)
		)
	)
)

(instance fishermanTacoDoco2 of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0 (Print 42 68))
			(1 (Print 42 69))
			(2
				(= state 1)
				(Print 42 70)
			)
		)
	)
)

(instance chairBase of Code
	(properties)
	
	(method (doit param1)
		(param1 brTop: (- (param1 y?) 5))
		(param1 brLeft: (- (param1 x?) 16))
		(param1 brBottom: (+ (param1 y?) 1))
		(param1 brRight: (+ (param1 x?) 5))
	)
)

(instance chairBlock of Blk
	(properties)
)
