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


(local
    local0[2]

)
(instance public rm400 of Rm
    (properties
        noun 5
        picture 81
    )

    (method (init param1)
        proc958_0(128 451)
        (send gRoom:addObstacle((send ((Polygon:new())):
                type(3)
                init(0 176 301 172 301 153 193 98 168 99 157 91 144 95 113 96 79 93 81 99 95 99 119 100 99 115 63 129 33 135 0 133)
                yourself()
            )
))
        (send gEgo:
            view(0)
            init()
        )
        (theExit:init())
        (theCanister:
            init()
            setOnMeCheck(1 4)
        )
        (theHeatwaves:init())
        (theMoon:init())
        (theRocks:
            init()
            setOnMeCheck(1 4096)
        )
        (switch (gGModNum)
            (case 240
                ((send gRoom:
                    style(7)
                    setScript(sInitRoom)
                )
  )
            )
            (case 410
                ((send gRoom:
                    style(12)
                    setScript(sInitRoom)
                )
  )
            )
            (default 
                ((send gRoom:
                    style(7)
                    setScript(sInitRoom)
                )
 )
            )
        )
        (super:init(rest param1))
    )


    (method (doit)
        (super:doit())
        (if ((proc0_5(gEgo 2) and (== global131 1)) and not (send gRoom:script))
            proc0_3(100)
            (send gRoom:newRoom(410))
        )
        (if (proc0_5(gEgo 8) and not (send gRoom:script))
            proc0_2(100)
            (send gRoom:newRoom(410))
        )
    )


    (method (dispose param1)
        (super:dispose(rest param1))
    )

)
(instance sInitRoom of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((send gSQ5:handsOff()) (sun:init()) (dust:init()) (dust2:init()) (dust3:init()) 
                (switch (global131)
                    (case 1
                        ((canCoverL:
                            init()
                            stopUpd()
                        )
 (canCoverR:
                            init()
                            stopUpd()
                        )
 
                        (if (proc0_1(100))
                            proc0_6(0 0)
                            (send gEgo:
                                init()
                                x(79)
                                y(93)
                                setScale(Scaler 100 48 163 99)
                                setMotion(MoveTo 124 101 self)
                            )
                        )(else
                            proc0_6(0 0)
                            (send gEgo:
                                init()
                                x(- (send gEgo:x) 320)
                                y((send gEgo:y))
                                setScale(Scaler 100 48 163 99)
                                setMotion(MoveTo 60 145 self)
                            )
                        )
 )
                    )
                    (case 2
                        ((send gEgo:
                            hide()
                            dispose()
                        )
 (roger:
                            init()
                            x(65496)
                            y(75)
                            hide()
                        )
 (rogblink:
                            init()
                            hide()
                        )
 (self:setScript(sCanister self))  )
                    )
                    (default 
                        (= cycles 1 )
                    )
                )
 = seconds 1  )
            )
            (case 1
                (= seconds 3  )
            )
            (case 2
                ((send gSQ5:handsOn()) (self:dispose()) )
            )
        )
    )

)
(instance public sUseComm of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((send gSQ5:handsOff()) (send gEgo:
                    view(14)
                    setLoop(0)
                    cel(0)
                    setCycle(End self)
                )
 (send gSq5Music2:
                    number(603)
                    loop(1)
                    play()
                )
  )
            )
            (case 1
                ((send gTestMessager:say(2 32 0 0 self 401))  )
            )
            (case 2
                ((send gEgo:setCycle(Beg self))  )
            )
            (case 3
                (proc0_6(0) (send gEgo:loop(2)) = seconds 1  )
            )
            (case 4
                ((send gEgo:
                    view(6)
                    setLoop(0)
                    cel(15)
                    setCycle(Beg self)
                )
 (send gSq5Music2:
                    number(260)
                    loop(1)
                    play()
                )
  )
            )
            (case 5
                ((send gSq5Music1:fade()) (send gRoom:newRoom(240)) )
            )
        )
    )

)
(instance sCanister of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (= seconds 3  )
            )
            (case 1
                ((roger:
                    show()
                    setPri(14)
                    setMotion(MoveTo 0 75 self)
                )
 (rogblink:show())  )
            )
            (case 2
                ((self:dispose()) )
            )
        )
    )

)
(instance sExit of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((roger:setMotion(MoveTo 65486 75 self))  )
            )
            (case 1
                ((roger:hide()) (rogblink:hide()) = cycles 2  )
            )
            (case 2
                ((send gRoom:newRoom(410)) )
            )
        )
    )

)
(instance roger of Actor
    (properties
        y 75
        view 451
        loop 2
        signal 24576
        illegalBits 0
    )

    (method (init param1)
        (super:init(rest param1))
        (self:
            setLoop(2)
            setCel(0)
        )
    )

)
(instance rogblink of Prop
    (properties
        x 36
        y sUseComm
        view 451
        loop 3
    )

    (method (init param1)
        (super:init(rest param1))
        (self:
            setLoop(3)
            cycleSpeed(100)
            setPri(15)
            setCycle(Fwd)
        )
    )


    (method (doit param1)
        (self:
            x(+ (roger:x) 36)
            y(112)
        )
        (super:doit(rest param1))
    )

)
(instance sun of Prop
    (properties
        x 88
        y 57
        view 451
        detailLevel 2
    )

    (method (init param1)
        (self:
            setLoop(0)
            setCycle(Fwd)
            cycleSpeed(10)
        )
        (super:init(rest param1))
    )

)
(instance dust of Prop
    (properties
        x 265
        y 28
        view 451
        loop 1
        detailLevel 2
    )

    (method (init param1)
        (self:
            setLoop(1)
            setCycle(Fwd)
            cycleSpeed(10)
        )
        (super:init(rest param1))
    )

)
(instance dust2 of Prop
    (properties
        x 253
        y 36
        view 451
        loop 1
        detailLevel 2
    )

    (method (init param1)
        (self:
            setLoop(1)
            setCycle(Fwd)
            cycleSpeed(10)
        )
        (super:init(rest param1))
    )

)
(instance dust3 of Prop
    (properties
        x 10
        y 11
        view 451
        loop 1
        detailLevel 2
    )

    (method (init param1)
        (self:
            setLoop(1)
            setCycle(Fwd)
            cycleSpeed(10)
        )
        (super:init(rest param1))
    )

)
(instance canCoverL of View
    (properties
        x 191
        y 114
        view 451
        loop 4
        cel 1
        priority 15
        signal 16
    )
)
(instance canCoverR of View
    (properties
        x 4
        y 126
        view 451
        loop 4
        priority 15
        signal 16
    )
)
(instance theExit of Feature
    (properties
        x 10
        nsBottom sExit
        nsRight 320
    )

    (method (doVerb param1 param2)
        (switch (param1)
            (case 3
                ((send gRoom:setScript(sExit))  )
            )
            (case 4
                ((send gRoom:setScript(sExit))  )
            )
            (default 
                ((super:doVerb(param1 rest param2)) )
            )
        )
    )

)
(instance theCanister of Feature
    (properties
        x sExit
        y 150
        noun 1
        onMeCheck 4
    )

    (method (doVerb param1 param2)
        (switch (param1)
            (case 1
                (
                (if (== global131 2)
                    proc0_10(222 50)
                    (send gTestMessager:say(1 1 0 0))
                )(else
                    (send gTestMessager:say(4 1 0 0))
                )
 )
            )
            (case 3
                (
                (if (== global131 2)
                    (send gTestMessager:say(1 3 0 0))
                )
 )
            )
            (case 4
                (
                (if (== global131 2)
                    (send gTestMessager:say(1 4 0 0))
                )
 )
            )
            (default 
                ((super:doVerb(rest param2)) )
            )
        )
    )

)
(instance theMoon of Feature
    (properties
        x 100
        y 28
        noun 3
        nsTop 9
        nsLeft 66
        nsBottom 58
        nsRight 151
    )
)
(instance theHeatwaves of Feature
    (properties
        x 100
        y 100
        noun 2
        nsTop 60
        nsLeft 91
        nsBottom 70
        nsRight 142
    )
)
(instance theRocks of Feature
    (properties
        x 160
        y 100
        noun 6
        onMeCheck 4096
    )

    (method (doVerb param1 param2)
        (switch (param1)
            (case 1
                ((send gTestMessager:say(6 1 0 Random(1 3) 0))  )
            )
            (default 
                ((super:doVerb(rest param2)) )
            )
        )
    )

)
