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


(local
    scriptClient
    local1
    local2
    local3
    local4[63] = (0 10 161 0 41 160 0 74 154 1 101 149 1 123 145 1 145 136 2 166 128 2 182 110 2 194 98 3 203 75 3 208 55 3 203 34 3 191 17 4 174 8 4 159 11 4 146 16 4 136 27 5 136 40 5 140 51 5 148 54 5 161 57 )

)
(instance public scumSoft of Rgn
    (properties)

    (method (init param1)
        (SL:enable())
        (super:init(rest param1))
        = global56 0
        proc0_3()
        Load(128 92)
        Load(128 0)
        Load(128 256)
        Load(128 113)
        Load(128 114)
        Load(128 115)
        Load(132 46)
        Load(132 47)
        Load(132 44)
        Load(132 55)
        Load(132 84)
        Load(132 102)
        Load(132 103)
        (jelloSound:init())
        (vaporizeSound:init())
        (if (not == global11 93)
            (send gLongSong:
                number(102)
                loop(-1)
                play()
            )
        )(else
            (send gLongSong:stop())
        )
        (announce:state(global242))
        (if (global233)
            (if (== gNorth 90)
                = global233 0
                = gShadowDroidX 0
                = gShadowDroidY 0
            )(else
                (if ((== 0 gShadowDroidX) and (== gShadowDroidX gShadowDroidY))
                    = gShadowDroidX 166
                    = gShadowDroidY 97
                )
                (User:canInput(0))
                (droidScript:changeState(1))
            )
        )
    )


    (method (doit)
        (if (not global233 and (== 700 Random(1 1400)))
            (announce:cue())
        )
    )


    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )
        (switch ((send pEvent:type))
            (case 128
                (if (Said('look[/area,department,deck,dirt,ceiling,left,right,up,down]'))
                    proc255_0(702 0)
                )(else
                    (if (Said('look/partition,partition'))
                        proc255_0(702 1)
                    )(else
                        (if (Said('*/cabinet,cabinet'))
                            proc255_0(702 2)
                        )(else
                            (if (Said('converse,look/man,folk,bystander,eightprong,accountant'))
                                proc255_0(702 3)
                            )(else
                                (if (Said('look/garbage,can,basket'))
                                    proc255_0(702 4)
                                )(else
                                    (if (Said('look/chart,paper,passenger,calendar,board,desk,chair'))
                                        proc255_0(702 5)
                                    )(else
                                        (if (Said('sit,explore,get,beat,beat,get,feel/chart,passenger,calendar,board,chair,man,desk,paper,partition'))
                                            proc255_0(702 6)
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )
        )
    )

)
(instance announce of Script
    (properties)

    (method (changeState newState)
        ++global242
        (switch (= state newState)
            (case 1
                proc255_0(702 7)
            )
            (case 2
                proc255_0(702 8)
            )
        )
    )

)
(class TrashBasket of Prop
    (properties
        y 0
        x 0
        z 0
        heading 0
        yStep 2
        view 0
        loop 0
        cel 0
        priority 0
        underBits 0
        signal 0
        nsTop 0
        nsLeft 0
        nsBottom 0
        nsRight 0
        lsTop 0
        lsLeft 0
        lsBottom 0
        lsRight 0
        brTop 0
        brLeft 0
        brBottom 0
        brRight 0
        cycleSpeed 0
        script 0
        cycler 0
        timer 0
        vaporized 0
        misses 0
        egoHere 0
        egoNear 0
        myNerd 0
        myID 0
        nearWest 0
        nearNorth 0
        nearEast 0
        nearSouth 0
    )

    (method (init)
        (self:
            vaporized(global567[myID])
            view(115)
            ignoreActors(0)
            setLoop(4)
            setCel(global567[(super:init())])
            stopUpd()
        )
        (if (vaporized and myID)
            (self:addToPic())
        )
    )


    (method (doit)
        (if (global233)
            (self:egoNear(0))
        )(else
            (if ((((<= nearWest (send gEgo:x)) and (<= (send gEgo:x) nearEast)) and (<= nearNorth (send gEgo:y))) and (<= (send gEgo:y) nearSouth))
                (if ((((send gEgo:has(12)) and (send gEgo:has(13))) and not vaporized) and myNerd)
                    (self:egoNear(1))
                )
            )(else
                (if ((egoNear and not vaporized) and myNerd)
                    (self:egoNear(0))
                    (alertScript:init((self:myNerd)))
                )(else
                    (if ((((not (send gEgo:mover) and not global243) and not global233) and myNerd) and (== 50 Random(1 100)))
                        (send myNerd:setCel(
                            (if ((send myNerd:cel))
                                0
                            )(else
                                3
                            )
))
                        (if (not (== global11 93) and (== 1 Random(1 2)))
                            (send gLongSong:
                                number(
                                    (if (== 1 Random(1 2))
                                        103
                                    )(else
                                        102
                                    )
)
                                play()
                            )
                        )
                    )
                )
            )
        )
    )


    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )
        (switch ((send pEvent:type))
            (case 128
                (if ((send gEgo:has(13)))
                    (if (Said('look/garbage<mr'))
                        (send ((send global9:at(13))):showSelf())
                    )(else
                        (if ((Said('blast[/garbage]') or Said('use/mrgarbage')) or Said('use/garbage<mr'))
                            (if ((self:perform(egoIsHere species)))
                                (self:egoHere(1))
                            )
                            (self:vaporize())
                        )(else
                            (if (Said('blast/*'))
                                proc255_0(702 9)
                            )
                        )
                    )
                )
            )
        )
    )


    (method (cue)
        (if (egoHere)
            (if (vaporized)
                proc255_0(702 10)
            )(else
                (self:
                    vaporized(1)
                    setCel(= global567[myID] 1)
                    misses(0)
                )
                (if (not == global11 93)
                    (self:addToPic())
                )(else
                    (if (not myNerd)
                        proc255_0(702 11)
                    )
                )
            )
            (self:egoHere(0))
        )(else
            (if (egoNear)
                (switch (++misses)
                    (case 1
                        proc255_0(702 12)
                    )
                    (case 2
                        proc255_0(702 13)
                    )
                    (case 3
                        proc255_0(702 14)
                    )
                    (case 4
                        proc255_0(702 15)
                    )
                    (case 5
                        proc255_0(702 16)
                    )
                    (case 6
                        (if (global233)
                            --misses
                        )(else
                            (self:egoNear(0))
                            (alertScript:init((self:myNerd)))
                        )
                    )
                )
            )(else
                proc255_0(702 17)
            )
        )
        (send gEgo:
            view(113)
            cycleSpeed(0)
            setCycle(Walk)
        )
        proc0_3()
    )


    (method (vaporize)
        proc0_2()
        (send gEgo:
            view(114)
            setCel(0)
            setCycle(End self)
        )
        (vaporizeSound:play())
    )

)
(instance egoIsHere of Code
    (properties)

    (method (doit param1)
        (if (global233)
            return 0
        )
        (switch ((send gEgo:loop))
            (case 0
                (if ((((> (send gEgo:brTop) (send param1:brBottom)) or (< (send gEgo:brBottom) (send param1:brTop))) or (> (send gEgo:brRight) (send param1:brLeft))) or (< (+ (send gEgo:brRight) (send gEgo:xStep)) (send param1:brLeft)))
                    return 0
                )
            )
            (case 1
                (if ((((> (send gEgo:brTop) (send param1:brBottom)) or (< (send gEgo:brBottom) (send param1:brTop))) or (< (send gEgo:brLeft) (send param1:brRight))) or (> (- (send gEgo:brLeft) (send gEgo:xStep)) (send param1:brRight)))
                    return 0
                )
            )
            (case 2
                (if ((((< (send gEgo:brRight) (send param1:brLeft)) or (> (send gEgo:brLeft) (send param1:brRight))) or (> (send gEgo:brBottom) (send param1:nsTop))) or (< (+ (send gEgo:brBottom) (send gEgo:yStep)) (send param1:nsTop)))
                    return 0
                )
            )
            (case 3
                (if ((((< (send gEgo:brRight) (send param1:brLeft)) or (> (send gEgo:brLeft) (send param1:brRight))) or (< (send gEgo:brTop) (send param1:nsBottom))) or (> (- (send gEgo:brTop) (send gEgo:yStep)) (send param1:nsBottom)))
                    return 0
                )
            )
        )
        return 1
    )

)
(class Nerd of Prop
    (properties
        y 0
        x 0
        z 0
        heading 0
        yStep 2
        view 0
        loop 0
        cel 0
        priority 0
        underBits 0
        signal 0
        nsTop 0
        nsLeft 0
        nsBottom 0
        nsRight 0
        lsTop 0
        lsLeft 0
        lsBottom 0
        lsRight 0
        brTop 0
        brLeft 0
        brBottom 0
        brRight 0
        cycleSpeed 0
        script 0
        cycler 0
        timer 0
        seeProblem 0
        speakX 0
        speakY 0
        speakCel 0
    )

    (method (init)
        (super:init())
        (self:
            view(115)
            setCel(0)
            stopUpd()
        )
    )

)
(class Fink of Act
    (properties
        y 0
        x 0
        z 0
        heading 0
        yStep 2
        view 0
        loop 0
        cel 0
        priority 0
        underBits 0
        signal 0
        nsTop 0
        nsLeft 0
        nsBottom 0
        nsRight 0
        lsTop 0
        lsLeft 0
        lsBottom 0
        lsRight 0
        brTop 0
        brLeft 0
        brBottom 0
        brRight 0
        cycleSpeed 0
        script 0
        cycler 0
        timer 0
        illegalBits -32768
        xLast 0
        yLast 0
        xStep 3
        moveSpeed 0
        blocks 0
        baseSetter 0
        mover 0
        looper 0
        viewer 0
        avoider 0
        seeProblem 0
        speakX 0
        speakY 0
        speakCel 0
    )

    (method (init)
        (super:init())
        (self:
            view(115)
            xStep(4)
            stopUpd()
        )
    )


    (method (doit)
        (super:doit())
        (if (seeProblem)
            (if (global233)
                = seeProblem 0
            )(else
                (alertScript:init(self))
            )
        )
    )

)
(instance alertScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (User:canInput(0))
                = global233 1
                (send gEgo:setMotion(0))
                = scriptClient (self:client)
                (alertBalloon:init())
                (send gLongSong:
                    number(84)
                    loop(-1)
                    play()
                )
                = local1 5
                (if (> (send scriptClient:loop) 3)
                    (self:cue())
                )(else
                    (send scriptClient:setCycle(End self))
                )
            )
            (case 1
                (if (--local1 and not (send gEgo:mover))
                    --state
                    (Timer:setReal(self 2))
                )(else
                    = cycles 1
                )
            )
            (case 2
                (if (> (send scriptClient:loop) 3)
                    = cycles 1
                )(else
                    (send scriptClient:setCycle(Beg self))
                )
            )
            (case 3
                (send scriptClient:stopUpd())
                (alertBalloon:dispose())
                (if (< (send scriptClient:loop) 3)
                    proc255_0(702 18)
                )
                (send global2:setScript(droidScript))
            )
        )
    )

)
(instance alertBalloon of View
    (properties)

    (method (init)
        (super:init())
        (self:
            posn((send scriptClient:speakX) (send scriptClient:speakY))
            view(115)
            setLoop(
                (if (== global11 93)
                    9
                )(else
                    5
                )
)
            setCel((send scriptClient:speakCel))
            setPri(15)
            stopUpd()
        )
    )

)
(instance shadowDroid of Act
    (properties)

    (method (init)
        (super:init())
        (self:
            setPri(0)
            view(256)
            setLoop(2)
            setCel(1)
            setCycle(Fwd)
            xStep(
                (if ((send gEgo:has(12)))
                    3
                )(else
                    8
                )
)
            yStep(
                (if ((send gEgo:has(12)))
                    2
                )(else
                    5
                )
)
            ignoreHorizon(1)
            ignoreActors(1)
            ignoreControl(-1)
        )
        (if ((== gShadowDroidX gShadowDroidY) and (== gShadowDroidY 0))
            (self:posn((+ (swoopDroid:x) 5) (+ (swoopDroid:y) 40)))
            (swoopDroid:dispose())
        )(else
            (if ((== gNorth 90) or (== gNorth 94))
                (self:posn(gShadowDroidX gShadowDroidY))
            )(else
                (switch ((send gEgo:loop))
                    (case 0
                        (self:posn(
                            (if (>= gShadowDroidX 0)
                                (- gShadowDroidX 320)
                            )(else
                                gShadowDroidX
                            )
 gShadowDroidY))
                    )
                    (case 1
                        (self:posn(
                            (if (<= gShadowDroidX 320)
                                (+ gShadowDroidX 320)
                            )(else
                                gShadowDroidX
                            )
 gShadowDroidY))
                    )
                    (case 2
                        (self:
                            ignoreHorizon(1)
                            posn(gShadowDroidX 
                                (if (>= gShadowDroidY 0)
                                    - gShadowDroidY 190
                                )(else
                                    gShadowDroidY
                                )
)
                        )
                    )
                    (case 3
                        (self:posn(gShadowDroidX 
                            (if (<= gShadowDroidY 190)
                                (+ gShadowDroidY 190)
                            )(else
                                gShadowDroidY
                            )
))
                    )
                )
            )
        )
    )

)
(instance securityDroid of Prop
    (properties)

    (method (init)
        (super:init())
        (self:
            setPri(
                (if (not (== global11 93) and (< (send gEgo:y) 116))
                    14
                )(else
                    15
                )
)
            view(256)
            setLoop(1)
            doit()
        )
    )


    (method (doit)
        = gShadowDroidX (shadowDroid:x)
        = gShadowDroidY (shadowDroid:y)
        (self:
            posn(gShadowDroidX - gShadowDroidY 40)
            setCel((shadowDroid:cel))
        )
    )

)
(instance swoopDroid of Prop
    (properties)

    (method (init)
        (super:init())
        (self:
            setPri(15)
            view(256)
            setLoop(0)
            ignoreActors(1)
        )
    )


    (method (doit)
        (if (not local2)
            return 
        )
        (if ((<= 0 local3) and (<= local3 62))
            (if (> local2 0)
                (self:
                    setCel(local4[local3])
                    x(local4[++local3])
                    y(local4[++local3])
                )
                ++local3
            )(else
                (self:
                    y(local4[local3])
                    x(- 320 local4[--local3])
                    setCel(local4[--local3])
                )
                --local3
            )
        )(else
            = local2 0
            (droidScript:cue())
        )
    )

)
(instance zapper of Prop
    (properties)

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


    (method (doit)
        (super:doit())
        (if ((send gEgo:has(12)))
            (send gEgo:
                view(
                    (if (cel)
                        113
                    )(else
                        92
                    )
)
                setLoop(
                    (if (cel)
                        2
                    )(else
                        5
                    )
)
                setCel(0)
            )
        )(else
            (send gEgo:
                view(
                    (if (cel)
                        0
                    )(else
                        92
                    )
)
                setLoop(2)
                setCel(0)
            )
        )
    )

)
(instance droidScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                = local2 1
                = local3 0
                (send gLongSong:
                    number(46)
                    loop(1)
                    play()
                )
                (swoopDroid:init())
            )
            (case 1
                (send gLongSong:
                    number(47)
                    loop(-1)
                    play()
                )
                (shadowDroid:init())
                (securityDroid:init())
                = local1 6
                (self:cue())
            )
            (case 2
                (if (((--local1 and not (send gEgo:mover)) and (== gShadowDroidX 166)) and (== gShadowDroidY 97))
                    --state
                    (Timer:setReal(self 2))
                )(else
                    (self:cue())
                )
            )
            (case 3
                (shadowDroid:setMotion(Chase gEgo 0 self))
            )
            (case 4
                (if (((& (send gEgo:onControl(-1)) $0002) or (>= (send gEgo:y) 191)) or (>= (send gEgo:x) 320))
                    = state (- state 2)
                )(else
                    proc0_2()
                )
                (Timer:setCycle(self 1))
            )
            (case 5
                (zapper:init())
                (jelloSound:play())
                (Timer:setCycle(self 4))
            )
            (case 6
                (if (<> (jelloSound:prevSignal) -1)
                    --state
                    (Timer:setCycle(self 4))
                )(else
                    (zapper:dispose())
                    (jelloSound:stop())
                    (Timer:setCycle(self 1))
                )
            )
            (case 7
                (send gEgo:
                    view(92)
                    setLoop(
                        (if ((send gEgo:has(12)))
                            5
                        )(else
                            2
                        )
)
                    setCycle(Fwd)
                    cycleSpeed(2)
                )
                (Timer:setCycle(self 1))
            )
            (case 8
                (shadowDroid:
                    xStep(6)
                    yStep(4)
                    setMotion(MoveTo - local4[61] 3 + local4[62] 40 self)
                )
            )
            (case 9
                (securityDroid:dispose())
                (shadowDroid:dispose())
                (send gLongSong:
                    number(46)
                    loop(1)
                    play()
                )
                = local2 -1
                = local3 62
                (swoopDroid:init())
            )
            (case 10
                (swoopDroid:dispose())
                (if (not == global11 93)
                    (send gLongSong:
                        number(102)
                        loop(-1)
                        play()
                    )
                )
                = global233 0
                (Timer:setReal(self 6))
            )
            (case 11
                (send gLongSong:stop())
                proc0_17(901 0 7 
                    (if ((send gEgo:has(12)))
                        9
                    )(else
                        15
                    )
)
            )
        )
    )

)
(instance jelloSound of Sound
    (properties
        number 44
        priority 3
    )
)
(instance vaporizeSound of Sound
    (properties
        number 55
        priority 2
    )
)
