(version 2)
(include "sci.sh")
(exports
    0 rm38
)
(use "Main")
(use "Class_255_0")
(use "NewFeature")
(use "Avoid")
(use "Cycle")
(use "Game")
(use "User")
(use "PicView")
(use "Obj")
(script 38)


(local
    local0
    local1
    local2
    local3[8] = (0 11 22 31 40 53 62 73 )
    local11[84] = (5 20 125 34 123 50 120 68 119 78 118 5 66 127 79 125 90 121 103 120 113 120 4 102 101 116 99 128 101 139 99 4 159 97 171 99 182 95 193 99 6 207 100 220 99 233 99 245 100 257 101 268 103 4 197 107 187 108 177 111 167 114 5 167 126 180 123 191 129 203 126 210 132 5 231 130 240 133 253 136 266 134 282 133 )

)
(instance public rm38 of Rm
    (properties
        picture 38
        north 43
        east 37
        south 27
        west 39
    )

    (method (init)
        (if (>= global101 1)
            Load(rsVIEW 304)
        )
        (self:style(
            (switch (gGNumber)
                (case north
                    5
                )
                (case west
                    3
                )
                (case east
                    2
                )
                (case south
                    4
                )
            )
))
        (super:init())
        (switch (gGNumber)
            (case north
                (send gEgo:posn(proc0_17(261 proc0_18(149 (send gEgo:x) 80) 35) 59))
            )
            (case south
                (send gEgo:y(188))
            )
            (case west
                (send gEgo:posn(3 proc0_17(188 (send gEgo:y) 59)))
            )
            (case east
                (send gEgo:posn(317 proc0_17(188 (send gEgo:y) 59)))
            )
            (default 
                (send gEgo:posn(3 137))
            )
        )
        (send gEgo:init())
        proc0_1()
        (if (>= global101 1)
            (butterfly:
                posn(259 94)
                init()
            )
        )
        (flowers:init())
        (flowers1:init())
        (flowers2:init())
        (flowers3:init())
        (flowers4:init())
        (flowers5:init())
        (tree:init())
        (bush:init())
    )


    (method (doit)
        (var temp0)
        (if (script)
            (send script:doit())
        )(else
            (if ((& (send gEgo:onControl(1)) $0200) and (<> (send gEgo:script) climbHill))
                (send gEgo:setScript(climbHill))
            )(else
                = temp0 
                    (switch ((send ((User:alterEgo)):edgeHit))
                        (case 1
                            north
                        )
                        (case 2
                            east
                        )
                        (case 3
                            south
                        )
                        (case 4
                            west
                        )
                    )
                (if (temp0)
                    (self:newRoom((= temp0 
                            (switch ((send ((User:alterEgo)):edgeHit))
                                (case 1
                                    north
                                )
                                (case 2
                                    east
                                )
                                (case 3
                                    south
                                )
                                (case 4
                                    west
                                )
                            )
)))
                )(else
                    (if ((((& (send gEgo:onControl(1)) $0002) and (<> (send gEgo:priority) 1)) and (<> (send gEgo:script) climbHill)) and not proc0_12(48))
                        (send gEgo:setPri(1))
                    )(else
                        (if ((not (& (send gEgo:onControl(1)) $0002) and (== (send gEgo:priority) 1)) and (<> (send gEgo:script) climbHill))
                            (send gEgo:setPri(-1))
                        )(else
                            (if ((& (send gGoat:onControl(1)) $0002) and (<> (send gGoat:priority) 1))
                                (send gGoat:setPri(1))
                            )(else
                                (if (not (& (send gGoat:onControl(1)) $0002) and (== (send gGoat:priority) 1))
                                    (send gGoat:setPri(-1))
                                )
                            )
                        )
                    )
                )
            )
        )
    )


    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )(else
            (if ((super:handleEvent(pEvent)))
                return 
            )(else
                (if (Said('look,look<down') or Said('look,look/grass'))
                    proc255_0(38 0)
                    (if (== gGNumber_4 gNumber)
                        proc255_0(38 1)
                    )
                )(else
                    (if (Said('smell,smell/blossom'))
                        (if ((send gEgo:inRect(60 80 260 120)))
                            proc255_0(38 2)
                        )(else
                            proc255_0(38 3)
                        )
                    )(else
                        (if (Said('get,get,pick/blossom'))
                            proc255_0(38 4)
                        )(else
                            (if (Said('look,look>'))
                                (if (Said('[<at,around][/room,clearing]'))
                                    (if (<> gNumber gGNumber_4)
                                        proc255_0(38 5)
                                    )(else
                                        proc255_0(38 6)
                                    )
                                )(else
                                    (if (Said('/blossom'))
                                        proc255_0(38 7)
                                    )
                                )
                            )(else
                                (if (Said('get,get,capture,chase/butterfly'))
                                    proc255_0(38 8)
                                )
                            )
                        )
                    )
                )
            )
        )
    )

)
(instance butterfly of Actor
    (properties
        view 304
    )

    (method (init)
        (self:
            ignoreControl()
            ignoreHorizon()
            ignoreActors()
            setCycle(Walk)
            setAvoider(Avoid)
            illegalBits(0)
        )
        (super:init())
    )


    (method (doit)
        (super:doit())
        (if (< Random(1 100) 25)
            (butterfly:posn((+ x (- 3 Random(0 6))) (+ y (- 2 Random(0 4)))))
        )
        (if (== (butterfly:script) 0)
            (butterfly:setScript(moveButterfly))
        )
    )


    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )(else
            (if ((super:handleEvent(pEvent)))
                return 
            )(else
                (if (Said('look,look/butterfly'))
                    (self:doVerb(1 pEvent))
                )(else
                    (if (Said('talk,speak/butterfly'))
                        proc255_0(38 9)
                    )(else
                        (if (Said('eat,consume/butterfly'))
                            proc255_0(38 10)
                        )
                    )
                )
            )
        )
    )


    (method (doVerb theVerb)
        (switch (theVerb)
            (case 1
                proc255_0(38 11)
            )
        )
    )

)
(instance moveButterfly of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (if (< Random(1 100) 10)
                    (while (TRUE)
                        = local2 Random(0 7)
                        <> local2 local0
                    )
                    = local0 local2
                )
                = local1 Random(1 local11[local3[local0]])
                (butterfly:setMotion(MoveTo local11[(+ local3[local0] (- (* local1 2) 1))] local11[(+ local3[local0] (* local1 2))] self))
            )
            (case 1
                (butterfly:setCycle(Fwd))
                = cycles Random(5 20)
            )
            (case 2
                (self:dispose())
            )
        )
    )

)
(instance climbHill of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (if ((send gEgo:looper))
                    (send ((send gEgo:looper)):dispose())
                )
                (send gEgo:
                    illegalBits(0)
                    setLoop(3)
                    setPri(0)
                    setCycle(Walk)
                    setMotion(MoveTo (send gEgo:x) 55 self)
                )
            )
            (case 1
                proc0_1()
                proc0_3()
                (send global2:newRoom((send global2:north)))
                (self:dispose())
            )
        )
    )

)
(instance flowers of NewFeature
    (properties
        x 71
        y 122
        noun 2313
        nsTop 120
        nsLeft 10
        nsBottom 124
        nsRight 133
        description 2411
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        lookStr 2419
    )
)
(instance flowers1 of NewFeature
    (properties
        x 82
        y 117
        noun 2313
        nsTop 115
        nsLeft 37
        nsBottom 120
        nsRight 127
        description 2411
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        lookStr 2419
    )
)
(instance flowers2 of NewFeature
    (properties
        x 61
        y 127
        noun 2313
        nsTop 124
        nsLeft 30
        nsBottom 130
        nsRight 93
        description 2411
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        lookStr 2419
    )
)
(instance tree of NewFeature
    (properties
        x 115
        y 21
        noun 2359
        nsTop -1
        nsLeft 85
        nsBottom 43
        nsRight 145
        description 2471
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        lookStr 2476
    )
)
(instance flowers3 of NewFeature
    (properties
        x 179
        y 100
        noun 2313
        nsTop 94
        nsLeft 86
        nsBottom 106
        nsRight 272
        description 2411
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        lookStr 2419
    )
)
(instance flowers4 of NewFeature
    (properties
        x 179
        y 120
        noun 2313
        nsTop 106
        nsLeft 148
        nsBottom 135
        nsRight 211
        description 2411
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        lookStr 2419
    )
)
(instance flowers5 of NewFeature
    (properties
        x 256
        y 130
        noun 2313
        nsTop 123
        nsLeft 211
        nsBottom 137
        nsRight 301
        description 2411
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        lookStr 2419
    )
)
(instance bush of NewFeature
    (properties
        x 104
        y 51
        noun 2363
        nsTop 44
        nsLeft 60
        nsBottom 59
        nsRight 149
        description 2557
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        lookStr 2562
    )
)
