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

(public
	Room24 0
)
(synonyms
	(pool pool lake)
)

(local
	local0
	newProp_9
	local2
	local3
	local4
	newProp_3
	newProp_7
	newProp_8
	newProp_4
	newProp
	newProp_2
	local11
	newProp_5
	newProp_6
)
(instance poofSound of Sound
	(properties
		number 59
	)
)

(instance Room24 of Rm
	(properties
		picture 24
	)
	
	(method (init)
		(= north 18)
		(= south 30)
		(= west 23)
		(= east 70)
		(= horizon 85)
		(= global101 0)
		(gEgo edgeHit: 0)
		(= global205 0)
		(super init:)
		(if global100 (gRoom overlay: 124))
		(self setRegions: 501 512 511 508)
		(Load rsVIEW 8)
		(if (gEgo has: 10)
			(Load rsVIEW 680)
			(Load rsVIEW 370)
			(Load rsVIEW 371)
			(Load rsVIEW 372)
			(Load rsVIEW 377)
		)
		(= newProp (Prop new:))
		(= newProp_2 (Prop new:))
		(if (== global223 2)
			(= newProp_3 (Prop new:))
			(= newProp_4 (Prop new:))
			(newProp_3
				isExtra: 1
				view: 651
				loop: 0
				cel: 2
				posn: 273 30
				setPri: 0
				setCycle: Fwd
				ignoreActors:
				init:
			)
			(newProp_4
				isExtra: 1
				view: 651
				loop: 3
				cel: 2
				posn: 251 100
				setPri: 0
				setCycle: Fwd
				ignoreActors:
				init:
			)
			(= newProp_5 (Prop new:))
			(= newProp_6 (Prop new:))
			(newProp_5
				isExtra: 1
				view: 653
				loop: 1
				cel: 0
				posn: 79 151
				setPri: 0
				setCycle: Fwd
				ignoreActors:
				init:
			)
			(newProp_6
				isExtra: 1
				view: 653
				loop: 2
				cel: 1
				posn: 107 158
				setPri: 0
				setCycle: Fwd
				ignoreActors:
				init:
			)
		)
		(= newProp_7 (Prop new:))
		(newProp_7
			isExtra: 1
			view: 651
			loop: 1
			cel: 3
			posn: 272 57
			setPri: 0
			setCycle: Fwd
			ignoreActors:
			init:
		)
		(= newProp_8 (Prop new:))
		(newProp_8
			isExtra: 1
			view: 651
			loop: 2
			cel: 2
			posn: 268 94
			setPri: 0
			setCycle: Fwd
			ignoreActors:
			init:
		)
		(newProp
			isExtra: 1
			view: 651
			loop: 4
			cel: 2
			posn: 262 145
			setPri: 0
			setCycle: Fwd
			ignoreActors:
			init:
		)
		(newProp_2
			isExtra: 1
			view: 651
			loop: 5
			cel: 2
			posn: 249 165
			setPri: 0
			setCycle: Fwd
			ignoreActors:
			init:
		)
		(switch gPrevRoomNum
			(north
				(gEgo view: 2 x: 47 y: (+ horizon (gEgo yStep?) 1))
			)
			(west
				(gEgo view: 2 x: 1)
				(if (<= (gEgo y?) horizon)
					(gEgo y: (+ horizon (gEgo yStep?) 1))
				)
			)
			(south
				(gEgo view: 2 y: 188)
				(if (> (gEgo x?) 214) (gEgo x: 214))
			)
			(east
				(gEgo view: 8 loop: 1 posn: 207 159)
			)
			(0 (gEgo x: 200 y: 188))
		)
		(gEgo init:)
	)
	
	(method (doit)
		(super doit:)
		(if
			(and
				(& (gEgo onControl: 0) $0010)
				(== (gEgo view?) 8)
				(== (gEgo script?) 0)
			)
			(gEgo setScript: swept)
		)
	)
	
	(method (handleEvent pEvent)
		(if (pEvent claimed?) (return 1))
		(return
			(if (== (pEvent type?) evSAID)
				(cond 
					((Said 'look>')
						(cond 
							((Said '<in/falls') (Print 24 0))
							((Said '<under/pool,water,falls')
								(if (!= (gEgo view?) 8)
									(Print 24 1)
								else
									(Print 24 2)
								)
							)
							((Said '<in,in/water,pool') (Print 24 3))
							((Said '<behind/falls') (Print 24 4))
							((Said '/falls') (Print 24 5))
							((Said '<in/pool') (Print 24 6))
							((Said '/pool') (Print 24 7))
							((Said '[<around][/room]') (Print 24 8))
						)
					)
					((Said 'enter<behind/falls') (Print 24 9))
					((Said 'bathe,dive<under/pool,water,falls')
						(cond 
							((== (gEgo view?) 8) (Print 24 10))
							((!= (gEgo view?) 2) (Print 24 11))
							(else (Print 24 12))
						)
					)
					((Said 'bathe,dive,wade')
						(cond 
							((== (gEgo view?) 2) (Print 24 13))
							((== (gEgo view?) 8) (Print 24 14))
							(else (Print 24 15))
						)
					)
					((Said 'dennis,place/crown')
						(if (gEgo has: 10)
							(if (== (gEgo view?) 2)
								(gEgo setScript: egoFrogActions)
								(egoFrogActions changeState: 1)
								(if (== global200 0)
									(gGame changeScore: 5)
									(= global200 1)
								)
							else
								(Print 24 16)
							)
						else
							(proc0_17)
						)
					)
				)
			else
				0
			)
		)
	)
	
	(method (newRoom newRoomNumber)
		(gEgo viewer: 0)
		(super newRoom: newRoomNumber)
	)
)

(instance egoFrogActions of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(1
				(proc0_8)
				(gEgo setMotion: 0)
				(poofSound play:)
				(= newProp_9 (Prop new:))
				(newProp_9
					posn: (gEgo x?) (gEgo y?)
					setPri: (+ (gEgo priority?) 1)
					view: 680
					cel: 0
					loop: 0
					ignoreActors:
					setCycle: CT 5 1 self
					init:
				)
			)
			(2
				(newProp_9 setCycle: End self)
				(gEgo view: 370 setCycle: Fwd setMotion: 0)
			)
			(3
				(Timer setReal: self 3)
				(newProp_9 dispose:)
			)
			(4
				(gEgo view: 372 setCycle: Walk setAvoider: Avoid)
				(gEgo viewer: frogViewer)
				(cond 
					(
						(or
							(gEgo inRect: 0 84 54 137)
							(gEgo inRect: 0 84 78 96)
						)
						(gEgo setMotion: MoveTo 38 (gEgo y?) self)
					)
					((gEgo inRect: 53 95 155 115) (gEgo setMotion: MoveTo 64 (gEgo y?) self))
					((gEgo inRect: 0 115 229 148) (gEgo setMotion: MoveTo 151 (gEgo y?) self))
					((gEgo inRect: 0 137 79 168)
						(gEgo setMotion: MoveTo 63 164 self)
						(self changeState: 10)
					)
					((> (gEgo y?) 171) (self changeState: 10))
					(else (self changeState: 20))
				)
			)
			(5
				(gEgo setMotion: MoveTo 151 141 self)
			)
			(6
				(gEgo setMotion: MoveTo 193 166 self)
			)
			(7 (self changeState: 20))
			(10
				(gEgo setMotion: MoveTo 217 182 self)
			)
			(11 (self changeState: 20))
			(20
				(gEgo setMotion: MoveTo 223 168 self)
			)
			(21
				(gEgo hide:)
				(= global205 1)
				(proc0_9)
				(gRoom newRoom: 70)
			)
		)
	)
)

(instance frogViewer of Script
	(properties)
	
	(method (doit)
		(super doit:)
		(= local4 (= local3 (gEgo onControl: 1)))
		(if (& local3 $0001)
			(gEgo view: 371)
		else
			(gEgo view: 377)
		)
	)
)

(instance swept of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(proc0_8)
				(if (< (gEgo x?) 255)
					(gEgo
						setLoop: 0
						xStep: 4
						setMotion: MoveTo (- (gEgo x?) 15) (gEgo y?) self
					)
				else
					(gEgo
						setLoop: 3
						illegalBits: 0
						xStep: 4
						yStep: 3
						setMotion: MoveTo (- (gEgo x?) 5) (+ (gEgo y?) 7) self
					)
				)
				(= local2 (Timer setReal: self 3))
			)
			(1
				(if (IsObject local2) (local2 dispose: delete:))
				(Print 24 17)
				(gEgo
					xStep: 3
					yStep: 2
					illegalBits: -32768
					setLoop: -1
					setScript: 0
				)
				(proc0_9)
			)
		)
	)
)
