(version 2)
(include "sci.sh")
(exports
    0 rm63
)
(use "Main")
(use "Class_255_0")
(use "NewFeature")
(use "n958")
(use "Cycle")
(use "Game")
(use "User")
(use "PicView")
(use "Obj")
(script 63)


(local
    local0

)
(procedure (localproc_0baa param1)
    proc0_2()
    (send (ScriptID(0 23)):fade())
    (if (proc0_12(1))
        proc255_0(63 13)
        (send gEgo:put(5))
        (send gGame:changeScore(-3))
    )
    (send gEgo:
        view(57)
        illegalBits(0)
        loop(param1)
        cel(0)
        setMotion(0)
        cycleSpeed(1)
    )
)


(procedure (localproc_0c01)
    (send (ScriptID(0 23)):
        number(17)
        loop(1)
        play()
    )
)


(instance public rm63 of Rm
    (properties
        picture 63
        horizon 62
        south 14
    )

    (method (init)
        proc958_0(128 57 48)
        proc958_0(132 17)
        (self:style(4))
        (super:init())
        (self:setScript(climbUp))
        (if (not 
        (if (proc0_12(94))
        )(else
            (send gEgo:has(15))
        )
)
            (goldEgg:
                init()
                setPri(4)
            )
        )
        proc0_11(46)
        (nest:init())
        (tree1:init())
        (tree2:init())
        (tree3:init())
        (tree4:init())
        (tree5:init())
        (tree6:init())
        (tree7:init())
        (tree8:init())
        (tree9:init())
        (tree10:init())
    )


    (method (doit)
        (var temp0)
        (if (script)
            (send script:doit())
        )(else
            (if (== (send gEgo:onControl(1)) 8)
                (self:setScript(longFallRight))
            )(else
                (if (== (send gEgo:onControl(1)) 16)
                    (self:setScript(longFallLeft))
                )(else
                    (if (== (send gEgo:onControl(1)) 2048)
                        (self:setScript(longFrontFallLeft))
                    )(else
                        (if (== (send gEgo:onControl(1)) 256)
                            (self:setScript(fallSEast))
                        )(else
                            (if (== (send gEgo:onControl(1)) 2)
                                (self:setScript(longFallSWest))
                            )(else
                                (if (== (send gEgo:onControl(1)) 1024)
                                    (self:setScript(longFallBack))
                                )(else
                                    (if (== (send gEgo:onControl(1)) 16384)
                                        (self:setScript(longFallFront))
                                    )(else
                                        (if (((== (send gEgo:onControl(1)) 512) and proc0_12(1)) and not local0)
                                            = local0 1
                                            proc255_0(63 0)
                                            (send gEgo:
                                                setMotion(0)
                                                illegalBits(-32256)
                                            )
                                        )(else
                                            = temp0 
                                                (switch ((send ((User:alterEgo)):edgeHit))
                                                    (case 1
                                                        north
                                                    )
                                                    (case 2
                                                        east
                                                    )
                                                    (case 3
                                                        south
                                                    )
                                                    (case 4
                                                        west
                                                    )
                                                )
                                            (if (temp0)
                                                proc0_26()
                                                (self:newRoom(temp0))
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )
        )
    )


    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )(else
            (if ((super:handleEvent(pEvent)))
                return 
            )(else
                (if (Said('climb,climb/ceder'))
                    proc255_0(63 1)
                )(else
                    (if (Said('look,look>'))
                        (if (Said('[<at,around][/room,ceder,branch]'))
                            proc255_0(63 2)
                        )(else
                            (if (Said('<down'))
                                proc255_0(63 3)
                            )(else
                                (if (Said('/egg[<gold]'))
                                    (if ((send gEgo:has(15)))
                                        (send pEvent:claimed(0))
                                    )(else
                                        (if ((== (send ((send gInv:at(15))):owner) gNumber) and (< (send gEgo:distanceTo(goldEgg)) 50))
                                            proc255_0(63 4)
                                        )(else
                                            (if (not < (send gEgo:distanceTo(goldEgg)) 50)
                                                proc255_0(63 5)
                                            )(else
                                                proc255_0(63 6)
                                            )
                                        )
                                    )
                                )(else
                                    (if (Said('/nest'))
                                        (if (not (send gEgo:inRect(150 75 236 110)))
                                            proc255_0(63 7)
                                        )(else
                                            (if ((send gEgo:has(15)) or proc0_12(94))
                                                proc255_0(63 8)
                                            )(else
                                                proc255_0(63 9)
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )(else
                        (if (Said('get,get/nest'))
                            proc255_0(63 10)
                        )(else
                            (if (Said('get,get/egg'))
                                (if (not (send gEgo:inRect(188 75 236 94)))
                                    proc255_0(63 7)
                                )(else
                                    (if ((send gEgo:has(15)) or proc0_12(94))
                                        proc255_0(63 11)
                                    )(else
                                        (self:setScript(getEgg))
                                    )
                                )
                            )
                        )
                    )
                )
            )
        )
    )

)
(instance climbUp of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:
                    view(48)
                    posn(50 201)
                    init()
                    setCycle(End self)
                )
            )
            (case 1
                proc0_1()
                (send gEgo:
                    view(0)
                    setMotion(MoveTo 50 184 self)
                )
            )
            (case 2
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance getEgg of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gEgo:setMotion(MoveTo 206 85 self))
            )
            (case 1
                (send gEgo:loop(3))
                (self:cue())
            )
            (case 2
                (send (ScriptID(0 21)):
                    number(105)
                    loop(1)
                    init()
                    play()
                )
                proc255_0(63 12)
                (send gEgo:get(15))
                (goldEgg:dispose())
                proc0_19(94 6)
                (self:dispose())
            )
        )
    )

)
(instance goldEgg of View
    (properties
        x 206
        y 66
        description 4246
        view 633
    )

    (method (doVerb theVerb)
        (switch (theVerb)
            (case 1
                proc255_0(63 4)
            )
        )
    )

)
(instance fallSEast of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                localproc_0baa(1)
                (send gEgo:setCycle(End self))
            )
            (case 1
                localproc_0c01()
                (send gEgo:
                    loop(3)
                    cel(0)
                    setCycle(CT 3 1 self)
                )
            )
            (case 2
                (send gEgo:
                    setPri(1)
                    setCycle(End self)
                )
            )
            (case 3
                (self:setScript(fellOffTree))
            )
        )
    )

)
(instance longFallSWest of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                localproc_0baa(0)
                (send gEgo:setCycle(End self))
            )
            (case 1
                localproc_0c01()
                (send gEgo:
                    loop(2)
                    cel(0)
                    setCycle(CT 3 1 self)
                )
            )
            (case 2
                (send gEgo:
                    setPri(1)
                    setCycle(End self)
                )
            )
            (case 3
                (self:setScript(fellOffTree))
            )
        )
    )

)
(instance longFallFront of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                localproc_0baa(0)
                (send gEgo:setCycle(End self))
            )
            (case 1
                localproc_0c01()
                (send gEgo:
                    loop(2)
                    cel(0)
                    setCycle(CT 3 1 self)
                )
            )
            (case 2
                (send gEgo:
                    setPri(5)
                    setCycle(End self)
                )
            )
            (case 3
                (self:setScript(fellOffTree))
            )
        )
    )

)
(instance longFallBack of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                localproc_0baa(8)
                (send gEgo:setCycle(End self))
            )
            (case 1
                localproc_0c01()
                (send gEgo:
                    loop(9)
                    cel(0)
                    setCycle(CT 3 1 self)
                )
            )
            (case 2
                (swoosh:
                    posn((send gEgo:x) + (send gEgo:y) 50)
                    cycleSpeed(1)
                    setPri(3)
                    init()
                )
                (send gEgo:
                    setPri(3)
                    setCycle(CT 6 1 self)
                )
            )
            (case 3
                (send gEgo:setCycle(End))
                (swoosh:setCycle(End self))
            )
            (case 4
                (self:setScript(fellOffTree))
            )
        )
    )

)
(instance fallNorth of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                localproc_0baa(8)
                (send gEgo:setCycle(End self))
            )
            (case 1
                localproc_0c01()
                (send gEgo:
                    loop(9)
                    cel(0)
                    setCycle(CT 3 1 self)
                )
            )
            (case 2
                (send gEgo:
                    setPri(1)
                    setCycle(End self)
                )
            )
            (case 3
                (self:setScript(fellOffTree))
            )
        )
    )

)
(instance longFallRight of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                localproc_0baa(4)
                (send gEgo:setCycle(End self))
            )
            (case 1
                localproc_0c01()
                (send gEgo:
                    loop(6)
                    cel(0)
                    setCycle(CT 3 1 self)
                )
            )
            (case 2
                (send gEgo:
                    setPri(1)
                    setCycle(End self)
                )
            )
            (case 3
                (self:setScript(fellOffTree))
            )
        )
    )

)
(instance longFallLeft of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                localproc_0baa(5)
                (send gEgo:setCycle(End self))
            )
            (case 1
                localproc_0c01()
                (send gEgo:
                    loop(7)
                    cel(0)
                    setCycle(CT 3 1 self)
                )
            )
            (case 2
                (send gEgo:
                    setPri(1)
                    setCycle(End self)
                )
            )
            (case 3
                (self:setScript(fellOffTree))
            )
        )
    )

)
(instance longFrontFallLeft of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                localproc_0baa(5)
                (send gEgo:setCycle(End self))
            )
            (case 1
                localproc_0c01()
                (send gEgo:
                    loop(7)
                    cel(0)
                    setCycle(CT 3 1 self)
                )
            )
            (case 2
                (send gEgo:
                    setPri(5)
                    setCycle(End self)
                )
            )
            (case 3
                (self:setScript(fellOffTree))
            )
        )
    )

)
(instance fellOffTree of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_10(46)
                (send global2:newRoom(14))
                (self:dispose())
            )
        )
    )

)
(instance crater of View
    (properties
        x 210
        y 161
        description 4383
        view 34
    )
)
(instance swoosh of Prop
    (properties
        description 4395
        view 57
        loop 9
        cel 4
    )
)
(instance tree1 of NewFeature
    (properties
        x 60
        y 107
        noun 4205
        nsTop 89
        nsLeft 50
        nsBottom 126
        nsRight 70
        description 4402
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 4407
    )
)
(instance tree2 of NewFeature
    (properties
        x 65
        y 145
        noun 4205
        nsTop 126
        nsLeft 54
        nsBottom 164
        nsRight 76
        description 4402
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 4407
    )
)
(instance tree3 of NewFeature
    (properties
        x 136
        y 84
        noun 4205
        nsTop 76
        nsLeft 121
        nsBottom 92
        nsRight 152
        description 4402
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 4407
    )
)
(instance tree4 of NewFeature
    (properties
        x 151
        y 106
        noun 4205
        nsTop 92
        nsLeft 133
        nsBottom 120
        nsRight 169
        description 4402
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 4407
    )
)
(instance tree5 of NewFeature
    (properties
        x 175
        y 89
        noun 4205
        nsTop 81
        nsLeft 152
        nsBottom 98
        nsRight 198
        description 4402
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 4407
    )
)
(instance tree6 of NewFeature
    (properties
        x 217
        y 84
        noun 4205
        nsTop 79
        nsLeft 197
        nsBottom 90
        nsRight 238
        description 4402
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 4407
    )
)
(instance tree7 of NewFeature
    (properties
        x 142
        y 134
        noun 4205
        nsTop 120
        nsLeft 124
        nsBottom 148
        nsRight 161
        description 4402
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 4407
    )
)
(instance tree8 of NewFeature
    (properties
        x 123
        y 154
        noun 4205
        nsTop 139
        nsLeft 100
        nsBottom 169
        nsRight 146
        description 4402
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 4407
    )
)
(instance tree9 of NewFeature
    (properties
        x 76
        y 165
        noun 4205
        nsTop 152
        nsLeft 52
        nsBottom 178
        nsRight 101
        description 4402
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 4407
    )
)
(instance tree10 of NewFeature
    (properties
        x 47
        y 183
        noun 4205
        nsTop 178
        nsLeft 25
        nsBottom 189
        nsRight 69
        description 4402
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        contClick 371
        lookStr 4407
    )
)
(instance nest of NewFeature
    (properties
        x 205
        y 68
        noun 4212
        nsTop 64
        nsLeft 198
        nsBottom 72
        nsRight 213
        description 4619
        sightAngle 360
        getableDist 320
        seeableDist 320
        shiftClick 369
        lookStr 4624
    )

    (method (doLook)
        (if ((== (send ((send gInv:at(15))):owner) gNumber) and (<= GetDistance((send gEgo:x) (send gEgo:y) 206 66 60) 50))
            proc255_0(63 4)
        )(else
            (if (>= GetDistance((send gEgo:x) (send gEgo:y) 206 66 60) 50)
                proc255_0(63 5)
            )(else
                proc255_0(63 6)
            )
        )
    )

)
