(version 2)
(include "sci.sh")
(exports
    0 rm013
)
(use "Main")
(use "Class_255_0")
(use "Timer")
(use "Sound")
(use "Cycle")
(use "Game")
(use "User")
(use "Feature")
(use "Obj")
(script 13)


(local
    local0
    local1
    local2
    local3
    local4
    local5

)
(instance public rm013 of Rm
    (properties
        picture 13
        style 0
        horizon 10
    )

    (method (init)
        (var temp0[50])
        proc0_3()
        Load(130 991)
        = local3 991
        Load(128 17)
        Load(128 26)
        Load(128 752)
        Load(128 852)
        Load(128 10)
        Load(128 289)
        (if (== global135 3)
            Load(128 260)
            Load(128 261)
        )(else
            Load(128 22)
            Load(128 23)
        )
        Load(132 35)
        Load(132 45)
        Load(132 52)
        Load(132 53)
        (if (not gGEgoX_2)
            = gGEgoX_2 226
        )
        (if (<> global12 12)
            = global132 3
        )
        (super:init())
        (bot:init())
        proc0_3()
        (send gEgo:setStep(-1 1))
        (if (== global132 3)
            (send gEgo:
                view(0)
                posn(304 111)
                setStep(3)
                setPri(9)
                init()
                setScript(railWalkScript)
            )
            (grabber:
                loop(
                    (if (== global135 3)
                        1
                    )(else
                        0
                    )
)
                setStep(3 1)
                posn(gGEgoX_2 104)
                init()
                stopUpd()
            )
        )(else
            (send gEgo:setScript(grabScript))
        )
    )


    (method (doit)
        (if (not local2 and (((send gEgo:inRect(35 103 260 105)) or (send gEgo:inRect(143 74 237 78))) or (== global132 6)))
            = local2 15
        )
        (if ((((> local2 2) and not (send gEgo:inRect(35 103 260 105))) and not (send gEgo:inRect(143 74 237 78))) and (<> global132 6))
            = local2 0
        )
        (if ((> local2 2) and global219)
            --local2
        )
        (if ((== (bot:script) botPanelScript) and (== local2 2))
            = local2 1
            (if ((send gEgo:inRect(35 103 260 105)) or (== global132 6))
                (bot:setScript(frontZapScript))
            )(else
                (if ((send gEgo:inRect(143 74 237 78)))
                    (bot:setScript(backZapScript))
                )(else
                    = local2 0
                )
            )
        )
        (super:doit())
    )


    (method (dispose)
        DisposeScript(991)
        (super:dispose())
    )


    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )
        (switch ((send pEvent:type))
            (case 1
                (if ((not global155 and (== (User:controls) 1)) and (<> global132 6))
                    (send gEgo:setMotion(MoveTo 
                        (if (< (send pEvent:x) 30)
                            -30
                        )(else
                            (if (> (send pEvent:x) 295)
                                330
                            )(else
                                (send pEvent:x)
                            )
                        )
 (send gEgo:y)))
                    (send pEvent:claimed(1))
                )
            )
            (case 128
                (if (Said('look>'))
                    (if (Said('/android'))
                        proc255_0(13 0)
                    )(else
                        (if (Said('/comp,console,(device<monitoring)'))
                            proc255_0(13 1)
                        )(else
                            (if (Said('/device,grabber,console[<control]'))
                                (if ((== global132 4) or (== global132 5))
                                    proc255_0(13 2)
                                )(else
                                    proc255_0(13 3)
                                )
                            )(else
                                (if (Said('/motivator,artifact'))
                                    (if (== global135 3)
                                        (if ((== global132 4) or (== global132 5))
                                            proc255_0(13 4)
                                        )(else
                                            proc255_0(13 5)
                                        )
                                    )(else
                                        proc255_0(13 6)
                                    )
                                )(else
                                    (if (Said('look/throttle,control,stick'))
                                        (if ((== global132 4) or (== global132 5))
                                            proc255_0(13 7)
                                        )(else
                                            proc255_0(13 8)
                                        )
                                    )(else
                                        (if (Said('/claw[<grabber]'))
                                            (if (== global132 6)
                                                proc255_0(13 9)
                                            )(else
                                                proc255_0(13 4)
                                            )
                                        )(else
                                            (if (Said('/chair[<grabber,device]'))
                                                (if ((== global132 4) or (== global132 5))
                                                    proc255_0(13 10)
                                                )(else
                                                    proc255_0(13 11)
                                                )
                                            )(else
                                                (if (Said('/system,pedestal,bin'))
                                                    (if (global133)
                                                        proc255_0(13 12)
                                                    )(else
                                                        proc255_0(13 13)
                                                    )
                                                )(else
                                                    (if (Said('/banister,banister'))
                                                        proc255_0(13 14)
                                                    )(else
                                                        (if (Said('look/partition'))
                                                            proc255_0(13 15)
                                                        )(else
                                                            (if (Said('[<at,around,in][/area,!*]'))
                                                                (if ((== global132 4) or (== global132 5))
                                                                    proc255_0(13 16)
                                                                )(else
                                                                    proc255_0(13 17)
                                                                )
                                                            )(else
                                                                (if (Said('/lamp<grabber,device,safety'))
                                                                    (if ((== global132 4) or (== global132 5))
                                                                        proc255_0(13 18)
                                                                    )(else
                                                                        proc255_0(13 19)
                                                                    )
                                                                )(else
                                                                    (if (Said('[<down]/dirt,deck') or Said('<down[/dirt,deck]'))
                                                                        proc255_0(13 20)
                                                                    )(else
                                                                        (if (Said('[<up,above]/ceiling') or Said('<up,above[/ceiling]'))
                                                                            proc255_0(13 21)
                                                                        )
                                                                    )
                                                                )
                                                            )
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
                (if (Said('holler,converse/android'))
                    proc255_0(13 22)
                )
                (if (Said('beat,attack/android'))
                    proc255_0(13 23)
                )
                (if ((Said('climb[<up][/grabber,device]') or Said('climb/banister,banister<up<to')) or Said('climb<up,on/banister,banister'))
                    proc255_0(13 24)
                )
                (if (Said('enter,(go<in,in)/system'))
                    proc255_0(13 25)
                )
                (if ((Said('enter,board[/device,grabber,chair]') or Said('get<on,in,onto,down/[device,grabber,chair]')) or Said('climb[<on,in,onto,in,down][/device,grabber,chair]'))
                    (if ((== global132 5) or (== global132 4))
                        proc255_0(13 26)
                    )(else
                        (if ((send gEgo:inRect(gGEgoX_2 110 (+ gGEgoX_2 40) 116)))
                            (send gEgo:setScript(ontoGrabScript))
                        )(else
                            (if (== global132 6)
                                (send gEgo:setScript(grabScript))
                            )(else
                                proc255_0(13 27)
                            )
                        )
                    )
                )
                (if (Said('drag,press,use,manipulate,go[<forward,backward,back][/stick,throttle,control,knob]') or Said('begin,manipulate,drive[<forward,backward,back]/grabber,device'))
                    proc255_0(13 28)
                )
                (if (Said('disembark,(stand[<up]),(climb,get<off,out)[/grabber,device,claw,!*]'))
                    (if ((== global132 5) or (== global132 4))
                        (if ((send gEgo:mover))
                            proc255_0(13 29)
                        )(else
                            (if ((send gEgo:inRect(126 103 154 107)))
                                (send gEgo:setScript(platformScript))
                            )(else
                                proc255_0(13 30)
                            )
                        )
                    )(else
                        proc255_0(13 31)
                    )
                )
            )
            (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 (<> local0 3)
            (if (== newRoomNumber 15)
                (send gLongSong:fade())
            )
            (super:newRoom(newRoomNumber))
        )
    )

)
(instance botPanelScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (bot:
                    setLoop(0)
                    cel(0)
                    cycleSpeed(4)
                    setCycle(End self)
                )
            )
            (case 1
                (bot:cel(0))
                = seconds Random(7 12)
            )
            (case 2
                (self:changeState(0))
            )
        )
    )

)
(instance frontZapScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (bot:
                    cycleSpeed(0)
                    setCycle(End self)
                )
            )
            (case 1
                = cycles 15
            )
            (case 2
                (bot:
                    setLoop(1)
                    cel(0)
                    cycleSpeed(0)
                    setCycle(End self)
                )
            )
            (case 3
                (bot:
                    setLoop(3)
                    setCycle(Walk)
                    setMotion(MoveTo 165 127 self)
                )
            )
            (case 4
                (bot:
                    cel(255)
                    loop(
                        (if (== global132 6)
                            3
                        )(else
                            (if (< (send gEgo:x) (- (bot:x) 20))
                                1
                            )(else
                                (if (> (send gEgo:x) (+ (bot:x) 45))
                                    2
                                )(else
                                    3
                                )
                            )
                        )
)
                    setCycle(Beg self)
                )
            )
            (case 5
                = seconds 3
            )
            (case 6
                (if ((== local2 1) and ((send gEgo:inRect(35 103 260 105)) or ((== global132 6) and (== (send gEgo:view) 0))))
                    (bot:
                        cel(0)
                        loop(
                            (if (== global132 6)
                                7
                            )(else
                                (if (< (send gEgo:x) (- (bot:x) 20))
                                    4
                                )(else
                                    (if (> (send gEgo:x) (+ (bot:x) 45))
                                        5
                                    )(else
                                        7
                                    )
                                )
                            )
)
                        setCycle(End self)
                    )
                    (zotSound:play())
                )(else
                    (bot:
                        cel(0)
                        setCycle(End self)
                    )
                )
            )
            (case 7
                (if (> (bot:loop) 2)
                    (if ((== local0 0) and ((send gEgo:inRect(35 103 260 105)) or (== global132 6)))
                        = local0 3
                        proc0_2()
                        (if (== global132 4)
                            (grabber:
                                view(752)
                                loop(
                                    (if (== global135 3)
                                        1
                                    )(else
                                        0
                                    )
)
                                posn((send gEgo:x) (send gEgo:y))
                                setMotion(0)
                                init()
                            )
                        )
                        (send gEgo:hide())
                        (zot:
                            x(
                                (if (<> global132 6)
                                    + (send gEgo:x) 11
                                )(else
                                    (send gEgo:x)
                                )
)
                            y(
                                (if (<> global132 6)
                                    + (send gEgo:y) 45
                                )(else
                                    - (send gEgo:y) 6
                                )
)
                            init()
                        )
                    )
                    = cycles 15
                    ShakeScreen(5)
                )(else
                    = cycles 2
                )
            )
            (case 8
                (if ((send global5:contains(zot)))
                    (zot:dispose())
                    proc0_10()
                    (send gEgo:dispose())
                    proc255_0(13 32)
                    proc0_17(901 0 10 14)
                )(else
                    (bot:
                        setLoop(3)
                        setCycle(Walk)
                        setMotion(MoveTo 165 109 self)
                    )
                )
            )
            (case 9
                (bot:
                    setLoop(1)
                    cel(255)
                    setCycle(Beg self)
                )
            )
            (case 10
                = local2 0
                (bot:setScript(botPanelScript))
            )
        )
    )

)
(instance backZapScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (bot:
                    cycleSpeed(0)
                    setCycle(End self)
                )
            )
            (case 1
                = seconds 2
            )
            (case 2
                (bot:
                    setLoop(9)
                    cel(0)
                    cycleSpeed(0)
                    setCycle(End self)
                )
            )
            (case 3
                (bot:
                    setLoop(8)
                    setCycle(Walk)
                    setMotion(MoveTo 192 100 self)
                )
            )
            (case 4
                = seconds 3
            )
            (case 5
                (if ((== local2 1) and (send gEgo:inRect(143 74 237 78)))
                    proc0_2()
                    (bot:
                        cel(0)
                        setCycle(End self)
                    )
                    (zotSound:play())
                )(else
                    (bot:
                        setCycle(Walk)
                        setMotion(MoveTo 165 109 self)
                    )
                )
            )
            (case 6
                (if (< (bot:y) 105)
                    (grabber:
                        view(752)
                        posn((send gEgo:x) (send gEgo:y))
                        setLoop(
                            (if (== global135 3)
                                3
                            )(else
                                2
                            )
)
                        init()
                        setPri((send gEgo:priority))
                        setMotion(0)
                    )
                    (send gEgo:hide())
                    (zot:
                        posn(+ (send gEgo:x) 7 + (send gEgo:y) 24)
                        init()
                    )
                    ShakeScreen(5)
                    = cycles 15
                )(else
                    (bot:
                        setLoop(9)
                        cel(255)
                        setCycle(Beg self)
                    )
                )
            )
            (case 7
                (if ((send global5:contains(zot)))
                    (zot:dispose())
                    proc0_10()
                    (send gEgo:dispose())
                    proc255_0(13 32)
                    proc0_17(901 0 10 14)
                )(else
                    (bot:
                        setLoop(0)
                        cel(0)
                        setScript(botPanelScript)
                    )
                    = local2 0
                )
            )
        )
    )

)
(instance railWalkScript of Script
    (properties)

    (method (doit)
        (if ((== (send gEgo:view) 0) and (<> (send gEgo:onControl(1)) 16384))
            (self:changeState(1))
            proc0_2()
            = global100 1
        )(else
            (if (> (send gEgo:x) 316)
                (send gEgo:setMotion(0))
                (send global2:newRoom(12))
            )
        )
        (super:doit())
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gEgo:setLoop(-1))
            )
            (case 1
                (send gEgo:
                    view(17)
                    setLoop((send gEgo:loop))
                    cel(0)
                    x(
                        (if (< (send gEgo:x) 22)
                            22
                        )(else
                            (send gEgo:x)
                        )
)
                    setMotion(0)
                    illegalBits(0)
                    setCycle(End self)
                )
            )
            (case 2
                (send gEgo:
                    setPri(
                        (if (< (send gEgo:y) 113)
                            8
                        )(else
                            9
                        )
)
                    setStep(3 20)
                    setMotion(MoveTo (send gEgo:x) 220 self)
                )
                (send gLongSong:
                    number(45)
                    loop(1)
                    play()
                )
            )
            (case 3
                = local4 proc255_0(13 33 91)
                = seconds 5
            )
            (case 4
                proc0_12()
                proc0_17(901 0 0 1)
            )
        )
    )

)
(instance ontoGrabScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = global100 1
                proc0_2()
                (if (== global132 3)
                    (send gEgo:
                        view(289)
                        posn(+ gGEgoX_2 7 (send gEgo:y))
                        cel(0)
                        setMotion(0)
                        cycleSpeed(2)
                        setCycle(End self)
                    )
                )(else
                    (self:changeState(2))
                )
            )
            (case 1
                = cycles 5
            )
            (case 2
                (grabber:dispose())
                proc0_3()
                (send gEgo:setScript(grabScript))
                = global100 0
            )
        )
    )

)
(instance grabScript of Script
    (properties)

    (method (doit)
        (if (not global155)
            (if (not (send gEgo:mover))
                (if ((== global132 4) and (<> (send gEgo:loop) 0))
                    (send gEgo:loop(0))
                )(else
                    (if ((== global132 5) and (<> (send gEgo:loop) 1))
                        (send gEgo:loop(1))
                    )
                )
                (if (== (send gLongSong:state) 3)
                    (send gLongSong:stop())
                )
            )(else
                (if (== global132 4)
                    (if ((== (send gEgo:loop) 0) and ((<> (send gLongSong:number) 52) or (<> (send gLongSong:state) 3)))
                        (send gLongSong:
                            stop()
                            number(52)
                            play()
                        )
                    )(else
                        (if ((== (send gEgo:loop) 1) and ((<> (send gLongSong:number) 53) or (<> (send gLongSong:state) 3)))
                            (send gLongSong:
                                stop()
                                number(53)
                                play()
                            )
                        )
                    )
                )(else
                    (if (== global132 5)
                        (if ((== (send gEgo:loop) 1) and ((<> (send gLongSong:number) 52) or (<> (send gLongSong:state) 3)))
                            (send gLongSong:
                                stop()
                                number(52)
                                play()
                            )
                        )(else
                            (if ((== (send gEgo:loop) 0) and ((<> (send gLongSong:number) 53) or (<> (send gLongSong:state) 3)))
                                (send gLongSong:
                                    stop()
                                    number(53)
                                    play()
                                )
                            )
                        )
                    )
                )
            )
        )
        (if (not global100)
            (if (== global132 4)
                (if (< (send gEgo:x) -8)
                    = global100 1
                    proc0_2()
                    (self:changeState(2))
                )
                (if (> (send gEgo:x) 316)
                    (send gEgo:setMotion(0))
                    (send global2:newRoom(12))
                )
            )
            (if (== global132 5)
                (if (< (send gEgo:x) 132)
                    = global100 1
                    proc0_2()
                    (self:changeState(6))
                )
                (if (> (send gEgo:x) 255)
                    (send gEgo:setMotion(0))
                    (send global2:newRoom(12))
                )
            )
        )
        (super:doit())
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (if (== global132 5)
                    (send gEgo:
                        view(
                            (if (== global135 3)
                                261
                            )(else
                                23
                            )
)
                        setPri(7)
                        posn(242 76)
                        setStep(2 1)
                        init()
                        setMotion(MoveTo -40 76)
                    )
                    (User:prevDir(7))
                )(else
                    (send gEgo:
                        setStep(3 1)
                        setPri(9)
                        y(104)
                    )
                    (if (== global132 4)
                        (send gEgo:
                            x(313)
                            init()
                            setMotion(MoveTo -40 (send gEgo:y))
                        )
                        (User:prevDir(7))
                    )(else
                        (send gEgo:
                            view(
                                (if (== global135 3)
                                    260
                                )(else
                                    22
                                )
)
                            loop(0)
                            cel(0)
                        )
                        (if (== global132 6)
                            (send gEgo:x((grabber:x)))
                            (grabber:dispose())
                        )(else
                            (send gEgo:x(gGEgoX_2))
                        )
                        = global132 4
                    )
                )
                (send gEgo:setCycle(Fwd))
                = cycles 2
            )
            (case 1
                (if (< (send gEgo:x) 230)
                    proc255_0(13 34)
                )
            )
            (case 2
                proc0_2()
                (User:
                    canControl(0)
                    canInput(1)
                )
                (send gEgo:
                    view(26)
                    setPri(7)
                    setLoop(
                        (if (<> global135 3)
                            2
                        )(else
                            5
                        )
)
                    illegalBits(0)
                    posn(-9 102)
                    setStep(1 2)
                    setMotion(MoveTo -9 96 self)
                )
            )
            (case 3
                (send gEgo:
                    setLoop(
                        (if (<> global135 3)
                            1
                        )(else
                            4
                        )
)
                    posn(-6 94)
                    setStep(5 1)
                    setMotion(MoveTo 59 81 self)
                )
            )
            (case 4
                (send gEgo:
                    view(
                        (if (== global135 3)
                            261
                        )(else
                            23
                        )
)
                    setPri(-1)
                    setLoop(-1)
                    loop(0)
                    setStep(2 1)
                    posn(132 76)
                    illegalBits(-32768)
                )
                = seconds 2
            )
            (case 5
                (send gEgo:setMotion(MoveTo 321 76))
                = global100 0
                proc0_3()
                = global132 5
                (User:prevDir(3))
            )
            (case 6
                proc0_2()
                (User:
                    canControl(0)
                    canInput(1)
                )
                = seconds 2
            )
            (case 7
                (send gEgo:
                    view(26)
                    setLoop(
                        (if (<> global135 3)
                            0
                        )(else
                            3
                        )
)
                    setStep(5 1)
                    posn(59 81)
                    setMotion(MoveTo -6 94 self)
                )
            )
            (case 8
                (send gEgo:
                    setLoop(
                        (if (<> global135 3)
                            2
                        )(else
                            5
                        )
)
                    posn(-9 96)
                    setStep(1 2)
                    setMotion(MoveTo -9 102 self)
                )
            )
            (case 9
                (send gEgo:
                    view(
                        (if (== global135 3)
                            260
                        )(else
                            22
                        )
)
                    setLoop(-1)
                    loop(0)
                    setPri(9)
                    setStep(3 1)
                    illegalBits(-32768)
                    posn(-8 104)
                    setMotion(MoveTo 322 104)
                )
                proc0_3()
                = global132 4
                = global100 0
                (User:prevDir(3))
            )
        )
    )


    (method (handleEvent pEvent)
        (var temp0[100])
        (super:handleEvent(pEvent))
        (if (((<> (send pEvent:type) 128) or global100) or (send pEvent:claimed))
            return 
        )
        (if (Said('lower/claw[<grabber]') or Said('use,press,press/claw,button'))
            proc255_0(13 35)
        )
    )

)
(instance platformScript of Script
    (properties)

    (method (doit)
        (if (global100)
            return 
        )
        (super:doit())
        (if ((== (send gEgo:onControl(0)) 5) or (send gEgo:inRect(99 168 190 172)))
            (self:changeState(1))
            = global100 1
        )
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = gGEgoX_2 (send gEgo:x)
                (grabber:
                    x((send gEgo:x))
                    y((send gEgo:y))
                    init()
                )
                = gGEgoX_2 (send gEgo:x)
                (send gEgo:
                    view(0)
                    loop(2)
                    posn(154 152)
                    setPri(14)
                    cycleSpeed(0)
                    setMotion(0)
                    setCycle(Walk)
                    setStep(3 2)
                )
                = global132 6
            )
            (case 1
                proc0_2()
                (send gEgo:
                    view(17)
                    setLoop((send gEgo:loop))
                    cel(0)
                    illegalBits(0)
                    setMotion(0)
                    setCycle(End self)
                )
            )
            (case 2
                (if (<> local0 3)
                    = local0 1
                    (send gEgo:setCycle(0))
                    (if ((send gEgo:inRect(99 168 190 172)))
                        (send gEgo:
                            setStep(3 20)
                            setMotion(MoveTo 148 229 self)
                        )
                    )(else
                        (send gEgo:
                            setPri(9)
                            setStep(5 20)
                            setMotion(MoveTo (send gEgo:x) 230 self)
                        )
                        (self:state(4))
                    )
                    (send gLongSong:
                        number(45)
                        loop(1)
                        play()
                    )
                )
            )
            (case 3
                (send gEgo:hide())
                (Timer:setCycle(self 2))
            )
            (case 4
                (if (not global133)
                    (send global1:changeScore(5))
                )
                (send global2:newRoom(15))
            )
            (case 5
                proc255_0(13 36)
                proc0_17(901 0 0 1)
            )
        )
    )

)
(instance grabber of Act
    (properties
        view 752
    )

    (method (init)
        (super:init())
        (self:
            setStep(3 1)
            setPri(9)
            ignoreActors(1)
        )
    )

)
(instance bot of Act
    (properties
        view 10
    )

    (method (init)
        (super:init())
        (self:
            cel(0)
            loop(0)
            posn(165 109)
            setPri(8)
            illegalBits(0)
            ignoreActors(1)
            setScript(botPanelScript)
        )
    )

)
(instance zot of View
    (properties
        view 10
    )

    (method (init)
        (super:init())
        (self:
            loop(6)
            ignoreActors(1)
            setPri(15)
        )
    )

)
(instance zotSound of Sound
    (properties
        number 35
        priority 1
    )
)
