(version 2)
(include "sci.sh")
(exports
    0 rm10
)
(use "Main")
(use "Class_255_0")
(use "Sound")
(use "Jump")
(use "Cycle")
(use "Game")
(use "User")
(use "Feature")
(use "Obj")
(script 10)


(local
    newProp
    local1
    local2
    local3

)
(instance grind of Sound
    (properties
        number 43
        priority 1
        loop -1
    )
)
(instance public rm10 of Rm
    (properties
        picture 10
        style 0
        horizon 10
        east 11
        west 9
    )

    (method (init)
        (var temp0[50])
        (self:setLocales(703))
        (User:
            canInput(1)
            canControl(0)
        )
        Load(128 750)
        Load(128 20)
        Load(132 42)
        Load(132 43)
        (if (== global132 4)
            Load(128 22)
            Load(128 258)
            Load(128 260)
        )(else
            (if (== global132 5)
                Load(128 23)
                Load(128 259)
                Load(128 261)
            )(else
                Load(130 991)
                = local3 991
                Load(128 0)
                Load(128 17)
                Load(128 24)
            )
        )
        (if ((<> global12 9) and (<> global12 11))
            = global132 2
        )
        (if (== global132 3)
            proc0_3()
            (send gEgo:
                init()
                setScript(railJump)
            )
        )(else
            (if (== global132 2)
                (send gEgo:
                    view(750)
                    posn(2 145)
                    setStep(3 1)
                    setLoop(1)
                    setCel(2)
                    setPri(8)
                    init()
                    setCycle(0)
                )
            )(else
                (if ((== global132 5) or (== global132 4))
                    (send gEgo:setScript(grabScript))
                )
            )
        )
        (if ((> global124 0) or (== global132 2))
            (pile1:init())
            (fallPile:init())
            (shredder:init())
            (send gLongSong:
                number(42)
                loop(-1)
                priority(0)
                play()
            )
        )(else
            (shredder:
                init()
                addToPic()
            )
        )
        (super:init())
        (self:setScript(rmScript))
    )


    (method (dispose)
        (if (== global132 3)
            DisposeScript(991)
        )
        (super:dispose())
    )


    (method (handleEvent pEvent)
        (super:handleEvent(pEvent))
        (if ((send pEvent:claimed) or (> global100 1))
            return 
        )
        (switch ((send pEvent:type))
            (case 1
                (if (not global155 and (== (User:controls) 1))
                    (send gEgo:setMotion(MoveTo (send pEvent:x) (send gEgo:y)))
                    (send pEvent:claimed(1))
                )
            )
            (case 128
                (if (Said('look>'))
                    (if (Said('/conveyer,belt'))
                        (if ((== global124 0) and (<> global132 2))
                            proc255_0(10 0)
                        )(else
                            proc255_0(10 1)
                        )
                    )(else
                        (if (Said('/iron,debris,scrap,heap'))
                            (if ((send global5:contains(shredder)))
                                proc255_0(10 2)
                            )(else
                                proc255_0(10 3)
                            )
                        )(else
                            (if (Said('/tackle,post,device'))
                                (if (== global124 0)
                                    proc255_0(10 4)
                                )(else
                                    proc255_0(10 5)
                                )
                            )(else
                                (if (Said('/conduit'))
                                    proc255_0(10 6)
                                )(else
                                    (if (Said('[<at,around,in][/area,!*]'))
                                        (if (== global132 3)
                                            proc255_0(10 7)
                                        )(else
                                            (if (== global132 2)
                                                proc255_0(10 8)
                                            )(else
                                                proc255_0(10 9)
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )(else
                    (if (Said('climb,descend,(climb[<up,down,on,onto])/conduit,sheet[<iron]'))
                        proc255_0(10 10)
                    )(else
                        (if (Said('jump,leap,(get,climb<on,onto)[<off]/conveyer,belt'))
                            (if (== global132 2)
                                proc255_0(10 11)
                            )(else
                                proc255_0(10 12)
                            )
                        )(else
                            (if (Said('(get<up),stand[<up][/belt,conveyer]'))
                                (if (== global132 2)
                                    (if (<> (send gEgo:view) 0)
                                        proc0_3()
                                        (send gEgo:
                                            view(0)
                                            setLoop(-1)
                                            loop(0)
                                            setCycle(Walk)
                                            setMotion(0)
                                            setStep(3 1)
                                        )
                                    )(else
                                        proc255_0(10 13)
                                    )
                                )(else
                                    (send pEvent:claimed(0))
                                    return 
                                )
                            )(else
                                (if (Said('get/banister'))
                                    (if (== global132 2)
                                        proc255_0(10 14)
                                    )(else
                                        proc255_0(10 15)
                                    )
                                )(else
                                    (if (Said('jump,leap,climb[<onto,on,to,up,down]/conduit'))
                                        proc255_0(10 16)
                                    )(else
                                        (if ((== global132 2) and Said('climb<up,onto/banister'))
                                            proc255_0(10 14)
                                        )(else
                                            (if (Said('jump,leap[<to,onto,on,up,down,off][/banister,banister]'))
                                                (if (== global132 2)
                                                    (if (== (send gEgo:view) 0)
                                                        (send gEgo:setScript(railJump))
                                                    )(else
                                                        proc255_0(10 17)
                                                    )
                                                )(else
                                                    (send pEvent:claimed(0))
                                                    return 
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )
            (case 64
                (if (global155 or ((<> global132 4) and (<> global132 5)))
                    return 
                )
                (switch ((send pEvent:message))
                    (case 1
                        (send gEgo:setMotion(0))
                        (send pEvent:claimed(1))
                        return 
                    )
                    (case 5
                        (send gEgo:setMotion(0))
                        (send pEvent:claimed(1))
                        return 
                    )
                    (case 8
                        (send gEgo:setMotion(0))
                        (send pEvent:claimed(1))
                        return 
                    )
                    (case 2
                        (send gEgo:setMotion(0))
                        (send pEvent:claimed(1))
                        return 
                    )
                    (case 4
                        (send gEgo:setMotion(0))
                        (send pEvent:claimed(1))
                        return 
                    )
                    (case 6
                        (send gEgo:setMotion(0))
                        (send pEvent:claimed(1))
                        return 
                    )
                )
            )
        )
    )


    (method (newRoom newRoomNumber)
        (if (<> global132 2)
            (send gLongSong:stop())
            (super:newRoom(newRoomNumber))
        )
    )

)
(instance newPileScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (fallPile:setCycle(End self))
            )
            (case 1
                (pile1:
                    setCel(Random(0 1))
                    posn(-32 145)
                    show()
                    setMotion(MoveTo 175 145 self)
                )
            )
            (case 2
                (pile1:hide())
                (self:changeState(0))
            )
        )
    )

)
(instance rmScript of Script
    (properties)

    (method (doit)
        (if ((== global132 2) and (> (send gEgo:x) 174))
            (User:
                canControl(0)
                canInput(0)
            )
        )
        (if ((((== global100 0) and (== (rmScript:state) 0)) and (== (send gEgo:view) 0)) and (== global132 2))
            (send gEgo:posn((+ (send gEgo:x) 3) (send gEgo:y)))
            (if (> (send gEgo:x) 182)
                (rmScript:changeState(1))
                return 
            )
            (if ((< (send gEgo:y) 141) or (> (send gEgo:y) 147))
                (send gEgo:setScript(faller))
                return 
            )
        )
        (super:doit())
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (if (== global132 2)
                    (send gEgo:setMotion(MoveTo 184 145 self))
                )
            )
            (case 1
                proc0_2()
                = global100 1
                (send gEgo:
                    setStep(5 5)
                    setPri(9)
                    setCycle(0)
                    setMotion(JumpTo 199 162 self)
                )
            )
            (case 2
                (send gEgo:hide())
                (grind:play())
                = newProp (Prop:new())
                (send newProp:
                    view(20)
                    setLoop(1)
                    posn(203 176)
                    setPri(15)
                    init()
                    setCycle(Fwd)
                    ignoreActors(1)
                )
                = seconds 3
            )
            (case 3
                (send newProp:dispose())
                (grind:fade())
                = cycles 5
            )
            (case 4
                = local2 proc255_0(10 18 91)
                = seconds 6
            )
            (case 5
                proc0_12()
                proc0_17(901 0 3 4)
            )
        )
    )

)
(instance railJump of Script
    (properties)

    (method (doit)
        (if (not global100 and (<> (send gEgo:onControl(0)) 16384))
            (send gEgo:setScript(faller))
        )
        (super:doit())
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (if (== global132 3)
                    (if (== global12 9)
                        (send gEgo:x(4))
                    )
                )(else
                    proc0_2()
                    = global100 1
                    (send gEgo:
                        setMotion(0)
                        view(24)
                        setLoop(0)
                        cel(0)
                        cycleSpeed(1)
                        illegalBits(-32768)
                        setCycle(End self)
                    )
                )
            )
            (case 1
                (send gEgo:
                    setLoop(1)
                    setCel(0)
                    setPri(9)
                    posn((send gEgo:x) 144)
                )
                = seconds 2
            )
            (case 2
                (send gEgo:
                    cycleSpeed(2)
                    setCycle(End self)
                )
            )
            (case 3
                (send gEgo:
                    setLoop(2)
                    setCel(0)
                    cycleSpeed(3)
                    setCycle(End self)
                )
            )
            (case 4
                (send gEgo:
                    setLoop(3)
                    setCel(0)
                    posn((send gEgo:x) 122)
                    setCycle(End self)
                )
            )
            (case 5
                (send gEgo:
                    view(0)
                    posn(+ (send gEgo:x) 9 123)
                    setLoop(-1)
                    loop(1)
                    setCycle(Walk)
                    cycleSpeed(0)
                    setDirection(0)
                )
                proc0_3()
                (if (not global241)
                    = global241 1
                    (send global1:changeScore(10))
                )
                = global132 3
                = global100 0
            )
            (case 6
                = global132 3
            )
        )
    )

)
(instance faller of Script
    (properties)

    (method (doit)
        (if ((< (send gEgo:loop) 11) and (> (send gEgo:y) 147))
            (send gEgo:setPri(11))
        )
        (super:doit())
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                = global100 1
                (send gEgo:
                    view(17)
                    setLoop((send gEgo:loop))
                    cel(0)
                    illegalBits(0)
                    setCycle(End self)
                    setMotion(0)
                    cycleSpeed(2)
                )
                (if (== global132 2)
                    (send gEgo:setPri(
                        (if (< (send gEgo:y) 141)
                            4
                        )(else
                            10
                        )
))
                )(else
                    (send gEgo:setPri(
                        (if (< (send gEgo:y) 125)
                            8
                        )(else
                            9
                        )
))
                )
            )
            (case 1
                (send gEgo:
                    setStep(1 15)
                    setMotion(MoveTo (send gEgo:x) 244 self)
                    setCycle(0)
                )
                (send gLongSong:
                    number(45)
                    loop(1)
                    priority(15)
                    play()
                )
            )
            (case 2
                (send gEgo:hide())
                = local2 
                    (if (== global132 2)
                        proc255_0(10 19 91)
                    )(else
                        proc255_0(10 20 91)
                    )
                = seconds 5
            )
            (case 3
                proc0_12()
                proc0_17(901 0 0 1)
            )
        )
    )

)
(instance grabScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_3()
                (if (== global12 9)
                    (send gEgo:x(4))
                )
                (if (== global132 5)
                    (send gEgo:
                        setStep(2)
                        setPri(5)
                    )
                )(else
                    (send gEgo:
                        setPri(14)
                        setStep(3)
                    )
                )
                (send gEgo:
                    init()
                    setCycle(Fwd)
                )
                (if (< global148 4)
                    (send gEgo:setMotion(MoveTo 
                        (if (== global12 9)
                            400
                        )(else
                            -50
                        )
 (send gEgo:y)))
                    (User:prevDir(
                        (if (== global12 9)
                            3
                        )(else
                            7
                        )
))
                )
            )
        )
    )


    (method (handleEvent pEvent)
        (var temp0[100])
        (super:handleEvent(pEvent))
        (if ((<> (send pEvent:type) 128) or (send pEvent:claimed))
            return 
        )
        (if (Said('look/grabber,control'))
            proc255_0(10 21)
        )(else
            (if (Said('lower/claw[<grabber]') or Said('use,press,press/claw,button'))
                proc255_0(10 22)
            )(else
                (if (Said('/chair[<grabber,device]'))
                    proc255_0(10 23)
                )(else
                    (if (Said('disembark[/grabber,device,!*]'))
                        proc255_0(10 24)
                    )
                )
            )
        )
    )

)
(instance pile1 of Act
    (properties
        view 750
    )

    (method (init)
        (super:init())
        (self:
            setCel(1)
            setLoop(0)
            ignoreActors(1)
            illegalBits(0)
            posn(-32 145)
            setPri(6)
            setStep(3 1)
        )
    )

)
(instance fallPile of Prop
    (properties
        view 750
    )

    (method (init)
        (super:init())
        (self:
            setLoop(2)
            cel(0)
            ignoreActors(1)
            posn(187 159)
            setPri(10)
            setScript(newPileScript)
        )
    )

)
(instance shredder of Prop
    (properties
        view 20
    )

    (method (init)
        (super:init())
        (self:
            ignoreActors(1)
            posn(204 169)
            setPri(9)
            setCycle(Fwd)
        )
    )

)
