(version 2)
(include "sci.sh")
(exports
    0 rm95
)
(use "Main")
(use "Class_255_0")
(use "Wander")
(use "Follow")
(use "Chase")
(use "Timer")
(use "Sound")
(use "Cycle")
(use "Game")
(use "User")
(use "Feature")
(use "Obj")
(script 95)


(local
    local0

)
(instance public rm95 of Rm
    (properties
        picture 95
        style 4
    )

    (method (init)
        (SL:enable())
        proc0_3()
        Load(128 901)
        Load(128 126)
        Load(128 127)
        Load(128 128)
        Load(128 210)
        Load(128 113)
        Load(128 114)
        Load(128 88)
        Load(128 116)
        Load(128 118)
        Load(132 44)
        Load(132 45)
        Load(132 48)
        Load(132 50)
        (super:init())
        (self:setScript(rmScript))
    )


    (method (doit)
        (var temp0)
        (super:doit())
        (if ((User:canControl()))
            (if (>= (send gEgo:y) 190)
                (send global2:setScript(exitHallScript))
            )
            = temp0 (send gEgo:onControl(-1))
            (if (& temp0 $0010)
                (send gEgo:setPri(5))
                (if (((< 120 (send gEgo:x)) and (< (send gEgo:x) 200)) and (>= (send gEgo:loop) 2))
                    (send gEgo:posn(
                        (if (< (send gEgo:x) 160)
                            120
                        )(else
                            200
                        )
 (send gEgo:y)))
                )
            )(else
                (if (& temp0 $0004)
                    (send gEgo:setPri(4))
                )(else
                    (if (& temp0 $0080)
                        (send gEgo:setPri(5))
                    )(else
                        (if (& temp0 $0008)
                            (if (<> (bridgeFront:cel) (bridgeFront:lastCel()))
                                (send gEgo:setPri(5))
                            )(else
                                return 
                            )
                        )(else
                            return 
                        )
                    )
                )
            )
            (send global2:setScript(gonner))
        )
    )


    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )
        (switch ((send pEvent:type))
            (case 128
                (if (Said('look<down') or Said('look/pit,deck,dirt'))
                    proc255_0(95 0)
                )(else
                    (if (Said('look/pedestal,aisle,aisle,ramp'))
                        proc255_0(95 1)
                    )(else
                        (if (Said('look/door,entrance'))
                            proc255_0(95 2)
                        )(else
                            (if (Said('look/crack,crack'))
                                proc255_0(95 3)
                            )(else
                                (if (Said('look/partition'))
                                    proc255_0(95 4)
                                )(else
                                    (if (Said('look<up') or Said('look/pane'))
                                        proc255_0(95 5)
                                    )(else
                                        (if (Said('look/control,console,button'))
                                            proc255_0(95 6)
                                        )(else
                                            (if (Said('jump[/*]'))
                                                proc255_0(95 7)
                                            )(else
                                                (if (Said('press,press,beat,feel,use/control,console,button'))
                                                    (if ((send gEgo:inRect(0 180 320 190)))
                                                        (send gEgo:setScript(buttonScript))
                                                    )(else
                                                        proc255_0(95 8)
                                                    )
                                                )(else
                                                    (if (<= (captureScript:state) 3)
                                                        (if (Said('look[/area,left,right]'))
                                                            proc255_0(95 9)
                                                        )(else
                                                            (if (Said('look,converse/man,folk'))
                                                                proc255_0(95 10)
                                                            )(else
                                                                (if (Said('free,release/man[<2]'))
                                                                    proc255_0(95 11)
                                                                )(else
                                                                    (if (Said('look/gel'))
                                                                        proc255_0(95 12)
                                                                    )(else
                                                                        (if (Said('melt/gel'))
                                                                            proc255_0(95 13)
                                                                        )(else
                                                                            (if (Said('consume/gel'))
                                                                                proc255_0(95 14)
                                                                            )(else
                                                                                (if ((Said('blast[/gel]') or Said('use/mrgarbage')) or Said('use/garbage<mr'))
                                                                                    (if ((send gEgo:inRect(140 102 176 110)) and (>= (send gEgo:loop) 2))
                                                                                        (send gEgo:setScript(captureScript))
                                                                                    )(else
                                                                                        proc255_0(95 15)
                                                                                    )
                                                                                )(else
                                                                                    (if (Said('blast/*'))
                                                                                        proc255_0(95 16)
                                                                                    )(else
                                                                                        (if (Said('*/gel'))
                                                                                            (if ((send gEgo:inRect(140 102 176 110)))
                                                                                                proc255_0(95 17)
                                                                                            )(else
                                                                                                proc255_0(95 15)
                                                                                            )
                                                                                        )
                                                                                    )
                                                                                )
                                                                            )
                                                                        )
                                                                    )
                                                                )
                                                            )
                                                        )
                                                    )(else
                                                        (if (Said('look/gel'))
                                                            proc255_0(95 18)
                                                        )(else
                                                            (if (Said('blast/gel'))
                                                                proc255_0(95 19)
                                                            )(else
                                                                (if (Said('*/gel'))
                                                                    proc255_0(95 20)
                                                                )(else
                                                                    (if (Said('blast[/*]'))
                                                                        proc255_0(95 21)
                                                                    )(else
                                                                        (if (Said('attack,combat,escape'))
                                                                            proc255_0(95 22)
                                                                        )(else
                                                                            (if (Said('look[/area,left,right]'))
                                                                                proc255_0(95 23)
                                                                                proc255_0(95 24)
                                                                            )(else
                                                                                (if (Said('*/man<2'))
                                                                                    proc255_0(95 25)
                                                                                )(else
                                                                                    (if (Said('look/guard'))
                                                                                        proc255_0(95 26)
                                                                                    )(else
                                                                                        (if (>= (captureScript:state) 16)
                                                                                            (if (Said('look/pane,man,guard,folk,accountant,eightprong'))
                                                                                                proc255_0(95 27)
                                                                                            )(else
                                                                                                (if (Said('look/elmo,elmo,boy,(man<little)'))
                                                                                                    proc255_0(95 28)
                                                                                                )(else
                                                                                                    (if (Said('converse/*'))
                                                                                                        proc255_0(95 29)
                                                                                                    )
                                                                                                )
                                                                                            )
                                                                                        )
                                                                                    )
                                                                                )
                                                                            )
                                                                        )
                                                                    )
                                                                )
                                                            )
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )
        )
    )


    (method (newRoom newRoomNumber)
        (send global7:eachElementDo(91 84))
        (super:newRoom(newRoomNumber))
    )

)
(instance rmScript of Script
    (properties)

    (method (init param1)
        (super:init(rest param1))
        (mrMark:init())
        (mrScott:init())
        (doorLeft:init())
        (doorRear:init())
        (doorRight:init())
        (bridgeLeft:init())
        (bridgeFront:init())
        (bridgeRight:init())
        (windowLeft:init())
        (windowCenter:init())
        (windowRight:init())
        (elmoPug:init())
        (jelloSound:init())
        (fallSound:init())
        (doorSound:init())
        (bridgeSound:init())
        (machineSound:init())
        (send gEgo:init())
        (send global10:add(progsLeft progsRear progsRight))
        (send global10:doit())
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (machineSound:play())
                (send gEgo:
                    view(113)
                    posn(158 190)
                    setCel(-1)
                    setLoop(-1)
                    ignoreActors(0)
                    setStep(3 2)
                    setPri(7)
                    setMotion(MoveTo 158 188 self)
                )
            )
            (case 1
                (rm95:south(90))
                proc0_3()
            )
        )
    )

)
(instance buttonScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (rm95:south(0))
                (send gEgo:setMotion(MoveTo 125 188 self))
            )
            (case 1
                (send gEgo:setMotion(MoveTo 120 207 self))
            )
            (case 2
                (send gEgo:setMotion(MoveTo (- (send gEgo:x) 1) (send gEgo:y) self))
            )
            (case 3
                (if (global238)
                    = global238 0
                    (bridgeFront:setCycle(Beg self))
                )(else
                    = global238 1
                    (bridgeFront:setCycle(End self))
                )
                (bridgeSound:play())
            )
            (case 4
                (bridgeFront:stopUpd())
                (send gEgo:setMotion(MoveTo 158 (send gEgo:y) self))
            )
            (case 5
                (send gEgo:setMotion(MoveTo 158 188 self))
            )
            (case 6
                (rm95:south(90))
                proc0_3()
            )
            (default 
                (self:changeState(0))
            )
        )
    )

)
(instance gonner of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (captureScript:changeState(99))
                (send gEgo:
                    view(88)
                    ignoreActors(1)
                    illegalBits(0)
                    setStep(3 12)
                    setLoop((send gEgo:loop))
                    setCycle(End self)
                )
            )
            (case 1
                (rm95:south(0))
                (send gEgo:
                    setCycle(0)
                    setMotion(MoveTo (send gEgo:x) 220 self)
                )
                (machineSound:stop())
                (fallSound:play())
            )
            (case 2
                (if (<> (fallSound:prevSignal) -1)
                    --state
                    (Timer:setCycle(self 4))
                )(else
                    (self:cue())
                )
            )
            (case 3
                proc0_17(901 0 0 10)
            )
        )
    )

)
(instance exitHallScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:setMotion(MoveTo (send gEgo:x) 190 self))
            )
            (case 1
                proc0_3()
                (send global2:newRoom(90))
            )
        )
    )

)
(instance captureScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (machineSound:stop())
                (jelloSound:play())
                (send gEgo:
                    view(114)
                    setCel(0)
                    setCycle(End self)
                )
            )
            (case 1
                (if (<> (jelloSound:prevSignal) -1)
                    --state
                    (send gEgo:
                        setCel(0)
                        setCycle(End self)
                    )
                )(else
                    (jelloSound:dispose())
                    (self:cue())
                )
            )
            (case 2
                (send gEgo:
                    view(113)
                    setCycle(Walk)
                )
                (mrMark:
                    view(126)
                    setPri((send gEgo:priority))
                    setLoop(-1)
                    setCel(-1)
                    setCycle(Walk)
                    observeControl(28)
                    setMotion(Wander)
                )
                (Timer:setCycle(self 2))
            )
            (case 3
                (mrScott:
                    view(127)
                    setPri((send gEgo:priority))
                    setLoop(-1)
                    setCel(-1)
                    setCycle(Walk)
                    observeControl(28)
                    setMotion(Wander)
                )
                = local0 global15
                = global15 global16
                (send global1:changeScore(-1))
                proc0_3()
                (Timer:setCycle(self 1))
            )
            (case 4
                proc255_0(95 30)
                proc255_0(95 31 67 -1 20 70 280)
                proc255_0(95 32)
                proc255_0(95 33 67 -1 20 70 280)
                (bridgeFront:setCycle(Beg self))
                (bridgeSound:play())
            )
            (case 5
                (if (<> (bridgeSound:prevSignal) -1)
                    --state
                    (Timer:setCycle(self 4))
                )(else
                    (bridgeFront:addToPic())
                    (self:cue())
                )
            )
            (case 6
                (Timer:setReal(self 10))
            )
            (case 7
                proc255_0(95 34 67 -1 20 70 280)
                (doorSound:play())
                (doorRear:setCycle(End self))
            )
            (case 8
                (if (<> (doorSound:prevSignal) -1)
                    --state
                    (Timer:setCycle(self 4))
                )(else
                    (doorRear:stopUpd())
                    (self:cue())
                )
            )
            (case 9
                (doorSound:play())
                (doorLeft:setCycle(End self))
            )
            (case 10
                (if (<> (doorSound:prevSignal) -1)
                    --state
                    (Timer:setCycle(self 4))
                )(else
                    (doorLeft:stopUpd())
                    (self:cue())
                )
            )
            (case 11
                (guardLeft:init())
                (guardLeft:setMotion(MoveTo 49 110 self))
            )
            (case 12
                (guardLeft:stopUpd())
                (doorSound:play())
                (doorRight:setCycle(End self))
            )
            (case 13
                (if (<> (doorSound:prevSignal) -1)
                    --state
                    (Timer:setCycle(self 4))
                )(else
                    (doorRight:stopUpd())
                    (self:cue())
                )
            )
            (case 14
                (guardRight:init())
                (guardRight:setMotion(MoveTo 271 110 self))
            )
            (case 15
                (guardRight:stopUpd())
                (windowLeft:dispose())
                (windowCenter:dispose())
                (windowRight:dispose())
                (Timer:setReal(self 3))
            )
            (case 16
                (mrMark:
                    setLoop(3)
                    setCel(0)
                    setMotion(0)
                )
                (mrScott:
                    setLoop(3)
                    setCel(0)
                    setMotion(0)
                )
                (elmoPug:setCycle(Fwd))
                (Timer:setReal(self 5))
            )
            (case 17
                (elmoPug:
                    setCel(1)
                    forceUpd()
                )
                proc255_0(95 35 67 -1 130 70 280)
                proc255_0(95 36 67 -1 130 70 280)
                proc255_0(95 37 67 -1 130 70 280)
                (elmoPug:
                    setCel(0)
                    addToPic()
                )
                proc0_2()
                = global15 local0
                (send global1:changeScore(10))
                (fallSound:dispose())
                (bridgeLeft:setCycle(End self))
                (bridgeSound:play())
            )
            (case 18
                (if (<> (bridgeSound:prevSignal) -1)
                    --state
                    (Timer:setCycle(self 4))
                )(else
                    (bridgeLeft:addToPic())
                    (self:cue())
                )
            )
            (case 19
                (doorSound:play())
                (doorLeft:setCycle(Beg self))
            )
            (case 20
                (if (<> (doorSound:prevSignal) -1)
                    --state
                    (Timer:setCycle(self 4))
                )(else
                    (doorLeft:addToPic())
                    (self:cue())
                )
            )
            (case 21
                (guardLeft:setMotion(MoveTo 90 110 self))
            )
            (case 22
                (mrMark:
                    setLoop(-1)
                    setCel(-1)
                    ignoreActors(1)
                    ignoreControl(-1)
                    setMotion(Follow gEgo 2)
                )
                (mrScott:
                    setLoop(-1)
                    setCel(-1)
                    ignoreActors(1)
                    ignoreControl(-1)
                    setMotion(Follow mrMark 2)
                )
                (guardLeft:setMotion(Follow gEgo 30))
                (bridgeRight:setCycle(End self))
                (bridgeSound:play())
            )
            (case 23
                (if (<> (bridgeSound:prevSignal) -1)
                    --state
                    (Timer:setCycle(self 4))
                )(else
                    (bridgeRight:addToPic())
                    (self:cue())
                )
            )
            (case 24
                (send gEgo:
                    setPri(6)
                    ignoreActors(1)
                    setMotion(MoveTo 205 110 self)
                )
                (mrMark:setPri(6))
                (mrScott:setPri(6))
            )
            (case 25
                (guardRight:
                    setLoop(1)
                    setMotion(MoveTo 320 110)
                )
                (send gEgo:setMotion(Follow guardRight 0))
                (guardLeft:setMotion(Chase gEgo 0 self))
            )
            (case 26
                (guardRight:dispose())
                (guardLeft:dispose())
                (mrMark:dispose())
                (mrScott:dispose())
                (doorSound:play())
                (doorRight:setCycle(Beg self))
            )
            (case 27
                (if (<> (doorSound:prevSignal) -1)
                    --state
                    (Timer:setCycle(self 4))
                )(else
                    (doorRight:addToPic())
                    (self:cue())
                )
            )
            (case 28
                (doorSound:play())
                (doorRear:setCycle(Beg self))
            )
            (case 29
                (if (<> (doorSound:prevSignal) -1)
                    --state
                    (Timer:setCycle(self 4))
                )(else
                    (doorRear:addToPic())
                    (doorSound:dispose())
                    (self:cue())
                )
            )
            (case 30
                (windowLeft:init())
                (windowCenter:init())
                (windowRight:init())
                (Timer:setReal(self 1))
            )
            (case 31
                (send gEgo:
                    put(12 -1)
                    put(13 -1)
                    put(11 -1)
                    put(15 -1)
                )
                (send global2:newRoom(121))
            )
        )
    )

)
(instance bridgeLeft of Prop
    (properties)

    (method (init)
        (super:init())
        (self:
            setPri(4)
            view(118)
            loop(1)
            cel(0)
            posn(84 121)
            ignoreActors(1)
            stopUpd()
        )
    )

)
(instance bridgeFront of Prop
    (properties)

    (method (init)
        (super:init())
        (self:
            cycleSpeed(1)
            setPri(6)
            view(118)
            loop(0)
            cel(
                (if (global238)
                    6
                )(else
                    0
                )
)
            posn(160 180)
            ignoreActors(1)
            stopUpd()
        )
    )

)
(instance bridgeRight of Prop
    (properties)

    (method (init)
        (super:init())
        (self:
            setPri(4)
            view(118)
            loop(2)
            cel(0)
            posn(233 121)
            ignoreActors(1)
            stopUpd()
        )
    )

)
(instance doorLeft of Prop
    (properties)

    (method (init)
        (super:init())
        (self:
            cycleSpeed(1)
            setPri(3)
            view(118)
            loop(4)
            cel(0)
            posn(54 125)
            ignoreActors(1)
            stopUpd()
        )
    )

)
(instance doorRear of Prop
    (properties)

    (method (init)
        (super:init())
        (self:
            cycleSpeed(1)
            setPri(3)
            view(118)
            loop(3)
            cel(0)
            posn(159 84)
            ignoreActors(1)
            stopUpd()
        )
    )

)
(instance doorRight of Prop
    (properties)

    (method (init)
        (super:init())
        (self:
            cycleSpeed(1)
            setPri(3)
            view(118)
            loop(5)
            cel(0)
            posn(266 124)
            ignoreActors(1)
            stopUpd()
        )
    )

)
(instance windowLeft of Prop
    (properties)

    (method (init)
        (super:init())
        (self:
            setPri(5)
            view(116)
            loop(0)
            cel(0)
            posn(80 32)
            stopUpd()
        )
    )

)
(instance windowCenter of Prop
    (properties)

    (method (init)
        (super:init())
        (self:
            setPri(5)
            view(116)
            loop(0)
            cel(1)
            posn(160 26)
            stopUpd()
        )
    )

)
(instance windowRight of Prop
    (properties)

    (method (init)
        (super:init())
        (self:
            setPri(5)
            view(116)
            loop(0)
            cel(2)
            posn(239 32)
            stopUpd()
        )
    )

)
(instance progsLeft of PV
    (properties)
)
(instance progsRear of PV
    (properties)
)
(instance progsRight of PV
    (properties)
)
(instance guardLeft of Act
    (properties)

    (method (init)
        (super:init())
        (self:
            ignoreActors(1)
            ignoreControl(1)
            setPri(6)
            view(210)
            setLoop(1)
            cel(0)
            posn(10 110)
            setCycle(Walk)
        )
    )

)
(instance elmoPug of Prop
    (properties)

    (method (init)
        (super:init())
        (self:
            setPri(4)
            view(116)
            loop(2)
            cel(0)
            posn(156 27)
            stopUpd()
        )
    )

)
(instance guardRight of Act
    (properties)

    (method (init)
        (super:init())
        (self:
            ignoreActors(1)
            ignoreControl(1)
            setPri(6)
            view(210)
            setLoop(0)
            cel(0)
            posn(300 110)
            setCycle(Walk)
        )
    )

)
(instance mrMark of Act
    (properties)

    (method (init)
        (super:init())
        (self:
            view(128)
            setLoop(0)
            setCel(0)
            posn(148 106)
            setPri(7)
            setCycle(Fwd)
        )
    )

)
(instance mrScott of Act
    (properties)

    (method (init)
        (super:init())
        (self:
            view(128)
            setLoop(1)
            setCel(2)
            posn(169 106)
            setPri(7)
            setCycle(Fwd)
        )
    )

)
(instance jelloSound of Sound
    (properties
        number 44
        priority 1
    )
)
(instance fallSound of Sound
    (properties
        number 45
        priority 2
    )
)
(instance doorSound of Sound
    (properties
        number 48
        priority 1
    )
)
(instance bridgeSound of Sound
    (properties
        number 48
        priority 1
    )
)
(instance machineSound of Sound
    (properties
        number 50
        loop -1
    )
)
