(version 2)
(include "sci.sh")
(exports
    0 rm28
)
(use "Main")
(use "Class_255_0")
(use "NewFeature")
(use "n958")
(use "RFeature")
(use "Sound")
(use "Cycle")
(use "Game")
(use "PicView")
(use "Obj")
(script 28)



(instance public rm28 of Rm
    (properties
        picture 28
        horizon 57
        north 37
        east 29
        south 21
        west 27
    )

    (method (init)
        proc958_0(128 228 2 45)
        proc958_0(132 16 15 83 29)
        (self:style(
            (switch (gGNumber)
                (case north
                    5
                )
                (case west
                    3
                )
                (case east
                    2
                )
                (case south
                    4
                )
                (default 
                    7
                )
            )
))
        (super:init())
        (door:
            setPri(8)
            init()
            stopUpd()
        )
        (cane:
            setPri(9)
            init()
            stopUpd()
        )
        (smoke:
            init()
            setCycle(Fwd)
        )
        (switch (gGNumber)
            (case north
                (send gEgo:posn(proc0_18(262 (send gEgo:x) 41) (+ horizon 2)))
            )
            (case south
                (send gEgo:posn(proc0_17(213 (send gEgo:x) 1) 188))
            )
            (case west
                (send gEgo:posn(3 proc0_17(188 (send gEgo:y) (+ horizon 2))))
            )
            (case east
                (send gEgo:posn(297 proc0_17(162 (send gEgo:y) (+ horizon 2))))
            )
            (default 
                (send gEgo:
                    posn(137 141)
                    loop(2)
                )
                (door:
                    cel(4)
                    setScript(closeIt)
                )
            )
        )
        (send gEgo:init())
        proc0_1()
        (if (<> gGNumber 65)
            (if (> Random(1 100) 50)
                proc0_10(16)
            )(else
                proc0_11(16)
            )
        )
        (if (proc0_12(74))
            proc0_11(16)
        )(else
            (if (== gGNumber 65)
                0
            )
        )
        (send gAddToPics:
            add(cookie1 cookie2 cookie3)
            eachElementDo(#init)
            doit()
        )
        (house5:init())
        (candy_canes1:init())
        (candy_canes:init())
        (candy_canes2:init())
        (candy_canes3:init())
        (candy_canes5:init())
        (candy_canes4:init())
        (chimney:init())
        (tree:init())
        (tree1:init())
        (tree3:init())
        (tree2:init())
        (backwind:init())
        (house:init())
        (house1:init())
        (house3:init())
        (house2:init())
        (house4:init())
        (house7:init())
        (house6:init())
        (house9:init())
        (house8:init())
        (house10:init())
        (steps2:init())
        (steps:init())
        (roof:init())
        (roof1:init())
        (roof2:init())
        (roof3:init())
    )


    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )(else
            (if ((super:handleEvent(pEvent)))
                return 
            )(else
                (if (Said('look,look/window') or proc0_14(pEvent 172 91 191 112))
                    (if ((send gEgo:inRect(150 120 220 155)))
                        proc255_0(28 0)
                    )(else
                        proc255_0(28 1)
                    )
                )(else
                    (if (Said('smell,smell/building,cake'))
                        proc255_0(28 2)
                    )(else
                        (if (Said('look,look/building'))
                            (if ((send gEgo:inRect(34 100 236 190)))
                                proc255_0(28 3)
                            )(else
                                proc255_0(28 4)
                            )
                        )(else
                            (if (Said('look,look>'))
                                (if (Said('[<at,around][/room]'))
                                    proc255_0(28 5)
                                )(else
                                    (if (Said('/witch'))
                                        proc255_0(28 6)
                                    )(else
                                        (if (Said('/path'))
                                            proc255_0(28 7)
                                        )(else
                                            (if (Said('/candy'))
                                                proc255_0(28 8)
                                            )(else
                                                (if (Said('/fence'))
                                                    proc255_0(28 9)
                                                )(else
                                                    (if (Said('/cake'))
                                                        proc255_0(28 10)
                                                    )(else
                                                        (if (Said('/frosting,frosting'))
                                                            proc255_0(28 11)
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )(else
                                (if (Said('knock'))
                                    (if (not (send gEgo:inRect(114 129 151 138)))
                                        proc0_4()
                                    )(else
                                        (if (proc0_12(1))
                                            proc255_0(28 12)
                                        )(else
                                            (self:setScript(knockDoor))
                                        )
                                    )
                                )(else
                                    (if (Said('open,open/door'))
                                        (if (not (send gEgo:inRect(114 129 151 138)))
                                            proc0_4()
                                        )(else
                                            (door:setScript(openIt))
                                        )
                                    )(else
                                        (if (Said('close,close/door'))
                                            (if (not (send gEgo:inRect(114 129 151 138)))
                                                proc0_4()
                                            )(else
                                                proc255_0(28 13)
                                            )
                                        )(else
                                            (if (Said('bend/window'))
                                                (if ((send gEgo:inRect(150 120 220 155)))
                                                    proc255_0(28 14)
                                                )(else
                                                    proc255_0(28 15)
                                                )
                                            )(else
                                                (if (Said('bend/door'))
                                                    (if ((send gEgo:inRect(2 106 316 166)))
                                                        proc255_0(28 16)
                                                    )(else
                                                        proc255_0(28 17)
                                                    )
                                                )(else
                                                    (if (Said('unlock/door,lock'))
                                                        proc255_0(28 18)
                                                    )(else
                                                        (if (Said('eat,consume>'))
                                                            (if (Said('/fence'))
                                                                (if ((send gEgo:inRect(114 146 245 162)))
                                                                    proc255_0(28 19)
                                                                )(else
                                                                    proc255_0(28 20)
                                                                )
                                                            )(else
                                                                (if (Said('/building,cake,frosting,frosting,cake,ceiling,door,window'))
                                                                    (if (not & (send gEgo:onControl(1)) $4000)
                                                                        proc255_0(28 21)
                                                                    )(else
                                                                        (if (proc0_12(16))
                                                                            proc0_15(gEgo 110 110)
                                                                            proc255_0(28 22)
                                                                            proc0_19(79 2)
                                                                        )(else
                                                                            proc255_0(28 23)
                                                                            proc0_19(79 2)
                                                                        )
                                                                    )
                                                                )(else
                                                                    (if (Said('/candy'))
                                                                        proc255_0(28 24)
                                                                    )(else
                                                                        (if (Said('/cookie'))
                                                                            proc255_0(28 25)
                                                                        )(else
                                                                            (if (Said('/blossom'))
                                                                                proc255_0(28 26)
                                                                            )(else
                                                                                (if ((Said('/cane<candy') or Said('/stick<peppermint')) or Said('/gumdrop'))
                                                                                    proc255_0(28 27)
                                                                                )(else
                                                                                    (if (Said('/chimney'))
                                                                                        proc255_0(28 28)
                                                                                    )(else
                                                                                        (if (Said('/man,boy[<cake]') or Said('/fairy,fairy[<cake]'))
                                                                                            proc255_0(28 29)
                                                                                        )(else
                                                                                            (super:handleEvent(pEvent))
                                                                                        )
                                                                                    )
                                                                                )
                                                                            )
                                                                        )
                                                                    )
                                                                )
                                                            )
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )
        )
    )

)
(instance smoke of Prop
    (properties
        x 68
        y 8
        view 228
        loop 3
        priority 10
        signal $0010
    )

    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )(else
            (if (Said('look,look/smoke'))
                (self:doVerb(1))
            )(else
                (super:handleEvent(pEvent))
            )
        )
    )


    (method (doVerb theVerb)
        (switch (theVerb)
            (case 1
                proc255_0(28 30)
            )
        )
    )

)
(instance cane of View
    (properties
        x 182
        y 112
        description 5459
        view 228
        loop 1
    )

    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )(else
            (if (Said('look,look/window'))
                (self:doVerb(1))
            )(else
                (super:handleEvent(pEvent))
            )
        )
    )


    (method (doVerb theVerb)
        (switch (theVerb)
            (case 1
                proc255_0(28 0)
            )
        )
    )

)
(instance door of Prop
    (properties
        x 111
        y 131
        view 228
        signal $0001
    )

    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )(else
            (if (Said('look,look/door') or proc255_5(self pEvent 3))
                (if (> (send gEgo:y) 130)
                    proc255_0(28 31)
                )(else
                    proc255_0(28 17)
                )
                (send pEvent:claimed(1))
            )(else
                (super:handleEvent(pEvent))
            )
        )
    )

)
(instance knockDoor of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:
                    view(45)
                    loop(0)
                    cycleSpeed(
                        (if (>= global101 1)
                            1
                        )(else
                            0
                        )
)
                    cel(0)
                    setMotion(0)
                )
                = cycles 2
            )
            (case 1
                (send (ScriptID(0 21)):
                    number(29)
                    loop(2)
                    play(self)
                )
                (send gEgo:
                    loop(1)
                    setCycle(Fwd)
                )
            )
            (case 2
                (send gEgo:
                    loop(0)
                    cel(0)
                    setCycle(0)
                )
                = cycles 2
            )
            (case 3
                (send gEgo:
                    view(2)
                    loop(3)
                    cel(0)
                )
                proc0_1()
                (if (proc0_12(16))
                    proc255_0(28 32)
                )(else
                    proc255_0(28 33)
                )
                (self:cue())
            )
            (case 4
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance closeIt of Script
    (properties
        cycles 1
    )

    (method (changeState newState)
        (switch (= state newState)
            (case 1
                proc0_2()
                (doorSound:
                    number(16)
                    loop(1)
                    play()
                )
                (door:
                    cel(4)
                    cycleSpeed(0)
                    setCycle(CT 1 -1 self)
                )
            )
            (case 2
                (doorSound:
                    number(83)
                    play()
                )
                (door:setCycle(Beg self))
            )
            (case 3
                (door:stopUpd())
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance openIt of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (doorSound:
                    number(15)
                    loop(1)
                    play()
                )
                (door:
                    cel(0)
                    cycleSpeed(2)
                    setCycle(End self)
                )
            )
            (case 1
                (doorSound:stop())
                (door:stopUpd())
                proc0_3()
                (send global2:newRoom(65))
            )
        )
    )

)
(instance cookie1 of RPicView
    (properties
        x 218
        y 169
        description 5501
        view 228
        loop 2
    )

    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )(else
            (if (proc255_5(self pEvent) or Said('look,look/cookie,man,fairy,boy,fairy'))
                proc255_0(28 34)
                (send pEvent:claimed(1))
            )(else
                (super:handleEvent(pEvent))
            )
        )
    )

)
(instance cookie2 of RPicView
    (properties
        x 120
        y 175
        description 5501
        view 228
        loop 2
        cel 1
    )

    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )(else
            (if (proc255_5(self pEvent) or Said('look,look/cookie,man'))
                proc255_0(28 34)
                (send pEvent:claimed(1))
            )(else
                (super:handleEvent(pEvent))
            )
        )
    )

)
(instance cookie3 of RPicView
    (properties
        x 102
        y 160
        description 5501
        view 228
        loop 2
        cel 2
    )

    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )(else
            (if (proc255_5(self pEvent) or Said('look,look/cookie,man'))
                proc255_0(28 34)
                (send pEvent:claimed(1))
            )(else
                (super:handleEvent(pEvent))
            )
        )
    )

)
(instance cookie3 of NewFeature
    (properties
        x 218
        y 155
        noun 5405
        nsTop 142
        nsLeft 212
        nsBottom 169
        nsRight 225
        description 5532
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 5548
    )
)
(instance candy_canes of NewFeature
    (properties
        x 84
        y 134
        noun 5308
        nsTop 116
        nsLeft 74
        nsBottom 153
        nsRight 94
        description 5641
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 5653
    )
)
(instance candy_canes1 of NewFeature
    (properties
        x 120
        y 141
        noun 5308
        nsTop 133
        nsLeft 112
        nsBottom 149
        nsRight 128
        description 5641
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 5653
    )
)
(instance candy_canes2 of NewFeature
    (properties
        x 134
        y 156
        noun 5308
        nsTop 145
        nsLeft 129
        nsBottom 167
        nsRight 140
        description 5641
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 5653
    )
)
(instance candy_canes3 of NewFeature
    (properties
        x 186
        y 144
        noun 5308
        nsTop 130
        nsLeft 176
        nsBottom 158
        nsRight 197
        description 5641
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 5653
    )
)
(instance candy_canes4 of NewFeature
    (properties
        x 201
        y 154
        noun 5308
        nsTop 142
        nsLeft 197
        nsBottom 166
        nsRight 206
        description 5641
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 5653
    )
)
(instance candy_canes5 of NewFeature
    (properties
        x 219
        y 123
        noun 5308
        nsTop 109
        nsLeft 211
        nsBottom 137
        nsRight 228
        description 5641
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 5653
    )
)
(instance chimney of NewFeature
    (properties
        x 74
        y 23
        noun 5326
        nsTop 3
        nsLeft 56
        nsBottom 43
        nsRight 93
        description 5835
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        lookStr 5843
    )
)
(instance tree of NewFeature
    (properties
        x 306
        y 93
        noun 5420
        nsTop -1
        nsLeft 294
        nsBottom 188
        nsRight 319
        description 5877
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        lookStr 5882
    )
)
(instance tree1 of NewFeature
    (properties
        x 219
        y 27
        noun 5420
        nsTop -1
        nsLeft 145
        nsBottom 55
        nsRight 294
        description 5877
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        lookStr 5882
    )
)
(instance tree2 of NewFeature
    (properties
        x 271
        y 179
        noun 5420
        nsTop 171
        nsLeft 249
        nsBottom 188
        nsRight 293
        description 5877
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        lookStr 5882
    )
)
(instance tree3 of NewFeature
    (properties
        x 236
        y 185
        noun 5420
        nsTop 183
        nsLeft 225
        nsBottom 188
        nsRight 248
        description 5877
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        lookStr 5882
    )
)
(instance house of NewFeature
    (properties
        x 104
        y 124
        noun 5424
        nsTop 116
        nsLeft 95
        nsBottom 132
        nsRight 113
        description 5996
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        lookStr 6002
    )
)
(instance house1 of NewFeature
    (properties
        x 182
        y 121
        noun 5424
        nsTop 113
        nsLeft 154
        nsBottom 130
        nsRight 210
        description 5996
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        lookStr 6002
    )
)
(instance house2 of NewFeature
    (properties
        x 225
        y 92
        noun 5424
        nsTop 75
        nsLeft 196
        nsBottom 109
        nsRight 254
        description 5996
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        lookStr 6002
    )
)
(instance house3 of NewFeature
    (properties
        x 167
        y 79
        noun 5424
        nsTop 75
        nsLeft 139
        nsBottom 83
        nsRight 195
        description 5996
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        lookStr 6002
    )
)
(instance house4 of NewFeature
    (properties
        x 158
        y 98
        noun 5424
        nsTop 84
        nsLeft 152
        nsBottom 112
        nsRight 165
        description 5996
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        lookStr 6002
    )
)
(instance house5 of NewFeature
    (properties
        x 77
        y 98
        noun 5424
        nsTop 81
        nsLeft 47
        nsBottom 115
        nsRight 108
        description 5996
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        lookStr 6002
    )
)
(instance house6 of NewFeature
    (properties
        x 100
        y 75
        noun 5424
        nsTop 70
        nsLeft 62
        nsBottom 80
        nsRight 138
        description 5996
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        lookStr 6002
    )
)
(instance house7 of NewFeature
    (properties
        x 38
        y 110
        noun 5424
        nsTop 90
        nsLeft 31
        nsBottom 131
        nsRight 46
        description 5996
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        lookStr 6002
    )
)
(instance house8 of NewFeature
    (properties
        x 59
        y 131
        noun 5424
        nsTop 115
        nsLeft 46
        nsBottom 147
        nsRight 73
        description 5996
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        lookStr 6002
    )
)
(instance house9 of NewFeature
    (properties
        x 104
        y 66
        noun 5424
        nsTop 64
        nsLeft 87
        nsBottom 69
        nsRight 121
        description 5996
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        lookStr 6002
    )
)
(instance house10 of NewFeature
    (properties
        x 239
        y 113
        noun 5424
        nsTop 109
        nsLeft 229
        nsBottom 118
        nsRight 249
        description 5996
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        lookStr 6002
    )
)
(instance steps of NewFeature
    (properties
        x 150
        y 138
        noun 5428
        nsTop 132
        nsLeft 129
        nsBottom 144
        nsRight 172
        description 6354
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        lookStr 6360
    )
)
(instance steps2 of NewFeature
    (properties
        x 157
        y 148
        noun 5428
        nsTop 145
        nsLeft 140
        nsBottom 151
        nsRight 175
        description 6354
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        lookStr 6360
    )
)
(instance roof of NewFeature
    (properties
        x 26
        y 78
        noun 5432
        nsTop 66
        nsLeft 11
        nsBottom 90
        nsRight 41
        description 6492
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        lookStr 6497
    )
)
(instance roof3 of NewFeature
    (properties
        x 49
        y 52
        noun 5432
        nsTop 33
        nsLeft 37
        nsBottom 71
        nsRight 62
        description 6492
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        lookStr 6497
    )
)
(instance roof2 of NewFeature
    (properties
        x 161
        y 58
        noun 5432
        nsTop 46
        nsLeft 62
        nsBottom 70
        nsRight 260
        description 6492
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        lookStr 6497
    )
)
(instance roof1 of NewFeature
    (properties
        x 118
        y 33
        noun 5432
        nsTop 21
        nsLeft 94
        nsBottom 46
        nsRight 142
        description 6492
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        lookStr 6497
    )
)
(instance backwind of NewFeature
    (properties
        x 234
        y 88
        noun 5436
        nsTop 80
        nsLeft 228
        nsBottom 96
        nsRight 241
        description 5459
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 6587
    )
)
(instance doorSound of Sound
    (properties
        priority 10
    )
)
