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


(local
    local0
    local1
    local2
    local3[5] = (0 9 20 31 40 )
    local8[51] = (4 88 149 101 152 114 144 128 145 5 207 147 194 146 180 145 166 145 149 144 5 180 165 167 165 152 162 141 158 128 157 4 34 164 47 162 61 158 70 155 5 8 147 25 144 40 140 58 143 71 144 )

)
(instance public rm24 of Rm
    (properties
        picture 24
        horizon 57
        north 25
        east 23
        south 9
        west 17
    )

    (method (init)
        (if (not proc0_12(70))
            Load(rsVIEW 1)
        )
        Load(rsVIEW 224)
        (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_18(263 (send gEgo:x) 48) (+ horizon 2)))
            )
            (case south
                (send gEgo:y(188))
            )
            (case west
                (send gEgo:posn(3 proc0_17(189 (send gEgo:y) (+ horizon 2))))
            )
            (case east
                (send gEgo:posn(317 proc0_17(189 (send gEgo:y) (+ horizon 2))))
            )
            (default 
                (send gEgo:posn(3 137))
            )
        )
        (send gEgo:init())
        proc0_1()
        (if (not proc0_12(70))
            (clover:
                init()
                setScript(flashClover)
            )
        )
        (send gAddToPics:
            add(cloverPatch (send (Clone(cloverPatch)):
                    cel(1)
                    x(25)
                    y(143)
                )
)
            eachElementDo(#init)
            doit()
        )
        (tree1:init())
        (tree2:init())
        (tree3:init())
        (tree4:init())
        (clover2:init())
        (clover1:init())
        (clover0:init())
        (clover3:init())
        (bush:init())
        (tree5:init())
        (if (proc0_12(109) and (== gGNumber_4 gNumber))
            (stalkIn24:init())
            (stalk2In24:init())
            (send gFeatures:delete(tree3))
        )
        (if (>= global101 1)
            (butterfly:
                posn(35 142)
                init()
            )
        )
    )


    (method (doit)
        (var temp0)
        (if (script)
            (send script:doit())
        )(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
                            )
                        )
)))
            )
        )
    )


    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )(else
            (if ((super:handleEvent(pEvent)))
            )(else
                (if (Said('bury/bean'))
                    (if (not proc0_12(109) and (send gEgo:has(20)))
                        (stalkIn24:init())
                        (stalk2In24:init())
                        (send gFeatures:delete(tree3))
                        (send pEvent:claimed(0))
                    )(else
                        (send pEvent:claimed(0))
                    )
                )(else
                    (if (Said('look,look>'))
                        (if (Said('[<at,around][/room,clearing]'))
                            (if (== gGNumber_4 gNumber)
                                proc255_0(24 0)
                            )(else
                                proc255_0(24 1)
                            )
                        )(else
                            (if (Said('<down') or Said('/grass'))
                                (if ((< (send gEgo:distanceTo(clover)) 30) and not (send gEgo:has(6)))
                                    proc255_0(24 2)
                                    (if (== gGNumber_4 gNumber)
                                        proc255_0(24 0)
                                    )
                                )(else
                                    (if (< (send gEgo:distanceTo(cloverPatch)) 20)
                                        proc255_0(24 3)
                                        (if (== gGNumber_4 gNumber)
                                            proc255_0(24 0)
                                        )
                                    )(else
                                        (if (== gGNumber_4 gNumber)
                                            proc255_0(24 0)
                                        )(else
                                            proc255_0(24 4)
                                        )
                                    )
                                )
                            )
                        )
                    )(else
                        (if (Said('get,get,pick/blossom,blossom'))
                            proc255_0(24 5)
                        )(else
                            (if (Said('get,get,pick/clover[<leaf<4,unusual]') or Said('get,get,pick/clover[<fourleaf,unusual]'))
                                (if (proc0_12(70))
                                    proc255_0(24 6)
                                )(else
                                    (if (> (send gEgo:distanceTo(clover)) 20)
                                        proc0_4()
                                    )(else
                                        (if (proc0_12(1))
                                            proc255_0(24 7)
                                        )(else
                                            (send global2:setScript(getClover))
                                        )
                                    )
                                )
                            )(else
                                (if (Said('get,get,pick/clover[<leaf<3]') or Said('get,get,pick/clover[<threeleaf]'))
                                    (if (proc0_12(70))
                                        proc255_0(24 8)
                                    )(else
                                        (if (> (send gEgo:distanceTo(clover)) 20)
                                            proc0_4()
                                        )(else
                                            (if (proc0_12(1))
                                                proc255_0(24 7)
                                            )(else
                                                proc255_0(24 9)
                                            )
                                        )
                                    )
                                )(else
                                    (if (Said('climb,climb/ceder'))
                                        proc255_0(24 10)
                                    )
                                )
                            )
                        )
                    )
                )
            )
        )
    )

)
(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('get,get,capture,chase/butterfly'))
                        proc255_0(24 11)
                    )(else
                        (if (Said('eat,consume/butterfly'))
                            proc255_0(24 12)
                        )(else
                            (if (Said('talk,speak/butterfly'))
                                proc255_0(24 13)
                            )
                        )
                    )
                )
            )
        )
    )


    (method (doVerb theVerb)
        (switch (theVerb)
            (case 1
                proc255_0(24 14)
            )
        )
    )

)
(instance moveButterfly of Script
    (properties)

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

)
(instance clover of Prop
    (properties
        x 42
        y 137
        view 224
        loop 1
    )

    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )
        (if ((Said('look,look/garden[<clover]') or Said('look,look/clover[<unusual]')) or proc255_5(self pEvent 3))
            (if (< (send gEgo:distanceTo(clover)) 50)
                proc255_0(24 15)
            )(else
                proc255_0(24 16)
            )
            (send pEvent:claimed(1))
        )
    )

)
(instance cloverPatch of RPicView
    (properties
        x 49
        y 147
        description 3558
        view 224
        signal $4000
    )

    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )
        (if (proc255_5(self pEvent 3))
            proc255_0(24 17)
            (send pEvent:claimed(1))
        )
    )

)
(instance flashClover of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = cycles Random(50 400)
            )
            (case 1
                (clover:setCycle(End self))
            )
            (case 2
                (clover:setCycle(Beg self))
            )
            (case 3
                (self:changeState(0))
            )
        )
    )

)
(instance getClover of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                proc0_15(gEgo clover)
                = cycles 2
            )
            (case 1
                (send gEgo:
                    view(1)
                    setMotion(0)
                    setCycle(End self)
                )
            )
            (case 2
                (send (ScriptID(0 21)):
                    number(105)
                    loop(1)
                    init()
                    play()
                )
                (send gEgo:get(6))
                (clover:
                    setScript(0)
                    startUpd()
                    dispose()
                )
                proc0_19(70 2)
                = cycles 4
            )
            (case 3
                (send gEgo:setCycle(Beg self))
            )
            (case 4
                proc0_1()
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance tree1 of NewFeature
    (properties
        x 192
        y 34
        noun 3500
        nsTop -1
        nsLeft 135
        nsBottom 69
        nsRight 250
        description 3605
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3610
    )
)
(instance tree2 of NewFeature
    (properties
        x 163
        y 81
        noun 3500
        nsTop 70
        nsLeft 157
        nsBottom 93
        nsRight 169
        description 3605
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3610
    )
)
(instance tree3 of NewFeature
    (properties
        x 207
        y 88
        noun 3500
        nsTop 70
        nsLeft 200
        nsBottom 107
        nsRight 214
        description 3605
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3610
    )
)
(instance tree4 of NewFeature
    (properties
        x 124
        y 41
        noun 3500
        nsTop 21
        nsLeft 115
        nsBottom 62
        nsRight 134
        description 3679
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3610
    )
)
(instance clover0 of NewFeature
    (properties
        x 50
        y 145
        noun 3504
        nsTop 124
        nsBottom 166
        nsRight 100
        description 3679
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3703
    )
)
(instance clover1 of NewFeature
    (properties
        x 144
        y 160
        noun 3504
        nsTop 152
        nsLeft 100
        nsBottom 169
        nsRight 188
        description 3679
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3765
    )
)
(instance clover2 of NewFeature
    (properties
        x 160
        y 144
        noun 3504
        nsTop 136
        nsLeft 100
        nsBottom 153
        nsRight 221
        description 3679
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3765
    )
)
(instance clover3 of NewFeature
    (properties
        x 114
        y 132
        noun 3504
        nsTop 129
        nsLeft 100
        nsBottom 135
        nsRight 128
        description 3679
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3765
    )
)
(instance tree5 of NewFeature
    (properties
        x 107
        y 18
        noun 3500
        nsTop -1
        nsLeft 85
        nsBottom 38
        nsRight 129
        description 3605
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3846
    )
)
(instance bush of NewFeature
    (properties
        x 86
        y 48
        noun 3513
        nsTop 39
        nsLeft 56
        nsBottom 58
        nsRight 117
        description 3910
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3915
    )
)
(instance stalkIn24 of NewFeature
    (properties
        x 192
        y 34
        nsTop -1
        nsLeft 120
        nsBottom 64
        nsRight 177
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3975
    )

    (method (init)
        (send gFeatures:addToFront(self))
    )

)
(instance stalk2In24 of NewFeature
    (properties
        x 192
        y 34
        nsTop 65
        nsLeft 122
        nsBottom 144
        nsRight 196
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 3975
    )

    (method (init)
        (send gFeatures:addToFront(self))
    )

)
