(include "sci.sh")
(use "Main")
(use "Scaler")
(use "RandCycle")
(use "Polygon")
(use "CueObj")
(use "n958")
(use "Sound")
(use "Cycle")
(use "Sounds")
(use "View")
(use "Obj")
(script 330)


(local
    local0

)
(instance public rm330 of Rm
    (properties
        noun rm330
        picture sShipBlow
        style 32778
        vanishingY 30
    )

    (method (init)
        (self:setRegions(350))
        proc958_0(128 0 446 445)
        (send gRoom:addObstacle((send ((Polygon:new())):
                type(3)
                init(70 91 75 106 63 111 60 140 113 139 110 129 127 117 200 113 204 118 188 129 139 130 128 139 131 153 161 161 261 160 264 146 229 136 237 121 274 131 304 126 188 99 172 99 173 94 147 88 136 88 163 98 162 105 168 107 123 111 94 103 81 89 68 90)
                yourself()
            )
))
        (lights1:
            init()
            setCycle(Fwd)
        )
        (lights2:
            init()
            setCycle(Fwd)
        )
        (lights3:
            init()
            setCycle(Fwd)
        )
        (send gSq5Music2:
            number(430)
            setLoop(-1)
            play()
        )
        (elevator:init())
        (cloakPanel:
            init()
            approachVerbs(4)
        )
        (pilotArea:
            init()
            approachVerbs(3 4)
            setOnMeCheck(1 2)
        )
        (leftDwoot:
            init()
            setOnMeCheck(1 64)
        )
        (rightDwoot:
            init()
            setOnMeCheck(1 512)
        )
        (screen:
            init()
            setOnMeCheck(1 16)
        )
        (viewWindow:
            init()
            setOnMeCheck(1 1024)
        )
        (switch (gGModNum)
            (case 335
                ((countdown1:
                    init()
                    setCycle(RTRandCycle)
                    setScript(sShipBlow)
                )
 (countdown2:
                    init()
                    setCycle(RTRandCycle)
                )
 (elevator:
                    x(183)
                    y(138)
                )
 (cloakPanel:cel(2)) proc0_6(0) (send gEgo:
                    x(225)
                    y(115)
                    loop(5)
                    setScale(Scaler 100 53 121 83)
                    actions(ScriptID(350 1))
                    init()
                )
 (send gSq5Music1:
                    number(124)
                    setLoop(-1)
                    play()
                )
 (send gSQ5:handsOn())  )
            )
            (default 
                ((send gRoom:setScript(sRogEnters)) (send gEgo:actions(ScriptID(350 1))) )
            )
        )
        (super:init())
        (send gWalkHandler:addToFront(pilotArea))
    )


    (method (doit param1)
        Palette(6 225 234 2)
        (if (proc0_5(gEgo 4) and not (send gRoom:script))
            (send gRoom:setScript(sRogExits))
        )
        (super:doit(rest param1))
    )


    (method (dispose param1)
        (theMusic3:dispose())
        (send gWalkHandler:delete(pilotArea))
        Joystick(3)
        (super:dispose(rest param1))
    )

)
(instance sShipBlow of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (= seconds 20  )
            )
            (case 1
                ((send gSQ5:handsOff()) Joystick(3) Joystick(0 921 1) (theMusic3:
                    number(203)
                    setLoop(1)
                    play(self)
                )
  )
            )
            (case 2
                (proc0_9(22) )
            )
        )
    )

)
(instance sRogEnters of Script
    (properties)

    (method (doit param1)
        (if (> (send gEgo:y) 146)
            (elevator:posn(183 (- (send gEgo:y) 9)))
        )
        (super:doit(rest param1))
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((send gEgo:
                    view(0)
                    setCel(2)
                    posn(191 216)
                    priority(4)
                    signal(16)
                    setScale(Scaler 100 53 121 83)
                    init()
                    setCycle(0)
                    setLoop(-1)
                    setLoop(8)
                )
 = ticks 10  )
            )
            (case 1
                ((theMusic3:
                    number(128)
                    setLoop(-1)
                    play()
                )
 (send gEgo:setMotion(MoveTo 191 147 self))  )
            )
            (case 2
                ((theMusic3:stop()) proc0_6(0) (send gEgo:setMotion(MoveTo 209 136 self))  )
            )
            (case 3
                ((send gSQ5:handsOn()) (self:dispose()) )
            )
        )
    )

)
(instance sRogExits of Script
    (properties)

    (method (doit param1)
        (if (> (send gEgo:y) 146)
            (elevator:
                x(183)
                y(- (send gEgo:y) 9)
            )
        )
        (super:doit(rest param1))
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((send gSQ5:handsOff()) 
                (if ((countdown1:script))
                    (sShipBlow:dispose())
                )
 (send gEgo:setMotion(MoveTo 191 147 self))  )
            )
            (case 1
                ((theMusic3:
                    number(128)
                    setLoop(-1)
                    play()
                )
 (send gEgo:
                    setPri(4)
                    setCycle(0)
                    setLoop(-1)
                    setLoop(2)
                    setMotion(MoveTo 191 216 self)
                )
  )
            )
            (case 2
                ((send gSq5Music2:fade()) (send gRoom:newRoom(325)) )
            )
        )
    )

)
(instance sRogSitAndFry of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((send gSQ5:handsOff()) (send gEgo:
                    view(446)
                    setLoop(-1)
                    setLoop(0)
                    setCel(5)
                    x(86)
                    y(88)
                    setScale(0)
                    setPri(3)
                    setCycle(End self)
                )
  )
            )
            (case 1
                ((send gEgo:
                    setLoop(1)
                    setCel(0)
                    setCycle(Fwd)
                )
 (theMusic3:
                    number(432)
                    setLoop(-1)
                    play()
                )
 (electric:
                    init()
                    setCycle(RTRandCycle)
                )
 = seconds 5  )
            )
            (case 2
                ((theMusic3:fade()) proc0_9(20) (self:dispose()) )
            )
        )
    )

)
(instance sOpenPanel of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((send gSQ5:handsOff()) (cloakPanel:setCycle(End self)) (theMusic3:
                    number(431)
                    setLoop(1)
                    play()
                )
  )
            )
            (case 1
                ((theMusic3:fade()) (send gRoom:newRoom(335)) (send gSQ5:handsOn()) (self:dispose()) )
            )
        )
    )

)
(instance lights1 of Prop
    (properties
        x 76
        y 67
        view 445
    )
)
(instance lights2 of Prop
    (properties
        x 105
        y 74
        view 445
        loop 1
    )
)
(instance lights3 of Prop
    (properties
        x 113
        y 77
        view 445
        loop 2
    )
)
(instance countdown1 of Prop
    (properties
        x 122
        y 44
        view 445
        loop 3
    )
)
(instance countdown2 of Prop
    (properties
        x 122
        y 44
        view 445
        loop 4
    )
)
(instance electric of Prop
    (properties
        x 64
        y 56
        view 446
        loop 2
    )
)
(instance elevator of Actor
    (properties
        x 183
        y 192
        noun 4
        view 445
        loop 5
        priority 4
        signal 16400
    )
)
(instance cloakPanel of Prop
    (properties
        x 236
        y 88
        noun 2
        approachX 225
        approachY 115
        view 445
        loop rm330
    )

    (method (doVerb param1 param2)
        (switch (param1)
            (case 4
                (
                (if (not proc0_1(212))
                    (send gRoom:setScript(sOpenPanel))
                )(else
                    (super:doVerb(param1 rest param2))
                )
 )
            )
            (default 
                ((super:doVerb(param1 rest param2)) )
            )
        )
    )

)
(instance pilotArea of Feature
    (properties
        x 100
        y 70
        noun 1
        onMeCheck 2
        approachX 80
        approachY 91
    )

    (method (doVerb param1 param2)
        (switch (param1)
            (case 4
                (
                (if (== local0 0)
                    (send gTestMessager:say(1 param1 0 0))
                    ++local0
                )(else
                    (send gRoom:setScript(sRogSitAndFry))
                )
 )
            )
            (case 3
                ((send gRoom:setScript(sRogSitAndFry))  )
            )
            (default 
                ((super:doVerb(param1 rest param2)) )
            )
        )
    )

)
(instance leftDwoot of Feature
    (properties
        x 88
        y 47
        noun 3
        onMeCheck 64
    )
)
(instance rightDwoot of Feature
    (properties
        x 173
        y 51
        noun 5
        onMeCheck 512
    )
)
(instance screen of Feature
    (properties
        x 125
        y 44
        noun 7
        onMeCheck 16
    )
)
(instance viewWindow of Feature
    (properties
        x 99
        y 67
        noun 8
        onMeCheck 1024
    )

    (method (doVerb param1 param2)
        (switch (param1)
            (case 4
                (
                (if (== local0 0)
                    (send gTestMessager:say(1 param1 0 0))
                    ++local0
                )(else
                    (send gRoom:setScript(sRogSitAndFry))
                )
 )
            )
            (case 3
                ((send gRoom:setScript(sRogSitAndFry))  )
            )
            (default 
                ((super:doVerb(param1 rest param2)) )
            )
        )
    )

)
(instance theMusic3 of Sound
    (properties
        flags 1
    )
)
