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

(public
	Room15 0
)
(synonyms
	(lake lake)
	(prince prince prince prince man)
)

(local
	local0
	local1
	local2
	newAct
	newProp_5
	local5
	newView
	newProp
	newProp_2
	newProp_3
	newProp_4
)
(instance frogTheme of Sound
	(properties
		number 28
	)
)

(instance poofSound of Sound
	(properties
		number 59
	)
)

(instance Room15 of Rm
	(properties
		picture 15
	)
	
	(method (init)
		(= north 9)
		(= south 21)
		(= east 16)
		(= west 14)
		(= horizon 75)
		(= global101 0)
		(if (<= (gEgo y?) horizon)
			(gEgo posn: (gEgo x?) (- horizon 2))
		)
		(if (< (gEgo x?) 29) (gEgo x: 29))
		(super init:)
		(if global100 (gRoom overlay: 115))
		(self setRegions: 507)
		(gEgo view: 2 setStep: 3 2 init:)
		(if (== global110 0)
			(Load rsVIEW 518)
			(Load rsVIEW 375)
			(Load rsVIEW 372)
			(Load rsVIEW 373)
			(Load rsVIEW 376)
			(Load rsVIEW 377)
			(Load rsVIEW 370)
			(Load rsVIEW 378)
			(Load rsVIEW 26)
			(Load rsVIEW 27)
			(Load rsVIEW 29)
			(Load rsVIEW 21)
			(Load rsVIEW 6)
			(Load rsVIEW 27)
			(Load rsVIEW 28)
			(Load rsVIEW 680)
			(Load rsVIEW 225)
			(Load rsVIEW 226)
			(Load rsVIEW 227)
		)
		(= newProp (Prop new:))
		(= newProp_2 (Prop new:))
		(= newProp_3 (Prop new:))
		(= newProp_4 (Prop new:))
		(newProp
			isExtra: 1
			view: 650
			loop: 2
			cel: 0
			posn: 242 153
			setPri: 11
			ignoreActors:
			cycleSpeed: 1
			setCycle: Fwd
			init:
		)
		(newProp_2
			isExtra: 1
			view: 650
			loop: 3
			cel: 0
			posn: 187 146
			setPri: 10
			ignoreActors:
			cycleSpeed: 1
			setCycle: Fwd
			init:
		)
		(newProp_3
			isExtra: 1
			view: 650
			loop: 4
			cel: 0
			posn: 89 141
			setPri: 10
			ignoreActors:
			cycleSpeed: 1
			setCycle: Fwd
			init:
		)
		(newProp_4
			isExtra: 1
			view: 650
			loop: 5
			cel: 1
			posn: 220 138
			setPri: 10
			ignoreActors:
			cycleSpeed: 1
			setCycle: Fwd
			init:
		)
		(if (== gPrevRoomNum 0) (gEgo x: 1 y: 150))
		((View new:)
			view: 518
			loop: 0
			cel: (if global100 1 else 0)
			setPri: 10
			posn: 204 147
			init:
			addToPic:
		)
		(if ((Inv at: 10) ownedBy: 200)
			(= newAct (Act new:))
			(frogTheme play:)
			(= global110 0)
			(newAct
				view: 370
				cycleSpeed: 2
				setCycle: Fwd
				x: 206
				y: 145
				ignoreActors:
				init:
			)
		)
		(if ((Inv at: 5) ownedBy: 15)
			((= newView (View new:))
				view: 518
				loop: 1
				cel: 0
				posn: 265 134
				ignoreActors:
				stopUpd:
				init:
			)
		)
		(gRoom setScript: frogActions)
	)
	
	(method (doit)
		(super doit:)
		(if
			(and
				(== (= local0 (gEgo onControl: 1)) 512)
				(== global110 0)
			)
			(frogActions changeState: 1)
		)
		(if (!= local1 local0)
			(= local1 local0)
			(switch local0
				(1
					(if (not (gEgo has: 11))
						(= global105 0)
						(gEgo view: 2)
					)
				)
				(512
					(if (not (gEgo has: 11))
						(gEgo view: 6)
						(= global105 2)
					)
				)
			)
		)
	)
	
	(method (handleEvent pEvent &tmp gInvSaidMe)
		(if
			(and
				(== global110 4)
				(or
					(!= (gEgo xLast?) (gEgo x?))
					(!= (gEgo yLast?) (gEgo y?))
					(== (pEvent type?) evJOYSTICK)
					(== (pEvent type?) evMOUSEBUTTON)
				)
			)
			((Inv at: 11) moveTo: 15)
			(frogActions changeState: 60)
			(= global110 7)
		)
		(if (pEvent claimed?) (return 1))
		(return
			(if (== (pEvent type?) evSAID)
				(cond 
					((Said '/prince>')
						(if
						(and (== global110 5) (gCast contains: newAct))
							(cond 
								((Said 'look') (Print 15 0))
								((Said 'converse') (Print 15 1))
								((Said 'get') (Print 15 2))
								((Said 'kiss') (Print 15 3))
							)
						else
							(Print 15 4)
							(pEvent claimed: 1)
						)
					)
					(
						(or
							(Said 'fish<enter')
							(Said 'capture/fish')
							(Said 'cast/pole')
						)
						(Print 15 5)
					)
					((Said 'look,find,look/frog')
						(cond 
							((gEgo has: 11) ((Inv at: 11) showSelf:))
							((or (== global110 0) (== global110 3)) (Print 15 6))
							((== global110 1) (Print 15 7))
							((== global110 2) (Print 15 8))
							((== global110 4) (Print 15 9))
							(else (Print 15 10))
						)
					)
					((Said 'look>')
						(cond 
							((Said '<under,in/water') (Print 15 7))
							((Said '/lake,water')
								(Print
									(Format
										@global228
										15
										11
										(if (== global110 0)
											{You spy a large frog sitting on top of a big lily pad, and YES!...it's wearing a little gold crown!}
										else
											{_}
										)
									)
								)
							)
							((or (Said '<down[/dirt]') (Said '/dirt'))
								(cond 
									(
									(and ((Inv at: 5) ownedBy: 15) (== global110 3)) (Print 15 12))
									(((Inv at: 5) ownedBy: 15) (Print 15 13))
									((== global110 3) (Print 15 14))
									(else (Print 15 15))
								)
							)
							((Said '/lilies,pad')
								(Print
									(Format
										@global228
										15
										16
										(if (== global110 0)
											{Atop one large lily pad, sits a big frog.}
										else
											{}
										)
									)
								)
							)
							((Said '/crown')
								(cond 
									((== global110 4) (Print 15 17))
									((gEgo has: 10) ((Inv at: 10) showSelf:))
									(else (Print 800 1))
								)
							)
							((Said '/blossom') (Print 15 18))
							((Said '[<around][/room]')
								(Print
									(Format
										@global228
										15
										19
										(if (== global110 0)
											{Atop one of the bigger lily pads, you notice a rather large frog...wearing a little gold crown!}
										else
											{}
										)
									)
								)
							)
						)
					)
					((Said 'get/blossom') (Print 15 20))
					((Said 'bathe,dive') (Print 15 21))
					((Said 'wade') (Print 15 22))
					((or (Said 'get/drink') (Said 'drink[/water]'))
						(= local2 (proc0_2 gEgo 12))
						(cond 
							((== (gEgo view?) 2)
								(if (& local2 $0200)
									(= gGEgoScript (gEgo script?))
									(gEgo setScript: drinking)
								else
									(Print 800 1)
								)
							)
							((== (gEgo view?) 6) (Print 15 23))
							(else (Print 15 24))
						)
					)
					((Said 'get,get,capture/frog')
						(cond 
							((== global110 4) (Print 800 0))
							((== global110 1) (Print 15 25))
							((== global110 5) (Print 15 26))
							((!= global110 3) (Print 15 27))
							((== (gEgo view?) 6) (Print 15 28))
							((gEgo has: 5) (proc0_16))
							((gEgo inRect: 249 133 266 139) (Print 15 29))
							((== global110 7) (proc0_16))
							((== global110 3)
								(if (< (gEgo distanceTo: newAct) 13)
									(proc0_8)
									(proc0_3 gEgo newAct)
									(frogActions changeState: 10)
								else
									(Print 15 30)
								)
							)
						)
					)
					((Said 'get/lilies,pad') (Print 15 31))
					((Said 'converse[/frog]')
						(if
						(or (== global110 0) (== global110 3) (== global110 4))
							(Print 15 32)
							(Print 15 33)
						else
							(Print 15 34)
						)
					)
					((Said 'fling,drop,place,deliver/ball')
						(if (gEgo has: 5)
							(cond 
								((== global110 0)
									(if ((Inv at: 10) ownedBy: 200)
										(if
											(and
												(& (= local2 (proc0_2 gEgo 15)) $0200)
												(== (gEgo view?) 2)
											)
											(proc0_8)
											(proc0_3 gEgo newAct)
											(Print 15 35 83)
											(= global110 2)
											(frogActions changeState: 3)
										else
											(Print 15 36)
										)
									else
										(Print 15 37)
									)
								)
								((!= (gEgo view?) 2) (Print 15 38))
								(else (Print 15 39))
							)
						else
							(Print 15 40)
						)
					)
					((or (Said 'kiss/frog') (Said 'kiss[/!*]'))
						(if (== global110 4)
							(Print 15 41)
							(frogActions changeState: 50)
							(= global110 5)
						else
							(Print 15 42)
						)
					)
					((Said 'get/ball')
						(if (== (gEgo view?) 2)
							(cond 
								((== global110 7) (proc0_16))
								(((Inv at: 5) ownedBy: 15)
									(if (< (gEgo distanceTo: newView) 10)
										(proc0_8)
										(gEgo setScript: ballActions)
										(ballActions changeState: 1)
									else
										(Print 800 1)
									)
								)
								((gEgo has: 5) (Print 800 0))
								(else (Print 15 43))
							)
						else
							(proc0_16)
						)
					)
					((Said 'deliver>')
						(if (= gInvSaidMe (gInv saidMe:))
							(if (gEgo has: (gInv indexOf: gInvSaidMe))
								(if (gCast contains: newAct)
									(Print 15 44)
								else
									(Print 15 45)
								)
							else
								(proc0_17)
							)
						)
					)
					((Said 'get,rob/crown')
						(cond 
							((gEgo has: 10) (Print 800 0))
							((== global110 4)
								(Print 15 46)
								((Inv at: 10) moveTo: gEgo)
								(= global182 1)
								(gEgo
									view: 2
									loop: 1
									cycleSpeed: 0
									setCycle: Walk
									put: 11 999
								)
								(gGame changeScore: 2)
								(= global110 6)
								(frogActions changeState: 70)
							)
							(else (Print 15 42))
						)
					)
				)
			else
				0
			)
		)
	)
	
	(method (newRoom newRoomNumber)
		(super newRoom: newRoomNumber)
	)
)

(instance frogActions of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(1
				(= global110 1)
				(Print 15 47 25 3)
				(newAct
					view: 373
					cycleSpeed: 0
					loop: 0
					cel: 255
					setCycle: End
					illegalBits: 0
					setMotion: MoveTo (+ (newAct x?) 10) (- (newAct y?) 5) self
				)
			)
			(2
				(newAct hide:)
				(frogActions changeState: 100)
			)
			(3
				(= seconds 2)
				(Load rsVIEW 377)
				(Load rsVIEW 372)
				(Load rsVIEW 373)
			)
			(4
				(gEgo setMotion: 0)
				(newAct
					view: 373
					show:
					cycleSpeed: 0
					setLoop: 0
					cel: 255
					xStep: 2
					yStep: 2
					illegalBits: 0
					ignoreActors: 0
					setCycle: End self
					setMotion: MoveTo (+ (newAct x?) 8) (newAct y?)
				)
				((Inv at: 5) moveTo: 15)
			)
			(5
				(newAct ignoreActors: hide:)
				(= seconds 4)
			)
			(6
				(if (gEgo inRect: 247 132 278 140)
					(gEgo setScript: ballActions)
					(ballActions changeState: 10)
				)
				(newAct
					view: 377
					setLoop: 0
					cel: 0
					xStep: 2
					setAvoider: (Avoid new:)
					setCycle: Fwd
					illegalBits: 0
					cycleSpeed: 0
					moveSpeed: 0
					show:
					setMotion: MoveTo 250 139 self
				)
			)
			(7
				(newAct
					view: 372
					xStep: 2
					setLoop: -1
					cel: 0
					cycleSpeed: 1
					moveSpeed: 1
					setMotion: MoveTo 265 137 self
				)
			)
			(8
				(newAct
					view: 370
					cel: 0
					ignoreActors: 0
					cycleSpeed: 2
					setCycle: Fwd
				)
				(= global110 3)
				(= newView (View new:))
				(newView
					view: 518
					loop: 1
					cel: 0
					posn: (+ (newAct x?) 5) (newAct y?)
					ignoreActors:
					stopUpd:
					init:
				)
				(proc0_9)
			)
			(10
				(proc0_3 gEgo newAct)
				(gEgo view: 21 ignoreActors: setCycle: End self)
			)
			(11
				(newAct dispose:)
				((Inv at: 11) moveTo: gEgo)
				(gEgo view: 27 ignoreActors: 0 setCycle: End self)
			)
			(12
				(gEgo
					view: 28
					setCycle: Walk
					setMotion: MoveTo 294 134 self
				)
			)
			(13
				(gEgo view: 30 loop: 0 cycleSpeed: 1 setCycle: Fwd)
				(proc0_18)
				(Print 15 48)
				(= global110 4)
				(proc0_9)
			)
			(50
				(proc0_8)
				(gEgo
					view: 29
					loop: 1
					cel: 0
					cycleSpeed: 0
					setCycle: End self
					put: 11 999
				)
				(gGame changeScore: 3)
			)
			(51
				(gEgo loop: 3 cel: 255 setCycle: End self)
			)
			(52
				(poofSound play:)
				((= newProp_5 (Prop new:))
					posn: (- (gEgo x?) 15) (gEgo y?)
					setPri: (+ (gEgo priority?) 1)
					view: 680
					cel: 255
					loop: 0
					ignoreActors:
					setCycle: CT 5 1 self
					init:
				)
			)
			(53
				(newProp_5 setCycle: End self)
				(= newAct (Act new:))
				(newAct
					posn: (- (gEgo x?) 19) (gEgo y?)
					view: 225
					cel: 0
					setLoop: 2
					illegalBits: -32256
					init:
				)
				(gEgo view: 2)
				(proc0_3 gEgo newAct 1)
			)
			(54
				(newProp_5 dispose:)
				(Print 15 49 67 -1 10)
				(Print 15 50 67 -1 10)
				(newAct cycleSpeed: 1 setAvoider: (Avoid new:))
				(Print 15 51)
				((Inv at: 10) moveTo: gEgo)
				(= global182 1)
				(gGame changeScore: 2)
				(if (< (newAct x?) (gEgo x?))
					(= local5 0)
				else
					(= local5 1)
				)
				(newAct
					view: 226
					setStep: 2 1
					setLoop: -1
					loop: local5
					setCycle: End self
				)
			)
			(55
				(newAct
					view: 227
					cycleSpeed: 0
					setCycle: Walk
					setAvoider: (Avoid new:)
				)
				(if (< (newAct x?) 150)
					(newAct setMotion: MoveTo -10 150 self)
				else
					(newAct setMotion: MoveTo 330 150 self)
				)
			)
			(56
				(proc0_9)
				(gEgo setCycle: Walk)
				(newAct dispose:)
			)
			(60
				(gEgo view: 2 setLoop: -1 cycleSpeed: 0 setCycle: Walk)
				(= newAct (Act new:))
				(newAct
					view: 372
					setCycle: Walk
					posn: (- (gEgo x?) 10) (gEgo y?)
					setMotion: MoveTo (- (newView x?) 3) (newView y?) self
					init:
				)
			)
			(61
				(= global110 3)
				(newAct view: 370 loop: 0 cycleSpeed: 3 setCycle: Fwd)
			)
			(70
				(= global110 1)
				(= newAct (Act new:))
				(newAct
					view: 378
					posn: (- (gEgo x?) 6) (+ (gEgo y?) 4)
					illegalBits: 0
					setAvoider: (Avoid new:)
					setCycle: Walk
					setMotion: MoveTo 244 142 self
					init:
				)
			)
			(71 (newAct dispose:))
			(100 (= seconds (Random 3 8)))
			(101
				(if (== (gEgo onControl: 1) 512)
					(self changeState: 100)
				else
					(newAct
						view: 378
						loop: 1
						posn: 216 139
						cel: 255
						cycleSpeed: 1
						setCycle: End self
						setMotion: MoveTo 206 145
						show:
					)
				)
			)
			(102
				(newAct
					view: 370
					loop: 0
					illegalBits: -32768
					cycleSpeed: 2
					setCycle: Fwd
				)
				(= global110 0)
			)
		)
	)
)

(instance ballActions of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(1
				(proc0_8)
				(proc0_3 gEgo newView)
				(gEgo view: 21 cel: 255 setCycle: End self)
			)
			(2
				(newView dispose:)
				(gEgo get: 5)
				(gEgo setCycle: Beg self)
			)
			(3
				(gEgo view: 2 setCycle: Walk)
				(if (or (== global110 4) (== global110 3))
					(newAct
						illegalBits: 0
						ignoreActors:
						view: 373
						cel: 255
						setLoop: 1
						setMotion: MoveTo 244 142
						cycleSpeed: 1
						setCycle: End self
					)
				)
				(proc0_9)
			)
			(4
				(= global110 1)
				(frogActions changeState: 100)
				(newAct hide:)
				(proc0_9)
			)
			(10
				(gEgo
					setMotion: MoveTo (+ (gEgo x?) 10) (- (gEgo y?) 10) self
				)
			)
			(11 (gEgo loop: 1))
		)
	)
)

(instance drinking of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(proc0_8)
				(gEgo view: 21 cel: 255 setCycle: End self)
			)
			(1
				(= seconds 5)
				(= global120 (Print 15 52 67 -1 10 88))
			)
			(2 (gEgo setCycle: Beg self))
			(3
				(proc0_9)
				(proc0_21)
				(gEgo view: 2 setCycle: Walk)
				(gEgo script: gGEgoScript)
			)
		)
	)
)
