(include "sci.sh")
(use "Main")
(use "genetix")
(use "Tumbler")
(use "Polygon")
(use "CueObj")
(use "n958")
(use "Cycle")
(use "Sounds")
(use "View")
(use "Obj")
(script 770)


(local
    gEgoOnControl
    local1

)
(instance public rm770 of Rm
    (properties
        noun 4
        picture 115
    )

    (method (init)
        proc958_0(143 number)
        (send gSq5Music2:stop())
        (self:setRegions(31))
        = style 32868
        (super:init())
        (plate:
            init()
            setOnMeCheck(1 (plate:onMeCheck))
        )
        proc0_6(603)
        (send gEgo:
            view(603)
            init()
            scaleSignal(0)
            cycleSpeed(3)
            setStep(3 3)
            scaleX(128)
            scaleY(128)
            setCycle(Walk)
        )
        (switch (gGModNum)
            (case 730
                ((send gRoom:setScript(sFrom730))  )
            )
            (case 790
                ((send gRoom:setScript(sFrom790))  )
            )
            (default 
                (proc0_2(24) proc0_2(25) proc0_2(26) proc0_2(22) proc0_2(27) (send gRoom:setScript(sFrom790)) )
            )
        )
        (beam1:init())
        (beam2:init())
        (beam3:init())
        (beam4:init())
        (beam5:init())
        (beam6:init())
        (beam7:init())
        (beam8:init())
        (beam9:init())
        (send gRoom:addObstacle((send ((Polygon:new())):
                type(3)
                init(107 96 186 130 215 117 256 133 256 104 146 71 106 81 106 94)
                yourself()
            )
))
        (tumbler1:init())
        (tumbler2:init())
        (tumbler3:init())
        (tumbler4:init())
        (send gSq5Music1:
            number(121)
            setLoop(-1)
            play()
        )
    )


    (method (doit)
        = gEgoOnControl (send gEgo:onControl())
        (if (not (send gRoom:script))
            (if (& $1000 gEgoOnControl)
                (send gRoom:setScript(ScriptID(31 3) 0 7))
            )
            (if (& $0800 gEgoOnControl)
                (send gRoom:setScript(ScriptID(31 3) 0 8))
            )
        )
        (super:doit())
    )

)
(instance sFrom790 of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((send gSQ5:handsOff()) (send gEgo:
                    posn(108 63)
                    setMotion(MoveTo 140 83 self)
                )
  )
            )
            (case 1
                ((send gSQ5:handsOn()) (self:dispose()) )
            )
        )
    )

)
(instance sFrom730 of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((send gSQ5:handsOff()) (send gEgo:
                    posn(281 126)
                    setMotion(MoveTo 231 117 self)
                )
  )
            )
            (case 1
                ((send gSQ5:handsOn()) (self:dispose()) )
            )
        )
    )

)
(class Tumbler of Prop
    (properties
        x 0
        y 0
        z 0
        heading 0
        noun 1
        modNum -1
        nsTop 0
        nsLeft 0
        nsBottom 0
        nsRight 0
        sightAngle 26505
        actions 0
        onMeCheck 26505
        state 0
        approachX 0
        approachY 0
        approachDist 0
        _approachVerbs 0
        yStep 2
        view 615
        loop 1
        cel 0
        priority 3
        underBits 0
        signal 16
        lsTop 0
        lsLeft 0
        lsBottom 0
        lsRight 0
        brTop 0
        brLeft 0
        brBottom 0
        brRight 0
        scaleSignal 0
        scaleX 128
        scaleY 128
        maxScale 128
        cycleSpeed 6
        script 0
        cycler 0
        timer 0
        detailLevel 0
        scaler 0
    )

    (method (init)
        (super:init())
        = signal (| signal $0008)
    )


    (method (dispose)
        = signal (| signal $0008)
        = signal (| signal $8000)
    )


    (method (hide)
        (super:hide())
        (self:cue())
    )


    (method (show)
        (super:show())
        (self:cue())
    )


    (method (cue)
        (send gSq5Music2:
            number(611)
            setLoop(1)
            play()
        )
    )

)
(instance tumbler1 of Tumbler
    (properties
        x 251
        y 80
    )
)
(instance tumbler2 of Tumbler
    (properties
        x 251
        y 71
    )
)
(instance tumbler3 of Tumbler
    (properties
        x 251
        y 62
    )
)
(instance tumbler4 of Tumbler
    (properties
        x 251
        y 53
    )
)
(class Beam of Prop
    (properties
        x 0
        y 0
        z 0
        heading 0
        noun 2
        modNum -1
        nsTop 0
        nsLeft 0
        nsBottom 0
        nsRight 0
        sightAngle 26505
        actions 0
        onMeCheck 26505
        state 0
        approachX 0
        approachY 0
        approachDist 0
        _approachVerbs 0
        yStep 2
        view 615
        loop 0
        cel 0
        priority 0
        underBits 0
        signal 16
        lsTop 0
        lsLeft 0
        lsBottom 0
        lsRight 0
        brTop 0
        brLeft 0
        brBottom 0
        brRight 0
        scaleSignal 0
        scaleX 128
        scaleY 128
        maxScale 128
        cycleSpeed 6
        script 0
        cycler 0
        timer 0
        detailLevel 0
        scaler 0
    )

    (method (doit)
        (if (& onMeCheck gEgoOnControl)
            (if (not & signal $0088)
                (self:hide())
            )
        )(else
            (if (& signal $0088)
                (self:show())
            )
        )
        (super:doit())
    )


    (method (hide)
        (if (not local1)
            = local1 1
            (super:hide())
            (switch (self)
                (case beam2
                    (tumbler1:show())
                )
                (case beam4
                    (tumbler2:show())
                )
                (case beam6
                    (tumbler3:show())
                )
                (case beam8
                    (tumbler4:show())
                )
            )
        )
    )


    (method (show)
        = local1 0
        (super:show())
        (switch (self)
            (case beam2
                ((tumbler1:hide())  )
            )
            (case beam4
                ((tumbler2:hide())  )
            )
            (case beam6
                ((tumbler3:hide())  )
            )
            (case beam8
                ((tumbler4:hide()) )
            )
        )
    )

)
(instance beam1 of Beam
    (properties
        x 142
        y 71
        onMeCheck 2
        cel rm770
        priority 7
    )
)
(instance beam2 of Beam
    (properties
        x 162
        y 65
        onMeCheck 4
        cel 7
        priority 6
    )
)
(instance beam3 of Beam
    (properties
        x 180
        y 60
        onMeCheck rm770
        cel 5
        priority 5
    )
)
(instance beam4 of Beam
    (properties
        x 164
        y 79
        onMeCheck 16
        cel 6
        priority rm770
    )
)
(instance beam5 of Beam
    (properties
        x 184
        y 73
        onMeCheck 32
        cel 1
        priority 7
    )
)
(instance beam6 of Beam
    (properties
        x 203
        y 67
        onMeCheck 64
        cel 2
        priority 6
    )
)
(instance beam7 of Beam
    (properties
        x 189
        y 89
        onMeCheck 128
        cel 3
        priority 9
    )
)
(instance beam8 of Beam
    (properties
        x 210
        y 82
        onMeCheck 256
        cel 1
        priority rm770
    )
)
(instance beam9 of Beam
    (properties
        x 228
        y 75
        onMeCheck 512
        priority 7
    )
)
(instance plate of Feature
    (properties
        x 271
        y 189
        noun 3
        onMeCheck 21502
    )
)
(instance cliffy of MyActor
    (properties
        noun 1
        view 20
        signal 16384
    )
)
