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

(public
	Room45 0
)
(synonyms
	(room room castle)
	(leopard leopard cat)
)

(local
	newAct
	newAct_2
	newProp
	newProp_2
	newProp_4
	local5
	newProp_3
	newProp_5
	newProp_6
	newProp_7
	[local10 2]
)
(instance Room45 of Rm
	(properties
		picture 45
		style $0010
	)
	
	(method (init)
		(Load rsVIEW 632)
		(Load rsVIEW 645)
		(Load rsVIEW 365)
		(Load rsVIEW 101)
		(Load rsVIEW 112)
		(Load rsVIEW 115)
		(super init:)
		(proc0_9)
		(= global205 0)
		(fairyMusic play:)
		(gEgo
			view: 4
			posn: 225 174
			illegalBits: -32768
			init:
			setStep: 4 2
			setPri: -1
		)
		(if global223
			((View new:) view: 632 posn: 115 100 setPri: 0 addToPic:)
			((View new:) view: 632 posn: 201 100 setPri: 0 addToPic:)
			((= newProp (Prop new:))
				view: 632
				posn: 115 43
				setLoop: 1
				setCycle: Fwd
				init:
			)
			((= newProp_2 (Prop new:))
				view: 632
				posn: 201 43
				setLoop: 1
				setCycle: Fwd
				init:
			)
		)
		((= newProp_3 (Prop new:))
			view: 101
			loop: 0
			cel: 0
			ignoreActors: 1
			posn: 159 126
			setPri: 11
			init:
		)
		((= newAct (Act new:))
			view: 112
			posn: 110 60
			setStep: 1 59
			setLoop: 0
			setCycle: Fwd
			setScript: Flutter3
			init:
		)
		((= newAct_2 (Act new:))
			view: 115
			posn: 200 59
			setStep: 1 1
			setLoop: 1
			setCycle: Fwd
			setScript: Flutter6
			init:
		)
		((= newProp_4 (Prop new:))
			view: 365
			posn: 59 130
			ignoreActors: 1
			init:
		)
		(if global223
			(newProp_4 setScript: catMove)
		else
			(newProp_4 addToPic:)
		)
		(gEgo observeBlocks: catBlock)
	)
	
	(method (doit)
		(super doit:)
		(if (gCast contains: gEgo)
			(if (& (gEgo onControl: 0) $0040)
				(gRoom newRoom: 46)
			)
			(if
				(and
					(gEgo inRect: 93 116 223 151)
					(!= (self script?) closer)
				)
				(cond 
					((< (gEgo x?) 158)
						(if (!= (newAct script?) ChaseEgo)
							(newAct setScript: ChaseEgo)
						)
					)
					((!= (newAct_2 script?) ChaseEgo) (newAct_2 setScript: ChaseEgo))
				)
			else
				(if (!= (newAct script?) ChaseEgoWhenTalk)
					(newAct setScript: Flutter3)
				)
				(if (!= (newAct_2 script?) ChaseEgoWhenTalk)
					(newAct_2 setScript: Flutter6)
				)
			)
		)
	)
	
	(method (dispose)
		(proc0_21)
		(super dispose:)
	)
	
	(method (handleEvent pEvent)
		(return
			(cond 
				((pEvent claimed?) (return 1))
				((== (pEvent type?) evSAID)
					(cond 
						((Said 'look>')
							(cond 
								((Said '[<on,in,at]/bed') (Print 45 0))
								((Said '<under/bed') (Print 45 1))
								((Said '/wand[<magic]') (Print 45 2))
								((Said '/window')
									(if (gEgo inRect: 113 110 208 122)
										(Print 45 3)
									else
										(Print 45 4)
									)
								)
								((Said '/blossom,flora') (Print 45 5))
								((Said '/stair') (Print 45 6))
								((Said '/chest,dresser,drawer>')
									(if (Said '<in,in')
										(Print 45 7)
									else
										(Print 45 8)
										(pEvent claimed: 1)
									)
								)
								((Said '/wall') (Print 45 9))
								((Said '[<down]/dirt') (Print 45 10))
								((Said '/genesta')
									(Print
										(Format
											@global228
											45
											11
											(if (== global169 1)
												{This will be a loss for Tamir, as the evil Lolotte will come to power!}
											else
												{_}
											)
										)
									)
								)
								((Said '/leopard[<snow,white]') (Print 45 12))
								(
								(Said '[<around][/room,tower,bedroom,chamber[<bed]]') (Print 45 13))
								(else (pEvent claimed: 0))
							)
						)
						((Said 'deliver,return/amulet[/genesta]')
							(if (gEgo has: 2)
								(proc0_21)
								(proc0_8)
								(= global160 30)
								(= global159 1)
								(gEgo put: 2 999)
								(fairyMusic dispose:)
								(Print 45 14 67 0 10 33 gSmallFont)
								(= global224 1)
								(self setScript: closer)
							else
								(Print 800 2)
							)
						)
						(
							(or
								(Said '(lay<down,on,in),(sleep<in,on),(get<in,on)[/bed]')
								(Said 'sleep[/!*]')
							)
							(Print 45 15)
						)
						((Said 'get/blossom') (Print 45 16))
						((Said 'get,get,rob/wand') (Print 45 17))
						((Said 'open/dresser,drawer,chest') (Print 45 7))
						(
						(or (Said 'converse/genesta') (Said 'converse[/!*]'))
							(Print 45 18)
							(cond 
								((< (gEgo x?) 158)
									(if (== (newAct script?) Flutter3)
										(newAct setScript: ChaseEgoWhenTalk)
									)
								)
								((== (newAct_2 script?) Flutter6) (newAct_2 setScript: ChaseEgoWhenTalk))
							)
						)
						((Said 'kill/genesta') (Print 45 19))
						((Said 'get/genesta') (Print 45 20))
						((or (Said 'kiss/genesta') (Said 'kiss[/!*]')) (Print 45 21))
						((Said 'help,save/genesta') (Print 45 22))
						(else (pEvent claimed: 0))
					)
					(if (not (pEvent claimed?))
						(cond 
							((Said 'look[/fairies[<little]]') (Print 45 23))
							((Said 'converse[/fairies]') (Print 45 24))
							((Said 'kill[/fairies]') (Print 45 25))
							((Said 'get/fairies') (Print 45 26))
							((Said 'capture/fairies') (Print 45 26))
							((Said 'kiss/fairies') (Print 45 27))
							((Said 'help/fairies') (Print 45 28))
							((Said 'converse/leopard[<snow,white]') (Print 45 29))
							((Said 'kill/leopard[<snow,white]') (Print 45 30))
							((Said 'get,capture/leopard[<snow,white]') (Print 45 31))
							((Said 'kiss,pat/leopard[<snow,white]') (Print 45 32))
							(
								(or
									(Said 'deliver/leopard/*')
									(Said 'deliver/*/leopard')
								)
								(Print 45 33)
							)
							(
								(or
									(Said 'deliver/fairies/*')
									(Said 'deliver/*/fairies')
								)
								(Print 45 34)
							)
							(
								(or
									(Said 'deliver/genesta,fairies/*')
									(Said 'deliver/*[/genesta,fairies]')
								)
								(Print 45 35)
							)
						)
					)
				)
			)
		)
	)
)

(instance ChaseEgo of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(Print 45 36 67 -1 10)
				(client
					yStep: 2
					illegalBits: 0
					setMotion: Chase gEgo 30 self
				)
			)
			(1
				(client
					yStep: 1
					setMotion: MoveTo (gEgo x?) (- (gEgo y?) 55) self
				)
			)
		)
	)
)

(instance ChaseEgoWhenTalk of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(client
					illegalBits: 0
					yStep: 2
					setMotion: MoveTo (gEgo x?) (+ (client y?) 25)
				)
				(= seconds 4)
			)
			(1 (client setScript: 0))
		)
	)
)

(instance Flutter3 of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(client illegalBits: 0 setMotion: MoveTo 103 60 self)
			)
			(1
				(client illegalBits: 8192 setMotion: Wander 5)
			)
		)
	)
)

(instance Flutter6 of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(client illegalBits: 0 setMotion: MoveTo 220 60 self)
			)
			(1
				(client illegalBits: 8192 setMotion: Wander 5)
			)
		)
	)
)

(instance catMove of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0 (= seconds 2))
			(1
				(newProp_4 setCycle: End self)
			)
			(2
				(if (> (Random 0 200) 180)
					(newProp_4
						cycleSpeed: 1
						setLoop: 1
						cel: 255
						setCycle: End self
					)
				else
					(self cue:)
				)
			)
			(3
				(newProp_4 stopUpd:)
				(= seconds 3)
			)
			(4
				(newProp_4 setLoop: 0)
				(= state -1)
				(self cue:)
			)
		)
	)
)

(instance closer of Script
	(properties)
	
	(method (init param1)
		(Load rsVIEW 101)
		(Load rsVIEW 103)
		(Load rsVIEW 104)
		(super init: param1)
	)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(proc0_8)
				(= global204 0)
				(proc0_21)
				(gGame changeScore: 10)
				(gCast eachElementDo: #hide)
				(DrawPic 991)
				(newProp_3 view: 103 loop: 0 posn: 160 159 show:)
				((= newProp_5 (Prop new:))
					view: 103
					loop: 1
					posn: (newProp_3 x?) (- (newProp_3 y?) 30)
					setPri: (+ (newProp_3 priority?) 1)
					init:
				)
				((= newProp_6 (Prop new:))
					view: 103
					loop: 2
					posn: (newProp_3 x?) (newProp_3 y?)
					setPri: (+ (newProp_3 priority?) 1)
					init:
					setCycle: Fwd
				)
				(= seconds 4)
			)
			(1
				(newProp_5 cycleSpeed: 2 setCycle: End)
				(= seconds 4)
			)
			(2
				(newProp_6 dispose:)
				(newProp_5 dispose:)
				(newProp_3 hide:)
				(= cycles 1)
			)
			(3
				(DrawPic 45 dpOPEN_CENTEREDGE)
				((View new:) view: 632 posn: 115 100 setPri: 0 addToPic:)
				((View new:) view: 632 posn: 201 100 setPri: 0 addToPic:)
				(newProp_3
					view: 101
					loop: 1
					cel: 0
					ignoreActors: 1
					posn: 159 126
					setPri: 11
				)
				(gCast eachElementDo: #show)
				(newProp_3 setCycle: End)
				(= seconds 4)
			)
			(4
				(Print 45 37 67 20 10)
				(Print 45 38 67 100 140)
				(newProp_3 loop: 2 setCycle: End self)
			)
			(5
				(Print 45 39 67 -1 150)
				(= local5 (Print 45 40 67 -1 10 88))
				(newProp_3 loop: 3 setCycle: Fwd)
				((= newProp_7 (Prop new:))
					view: 686
					ignoreActors: 1
					posn: (gEgo x?) (gEgo y?)
					setPri: (+ (gEgo priority?) 1)
					init:
					cel: 0
					setCycle: CT 5 1 self
				)
			)
			(6
				(gEgo dispose:)
				(newProp_7 cel: 5 setCycle: End self)
			)
			(7
				(newProp_7 dispose:)
				(proc0_21)
				(newProp_3 view: 104 loop: 1 setCycle: End self)
			)
			(8
				(= global205 1)
				(gRoom newRoom: 690)
			)
		)
	)
)

(instance fairyMusic of Sound
	(properties
		number 34
	)
)

(instance catBlock of Blk
	(properties
		top 125
		left 31
		bottom 131
		right 80
	)
)
