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

(public
	Room57 0
)
(synonyms
	(dirt dirt dirt dirt dirt)
	(hag hag fishwife)
)

(local
	newView
	newProp_2
	newProp_3
	newAct_2
	newProp_5
	newProp_6
	newProp_8
	newProp_7
	local8
	newProp_4
	local10
	newAct
	local12
	local13
	newProp
)
(instance Room57 of Rm
	(properties
		picture 57
		style $0010
	)
	
	(method (init)
		(= south 6)
		(Load rsVIEW 631)
		(if (>= global109 3)
			(Load rsVIEW 183)
			(Load rsVIEW 184)
			(Load rsVIEW 185)
			(Load rsVIEW 186)
			(Load rsVIEW 180)
			(Load rsVIEW 64)
			(Load rsVIEW 21)
		)
		(Load rsVIEW 65)
		(Load rsVIEW 66)
		(super init:)
		(= global101 1)
		(= global189 1)
		(self setScript: rm57Script)
		(gEgo
			posn: 160 184
			view: 2
			setStep: 3 2
			setPri: -1
			loop: 3
			init:
		)
		(if global207
			((= newAct (Act new:))
				view: 631
				loop: 3
				cel: 0
				illegalBits: 0
				ignoreActors: 1
				posn: gNewActX gNewActY
				setScript: scarabToss
				init:
			)
		)
		((= newProp (Prop new:))
			isExtra: 1
			view: 631
			loop: 1
			cel: 0
			posn: 105 83
			init:
			cycleSpeed: 2
			setCycle: Fwd
		)
		((= newView (View new:))
			view: 631
			loop: 4
			cel: 0
			posn: 159 151
			setPri: 12
			init:
			addToPic:
		)
		((= newProp_2 (Prop new:))
			isExtra: 1
			view: 631
			loop: 5
			posn: 159 157
			setCycle: Fwd
			setPri: 12
			init:
		)
		((= newProp_3 (Prop new:))
			view: 631
			loop: 0
			posn: 159 140
			setPri: 12
			ignoreActors:
			setCycle: Fwd
			init:
		)
		(newProp_3
			brTop: (+ (newProp_3 brTop?) 14)
			brBottom: (+ (newProp_3 brBottom?) 19)
		)
		(if (> global109 2)
			(witchMusic loop: 1 play:)
			((= newProp_4 (Prop new:))
				view: 631
				setLoop: 2
				cycleSpeed: 2
				setCycle: Fwd
				setPri: 12
				init:
				stopUpd:
				hide:
			)
			((= newProp_5 (Prop new:))
				view: 186
				loop: 0
				cel: 5
				posn: 108 101
				setLoop: 1
				init:
				stopUpd:
			)
			((= newProp_6 (Prop new:))
				view: 186
				setLoop: 3
				cel: 0
				posn: 108 121
				init:
				stopUpd:
			)
			((= newProp_7 (Prop new:))
				view: 184
				loop: 0
				cel: 5
				posn: 135 100
				init:
				stopUpd:
			)
			((= newProp_8 (Prop new:))
				view: 184
				setLoop: 2
				cel: 0
				posn: 135 120
				init:
				stopUpd:
			)
			(blockWitch2
				top: 115
				bottom: (newProp_5 brBottom?)
				left: (- (newProp_5 brLeft?) 2)
				right: (+ (newProp_5 brBottom?) 2)
				init:
			)
			(blockWitch3
				top: 115
				bottom: (newProp_7 brBottom?)
				left: (- (newProp_7 brLeft?) 2)
				right: (+ (newProp_7 brBottom?) 2)
				init:
			)
			(gEgo observeBlocks: blockWitch2 blockWitch3)
			((= newAct_2 (Act new:))
				view: 185
				posn: 83 126
				illegalBits: -32768
				setLoop: 0
				init:
			)
			(if (gEgo has: 6)
				(= local10 1)
				(if (and (not (gEgo has: 7)) (not global207))
					(Load rsSCRIPT 991)
					((= newAct (Act new:))
						view: 631
						loop: 3
						cel: 0
						illegalBits: 0
						ignoreActors: 1
						posn: (newAct_2 x?) (- (newAct_2 y?) 30)
						setScript: scarabToss
						init:
					)
					(rm57Script changeState: 1)
				else
					(rm57Script changeState: 3)
				)
				(newProp_7 setScript: witchMoan)
			else
				(= local10 0)
				(newProp_5 setScript: witchEye)
			)
		)
	)
	
	(method (doit)
		(cond 
			(
				(and
					(& (gEgo onControl:) $0004)
					(not local12)
					(not local13)
				)
				(Print 57 0 25 3)
				(ouchness cue:)
			)
			((> global109 2)
				(cond 
					(
					(and (gEgo has: 6) (!= (newProp_7 script?) witchMoan))
						(newAct_2 setScript: 0 setMotion: 0)
						(witchEye changeState: 20)
					)
					(
						(and
							(!= (newAct_2 script?) witchChase)
							(< (gEgo distanceTo: newAct_2) 30)
							(not (gEgo has: 6))
							(!= (newProp_7 script?) witchMoan)
						)
						(newAct_2 setScript: witchChase)
					)
					(
						(and
							(gEgo inRect: 110 123 119 133)
							(not (gEgo has: 6))
							(not local12)
							(== (newAct_2 script?) witchChase)
						)
						(Print 57 1 25 2)
						(Print 57 2 25 2)
						(newProp_5 hide:)
						(newProp_6 hide: ignoreActors:)
						(gEgo
							setMotion: 0
							view: 186
							loop: 2
							posn: (newProp_6 x?) (newProp_6 y?)
							setLoop: 2
							setCycle: Fwd
						)
						(= local12 1)
						(witchMusic number: 13 loop: 1 play:)
						(User canControl: 0 canInput: 0)
						(witchEye changeState: 7)
					)
					(
						(and
							(gEgo inRect: 131 122 138 131)
							(not (gEgo has: 6))
							(not local12)
							(== (newAct_2 script?) witchChase)
						)
						(Print 57 1 25 2)
						(Print 57 2 25 2)
						(proc0_8)
						(gEgo
							setMotion: 0
							view: 184
							loop: 1
							posn: (newProp_8 x?) (newProp_8 y?)
							setLoop: 1
							setCycle: Fwd
						)
						(newProp_7 hide:)
						(newProp_8 hide: ignoreActors:)
						(= local12 1)
						(witchMusic number: 13 loop: 1 play:)
						(witchEye changeState: 4)
					)
					(
						(and
							(!= (newAct_2 script?) witchChase)
							(!= (newProp_7 script?) witchMoan)
							(gEgo inRect: 110 123 138 133)
						)
						(newAct_2 setScript: witchChase)
					)
				)
			)
		)
		(super doit:)
	)
	
	(method (dispose)
		(gSounds eachElementDo: #stop 0)
		(gTimers eachElementDo: #dispose 84)
		(= global189 0)
		(DisposeScript 991)
		(super dispose:)
	)
	
	(method (handleEvent pEvent &tmp gInvSaidMe)
		(if
		(or (!= (pEvent type?) evSAID) (pEvent claimed?))
			(return)
		)
		(if (> global109 2)
			(cond 
				((Said 'look>')
					(cond 
						((Said '/eye')
							(if ((gInv at: 6) ownedBy: 57)
								(Print 57 3)
							else
								(pEvent claimed: 0)
							)
						)
						((Said '/hag')
							(cond 
								((not (gEgo has: 6)) (Print 57 4))
								(local10 (Print 57 5))
								(((gInv at: 6) ownedBy: -1) (Print 57 6))
								(else (Print 57 5))
							)
						)
						(else (pEvent claimed: 0))
					)
				)
				((Said 'converse')
					(cond 
						(((gInv at: 6) ownedBy: 57) (answer1 cue:))
						((gEgo has: 6) (answer2 cue:))
						(else (answer3 cue:))
					)
				)
				((Said 'rob,get/charm')
					(cond 
						((gEgo has: 7) (Print 800 0))
						((not global207) (Print 57 7))
						((> (gEgo distanceTo: newAct) 20) (Print 800 1))
						(else (gEgo setScript: pickUp))
					)
				)
				((Said 'get,rob/eye')
					(if (not (gEgo has: 6))
						(if ((gInv at: 6) ownedBy: 57)
							(if (gEgo inRect: 119 122 129 136)
								(Print 57 8)
								(gEgo get: 6)
								(gGame changeScore: 3)
								(= global182 1)
							else
								(Print 800 1)
							)
						else
							(Print 57 9)
						)
					else
						(Print 800 0)
					)
				)
				((Said 'deliver,return,fling/eye')
					(if (gEgo has: 6)
						(if (not local10)
							(Print 57 10)
							(gEgo put: 6 -1)
						else
							(gGame changeScore: 3)
							(gEgo put: 6 -1)
							(Print 57 11)
						)
						(witchMoan changeState: 4)
					else
						(Print 800 2)
					)
				)
				((Said '/hag>')
					(cond 
						((Said 'kill') (Print 57 12))
						((Said 'get') (Print 57 13))
						((Said 'kiss') (Print 57 14))
						(
						(and (Said 'deliver>') (= gInvSaidMe (gInv saidMe:)))
							(if (gEgo has: (gInv indexOf: gInvSaidMe))
								(Print 57 15)
							else
								(proc0_17)
							)
						)
					)
				)
			)
		)
		(cond 
			((Said 'look>')
				(cond 
					((Said '/bottle') (Print 57 16))
					(
					(or (Said '[<around,in][/room,cave]') (Said '[/!*]'))
						(Print
							(Format
								@global228
								57
								17
								(if (> global109 2)
									{Within it, reside three one-eyed old witches.}
								else
									{_}
								)
								(if (gCast contains: newAct)
									{You see a black scarab on the cave floor.}
								else
									{_}
								)
							)
						)
					)
					((Said '/caldron') (Print 57 18))
					((Said '/brew') (Print 57 19))
					((Said '/fire') (Print 57 20))
					((Said '<out/cave') (Print 57 21))
					((or (Said '/dirt') (Said '<down')) (if global207 (Print 57 22) else (Print 57 23)))
					((Said '/wall') (Print 57 24))
					((Said '/shelf') (Print 57 25))
					((Said '/skull') (Print 57 26))
				)
			)
			((Said 'get,rob>')
				(cond 
					((Said '/bottle') (Print 57 27))
					((Said '/skull') (Print 57 28))
					((Said '/brew') (Print 57 29))
				)
			)
			((Said 'chew,drink/brew') (Print 57 30))
			((Said 'get/caldron') (Print 57 31))
		)
	)
	
	(method (newRoom newRoomNumber)
		(gEgo loop: 2)
		(Animate (gCast elements?) 0)
		(= global189 0)
		(super newRoom: newRoomNumber)
	)
)

(instance witchEye of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(newAct_2 view: 185 loop: 0 setCycle: Beg self)
			)
			(1
				(newProp_4
					x: (+ (newAct_2 x?) 1)
					y: (- (newAct_2 y?) 43)
					show:
				)
				(= seconds 4)
			)
			(2
				(newProp_4 hide:)
				(newAct_2 loop: 1 setCycle: End self)
			)
			(3
				(if (not ((gInv at: 6) ownedBy: -1))
					(newAct_2 setScript: witchChase)
				)
				(newProp_5 loop: 0 setCycle: CT 4 1 self)
			)
			(4
				(newProp_7 stopUpd:)
				(newProp_4
					x: (- (newProp_5 x?) 1)
					y: (- (newProp_5 y?) 12)
					show:
				)
				(if (not local12) (= seconds 5))
			)
			(5
				(newProp_4 hide:)
				(newProp_5 setLoop: 0 setCycle: Beg self)
			)
			(6
				(newProp_5 setCycle: CT 5 -1)
				(newProp_7 setCycle: CT 4 1 self)
			)
			(7
				(newProp_5 stopUpd:)
				(newProp_4
					x: (+ (newProp_7 x?) 0)
					y: (- (newProp_7 y?) 12)
					show:
				)
				(if (not local12) (= seconds 5))
			)
			(8
				(newProp_4 hide:)
				(newProp_7 setCycle: Beg self)
			)
			(9
				(newProp_7 setCycle: CT 5 -1)
				(if (== (newAct_2 script?) witchChase) (= state 3))
				(newProp_5 setCycle: CT 4 1 self)
			)
			(10
				(newProp_7 stopUpd:)
				(newProp_4
					x: (- (newProp_5 x?) 1)
					y: (- (newProp_5 y?) 40)
					show:
				)
				(if (not local12) (= seconds 5))
			)
			(11
				(newProp_4 hide:)
				(newProp_5 loop: 0 cel: 255 setCycle: End self)
			)
			(12 (self changeState: 0))
			(20
				(newProp_4 hide:)
				(client setScript: 0)
				(newProp_7 setScript: witchMoan)
			)
		)
	)
)

(instance witchChase of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(newAct_2
					view: 180
					moveSpeed: 2
					setAvoider: Avoid
					setLoop: -1
					setCycle: Walk
					setMotion: Chase gEgo 7 self
				)
			)
			(1
				(proc0_8)
				(gEgo ignoreActors: hide:)
				(newProp_5 show:)
				(newProp_6 show:)
				(newProp_7 show:)
				(newProp_8 show:)
				(newAct_2 view: 65 moveSpeed: 0)
				(self cue:)
			)
			(2
				(witchMusic number: 13 loop: 1 play:)
				(= local12 1)
				(newAct_2
					view: 66
					setLoop:
						(if
							(<
								180
								(GetAngle
									(gEgo x?)
									(gEgo y?)
									(newAct_2 x?)
									(newAct_2 y?)
								)
							)
							1
						else
							0
						)
					setAvoider: Avoid
					setMotion: MoveTo 157 (if (< (newAct_2 y?) 154) 143 else 164) self
				)
			)
			(3
				(Print 57 32 67 -1 20)
				(newAct_2
					view: 66
					setLoop: (+ (newAct_2 loop?) 2)
					cel: 255
					setCycle: End self
				)
			)
			(4
				(newAct_2
					setLoop: -1
					illegalBits: -32768
					ignoreActors: 0
					setAvoider: Avoid
					view: 180
					setMotion: MoveTo 95 (newAct_2 y?)
				)
				(newProp_5 stopUpd:)
				(newProp_7 stopUpd:)
				(witchMusic stop:)
				(gEgo
					view: 64
					posn: (newProp_3 x?) (+ (newProp_3 y?) 1)
					cel: 255
					ignoreActors: 1
					setPri: 12
					setLoop: (newAct_2 loop?)
					show:
					setMotion: 0
					setCycle: End self
				)
			)
			(5
				(gEgo setLoop: 2 cycleSpeed: 1 setCycle: Fwd)
				(= cycles (* (NumCels gEgo) 6))
			)
			(6
				(gEgo cel: 255 setLoop: 3 setCycle: End self)
			)
			(7 (= seconds 6))
			(8 (= global127 1))
		)
	)
)

(instance witchMoan of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(newAct_2 setScript: 0)
				(newProp_4 hide:)
				(newProp_7 hide: ignoreActors:)
				(newProp_8
					view: 183
					setLoop: 2
					cel: 255
					setCycle: End self
					ignoreActors: 0
				)
			)
			(1
				(newProp_8 stopUpd:)
				(newProp_5 hide: ignoreActors:)
				(newProp_6
					view: 183
					setLoop: 1
					cel: 255
					ignoreActors: 0
					setCycle: End self
				)
			)
			(2
				(newProp_6 stopUpd:)
				(newAct_2 ignoreActors: 0 setMotion: MoveTo 125 133 self)
			)
			(3
				(if (not ((gInv at: 6) ownedBy: -1))
					(Print 57 33)
				)
				(newAct_2 view: 183 setLoop: 0 cel: 255 setCycle: End)
			)
			(4
				(newProp_8 setCycle: Beg)
				(newAct_2 setCycle: Beg)
				(newProp_6 setCycle: Beg)
				((ScriptID 0 4) setReal: self 4)
			)
			(5
				(newAct_2
					view: 180
					setLoop: -1
					setMotion: MoveTo 88 129 self
				)
			)
			(6
				(newProp_6 view: 186 setLoop: 3 cel: 0)
				(newProp_8 view: 184 setLoop: 2 cel: 0)
				(newProp_5 show:)
				(newProp_7 show:)
				(client setScript: 0)
				(newProp_5 setScript: witchEye)
			)
		)
	)
)

(instance answer1 of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0 (Print 57 34))
			(1 (Print 57 35))
			(2
				(Print 57 36)
				(= state 1)
			)
		)
	)
)

(instance answer2 of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(if (not ((gInv at: 6) ownedBy: -1))
					(Print 57 37)
				)
			)
			(1
				(if (not ((gInv at: 6) ownedBy: -1))
					(switch (Random 1 4)
						(1 (Print 57 38))
						(2 (Print 57 39))
						(3 (Print 57 40))
						(4 (Print 57 37))
					)
					(= state 0)
				)
			)
		)
	)
)

(instance answer3 of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0 (Print 57 41))
			(1
				(switch (Random 1 3)
					(1 (Print 57 42))
					(2 (Print 57 43))
					(3 (Print 57 41))
				)
				(= state 0)
			)
		)
	)
)

(instance scarabToss of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(if global207
					(self changeState: 1)
				else
					(newAct
						setMotion: JumpTo (- (gEgo x?) 20) (- (gEgo y?) 20) self
					)
				)
			)
			(1
				(= gNewActX (newAct x?))
				(= gNewActY (newAct y?))
				(= global207 1)
				(newAct setPri: -1)
				(= seconds 2)
			)
			(2
				(if (gCast contains: newAct)
					(newAct setCycle: End self)
				)
			)
			(3
				(if (gCast contains: newAct)
					(newAct setCycle: Beg self)
				)
			)
			(4
				(newAct stopUpd:)
				(= state 1)
				(= seconds 5)
			)
		)
	)
)

(instance ouchness of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(= local13 1)
				((ScriptID 0 5) setReal: self 3)
			)
			(1 (= state -1) (= local13 0))
		)
	)
)

(instance witchMusic of Sound
	(properties
		number 12
	)
)

(instance blockWitch2 of Blk
	(properties)
)

(instance blockWitch3 of Blk
	(properties)
)

(instance pickUp of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0 (self cue:))
			(1
				(proc0_8)
				(proc0_3 gEgo newAct)
				(gEgo view: 21 cel: 255 setCycle: End self)
			)
			(2
				(newAct dispose:)
				(= global207 0)
				(gEgo get: 7)
				(= global182 1)
				(gGame changeScore: 2)
				(= seconds 2)
			)
			(3 (gEgo setCycle: Beg self))
			(4
				(gEgo view: 2 setCycle: Walk)
				(proc0_9)
			)
		)
	)
)

(instance rm57Script of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(1 (proc0_8) (= seconds 3))
			(2
				(Print 57 44 67 -1 20)
				(= state 4)
				(= seconds 3)
				(proc0_9)
			)
			(3 (= seconds 3))
			(4
				(if (not ((gInv at: 6) ownedBy: -1))
					(Print 57 45)
				)
			)
			(5 (Print 57 46))
		)
	)
)
