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


(local
    local0

)
(instance waves of List
    (properties)
)
(instance wave1 of Prop
    (properties)
)
(instance wave2 of Prop
    (properties)
)
(instance wave3 of Prop
    (properties)
)
(instance public Room35 of Rm
    (properties
        picture 35
    )

    (method (init)
        (if (global100)
            = picture 135
        )
        = east (= north 31)
        = west 34
        = horizon 80
        = global101 0
        = gHorizon horizon
        (send gEgo:edgeHit(0))
        (super:init())
        (self:setRegions(505 501 503 504))
        (wave1:
            isExtra(1)
            view(662)
            loop(0)
            cel(0)
            posn(110 124)
            setPri(0)
            ignoreActors()
            cycleSpeed(3)
            init()
        )
        (wave2:
            isExtra(1)
            view(662)
            loop(1)
            cel(0)
            posn(166 143)
            setPri(0)
            ignoreActors()
            cycleSpeed(3)
            init()
        )
        (wave3:
            isExtra(1)
            view(662)
            loop(2)
            cel(0)
            posn(228 186)
            setPri(0)
            ignoreActors()
            cycleSpeed(3)
            init()
        )
        (waves:add(wave1 wave2 wave3))
        (wave1:setScript(waveActions))
        (switch (gPicture)
            (case 38
                ((send gEgo:
                    x(93)
                    y(188)
                )
  )
            )
            (case 41
                (
                (if (== (send gEgo:view()) 5)
                    (send gEgo:
                        x(236)
                        y(187)
                    )
                )(else
                    (if (== (send gEgo:view()) 6)
                        (send gEgo:
                            x(266)
                            y(187)
                        )
                    )(else
                        (if (== (send gEgo:view()) 7)
                            (send gEgo:
                                x(289)
                                y(187)
                            )
                        )(else
                            (if (== (send gEgo:view()) 8)
                                (send gEgo:
                                    x(310)
                                    y(187)
                                )
                            )(else
                                (send gEgo:
                                    x(212)
                                    y(183)
                                )
                            )
                        )
                    )
                )
 (send ((send gEgo:viewer())):doit())  )
            )
            (case 31
                (
                (if (<= (send gEgo:y()) horizon)
                    (send gEgo:posn((send gEgo:x()) (+ horizon 2)))
                )(else
                    (send gEgo:posn(317 (send gEgo:y())))
                )
 )
            )
            (case 34
                ((send gEgo:x(1)) )
            )
        )
        (send gEgo:
            xStep(2)
            yStep(1)
            init()
        )
    )


    (method (doit)
        (if (>= (send gEgo:y()) 189)
            (if (< (send gEgo:x()) 125)
                = gTheGGNewPropX 38
            )(else
                = gTheGGNewPropX 41
            )
        )(else
            (if (>= (send gEgo:x()) 319)
                = gTheGGNewPropX 31
            )(else
                (if (<= (send gEgo:x()) 0)
                    = gTheGGNewPropX 34
                )(else
                    (if (<= (send gEgo:y()) horizon)
                        = gTheGGNewPropX 31
                    )
                )
            )
        )
    )


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


    (method (handleEvent pEvent)
        (if ((== (send pEvent:type()) 128) and Said('look[<around][/room,island]'))
            Print(35 0)
        )
    )

)
(instance waveActions of Script
    (properties)

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

)
