(include "sci.sh")
(use "Main")
(use "Class_255_0")
(use "Cycle")
(use "Game")
(use "PV")
(use "Obj")
(script 1)


(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 public Room1 of Rm
    (properties
        picture 1
    )

    (method (init)
        = north 25
        = south 7
        = west 31
        = east 2
        = horizon 100
        = global101 0
        (send gEgo:edgeHit(0))
        (if (global100)
            = picture 101
        )
        (super:init())
        (self:setRegions(503 501 504 506))
        = gEgoViewer (send gEgo:viewer())
        (if (== gPicture 2)
            = global105 0
        )
        = newProp (Prop:new())
        (wave1:
            isExtra(1)
            view(665)
            loop(0)
            cel(0)
            posn(203 76)
            setPri(0)
            ignoreActors()
            cycleSpeed(3)
            init()
        )
        (wave2:
            isExtra(1)
            view(665)
            loop(1)
            cel(0)
            posn(191 116)
            setPri(0)
            ignoreActors()
            cycleSpeed(3)
            init()
        )
        (wave3:
            isExtra(1)
            view(665)
            loop(2)
            cel(0)
            posn(191 189)
            setPri(0)
            ignoreActors()
            init()
            cycleSpeed(3)
            init()
        )
        (send newProp:
            isExtra(1)
            view(650)
            loop(1)
            cel(1)
            posn(69 62)
            setPri(0)
            ignoreActors()
            setCycle(Fwd)
            init()
        )
        (waves:add(wave1 wave2 wave3))
        (wave1:setScript(waveActions))
        (switch (global105)
            (case 0
                (
                (switch (gPicture)
                    (case south
                        (
                        (if (> (send gEgo:x()) 128)
                            (send gEgo:posn(300 188))
                        )(else
                            (send gEgo:posn(225 188))
                        )
 )
                    )
                    (case north
                        ((send gEgo:
                            x(225)
                            y(+ horizon (+ (send gEgo:yStep()) 1))
                        )
  )
                    )
                    (case 0
                        ((send gEgo:
                            x(220)
                            y(135)
                        )
  )
                    )
                    (case east
                        (
                        (if (<= (send gEgo:y()) horizon)
                            (send gEgo:
                                x(318)
                                y(+ horizon (+ (send gEgo:yStep()) 1))
                            )
                        )(else
                            (send gEgo:x(318))
                        )
 )
                    )
                )
  )
            )
            (case 1
                (
                (switch (gPicture)
                    (case south
                        ((send gEgo:
                            x(186)
                            y(188)
                        )
  )
                    )
                    (case north
                        ((send gEgo:
                            x(180)
                            y(+ horizon (+ (send gEgo:yStep()) 1))
                        )
 )
                    )
                )
  )
            )
            (case 2
                (
                (switch (gPicture)
                    (case south
                        ((send gEgo:
                            x(145)
                            y(188)
                        )
  )
                    )
                    (case north
                        ((send gEgo:
                            x(167)
                            y(+ horizon (+ (send gEgo:yStep()) 1))
                        )
 )
                    )
                )
  )
            )
            (case 3
                (
                (switch (gPicture)
                    (case south
                        ((send gEgo:
                            x(100)
                            y(188)
                        )
  )
                    )
                    (case north
                        ((send gEgo:
                            x(149)
                            y(+ horizon (+ (send gEgo:yStep()) 1))
                        )
 )
                    )
                )
  )
            )
            (case 4
                (
                (switch (gPicture)
                    (case south
                        (
                        (if (> (send gEgo:x()) 78)
                            (send gEgo:
                                x(30)
                                y(188)
                            )
                        )(else
                            (if (< (send gEgo:x()) 20)
                                (send gEgo:
                                    x(20)
                                    y(188)
                                )
                            )(else
                                (send gEgo:
                                    x((send gEgo:x()))
                                    y(188)
                                )
                            )
                        )
 )
                    )
                    (case 25
                        (
                        (if (> (send gEgo:x()) 78)
                            (send gEgo:
                                x(78)
                                y(+ horizon (+ (send gEgo:yStep()) 1))
                            )
                        )(else
                            (send gEgo:
                                x(95)
                                y(+ horizon (+ (send gEgo:yStep()) 1))
                            )
                        )
 )
                    )
                    (case 31
                        ((send gEgo:x(1)) )
                    )
                )
  )
            )
            (case 14
                ((send gEgo:
                    viewer(0)
                    view(312)
                    setScript(rideDolphin)
                )
 (rideDolphin:changeState(1)) )
            )
        )
        (send gEgo:init())
    )


    (method (dispose)
        (waves:dispose())
        (super:dispose())
    )


    (method (handleEvent pEvent)
        (if ((send pEvent:claimed()))
            return 1
        )
        return 
            (if ((== (send pEvent:type()) 128) and Said('look>'))
                (if (Said('/grass'))
                    Print(1 0)
                )(else
                    (if (Said('/brook'))
                        Print(1 1)
                    )(else
                        (if (Said('[<around][/room]'))
                            Print(1 2)
                        )
                    )
                )
            )(else
                0
            )
    )

)
(instance rideDolphin of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 1
                (proc0_10() (send gEgo:setMotion(MoveTo 66 136 self))  )
            )
            (case 2
                (= newAct (Act:new()) = global105 4 (send gEgo:
                    viewer(gEgoViewer)
                    setStep(2 1)
                )
 (send newAct:
                    view(311)
                    posn((send gEgo:x()) - (send gEgo:y()) 5)
                    setLoop(2)
                    xStep(2)
                    yStep(1)
                    setCycle(Fwd)
                    init()
                )
 = seconds 4  )
            )
            (case 3
                ((send newAct:
                    xStep(4)
                    yStep(3)
                    setLoop(5)
                    ignoreHorizon()
                    ignoreActors()
                    moveSpeed(1)
                    setMotion(MoveTo 65526 100 self)
                )
 proc0_11() = global205 0  )
            )
            (case 4
                ((send newAct:dispose()) (send gEgo:setScript(0)) )
            )
        )
    )

)
(instance waveActions of Script
    (properties)

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

)
