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

(public
	Room82 0
)

(local
	newAct
	newView
	newProp_3
	newProp_4
	local4
	newAct_2
	local6
	newProp
	newProp_2
)
(procedure (localproc_0060)
	(= global220 1)
	(Print 82 0)
	(gGame changeScore: 2)
)

(instance theMusic of Sound
	(properties
		number 45
	)
)

(instance doorSound of Sound
	(properties
		number 300
	)
)

(instance Room82 of Rm
	(properties
		picture 82
		style $0010
	)
	
	(method (init)
		(Load rsVIEW 605)
		(Load rsVIEW 122)
		(if (gEgo has: 14) (Load rsVIEW 123) (Load rsVIEW 68))
		(Load rsVIEW 85)
		(Load rsVIEW 633)
		(Load rsVIEW 646)
		(Load rsSOUND 46)
		(Load rsSOUND 45)
		(self setRegions: 604)
		(super init:)
		(proc0_10 604 0)
		((View new:)
			view: 633
			loop: 4
			cel: 0
			posn: 61 83
			setPri: 4
			addToPic:
		)
		((View new:)
			view: 633
			loop: 4
			cel: 0
			posn: 38 87
			setPri: 5
			addToPic:
		)
		(if global100
			((Prop new:)
				view: 633
				loop: 0
				posn: 62 69
				setPri: 3
				init:
				setCycle: Fwd
			)
			((Prop new:)
				view: 633
				loop: 1
				posn: 39 73
				setPri: 4
				init:
				setCycle: Fwd
			)
			((= newProp (Prop new:))
				view: 646
				loop: 0
				cel: 0
				posn: 92 92
				cycleSpeed: 5
				init:
				stopUpd:
			)
			((= newProp_2 (Prop new:))
				view: 646
				loop: 1
				cel: 0
				posn: 225 93
				cycleSpeed: 5
				init:
				stopUpd:
			)
		)
		(gEgo
			posn: 233 165
			view: 4
			setStep: 4 2
			baseSetter: 0
			ignoreActors: 0
			illegalBits: -16384
			setPri: -1
			init:
		)
		(if global169
			((= newAct (Act new:))
				view: 122
				illegalBits: 0
				posn: 165 91
				init:
				stopUpd:
			)
			((= newProp_3 (Prop new:))
				view: 123
				posn: (newAct x?) (- (newAct y?) 20)
				init:
				hide:
			)
			((= newProp_4 (Prop new:))
				view: 605
				cel: 0
				posn: 256 155
				init:
				stopUpd:
				ignoreActors: 0
			)
		else
			((= newProp_4 (Prop new:))
				view: 605
				posn: 256 155
				init:
				stopUpd:
				ignoreActors: 1
			)
			((= newAct (Act new:))
				view: 123
				illegalBits: 0
				posn: 165 91
				setLoop: 1
				setCel: 255
				init:
				stopUpd:
			)
			(if (== ((gInv at: 2) owner?) 82)
				((= newView (View new:))
					view: 123
					loop: 3
					posn: 172 91
					setPri: 6
					init:
				)
			)
			(gEgo illegalBits: -32768)
		)
		(if (== global227 1)
			(newProp_4 setCel: 255 ignoreActors: 1)
		)
	)
	
	(method (doit)
		(super doit:)
		(if (& (gEgo onControl: 0) $0040)
			(gRoom newRoom: 88)
		)
	)
	
	(method (handleEvent pEvent)
		(return
			(cond 
				((pEvent claimed?) (return 1))
				((== (pEvent type?) evSAID)
					(cond 
						((not (& (gEgo onControl: 0) $0800))
							(cond 
								(
									(or
										(Said 'look[<around][/!*]')
										(Said 'look[<around]/room')
										(Said 'look/castle,tower,bedroom')
									)
									(Print
										(Format
											@global228
											82
											1
											(if (== (newAct view?) 122)
												{And speaking of Lolotte...the old bat is sound asleep on her massive bed.}
											else
												{However, since Lolotte is now dead, it doesn't really matter anymore.}
											)
										)
									)
								)
								((Said 'bang') (if global169 (Print 82 2) else (Print 82 3)))
								((Said 'look>')
									(cond 
										((Said '<under/bed') (Print 82 4))
										((Said '/bed') (Print 82 5))
										((Said '/window')
											(if
												(or
													(gEgo inRect: 66 118 131 131)
													(gEgo inRect: 196 118 240 135)
												)
												(Print 82 6)
											else
												(proc0_13)
											)
										)
										((Said '/wall') (Print 82 7))
										((Said '/dirt') (Print 82 8))
										((Said '/carpet') (Print 82 9))
										((Said '/mirror')
											(if (gEgo inRect: 42 123 108 144)
												(Print 82 10)
											else
												(proc0_13)
											)
										)
										((Said '/stair') (Print 82 11))
										((Said '/door') (Print 82 12))
										((Said '/lolotte,fairies')
											(if global169
												(Print 82 13)
											else
												(Print
													(Format
														@global228
														82
														14
														(if (== ((gInv at: 2) owner?) 82)
															{\0AGenesta's magic talisman hangs from around her neck.}
														else
															{_}
														)
													)
												)
											)
										)
										(else (pEvent claimed: 0))
									)
								)
								((Said 'help,save/lolotte,fairies') (Print 82 15))
								((Said 'kiss[/lolotte,fairies]') (if global169 (Print 82 16) else (Print 82 17)))
								((Said 'deliver>') (Print 82 18) (pEvent claimed: 1))
								((Said 'awaken/lolotte,fairies')
									(if global169
										(gRoom setScript: egoZapped)
									else
										(Print 82 19 33 gSmallFont 67 15 10 25 4)
									)
								)
								((Said 'get,capture/lolotte,fairies') (if global169 (Print 82 20) else (Print 82 17)))
								((Said 'converse[<lolotte,fairies]')
									(if global169
										(gRoom setScript: egoZapped)
									else
										(Print 82 21 25 5)
									)
								)
								((Said 'blow/whistle')
									(if global169
										(gRoom setScript: egoZapped)
									else
										(pEvent claimed: 0)
									)
								)
								((Said 'get/amulet')
									(cond 
										((gEgo has: 2) (Print 82 22 25 3))
										((!= ((gInv at: 2) owner?) 82) (Print 82 23 25 5))
										((not (gEgo inRect: 120 120 215 135)) (Print 82 24 25 3))
										(global169 (gRoom setScript: egoZapped))
										(else
											(Print 82 25 25 2)
											(gEgo get: 2)
											(newView dispose:)
											(= global182 1)
											(gGame changeScore: 5)
										)
									)
								)
								((Said 'close/door')
									(if (== (newProp_4 cel?) 0)
										(Print 82 26)
									else
										(Print 82 27)
									)
								)
								(
									(or
										(Said 'lay<down,sleep')
										(Said '(sleep<in,on),(lay<down,in,on),(get<in,on)/bed')
									)
									(Print 82 28)
								)
								((Said 'kill/lolotte,fairies')
									(cond 
										((== global169 0) (Print 82 29))
										((gEgo has: 14) (Print 82 30))
										(else (Print 82 31))
									)
								)
								((Said 'launch[/!*]') (Print 82 32))
								((Said 'launch/lolotte,fairies,arrow,arrow')
									(if (gEgo has: 14)
										(cond 
											((>= ((gInv at: 14) loop?) 2) (Print 82 33))
											((not global169) (Print 82 34))
											((== (gRoom script?) lolotteDead) (Print 82 35))
											(else (self setScript: shootLolotte))
										)
									else
										(Print 82 36)
									)
								)
							)
						)
						((Said 'look/stair') (Print 82 37))
						((Said 'look/wall') (Print 82 7))
						((Said 'look/door') (Print 82 38))
						((Said 'open/window') (Print 82 39))
						((Said 'break/window') (Print 82 40))
						((Said 'look[<around][/room]') (Print 82 41))
						((Said 'unlatch/door>')
							(cond 
								(global220 (pEvent claimed: 1) (Print 82 26))
								((not (gEgo inRect: 233 155 251 162)) (pEvent claimed: 1) (proc0_13))
								(
									(or
										(and (gEgo has: 32) (not (gEgo has: 20)))
										(and (Said '*/*/(key<gold)') (gEgo has: 32))
									)
									(pEvent claimed: 1)
									(localproc_0060)
								)
								((and (Said '*/*/key<skeleton') (gEgo has: 20)) (Print 82 42))
								((and (gEgo has: 20) (gEgo has: 32)) (pEvent claimed: 1) (Print 82 43) (= local4 1))
								(else (pEvent claimed: 1) (Print 82 44))
							)
						)
						((or (Said '[use]/key<gold') (Said '/gold'))
							(cond 
								((not (gEgo has: 32)) (Print 82 45))
								((not (gEgo inRect: 233 155 251 162)) (pEvent claimed: 1) (proc0_13))
								(global220 (Print 82 46))
								((or local4 (not (gEgo has: 20))) (localproc_0060))
								(else (Print 82 47))
							)
						)
						(
						(or (Said '[use]/key<skeleton') (Said '/skeleton'))
							(if (and (gEgo has: 20) local4 (not global220))
								(Print 82 42)
							else
								(Print 82 48)
							)
						)
						((Said 'open/door')
							(if (gEgo inRect: 233 155 251 162)
								(cond 
									((and global220 (== (newProp_4 cel?) 0))
										(User canControl: 0 canInput: 0)
										(newProp_4 startUpd: ignoreActors: 1 setCycle: End doDoor)
										(gEgo stopUpd:)
										(doorSound play:)
									)
									((not global220) (Print 82 49))
									(else (Print 82 50))
								)
							else
								(proc0_13)
							)
						)
						((Said 'close/door')
							(if (== (newProp_4 cel?) 0)
								(Print 82 26)
							else
								(Print 82 27)
							)
						)
					)
				)
			)
		)
	)
)

(instance doDoor of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(newProp_4 stopUpd:)
				(User canControl: 1 canInput: 1)
				(= global227 1)
				(gEgo illegalBits: -32768 startUpd:)
			)
		)
	)
)

(instance lolotteDead of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(theMusic number: 46 loop: 1 play:)
				(= cycles 2)
			)
			(1
				(proc0_21)
				(newAct setCycle: End self)
			)
			(2
				(Print 82 51 33 gSmallFont 70 135 67 2 10)
				(Print 82 52 33 gSmallFont 70 135 67 2 10)
				(newProp_3
					loop: 2
					cel: 255
					show:
					cycleSpeed: 4
					setCycle: End stopHeart
				)
				(newAct
					view: 123
					loop: 0
					cel: 255
					cycleSpeed: 2
					setCycle: End self
				)
			)
			(3
				(Print 82 53 67 -1 10 33 gSmallFont 70 250)
				(newAct loop: 1 cel: 255 cycleSpeed: 3 setCycle: End self)
			)
			(4
				(Print 82 54 67 -1 10 70 250 33 gSmallFont)
				((= newView (View new:))
					view: 123
					loop: 3
					posn: 172 91
					init:
					setPri: (+ (newAct priority?) 1)
				)
				(Print 82 55 67 -1 10 33 gSmallFont 70 250)
				(gGame changeScore: 8)
				(newAct stopUpd:)
				(= global169 0)
				(if (< global160 30) (= global160 30) (= global159 0))
				(= seconds 3)
			)
			(5
				(Print 82 56 67 -1 10 33 gSmallFont)
				(newProp setCycle: End self)
				(newProp_2 setCycle: End)
				(= global100 0)
			)
			(6
				(User canControl: 1 canInput: 1)
				(gRoom setScript: edsHere)
			)
		)
	)
)

(instance shootLolotte of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(User canControl: 0 canInput: 0)
				(proc0_3 gEgo newAct)
				(gEgo view: 68 cel: 255 setMotion: 0 setCycle: End self)
			)
			(1
				(Print 82 57 67 -1 10 33 gSmallFont)
				(= seconds 1)
			)
			(2
				(gEgo view: 4 setCycle: Walk)
				((Inv at: 14) loop: (+ ((Inv at: 14) loop?) 1))
				(gRoom setScript: lolotteDead)
			)
		)
	)
)

(instance stopHeart of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0 (newProp_3 dispose:))
		)
	)
)

(instance egoZapped of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(User canControl: 0 canInput: 0)
				(newProp startUpd:)
				(newProp_2 startUpd:)
				(theMusic number: 45 loop: 1 play:)
				(newAct setCycle: End self)
			)
			(1
				(newAct loop: 1 setCycle: Fwd)
				(gEgo
					view: 85
					loop: 0
					cel: 255
					cycleSpeed: 1
					setCycle: End self
				)
			)
			(2
				(newAct setCycle: 0 cel: 0)
				(gEgo loop: 1 setCycle: End self)
			)
			(3
				(Print 82 58 67 15 5 33 gSmallFont)
				((ScriptID 0 4) setReal: self 3)
			)
			(4 (= global127 1))
		)
	)
)

(instance edsHere of Script
	(properties)
	
	(method (init param1)
		(Load rsVIEW 130)
		(Load rsVIEW 132)
		(super init: param1)
	)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(theMusic number: 43 loop: 1 play:)
				(User canControl: 0 canInput: 0)
				(gEgo setMotion: 0 loop: 0)
				((= newAct_2 (Act new:))
					view: 130
					illegalBits: 0
					posn: 185 203
					init:
					ignoreActors: 0
					setCycle: Walk
					setMotion: MoveTo 251 162 self
				)
			)
			(1
				(newAct_2
					view: 132
					loop: 1
					cel: 255
					cycleSpeed: 6
					setCycle: CT 3 1 self
				)
				(= seconds 1)
			)
			(2
				(newAct_2 setCycle: CT 0 -1)
				(= seconds 2)
			)
			(3
				(Print 82 59)
				(newAct_2
					view: 132
					setLoop: 2
					cycleSpeed: 0
					setCycle: End
				)
				(= seconds 3)
			)
			(4
				(newAct_2
					view: 130
					setLoop: -1
					setCycle: Walk
					setMotion: MoveTo 185 205 self
				)
			)
			(5
				(User canControl: 1 canInput: 1)
				(newAct_2 dispose:)
				(= state -1)
			)
		)
	)
)
