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

(public
	Room1 0
)

(local
	newAct
	newProp
	local2
	gEgoViewer
)
(instance waves of List
	(properties)
)

(instance wave1 of Prop
	(properties)
)

(instance wave2 of Prop
	(properties)
)

(instance wave3 of Prop
	(properties)
)

(instance Room1 of Rm
	(properties
		picture 1
	)
	
	(method (init)
		(= north 25)
		(= south 7)
		(= west 31)
		(= east 2)
		(= horizon 100)
		(= global101 0)
		(gEgo edgeHit: 0)
		(super init:)
		(if global100 (gRoom overlay: 101))
		(self setRegions: 503 501 504 506)
		(= gEgoViewer (gEgo viewer?))
		(if (== gPrevRoomNum 2) (= global105 0))
		(= newProp (Prop new:))
		(wave1
			isExtra: 1
			view: 665
			loop: 0
			cel: 0
			posn: 203 75
			setPri: 0
			ignoreActors:
			cycleSpeed: 3
			init:
		)
		(wave2
			isExtra: 1
			view: 665
			loop: 1
			cel: 0
			posn: 191 115
			setPri: 0
			ignoreActors:
			cycleSpeed: 3
			init:
		)
		(wave3
			isExtra: 1
			view: 665
			loop: 2
			cel: 0
			posn: 191 188
			setPri: 0
			ignoreActors:
			init:
			cycleSpeed: 3
			init:
		)
		(newProp
			isExtra: 1
			view: 650
			loop: 1
			cel: 1
			posn: 69 61
			setPri: 0
			ignoreActors:
			setCycle: Fwd
			init:
		)
		(waves add: wave1 wave2 wave3)
		(wave1 setScript: waveActions)
		(switch global105
			(0
				(switch gPrevRoomNum
					(south
						(if (> (gEgo x?) 128)
							(gEgo posn: 300 187)
						else
							(gEgo posn: 225 187)
						)
					)
					(north
						(gEgo x: 225 y: (+ horizon (gEgo yStep?) 1))
					)
					(0 (gEgo x: 220 y: 135))
					(east
						(if (<= (gEgo y?) horizon)
							(gEgo x: 318 y: (+ horizon (gEgo yStep?) 1))
						else
							(gEgo x: 318)
						)
					)
				)
			)
			(1
				(switch gPrevRoomNum
					(south (gEgo x: 186 y: 187))
					(north
						(gEgo x: 180 y: (+ horizon (gEgo yStep?) 1))
					)
				)
			)
			(2
				(switch gPrevRoomNum
					(south (gEgo x: 145 y: 187))
					(north
						(gEgo x: 167 y: (+ horizon (gEgo yStep?) 1))
					)
				)
			)
			(3
				(switch gPrevRoomNum
					(south (gEgo x: 100 y: 187))
					(north
						(gEgo x: 149 y: (+ horizon (gEgo yStep?) 1))
					)
				)
			)
			(4
				(switch gPrevRoomNum
					(south
						(cond 
							((> (gEgo x?) 78) (gEgo x: 30 y: 187))
							((< (gEgo x?) 20) (gEgo x: 20 y: 187))
							(else (gEgo x: (gEgo x?) y: 187))
						)
					)
					(25
						(if (> (gEgo x?) 78)
							(gEgo x: 78 y: (+ horizon (gEgo yStep?) 1))
						else
							(gEgo x: 95 y: (+ horizon (gEgo yStep?) 1))
						)
					)
					(31 (gEgo x: 1))
				)
			)
			(14
				(= global205 0)
				(gEgo viewer: 0 view: 312 setScript: rideDolphin)
				(rideDolphin changeState: 1)
			)
		)
		(gEgo init:)
	)
	
	(method (dispose)
		(waves dispose:)
		(super dispose:)
	)
	
	(method (handleEvent pEvent)
		(if (pEvent claimed?) (return 1))
		(return
			(if
			(and (== (pEvent type?) evSAID) (Said 'look>'))
				(cond 
					((Said '/grass') (Print 1 0))
					((Said '/brook') (Print 1 1))
					((Said '[<around][/room]') (Print 1 2))
				)
			else
				0
			)
		)
	)
)

(instance rideDolphin of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(1
				(proc0_8)
				(gEgo setMotion: MoveTo 66 136 self)
			)
			(2
				(= newAct (Act new:))
				(= global105 4)
				(gEgo viewer: gEgoViewer)
				(gEgo setStep: 3 2)
				(newAct
					view: 311
					posn: (gEgo x?) (- (gEgo y?) 5)
					setLoop: 2
					xStep: 2
					yStep: 1
					setCycle: Fwd
					init:
				)
				(= seconds 4)
			)
			(3
				(newAct
					xStep: 4
					yStep: 3
					setLoop: 5
					ignoreHorizon:
					ignoreActors:
					moveSpeed: 1
					setMotion: MoveTo -10 100 self
				)
				(proc0_9)
				(= global205 0)
			)
			(4
				(newAct dispose:)
				(gEgo setScript: 0)
			)
		)
	)
)

(instance waveActions of Script
	(properties)
	
	(method (changeState newState)
		(switch (= state newState)
			(0
				(= local2 0)
				(while (< local2 (waves size?))
					((View new:)
						view: ((waves at: local2) view?)
						loop: ((waves at: local2) loop?)
						cel: 0
						setPri: 0
						ignoreActors:
						x: ((waves at: local2) x?)
						y: ((waves at: local2) y?)
						init:
						addToPic:
						yourself:
					)
					(++ local2)
				)
				(= local2 0)
				(self changeState: 1)
			)
			(1
				((waves at: local2) cel: 255 show: setCycle: End self)
			)
			(2
				((waves at: local2) hide:)
				(if (< local2 (- (waves size?) 1))
					(++ local2)
				else
					(= local2 0)
				)
				(waveActions changeState: 1)
			)
		)
	)
)
