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

(public
	Room7 0
)
(synonyms
	(fisherman fisherman fisherman fisherman man)
)

(local
	local0
	local1
	gEgoOnControl
	local3
	newAct
	newProp_4
	[local6 2]
	newProp
	newProp_2
	newProp_3
	local11
	local12
	local13
)
(instance fallSound of Sound
	(properties
		number 51
	)
)

(instance dizzySound of Sound
	(properties
		number 80
	)
)

(instance doorSound of Sound
	(properties
		number 300
	)
)

(instance fisherCage of Cage
	(properties
		top 137
		bottom 149
		right 231
	)
)

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

(instance waves of List
	(properties)
)

(instance wave1 of Prop
	(properties)
)

(instance wave2 of Prop
	(properties)
)

(instance wave3 of Prop
	(properties)
)

(instance Room7 of Rm
	(properties
		picture 7
	)
	
	(method (init)
		(= north 1)
		(= south 13)
		(= east 8)
		(= west 95)
		(= horizon 86)
		(= global101 0)
		(gEgo edgeHit: 0)
		(super init:)
		(if global100 (gRoom overlay: 107))
		(self setRegions: 503 504)
		(Load rsVIEW 2)
		(Load rsVIEW 5)
		(Load rsVIEW 6)
		(Load rsVIEW 7)
		(Load rsVIEW 8)
		(Load rsVIEW 17)
		(Load rsVIEW 19)
		(Load rsVIEW 18)
		(Load rsSOUND 80)
		(Load rsSOUND 51)
		(Load rsSOUND 300)
		(wave1
			isExtra: 1
			view: 667
			loop: 0
			cel: 0
			posn: 98 84
			setPri: 0
			ignoreActors:
			cycleSpeed: 3
			init:
		)
		(wave2
			isExtra: 1
			view: 667
			loop: 1
			cel: 0
			posn: 97 109
			setPri: 0
			ignoreActors:
			cycleSpeed: 3
			init:
		)
		(wave3
			isExtra: 1
			view: 667
			loop: 2
			cel: 0
			posn: 79 136
			setPri: 0
			ignoreActors:
			cycleSpeed: 3
			init:
		)
		(= newProp (Prop new:))
		(= newProp_2 (Prop new:))
		(= newProp_3 (Prop new:))
		(newProp
			isExtra: 1
			view: 667
			loop: 3
			cel: 0
			posn: 11 168
			setPri: 0
			ignoreActors:
			setCycle: Fwd
			cycleSpeed: 2
			init:
		)
		(newProp_2
			isExtra: 1
			view: 667
			loop: 5
			cel: 0
			posn: 103 166
			setPri: 0
			ignoreActors:
			setCycle: Fwd
			cycleSpeed: 2
			init:
		)
		(newProp_3
			isExtra: 1
			view: 667
			loop: 4
			cel: 0
			posn: 117 177
			setPri: 0
			ignoreActors:
			setCycle: Fwd
			cycleSpeed: 2
			init:
		)
		(waves add: wave1 wave2 wave3)
		(wave1 setScript: waveActions)
		(= newProp_4 (Prop new:))
		(newProp_4
			isExtra: 1
			view: 625
			loop: 1
			cel: 0
			x: 200
			y: 19
			setCycle: Fwd
			cycleSpeed: 1
			init:
		)
		(door
			view: 601
			loop: 0
			cel: 0
			x: 220
			y: 139
			setPri: 9
			ignoreActors:
			init:
			stopUpd:
		)
		(if (== global116 2)
			(if
				(<
					(= local12
						(+
							(* 3600 (- global160 global199))
							(* 60 (- global159 global197))
							(- global158 global198)
						)
					)
					40
				)
				((= newAct (Act new:)) view: 230)
				(cond 
					((<= local12 12) (= local13 40))
					((< local12 20) (= local13 120))
					(else (= local13 166))
				)
				(newAct
					posn: local13 144
					setPri: 13
					loop: 0
					setCycle: Walk
					xStep: 3
					yStep: 1
					setScript: fishWalkHouse
					init:
				)
				(newAct baseSetter: (ScriptID 0 1))
			else
				(= global116 3)
			)
		)
		(gEgo observeControl: -32768 16384 1024)
		(if (<= (gEgo y?) (+ horizon 1))
			(gEgo y: (+ horizon 2))
		)
		(if
			(or
				(== gPrevRoomNum 0)
				(== gPrevRoomNum 8)
				(== (gEgo view?) 2)
			)
			(= global105 0)
		)
		(switch global105
			(0
				(switch gPrevRoomNum
					(13
						(if (< (gEgo x?) 164)
							(gEgo posn: 170 188)
						else
							(gEgo posn: 304 187)
						)
					)
					(1
						(if (> (gEgo x?) 277)
							(gEgo posn: 143 (+ horizon 2))
						else
							(gEgo posn: 113 (+ horizon 2))
						)
					)
					(42
						(gEgo view: 2 loop: 1 posn: 212 140 xStep: 3 yStep: 2)
					)
					(95
						(if (== global107 9)
							(gEgo
								view: 2
								illegalBits: -32768
								observeControl: 128 1024
								posn: 1 143
							)
						else
							(gEgo posn: 1 (gEgo y?))
						)
					)
					(8
						(if (< (gEgo y?) 125)
							(gEgo x: 280)
						else
							(gEgo x: 317)
						)
						(if (<= (gEgo y?) (+ horizon 1))
							(gEgo y: (+ horizon 2))
						)
						(if (gEgo inRect: 193 129 319 157) (gEgo setPri: 12))
					)
				)
			)
			(1
				(switch gPrevRoomNum
					(13 (gEgo posn: 189 185))
					(1
						(gEgo posn: 93 (+ horizon 2))
					)
				)
			)
			(2
				(switch gPrevRoomNum
					(13 (gEgo posn: 137 185))
					(1
						(gEgo posn: 88 (+ horizon 2))
					)
				)
			)
			(3
				(switch gPrevRoomNum
					(13 (gEgo posn: 105 184))
					(1
						(gEgo posn: 73 (+ horizon 2))
					)
				)
			)
			(4
				(switch gPrevRoomNum
					(95 (gEgo x: 2))
					(13 (gEgo posn: 42 184))
					(1
						(gEgo posn: 20 (+ horizon 2))
					)
				)
			)
		)
		(gEgo xStep: 3 yStep: 2 init: viewer: water)
		(gEgo y: (& (gEgo y?) $fffe))
		(fisherCage init:)
	)
	
	(method (doit)
		(super doit:)
		(if (not (gEgo inRect: -5 135 174 153))
			(= global107 0)
		)
		(= gEgoOnControl (gEgo onControl:))
		(if
		(and (gEgo inRect: -3 0 27 189) (!= global107 9))
			(gEgo view: 8)
		)
		(if
		(and (& (gEgo onControl: 1) $0040) (== global107 9))
			(gEgo observeControl: 16384)
			(gEgo ignoreControl: 128)
			(gEgo setPri: -1)
			(= global107 0)
		)
		(if
		(and (& (gEgo onControl: 1) $0020) (!= global107 9))
			(gEgo setPri: 13)
			(gEgo illegalBits: -32768 observeControl: 1024)
			(gEgo observeControl: 128)
			(= global107 9)
		)
		(if (== (gRoom script?) 0)
			(if (!= global107 9)
				(cond 
					((gEgo inRect: 103 157 219 189) (gEgo setPri: 15))
					((gEgo inRect: 193 129 319 157) (gEgo setPri: 12))
					((gEgo inRect: 80 125 157 158) (gEgo setPri: 8))
					(else (gEgo setPri: -1))
				)
			)
			(cond 
				(
					(and
						(== global105 0)
						(& gEgoOnControl $1000)
						(> (gEgo heading?) 135)
					)
					(self setScript: fallRocks)
				)
				(
					(and
						(== global105 0)
						(& gEgoOnControl $1000)
						(<= (gEgo heading?) 135)
					)
					(gEgo setPri: -1)
				)
				((& gEgoOnControl $2000)
					(if
						(and
							(!= global107 9)
							(> (gEgo heading?) 90)
							(< (gEgo heading?) 270)
						)
						(gEgo setPri: -1)
					else
						(gEgo setPri: 12)
					)
				)
				((& gEgoOnControl $0100)
					(if (!= global107 9)
						(if
						(and (> (gEgo heading?) 90) (< (gEgo heading?) 270))
							(gEgo setPri: 12)
						else
							(gEgo setPri: -1)
						)
					)
				)
				((== global107 9)
					(cond 
						((& gEgoOnControl $0010) (self setScript: fallNorth))
						((& gEgoOnControl $0004) (self setScript: fallSouth))
					)
				)
			)
		)
	)
	
	(method (dispose)
		(gEgo setPri: -1)
		(waves dispose:)
		(super dispose:)
	)
	
	(method (handleEvent pEvent &tmp gInvSaidMe)
		(if (pEvent claimed?) (return 1))
		(return
			(if (== (pEvent type?) evSAID)
				(cond 
					((Said 'get/fisherman')
						(if (== global116 2)
							(Print 7 0)
						else
							(Print 7 1)
						)
					)
					((Said 'get/pole')
						(if (gCast contains: newAct)
							(Print 7 2)
						else
							(Print 7 3)
						)
					)
					((Said 'rob/pole')
						(if (gCast contains: newAct)
							(Print 7 4)
						else
							(Print 7 3)
						)
					)
					((Said 'kiss')
						(if (== global116 2)
							(Print 7 5)
						else
							(Print 7 6)
						)
					)
					((Said 'deliver>')
						(if (= gInvSaidMe (gInv saidMe:))
							(if (gEgo has: (gInv indexOf: gInvSaidMe))
								(if (== global116 2)
									(Print 7 7)
								else
									(Print 7 8)
								)
							else
								(proc0_17)
							)
						)
					)
					((Said 'help/fisherman') (Print 7 9))
					(
						(or
							(Said 'look/around')
							(Said 'look/room')
							(Said 'look[<around][/!*]')
						)
						(Print 7 10)
					)
					((Said 'look>')
						(cond 
							((Said '/anchor') (Print 7 11))
							((Said '/cottage') (Print 7 12))
							((Said '<under/dock') (Print 7 13))
							((Said '/door') (Print 7 14))
							((Said '/window')
								(if
									(or
										(gEgo inRect: 185 126 207 140)
										(gEgo inRect: 230 141 256 153)
										(gEgo inRect: 270 140 315 151)
										(gEgo inRect: 204 129 233 148)
									)
									(Print 7 15)
								else
									(Print 800 1)
								)
							)
							((Said '/dock') (Print 7 16))
							((Said '/fisherman')
								(if (== global116 2)
									(Print 7 17)
								else
									(Print 7 3)
								)
							)
							((Said '/grass') (Print 7 18))
						)
					)
					((Said 'get/anchor') (Print 7 19))
					((Said 'break/window') (Print 7 20))
					((Said 'break/door') (Print 7 21))
					((Said 'open/window') (Print 7 22))
					((Said 'close/door') (Print 7 23))
					(
						(Said
							'converse[/fisherman,fisherman,fisherman,fisherman,fisherman]'
						)
						(if (== global116 2)
							(Print 7 24)
						else
							(pEvent claimed: 0)
						)
					)
					((Said 'unlatch/door')
						(if (not global100)
							(Print 7 25)
						else
							(Print 7 26)
						)
					)
					((Said 'bang/door')
						(if (gEgo inRect: 204 129 233 148)
							(if (not global100)
								(Print 7 27)
							else
								(Print 7 28)
							)
						else
							(Print 800 1)
						)
					)
					((Said 'open/door')
						(cond 
							((!= (door cel?) 0) (Print 7 29))
							((gEgo inRect: 204 129 233 148)
								(if (not global100)
									(proc0_8)
									(gEgo loop: 0)
									(doorSound play: door)
									(door ignoreActors: setCycle: End)
								else
									(Print 7 26)
								)
							)
							(else (Print 800 1))
						)
					)
				)
			else
				0
			)
		)
	)
	
	(method (newRoom newRoomNumber)
		(proc0_9)
		(gEgo setPri: -1 illegalBits: -32768)
		(if (== global116 2) (= global116 3))
		(super newRoom: newRoomNumber)
	)
)

(instance water of Script
	(properties)
	
	(method (doit)
		(if
			(and
				(!= local0 (= local1 (gEgo onControl: 1)))
				(!= global107 9)
			)
			(= local0 local1)
			(gEgo setCycle: Walk)
			(switch local1
				(1
					(= global105 0)
					(gEgo view: 2)
				)
				(2048
					(gEgo observeControl: 16384)
					(= global105 1)
					(gEgo view: 5)
				)
				(512
					(= global105 2)
					(gEgo view: 6)
				)
				(8
					(gEgo view: 7)
					(= global105 3)
				)
				(2
					(gEgo view: 8)
					(= global105 4)
					(gEgo setCycle: Fwd)
				)
			)
		)
	)
)

(instance fallSouth of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(proc0_8)
				(fallSound play:)
				(gEgo
					viewer: 0
					illegalBits: 0
					yStep: 9
					setMotion: MoveTo (gEgo x?) (+ (gEgo y?) 35) self
					view: 17
					cel: 255
					setCycle: End
				)
			)
			(1
				(= global107 0)
				(gEgo yStep: 2 setPri: -1)
				(gEgo
					view: 19
					loop: (& (gEgo loop?) $0001)
					cel: 255
					setCycle: End self
				)
			)
			(2
				(proc0_9)
				(gEgo
					viewer: water
					illegalBits: -32768
					observeControl: 1024
				)
				(gRoom setScript: 0)
			)
		)
	)
)

(instance fallNorth of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(proc0_8)
				(fallSound play:)
				(gEgo
					viewer: 0
					illegalBits: 0
					setPri: 11
					posn: (gEgo x?) (- (gEgo y?) 5)
					yStep: 8
					view: 17
					cel: 255
					setCycle: End
					setMotion: MoveTo (gEgo x?) (+ (gEgo y?) 10) self
				)
			)
			(1
				(gEgo
					yStep: 2
					setPri: -1
					loop: 3
					view: 7
					illegalBits: -32768
					observeControl: 1024
					viewer: water
				)
				(= global107 0)
				(gRoom setScript: 0)
				(proc0_9)
			)
		)
	)
)

(instance fallRocks of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(proc0_8)
				(gEgo
					viewer: 0
					view: 17
					illegalBits: 0
					setPri: 14
					xStep: 10
					yStep: 4
					setCycle: Fwd
					setMotion: MoveTo 173 186 self
				)
				(fallSound play:)
			)
			(1
				(gEgo xStep: 3 yStep: 2 view: 18 loop: 0 setCycle: Fwd)
				(= global107 0)
				(= seconds 5)
				(dizzySound play:)
			)
			(2
				(gEgo
					illegalBits: -32768
					observeControl: 1024
					setCycle: Walk
					loop: 1
					view: 2
					cycleSpeed: 0
					viewer: water
				)
				(gRoom setScript: 0)
				(proc0_9)
			)
		)
	)
)

(instance fishWalkHouse of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(newAct setMotion: MoveTo 207 140 self)
			)
			(1
				(newAct setPri: 10)
				(door setCycle: End self)
				(doorSound play:)
			)
			(2
				(newAct setMotion: MoveTo 226 134 self)
			)
			(3
				(newAct setMotion: MoveTo 255 134 self)
			)
			(4
				(door ignoreActors: 0 setCycle: Beg self)
				(= global116 3)
				(newAct dispose:)
			)
			(5 (door stopUpd:))
		)
	)
)

(instance waveActions of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(= local11 0)
				(while (< local11 (waves size?))
					((View new:)
						view: ((waves at: local11) view?)
						loop: ((waves at: local11) loop?)
						cel: 255
						setPri: 0
						ignoreActors:
						x: ((waves at: local11) x?)
						y: ((waves at: local11) y?)
						init:
						addToPic:
						yourself:
					)
					(++ local11)
				)
				(= local11 0)
				(self changeState: 1)
			)
			(1
				((waves at: local11) cel: 255 show: setCycle: End self)
			)
			(2
				((waves at: local11) hide:)
				(if (< local11 (- (waves size?) 1))
					(++ local11)
				else
					(= local11 0)
				)
				(waveActions changeState: 1)
			)
		)
	)
)
