(version 2)
(include "sci.sh")
(exports
    0 rm270
)
(use "Main")
(use "TellerIcon")
(use "ArrayPath")
(use "Scaler")
(use "PolyPath")
(use "Polygon")
(use "CueObj")
(use "n958")
(use "Grooper")
(use "Cycle")
(use "Game")
(use "View")
(use "Obj")
(script 270)


(local
    local0[17] = (-15 156 20 154 40 132 107 121 127 97 114 89 42 97 10 77 -32768 )
    local17[17] = (10 77 42 97 114 89 127 97 107 121 40 132 20 154 -15 156 -32768 )
    local34[21] = (-15 162 30 156 52 137 118 124 143 102 213 97 270 48 237 36 240 26 330 18 -32768 )
    local55[21] = (330 18 240 26 237 36 270 48 213 97 143 102 118 124 52 137 30 156 -15 162 -32768 )
    local76[15] = (41 70 71 91 116 87 149 97 220 100 288 51 330 54 -32768 )
    local91[15] = (330 54 288 51 220 100 149 97 116 87 71 91 41 70 -32768 )
    local106[9] = (44 71 71 90 116 85 330 159 -32768 )
    local115[9] = (330 159 116 85 71 90 44 71 -32768 )
    local124[11] = (330 150 235 120 230 104 291 56 330 59 -32768 )
    local135[11] = (330 59 291 56 230 104 235 120 330 150 -32768 )
    local146[15] = (-15 178 45 163 65 142 129 129 159 107 201 107 330 154 -32768 )
    local161[15] = (330 154 201 107 159 107 129 129 65 142 45 163 -15 178 -32768 )
    local176[20]
    local196[10]
    local206
    local207 =     4
    local208
    local209[5] = (270 271 272 271 272 )
    local214[5] = (15 16 17 18 19 )
    local219
    local220
    local221

)
(instance public rm270 of Rm
    (properties
        noun 21
        picture 270
        horizon 70
        north 320
        picAngle 70
        vanishingX 310
        vanishingY -100
    )

    (method (init)
        = local208 1
        = local176[0] @local0
        = local176[1] @local161
        = local176[2] @local34
        = local176[3] @local146
        = local176[4] @local106
        = local176[5] @local76
        = local176[6] @local106
        = local176[7] @local34
        = local176[8] @local106
        = local176[9] @local135
        = local176[10] @local17
        = local176[11] @local124
        = local176[12] @local55
        = local176[13] @local161
        = local176[14] @local34
        = local176[15] @local91
        = local176[16] @local115
        = local176[17] @local91
        = local176[18] @local115
        = local176[19] @local124
        proc958_0(128 270 271 272)
        (send gOwner:
            init()
            normalize()
            setScale(Scaler 39 30 135 70)
        )
        (switch (gGClientModNum)
            (case 200
                (send gOwner:
                    x(325)
                    y(153)
                )
                = local219 312
                = local220 153
                proc0_2()
                (self:setScript(moveOut))
            )
            (case 210
                (send gOwner:
                    x(325)
                    y(153)
                )
                = local219 312
                = local220 153
                proc0_2()
                (self:setScript(moveOut))
            )
            (case 240
                (send gOwner:
                    x(-5)
                    y(157)
                )
                = local219 8
                = local220 152
                proc0_2()
                (self:setScript(moveOut))
            )
            (case 280
                (send gLongSong:
                    fade(70 5 3 0)
                    hold(1)
                )
                (send gOwner:
                    x(297)
                    y(127)
                )
                = local219 277
                = local220 132
                proc0_2()
                (self:setScript(moveOut))
            )
            (case 285
                (send gLongSong:
                    fade(70 5 3 0)
                    hold(1)
                )
                (send gOwner:
                    x(297)
                    y(127)
                )
                = local219 278
                = local220 132
                proc0_2()
                (self:setScript(moveOut))
            )
            (case 290
                (send gLongSong:
                    fade(70 5 3 0)
                    hold(1)
                    holdVal(1)
                )
                (send gOwner:
                    x(142)
                    y(76)
                )
                = local219 132
                = local220 83
                proc0_2()
                (self:setScript(moveOut))
            )
            (case 300
                (send gLongSong:
                    fade(70 5 3 0)
                    hold(1)
                )
                (if (< (send gOwner:x) 115)
                    (send gOwner:
                        x(56)
                        y(81)
                    )
                    = local219 69
                    = local220 88
                )(else
                    (send gOwner:
                        x(22)
                        y(84)
                    )
                    = local219 35
                    = local220 91
                )
                proc0_2()
                (self:setScript(moveOut))
            )
            (case 320
                (send gOwner:
                    x(259)
                    y(71)
                )
                proc0_3()
            )
            (default 
                (send gOwner:
                    x(160)
                    y(160)
                )
                proc0_3()
            )
        )
        (if (<> gGClientModNum 210)
            (send gLongSong3:
                number(925)
                setLoop(-1)
                play(100)
            )
        )
        (super:init())
        (send global2:addObstacle((send ((Polygon:new())):
                type(2)
                init(319 145 286 136 294 123 278 134 255 126 271 119 238 108 302 59 319 60)
                yourself()
            )
 (send ((Polygon:new())):
                type(2)
                init(0 0 116 0 263 48 205 97 176 88 148 91 130 83 140 72 124 81 106 75 90 75 94 87 71 89 45 72 65 91 40 92 18 78 30 93 8 95 7 101 116 91 95 117 22 126 0 146)
                yourself()
            )
 (send ((Polygon:new())):
                type(2)
                init(0 187 53 183 59 170 82 146 186 124 203 126 95 146 194 186 319 164 319 189 0 189)
                yourself()
            )
 (send ((Polygon:new())):
                type(2)
                init(201 136 263 160 195 173 135 148)
                yourself()
            )
))
        (if ((townPerson1:checkDetail()))
            ++local206
            (townPerson1:
                detailLevel(0)
                init()
                setScript((walkAround:new()))
                setScale(Scaler 91 43 190 0)
                setLoop(Grooper)
                setCycle(Walk)
            )
        )
        (if (not global121)
            (if ((townPerson2:checkDetail()))
                ++local206
                (townPerson2:
                    detailLevel(0)
                    init()
                    setScript((walkAround:new()))
                    setScale(Scaler 91 43 190 0)
                    setLoop(Grooper)
                    setCycle(Walk)
                )
            )
            (if ((townPerson3:checkDetail()))
                ++local206
                (townPerson3:
                    detailLevel(0)
                    init()
                    setScript((walkAround:new()))
                    setScale(Scaler 91 43 190 0)
                    setLoop(Grooper)
                    setCycle(Walk)
                )
            )
            (if ((townPerson4:checkDetail()))
                ++local206
                (townPerson4:
                    detailLevel(0)
                    init()
                    setScript((walkAround:new()))
                    setScale(Scaler 91 43 190 0)
                    setLoop(Grooper)
                    setCycle(Walk)
                )
            )
        )
        (guard1:
            init()
            noun(20)
            addToPic()
        )
        (garden:init())
        (trees:init())
        (magicsign:init())
        (apothsign:init())
        (restsign:init())
        (restentr:init())
        (apothentr:init())
        (magicentr:init())
        (kingentr:init())
        (bazstair:init())
        (upplant:init())
        (rightplant:init())
        (upstair:init())
    )


    (method (doit param1)
        (var temp0)
        (super:doit(rest param1))
        = temp0 (send gOwner:onControl(1))
        (if ((== temp0 512) and not local221)
            = local221 1
            (send gLongSong3:fade(1 3 5 0))
            (send gLongSong:
                number(280)
                setLoop(-1)
                play(1)
                hold(1)
            )
            (send gLongSong:fade(70 3 5 0))
        )(else
            (if ((== temp0 1024) and local221)
                = local221 0
                (send gLongSong:fade(0 5 3 1))
                (send gLongSong3:fade(100 3 5 0))
            )(else
                (if ((== temp0 2048) and not local221)
                    = local221 1
                    (send gLongSong3:fade(1 3 5 0))
                    (send gLongSong:
                        number(290)
                        setLoop(-1)
                        play(1)
                        hold(1)
                    )
                    (send gLongSong:fade(70 3 5 0))
                )(else
                    (if ((== temp0 4096) and local221)
                        = local221 0
                        (send gLongSong:fade(0 5 3 1))
                        (send gLongSong3:fade(100 3 5 0))
                    )(else
                        (if ((== temp0 8192) and not local221)
                            = local221 1
                            (send gLongSong3:fade(1 3 5 0))
                            (send gLongSong:
                                number(300)
                                setLoop(-1)
                                play(1)
                                hold(1)
                            )
                            (send gLongSong:fade(70 3 5 0))
                        )(else
                            (if ((== temp0 16384) and local221)
                                = local221 0
                                (send gLongSong:fade(0 5 3 1))
                                (send gLongSong3:fade(100 3 5 0))
                            )
                        )
                    )
                )
            )
        )
        (if (script)
        )(else
            (if (not 
            (if (< 5 (send gOwner:x))
                < (send gOwner:x) 315
            )
)
                proc0_2()
                (self:setScript(sExit))
            )(else
                (if (== temp0 2)
                    proc0_2()
                    (self:setScript(toRestLeft))
                )(else
                    (if (== temp0 4)
                        proc0_2()
                        (self:setScript(toRestRight))
                    )(else
                        (if (== temp0 8)
                            proc0_2()
                            (self:setScript(toApoth))
                        )(else
                            (if (== temp0 16)
                                proc0_2()
                                (self:setScript(toKreesha))
                            )(else
                                (if (== temp0 32)
                                    (if (not & (send gOwner:signal) $0010)
                                        (send gOwner:
                                            signal(| (send gOwner:signal) $0010)
                                            priority(9)
                                        )
                                    )
                                )(else
                                    (if (& (send gOwner:signal) $0010)
                                        (send gOwner:signal((& (send gOwner:signal) $ffef)))
                                    )
                                )
                            )
                        )
                    )
                )
            )
        )
    )


    (method (dispose)
        UnLoad(128 270)
        UnLoad(128 271)
        UnLoad(128 272)
        (super:dispose())
    )


    (method (newRoom newRoomNumber)
        (if (== newRoomNumber 320)
            (send gLongSong3:fade())
        )
        (super:newRoom(newRoomNumber))
    )

)
(instance sExit of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (if (<= (send gOwner:x) 5)
                    = register 240
                    (send gOwner:setMotion(PolyPath -5 (send gOwner:y) self))
                )(else
                    = register 210
                    (send gOwner:setMotion(PolyPath 325 (send gOwner:y) self))
                )
            )
            (case 1
                (send global2:newRoom(register))
            )
        )
    )

)
(instance toRestLeft of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gLongSong:fade(100 5 5 0))
                (send gOwner:setMotion(PolyPath 22 84 self))
            )
            (case 1
                (send gLongSong3:fade())
                (send gLongSong:fade(110 5 5 0))
                (send global2:newRoom(300))
            )
        )
    )

)
(instance toRestRight of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gLongSong:fade(100 5 5 0))
                (send gOwner:setMotion(PolyPath 56 81 self))
            )
            (case 1
                (send gLongSong3:fade())
                (send gLongSong:fade(110 5 5 0))
                (send global2:newRoom(300))
            )
        )
    )

)
(instance toKreesha of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gLongSong:fade(100 5 5 0))
                (send gOwner:setMotion(PolyPath 297 127 self))
            )
            (case 1
                (send gLongSong3:fade())
                (send gLongSong:fade(127 5 5 0))
                (send global2:newRoom(280))
            )
        )
    )

)
(instance toApoth of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gLongSong:fade(127 5 5 0))
                (send gOwner:setMotion(PolyPath 142 76 self))
            )
            (case 1
                (send gLongSong3:fade())
                (send global2:newRoom(290))
            )
        )
    )

)
(instance walkAround of Script
    (properties)

    (method (changeState newState)
        (var temp0, temp1)
        (switch (= state newState)
            (case 0
                (if ((< local208 local206) and not Random(0 2))
                    ++local208
                    = seconds Random(10 25)
                )(else
                    (self:cue())
                )
            )
            (case 1
                = temp0 Random(5 12)
                = temp1 Random(0 local207)
                (send client:
                    view(local209[temp1])
                    noun(local214[temp1])
                    moveSpeed(temp0)
                    cycleSpeed(temp0)
                )
                = register Random(0 9)
                (if (== (send client:view) 270)
                    (while (proc999_5(local176[register] @local0 @local76 @local106))
                        = register Random(0 9)
                    )
                )(else
                    (while (local196[register])
                        = register Random(0 9)
                    )
                )
                = local196[register] 1
                (if (Random(0 1))
                    = register (+ register 10)
                )
                (if (< local208 local206)
                    ++local208
                    (send client:
                        x(proc999_6(local176[register] 2))
                        y(proc999_6(local176[register] 3))
                        setMotion(ArrayPath local176[register] 2 self)
                    )
                )(else
                    (send client:
                        x(proc999_6(local176[register] 0))
                        y(proc999_6(local176[register] 1))
                        setMotion(ArrayPath local176[register] 0 self)
                    )
                )
            )
            (case 2
                (if (> register 9)
                    = register (- register 10)
                )
                = local196[register] 0
                (send client:
                    x(- 0 Random(200 500))
                    y(- 0 Random(200 500))
                )
                = seconds Random(5 35)
            )
            (case 3
                (self:init())
            )
        )
    )

)
(instance moveOut of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gOwner:setMotion(PolyPath local219 local220 self))
                = seconds 3
            )
            (case 1
                (if ((<> (send gOwner:x) local219) and (<> (send gOwner:y) local220))
                    (self:init())
                )
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance townPerson1 of Actor
    (properties
        view 270
        signal $6000
        detailLevel 5
    )

    (method (doVerb theVerb param2)
        (if ((== theVerb 1) or (== theVerb 2))
            (super:doVerb(theVerb rest param2))
        )(else
            (Teller:doVerb(theVerb rest param2))
        )
    )


    (method (checkDetail)
        return 
            (if (< (send gGame:detailLevel()) detailLevel)
                return 0
            )(else
                return 1
            )
    )

)
(instance townPerson2 of Actor
    (properties
        view 270
        signal $6000
        detailLevel 4
    )

    (method (doVerb theVerb param2)
        (if ((== theVerb 1) or (== theVerb 2))
            (super:doVerb(theVerb rest param2))
        )(else
            (Teller:doVerb(theVerb rest param2))
        )
    )


    (method (checkDetail)
        return 
            (if (< (send gGame:detailLevel()) detailLevel)
                return 0
            )(else
                return 1
            )
    )

)
(instance townPerson3 of Actor
    (properties
        view 270
        signal $6000
        detailLevel 3
    )

    (method (doVerb theVerb param2)
        (if ((== theVerb 1) or (== theVerb 2))
            (super:doVerb(theVerb rest param2))
        )(else
            (Teller:doVerb(theVerb rest param2))
        )
    )


    (method (checkDetail)
        return 
            (if (< (send gGame:detailLevel()) detailLevel)
                return 0
            )(else
                return 1
            )
    )

)
(instance townPerson4 of Actor
    (properties
        view 270
        signal $6000
        detailLevel 2
    )

    (method (doVerb theVerb param2)
        (if ((== theVerb 1) or (== theVerb 2))
            (super:doVerb(theVerb rest param2))
        )(else
            (Teller:doVerb(theVerb rest param2))
        )
    )


    (method (checkDetail)
        return 
            (if (< (send gGame:detailLevel()) detailLevel)
                return 0
            )(else
                return 1
            )
    )

)
(instance guard1 of View
    (properties
        x 273
        y 43
        view 197
        loop 1
        signal $4000
    )

    (method (doVerb theVerb param2)
        (if ((== theVerb 1) or (== theVerb 2))
            (super:doVerb(theVerb rest param2))
        )(else
            (Teller:doVerb(theVerb rest param2))
        )
    )

)
(instance garden of Feature
    (properties
        x 198
        y 150
        noun 3
        nsTop 136
        nsLeft 156
        nsBottom 165
        nsRight 240
        sightAngle 180
    )
)
(instance trees of Feature
    (properties
        x 191
        y 118
        noun 4
        nsTop 102
        nsLeft 152
        nsBottom 135
        nsRight 230
        sightAngle 180
    )
)
(instance magicsign of Feature
    (properties
        x 285
        y 101
        noun 5
        nsTop 87
        nsLeft 269
        nsBottom 116
        nsRight 302
        sightAngle 180
    )
)
(instance apothsign of Feature
    (properties
        x 128
        y 55
        noun 6
        nsTop 45
        nsLeft 116
        nsBottom 65
        nsRight 140
        sightAngle 180
    )
)
(instance restsign of Feature
    (properties
        x 48
        y 63
        noun 8
        nsTop 59
        nsLeft 21
        nsBottom 68
        nsRight 76
        sightAngle 180
    )
)
(instance restentr of Feature
    (properties
        x 48
        y 78
        noun 9
        nsTop 69
        nsLeft 22
        nsBottom 88
        nsRight 75
        sightAngle 180
    )
)
(instance apothentr of Feature
    (properties
        x 128
        y 73
        noun 7
        nsTop 65
        nsLeft 117
        nsBottom 82
        nsRight 140
        sightAngle 180
    )
)
(instance magicentr of Feature
    (properties
        x 285
        y 125
        noun 2
        nsTop 114
        nsLeft 270
        nsBottom 137
        nsRight 300
        sightAngle 180
    )
)
(instance kingentr of Feature
    (properties
        x 302
        y 24
        noun 10
        nsTop 10
        nsLeft 289
        nsBottom 39
        nsRight 315
        sightAngle 180
    )
)
(instance bazstair of Feature
    (properties
        x 33
        y 145
        noun 11
        nsTop 121
        nsBottom 170
        nsRight 66
        sightAngle 180
    )
)
(instance upplant of Feature
    (properties
        x 152
        y 35
        noun 14
        nsTop 28
        nsLeft 135
        nsBottom 42
        nsRight 170
        sightAngle 180
    )
)
(instance rightplant of Feature
    (properties
        x 305
        y 79
        noun 13
        nsTop 71
        nsLeft 291
        nsBottom 87
        nsRight 319
        sightAngle 180
    )
)
(instance upstair of Feature
    (properties
        x 256
        y 69
        noun 12
        nsTop 52
        nsLeft 234
        nsBottom 87
        nsRight 279
        sightAngle 180
    )
)
