(version 2)
(include "sci.sh")
(exports
    0 rm015
)
(use "Main")
(use "Class_255_0")
(use "Rev")
(use "Extra")
(use "Sound")
(use "Cycle")
(use "Game")
(use "User")
(use "Feature")
(use "Obj")
(script 15)


(local
    local0

)
(instance public rm015 of Rm
    (properties
        style 0
    )

    (method (init)
        (var temp0[50])
        (if ((send ((send global9:at(3))):ownedBy(15)))
            (self:picture(15))
        )(else
            (self:picture(157))
        )
        (self:setLocales(700))
        proc0_2()
        Load(128 19)
        Load(128 29)
        Load(128 32)
        Load(128 6)
        Load(128 33)
        Load(128 34)
        Load(128 35)
        (if (not proc0_13(2 8) and not (send gEgo:has(2)))
            Load(128 15)
        )(else
            Load(128 288)
        )
        (if (<> global12 3)
            Load(132 56)
        )
        (if (global133 and (== global12 3))
            Load(132 11)
        )
        Load(132 12)
        = global132 0
        (super:init())
        (self:setScript(rmScript))
    )


    (method (doit)
        (if (proc0_13(3))
            (if ((== (send gEgo:view) 0) and ((== (send gEgo:onControl(0)) 4) or (== (send gEgo:onControl(0)) 5)))
                (send gEgo:view(32))
            )
            (if ((== (send gEgo:view) 32) and (== (send gEgo:onControl(0)) 1))
                (send gEgo:view(0))
            )
        )
        (if ((proc0_13(2 8) and not global155) and (send gEgo:inRect(165 150 175 186)))
            proc0_2()
            (self:setScript(mugScript))
        )
        (super:doit())
    )


    (method (handleEvent pEvent)
        (if (((<> (send pEvent:type) 128) or global100) or (send pEvent:claimed))
            return 
        )
        (if (Said('look>'))
            (if (Said('[<around,at,in][/area,!*]'))
                (if (proc0_13(3))
                    proc255_0(15 0)
                )(else
                    proc255_0(15 1)
                )
            )(else
                (if (Said('/lamp'))
                    (if (proc0_13(3))
                        proc255_0(15 2)
                    )(else
                        proc255_0(15 3)
                    )
                )(else
                    (if (Said('/cable'))
                        proc255_0(15 4)
                    )(else
                        (if (local0 and Said('/hook'))
                            proc255_0(15 5)
                        )(else
                            (if (local0 and Said('/mice,animal,animal'))
                                proc255_0(15 6)
                            )(else
                                (if (Said('/hal<cable') or Said('/cable<hal'))
                                    (if ((send gEgo:inRect(0 125 38 155)))
                                        (if (proc0_13(3))
                                            proc255_0(15 7)
                                        )(else
                                            proc255_0(15 8)
                                        )
                                    )(else
                                        proc255_0(15 9)
                                    )
                                )(else
                                    (if (Said('/cavity'))
                                        (if ((send gEgo:inRect(0 125 38 155)))
                                            proc255_0(Format(@global402 15 10 
                                                    (if ((proc0_13(3) and proc0_13(0)) and proc0_13(1))
                                                        "a tiny reactor which seems to be providing power for the lights, a formerly lustrous gem, and an unconnected wire"
                                                    )(else
                                                        (if (proc0_13(3) and proc0_13(0))
                                                            "a tiny reactor which seems to be providing power for the lights and a formerly lustrous gem"
                                                        )(else
                                                            (if (proc0_13(3) and proc0_13(1))
                                                                "a tiny reactor which seems to be providing power for the lights and an unconnected wire"
                                                            )(else
                                                                (if (proc0_13(0) and proc0_13(1))
                                                                    "a formerly lustrous gem, and an unconnected wire"
                                                                )(else
                                                                    (if (proc0_13(3))
                                                                        "a tiny reactor which seems to be providing power for the lights"
                                                                    )(else
                                                                        (if (proc0_13(1))
                                                                            "an unconnected wire"
                                                                        )(else
                                                                            (if (proc0_13(0))
                                                                                "a formerly lustrous gem"
                                                                            )(else
                                                                                "nothing but crusty wire ends"
                                                                            )
                                                                        )
                                                                    )
                                                                )
                                                            )
                                                        )
                                                    )
))
                                        )(else
                                            (if ((send gEgo:inRect(248 69 265 77)))
                                                proc255_0(15 11)
                                            )(else
                                                proc255_0(15 12)
                                            )
                                        )
                                    )(else
                                        (if (Said('<up[/ceiling,!*]') or Said('[<up]/ceiling'))
                                            proc255_0(15 13)
                                        )(else
                                            (if (Said('/left,partition<w'))
                                                proc255_0(15 14)
                                            )(else
                                                (if (Said('climb/support,cover'))
                                                    proc255_0(15 15)
                                                )(else
                                                    (if (Said('/system,door[<garbage]'))
                                                        proc255_0(15 16)
                                                    )(else
                                                        (if (Said('look/ladder'))
                                                            (if (proc0_13(2))
                                                                proc255_0(15 17)
                                                            )(else
                                                                (send pEvent:claimed(0))
                                                            )
                                                        )(else
                                                            (if (Said('<down[/deck,!*]') or Said('[<down]/deck'))
                                                                proc255_0(15 18)
                                                            )(else
                                                                (if (Said('/partition[<leech,north,e]'))
                                                                    proc255_0(15 19)
                                                                )(else
                                                                    (if (Said('/heap,artifact,chunk'))
                                                                        proc255_0(15 20)
                                                                    )(else
                                                                        (if (Said('/support'))
                                                                            proc255_0(15 21)
                                                                        )(else
                                                                            (if (Said('/cover'))
                                                                                proc255_0(15 22)
                                                                            )
                                                                        )
                                                                    )
                                                                )
                                                            )
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )
        )(else
            (if (Said('climb[/ladder]') or Said('go<up/ladder'))
                (if ((send gEgo:inRect(248 69 265 77)) and proc0_13(2))
                    (send gEgo:setScript(ladderScript))
                )(else
                    proc255_0(15 23)
                )
            )(else
                (if (Said('get>'))
                    (if (Said('/all'))
                        (if ((send gEgo:inRect(0 125 38 155)))
                            (if (proc0_13(0))
                                (send gEgo:get(0))
                                (send global1:changeScore(5))
                            )
                            (if (proc0_13(1))
                                (send gEgo:get(1))
                                (send global1:changeScore(5))
                            )
                            (if (proc0_13(3))
                                (send gEgo:get(3))
                                proc255_0(15 24)
                                (reactorScript:init())
                                (send global1:changeScore(15))
                            )(else
                                proc255_0(15 24)
                            )
                        )(else
                            proc0_5()
                        )
                    )(else
                        (if (Said('/ladder'))
                            (if ((send gEgo:inRect(248 69 265 77)) and (send ((send global9:at(2))):ownedBy(15)))
                                (ladder:dispose())
                                (send gEgo:get(2))
                                (send global1:changeScore(10))
                                proc255_0(15 25)
                                proc255_0(15 26)
                            )(else
                                proc255_0(15 27)
                            )
                        )(else
                            (if (Said('/hal<cable') or Said('/cable<hal'))
                                (if ((send gEgo:inRect(0 125 38 155)))
                                    (if (proc0_13(3))
                                        proc255_0(15 7)
                                    )(else
                                        proc255_0(15 28)
                                    )
                                )(else
                                    proc255_0(15 28)
                                )
                            )(else
                                (if (Said('/artifact,support,cover'))
                                    proc255_0(15 29)
                                )(else
                                    (if (Said('/generator'))
                                        (if (proc0_13(3))
                                            (if ((send gEgo:inRect(0 125 38 155)))
                                                (send global1:changeScore(15))
                                                proc255_0(15 30)
                                                (reactorScript:init())
                                            )(else
                                                proc255_0(15 31)
                                            )
                                        )(else
                                            proc255_0(15 32)
                                        )
                                    )(else
                                        (if (Said('/cable'))
                                            (if (proc0_13(1))
                                                (if ((send gEgo:inRect(0 125 38 155)))
                                                    proc255_0(15 24)
                                                    (send gEgo:get(1))
                                                    (send global1:changeScore(5))
                                                )(else
                                                    proc0_5()
                                                )
                                            )(else
                                                (send pEvent:claimed(0))
                                            )
                                        )(else
                                            (if (Said('/crystal'))
                                                (if (proc0_13(0))
                                                    (if ((send gEgo:inRect(0 125 38 155)))
                                                        proc255_0(15 24)
                                                        (send gEgo:get(0))
                                                        (send global1:changeScore(5))
                                                    )(else
                                                        proc0_5()
                                                    )
                                                )(else
                                                    (send pEvent:claimed(0))
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )(else
                    (if (Said('climb,crawl[<through,up,on]/partition,cavity,system'))
                        proc255_0(15 33)
                    )(else
                        (if (Said('use,afix,(jar<up)/generator'))
                            (if ((send gEgo:has(3)) or proc0_13(3))
                                proc255_0(15 34)
                            )(else
                                (send pEvent:claimed(0))
                            )
                        )(else
                            (if (Said('erect,stand,drop,place,use/ladder[/cavity[<by,in]]'))
                                (if ((send gEgo:inRect(170 66 292 97)))
                                    (if ((send gEgo:has(2)))
                                        (send gEgo:setScript(putLadderScript))
                                    )(else
                                        proc255_0(15 35)
                                    )
                                )(else
                                    proc255_0(15 36)
                                )
                            )(else
                                (if (Said('open/system,door'))
                                    proc255_0(15 37)
                                )
                            )
                        )
                    )
                )
            )
        )
    )


    (method (newRoom newRoomNumber)
        DisposeScript(988)
        (super:newRoom(newRoomNumber))
    )

)
(instance rmScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (doors:init())
                (if ((send ((send global9:at(2))):ownedBy(15)))
                    (ladder:
                        init()
                        stopUpd()
                    )
                )
                (if (== global12 3)
                    (send gEgo:setScript(ladderScript))
                    (doors:stopUpd())
                )(else
                    = cycles 3
                )
            )
            (case 1
                (doors:setCycle(End self))
            )
            (case 2
                (send gEgo:
                    view(35)
                    posn(70 120)
                    setPri(8)
                    setLoop(0)
                    cel(0)
                    cycleSpeed(1)
                    init()
                    setMotion(0)
                    setCycle(End self)
                )
            )
            (case 3
                (doors:stopUpd())
                (send gEgo:
                    setLoop(1)
                    cel(0)
                    setCycle(End self)
                )
                (thump:play())
            )
            (case 4
                (send gEgo:hide())
                (doors:setCycle(Beg self))
            )
            (case 5
                (doors:addToPic())
                proc255_0(15 38)
                = seconds 2
            )
            (case 6
                proc0_3()
                (send gEgo:
                    view(
                        (if (proc0_13(3))
                            32
                        )(else
                            6
                        )
)
                    illegalBits(-32768)
                    posn(80 132)
                    setLoop(-1)
                    setPri(-1)
                    loop(2)
                    setStep(3 2)
                    show()
                    cycleSpeed(0)
                    setCycle(Walk)
                )
                (if (proc0_13(3) and not proc0_13(2 8))
                    (rat1:setScript(ratsScript))
                )
                (if (global133 and (== global12 3))
                    (send gLongSong:
                        number(11)
                        loop(-1)
                        play()
                    )
                )
                = global100 0
            )
        )
    )

)
(instance reactorScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (ladder:
                    setLoop(1)
                    forceUpd()
                )
                (send gEgo:
                    get(3)
                    view(6)
                )
                (send global2:drawPic(157))
                (doors:
                    setLoop(1)
                    init()
                    addToPic()
                )
                (rat1:
                    setLoop(4)
                    init()
                    addToPic()
                )
                (rat2:
                    setLoop(4)
                    init()
                    addToPic()
                )
                (rat3:
                    setLoop(4)
                    init()
                    addToPic()
                )
                (eye1:setLoop(5))
                (eye2:setLoop(6))
                (eye3:setLoop(7))
            )
        )
    )

)
(instance mugScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc255_0(15 39)
                proc255_0(15 40)
                (send gEgo:
                    view(288)
                    setLoop(0)
                    setMotion(MoveTo 170 145 self)
                )
            )
            (case 1
                (send gEgo:
                    setLoop(1)
                    setCycle(Fwd)
                )
                (mugRat1:
                    init()
                    setCycle(Walk)
                    setMotion(MoveTo 165 145 self)
                )
                (mugRat2:
                    init()
                    setCycle(Walk)
                    setMotion(MoveTo 175 145)
                )
            )
            (case 2
                (cloud:init())
                (rumble:play())
                (send gEgo:hide())
                (mugRat1:hide())
                (mugRat2:hide())
                = seconds 6
            )
            (case 3
                (send gEgo:
                    setLoop(2)
                    posn(- (send gEgo:x) 20 - (send gEgo:y) 7)
                    show()
                    stopUpd()
                )
                (mugRat1:
                    setLoop(1)
                    x(- (mugRat1:x) 50)
                    show()
                    setMotion(MoveTo 20 155 self)
                )
                (mugRat2:
                    setLoop(0)
                    x(+ (mugRat2:x) 50)
                    show()
                    setMotion(MoveTo 320 155)
                )
                (cloud:dispose())
                (rumble:stop())
            )
            (case 4
                proc255_0(15 41)
                proc0_17(901 0 2 3)
            )
        )
    )

)
(instance ladderScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:
                    view(19)
                    setLoop(
                        (if (proc0_13(3))
                            0
                        )(else
                            1
                        )
)
                    setPri(4)
                    illegalBits(0)
                    ignoreActors(1)
                )
                (if ((send gEgo:inRect(248 69 265 77)))
                    (send gEgo:
                        posn(258 73)
                        setMotion(MoveTo 258 23 self)
                    )
                )(else
                    (send gEgo:
                        posn(258 23)
                        init()
                        setMotion(MoveTo 258 73 self)
                        setCycle(Rev)
                    )
                )
            )
            (case 1
                (if ((send gEgo:inRect(248 69 265 77)))
                    (send gEgo:
                        setPri(-1)
                        setLoop(-1)
                        view(
                            (if (not proc0_13(3))
                                6
                            )(else
                                0
                            )
)
                        setCycle(Walk)
                        illegalBits(-32768)
                        ignoreActors(0)
                    )
                    (User:
                        canControl(1)
                        canInput(1)
                    )
                    = global100 0
                )(else
                    (send global2:newRoom(3))
                )
            )
        )
    )

)
(instance putLadderScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (User:canControl(0))
                = global100 1
                (send gEgo:setMotion(MoveTo 258 76 self))
            )
            (case 1
                (send gEgo:loop(3))
                (ladder:
                    setLoop(
                        (if (proc0_13(3))
                            0
                        )(else
                            1
                        )
)
                    init()
                    stopUpd()
                )
                proc0_14(2)
                (send global1:changeScore(-10))
                = global100 0
                (User:canControl(1))
            )
        )
    )

)
(instance ratsScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (ratTune:play())
                = local0 1
                (rat1:
                    posn(-24 242)
                    init()
                    setMotion(MoveTo 24 194 self)
                )
            )
            (case 1
                (eye1:
                    init()
                    startExtra()
                )
                (rat2:
                    posn(348 227)
                    init()
                    setMotion(MoveTo 297 176 self)
                )
            )
            (case 2
                (rat2:addToPic())
                (eye2:
                    init()
                    startExtra()
                )
                (rat3:
                    init()
                    posn(303 2)
                    setMotion(MoveTo 261 44 self)
                )
            )
            (case 3
                (rat3:addToPic())
                (eye3:
                    init()
                    startExtra()
                )
            )
        )
    )

)
(instance doors of Prop
    (properties)

    (method (init)
        (super:init())
        (self:
            view(33)
            loop(
                (if (proc0_13(3))
                    0
                )(else
                    1
                )
)
            cel(0)
            posn(64 110)
            setPri(8)
            cycleSpeed(2)
        )
    )

)
(instance ladder of Prop
    (properties)

    (method (init)
        (super:init())
        (self:
            view(29)
            setLoop(
                (if (proc0_13(3))
                    0
                )(else
                    1
                )
)
            setCel(0)
            posn(256 70)
        )
    )

)
(instance rat1 of Act
    (properties)

    (method (init)
        (super:init())
        (self:
            view(34)
            setLoop(
                (if (proc0_13(3))
                    0
                )(else
                    4
                )
)
            setCel(0)
            setStep(3 3)
            illegalBits(0)
            setPri(15)
            setCycle(0)
        )
    )

)
(instance rat2 of Act
    (properties)

    (method (init)
        (super:init())
        (self:
            view(34)
            setLoop(
                (if (proc0_13(3))
                    0
                )(else
                    4
                )
)
            setCel(1)
            setStep(3 3)
            illegalBits(0)
            setPri(15)
            setCycle(0)
        )
    )

)
(instance rat3 of Act
    (properties)

    (method (init)
        (super:init())
        (self:
            view(34)
            setLoop(
                (if (proc0_13(3))
                    0
                )(else
                    4
                )
)
            setCel(2)
            setStep(3 3)
            illegalBits(0)
            ignoreHorizon()
            setPri(15)
            setCycle(0)
        )
    )

)
(instance eye1 of Extra
    (properties)

    (method (init)
        (super:init())
        (self:
            view(34)
            loop(
                (if (proc0_13(3))
                    1
                )(else
                    5
                )
)
            cel(0)
            posn(18 171)
            setPri(15)
            cycleSpeed(2)
            pauseCel(0)
            minPause(20)
            maxPause(50)
            minCycles(2)
            maxCycles(4)
            isExtra(1)
        )
    )

)
(instance eye2 of Extra
    (properties)

    (method (init)
        (super:init())
        (self:
            view(34)
            loop(
                (if (proc0_13(3))
                    2
                )(else
                    6
                )
)
            cel(0)
            posn(285 153)
            setPri(15)
            cycleSpeed(2)
            pauseCel(0)
            minPause(20)
            maxPause(50)
            minCycles(2)
            maxCycles(4)
            isExtra(1)
        )
    )

)
(instance eye3 of Extra
    (properties)

    (method (init)
        (super:init())
        (self:
            view(34)
            loop(
                (if (proc0_13(3))
                    3
                )(else
                    7
                )
)
            cel(0)
            posn(249 30)
            setPri(15)
            cycleSpeed(2)
            pauseCel(0)
            minPause(50)
            maxPause(100)
            minCycles(2)
            maxCycles(4)
            isExtra(1)
        )
    )

)
(instance mugRat1 of Act
    (properties
        view 15
    )

    (method (init)
        (super:init())
        (self:
            setLoop(0)
            ignoreActors(1)
            illegalBits(0)
            posn(20 155)
            setStep(12 2)
        )
    )

)
(instance mugRat2 of Act
    (properties
        view 15
    )

    (method (init)
        (super:init())
        (self:
            setLoop(1)
            ignoreActors(1)
            illegalBits(0)
            posn(320 155)
            setStep(12 2)
        )
    )

)
(instance cloud of Prop
    (properties
        view 15
    )

    (method (init)
        (super:init())
        (self:
            setLoop(3)
            ignoreActors(1)
            posn(- (send gEgo:x) 1 - (send gEgo:y) 1)
            setPri(+ (send gEgo:priority) 1)
            setCycle(Fwd)
        )
    )

)
(instance ratTune of Sound
    (properties
        number 12
    )
)
(instance thump of Sound
    (properties
        number 56
        priority 2
    )
)
(instance rumble of Sound
    (properties
        number 60
        priority 2
        loop -1
    )
)
