(version 2)
(include "sci.sh")
(exports
    0 rm780
)
(use "Main")
(use "TellerIcon")
(use "PolyPath")
(use "Polygon")
(use "CueObj")
(use "Cycle")
(use "Game")
(use "View")
(use "Obj")
(script 780)


(local
    local0
    local1

)
(instance public rm780 of Rm
    (properties
        noun 10
        picture 780
    )

    (method (init)
        (send gOwner:
            setScale(190)
            x(5)
            y(76)
            init()
            normalize()
        )
        proc0_3()
        (send gMainIconBar:disable(6))
        (super:init())
        (if (global121)
            (send gLongSong2:
                number(927)
                setLoop(-1)
                play(127)
            )
        )(else
            (send gLongSong2:
                number(914)
                setLoop(-1)
                play(127)
            )
        )
        (send global2:addObstacle((send ((Polygon:new())):
                type(3)
                init(170 120 170 123 204 123 204 120 173 120)
                yourself()
            )
 (send ((Polygon:new())):
                type(3)
                init(168 111 129 126 48 126 48 139 147 156 213 146 230 137 143 143 129 147 55 136 55 130 132 130 187 109 195 104 124 104 0 73 0 92 137 111)
                yourself()
            )
))
        (egoTell:init(gOwner))
        (platform:init())
        (stream:init())
        (purpleLeaves:init())
        (purpleTree:init())
        (purpleBranch:init())
        (orangeTree:init())
        (fungi:init())
        (flower:init())
        (if (> (send gGame:detailLevel()) 2)
            (water1:
                setCycle(Fwd)
                init()
            )
            (water2:
                setCycle(Fwd)
                init()
            )
        )
        (send gQg3Walkers:addToFront(platform))
        (send global2:setScript(egoEnters))
    )


    (method (dispose)
        (send gQg3Walkers:delete(platform))
        (super:dispose())
    )


    (method (doVerb theVerb param2)
        (switch (theVerb)
            (case 81
                (send gQg3Messager:say(1 6 3))
            )
            (case 83
                (send gQg3Messager:say(1 6 3))
            )
            (case 20
                (send gQg3Messager:say(1 6 3))
            )
            (case 88
                (send gQg3Messager:say(1 6 3))
            )
            (case 33
                (send gQg3Messager:say(1 6 3))
            )
            (case 78
                (send gQg3Messager:say(1 6 3))
            )
            (case 76
                (send gQg3Messager:say(1 6 3))
            )
            (case 84
                (send gQg3Messager:say(1 6 3))
            )
            (case 80
                (send gQg3Messager:say(1 6 3))
            )
            (case 86
                (send gQg3Messager:say(1 6 3))
            )
            (case 74
                (if (== local0 0)
                    (self:setScript(goToBed))
                )(else
                    (send gQg3Messager:say(1 6 4))
                )
            )
            (default 
                (super:doVerb(theVerb rest param2))
            )
        )
    )

)
(instance goToBed of Script
    (properties)

    (method (changeState newState)
        (var temp0)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gOwner:setMotion(PolyPath 147 148 self))
            )
            (case 1
                (send gOwner:
                    view(35)
                    loop(0)
                    cel(0)
                    x(166)
                    setCycle(End self)
                )
            )
            (case 2
                = temp0 PalVary(pvGET_CURRENT_STEP)
                (if (temp0)
                    (if (< (= temp0 PalVary(pvGET_CURRENT_STEP)) 64)
                        PalVary(pvCHANGE_TICKS 3)
                        = seconds 5
                    )(else
                        (self:cue())
                    )
                )(else
                    PalVary(pvINIT 310 3)
                    proc0_6(81)
                    = seconds 15
                )
            )
            (case 3
                PalVary(pvREVERSE 3)
                proc0_5(81)
                = seconds 4
            )
            (case 4
                (send (ScriptID(7 7)):init(5 40))
                (send gOwner:setCycle(Beg self))
            )
            (case 5
                (send gOwner:
                    normalize(6)
                    cel(6)
                    x(147)
                    changeGait(0)
                    code(outChek)
                )
                proc0_3()
                (send gMainIconBar:disable(6))
                (self:dispose())
            )
        )
    )

)
(instance climbDownPlatform of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (if (== (send gLongSong:number) 782)
                    (send gLongSong:
                        number(780)
                        setLoop(-1)
                        play(127)
                    )
                )
                (send gOwner:setMotion(MoveTo 161 124 self))
            )
            (case 1
                (send gOwner:setMotion(MoveTo 194 133 self))
            )
            (case 2
                (send gOwner:setMotion(MoveTo 172 137 self))
            )
            (case 3
                (send gOwner:
                    setLoop(3)
                    setMotion(MoveTo 163 155 self)
                )
            )
            (case 4
                (send gOwner:
                    setLoop(-1)
                    code(outChek)
                    setMotion(MoveTo 139 146 self)
                )
            )
            (case 5
                (send gOwner:
                    setPri(-1)
                    setScale(190)
                )
                proc0_3()
                (send gMainIconBar:disable(6))
                = local0 0
                (self:dispose())
            )
        )
    )

)
(instance climbOntoPlatform of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gOwner:setMotion(PolyPath 139 146 self))
            )
            (case 1
                (send gOwner:
                    setScale()
                    setPri(12)
                    setMotion(MoveTo 163 155 self)
                )
            )
            (case 2
                (send gOwner:
                    setPri(12)
                    setLoop(2)
                    setMotion(MoveTo 172 137 self)
                )
            )
            (case 3
                (send gOwner:
                    setLoop(-1)
                    setMotion(MoveTo 194 133 self)
                )
            )
            (case 4
                (send gOwner:setMotion(MoveTo 161 124 self))
            )
            (case 5
                (send gOwner:setMotion(MoveTo 187 122 self))
            )
            (case 6
                (send gOwner:
                    code(downChek)
                    setHeading(180)
                )
                proc0_3()
                (send gMainIconBar:disable(6))
                = local0 1
                (self:dispose())
            )
        )
    )

)
(instance egoEnters of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                = gGOwnerMaxStamina[18] (send gOwner:maxMana())
                = gGOwnerMaxStamina[16] (send gOwner:maxHealth())
                = gGOwnerMaxStamina[17] (send gOwner:maxStamina())
                (send gLongSong:fade(self))
            )
            (case 1
                (send gLongSong:
                    number(780)
                    setLoop(-1)
                    play(127)
                )
                (send gQg3Messager:say(1 6 1 0 self))
            )
            (case 2
                (send gOwner:setMotion(PolyPath 147 148 self))
            )
            (case 3
                (send gOwner:
                    code(outChek)
                    setHeading(180)
                )
                proc0_3()
                (send gMainIconBar:disable(6))
                (self:dispose())
            )
        )
    )

)
(instance giveItem of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (if (== local0 0)
                    (self:setScript(climbOntoPlatform self))
                )(else
                    = cycles 1
                )
            )
            (case 1
                proc0_2()
                (send gOwner:
                    view(4)
                    loop(0)
                    setCycle(End self)
                )
            )
            (case 2
                (if (not local1)
                    (send gQg3Messager:say(1 6 8))
                )
                (send gOwner:setCycle(Beg self))
                (send gLongSong:
                    number(783)
                    setLoop(1)
                    play(127 self)
                )
            )
            (case 3
            )
            (case 4
                (send gLongSong:
                    number(783)
                    setLoop(1)
                    play(127 self)
                )
                (if (local1)
                    (thatOldFruit:
                        init()
                        setPri(12)
                    )
                    (send gOwner:
                        drop(37 1)
                        get(15)
                    )
                    (send gQg3Messager:say(1 6 7 0 self))
                )(else
                    (send gOwner:
                        normalize()
                        setPri(12)
                        setHeading(270)
                    )
                    (thatOldStaff:
                        init()
                        cycleSpeed(7)
                        setCycle(End self)
                    )
                )
            )
            (case 5
            )
            (case 6
                (send gLongSong:
                    number(782)
                    setLoop(-1)
                    play(127)
                )
                (send gOwner:
                    normalize()
                    setPri(12)
                    setMotion(MoveTo 178 122 self)
                )
            )
            (case 7
                (send gOwner:
                    view(31)
                    loop(1)
                    cel(0)
                    setCycle(End self)
                )
            )
            (case 8
                (if (local1)
                    (thatOldFruit:dispose())
                    (send gOwner:setCycle(Beg self))
                )(else
                    (thatOldStaff:dispose())
                    (send gOwner:setCycle(Beg self))
                )
            )
            (case 9
                proc0_3()
                (if (local1)
                    (send gOwner:
                        get(38)
                        solvePuzzle(327 5)
                        normalize()
                        setPri(12)
                    )
                    proc0_4(157)
                )(else
                    (send gOwner:
                        get(44)
                        solvePuzzle(328 5 2)
                        normalize()
                        setPri(12)
                    )
                    (send gOwner:drop(39))
                    (send gQg3Messager:say(1 6 9))
                )
                (send gMainIconBar:disable(6))
                (self:dispose())
            )
        )
    )

)
(instance thatOldFruit of Prop
    (properties
        x 177
        y 75
        view 790
        signal $4000
    )
)
(instance thatOldStaff of Prop
    (properties
        x 143
        y 83
        view 781
        loop 1
        signal $4000
    )
)
(instance stepFeat of Feature
    (properties
        x 180
        y 141
        nsTop 121
        nsLeft 147
        nsBottom 161
        nsRight 213
        sightAngle 40
    )

    (method (doVerb theVerb)
        (switch (theVerb)
            (case 4
                (if (== local0 0)
                    (send global2:setScript(climbOntoPlatform))
                )(else
                    (send global2:setScript(climbDownPlatform))
                )
            )
            (default 
                (super:doVerb(theVerb))
            )
        )
    )

)
(instance water1 of Prop
    (properties
        x 203
        y 189
        view 780
        priority 14
        signal $4010
        detailLevel 3
    )
)
(instance water2 of Prop
    (properties
        x 245
        y 189
        view 780
        loop 1
        priority 14
        signal $4010
        detailLevel 3
    )
)
(instance egoTell of Teller
    (properties)

    (method (doVerb theVerb)
        (if (local0)
            (platform:doVerb(theVerb))
        )(else
            (super:doVerb(theVerb))
        )
    )

)
(instance sFx of GlorySong
    (properties)
)
(instance platform of Feature
    (properties
        x 186
        y 119
        z 1
        noun 8
        nsTop 119
        nsLeft 150
        nsBottom 165
        nsRight 210
        sightAngle 40
    )

    (method (doVerb theVerb)
        (switch (theVerb)
            (case 50
                (if ((send ((send gInv:at(39))):state))
                    = local1 0
                    proc0_4(139)
                    (if (not proc0_6(139))
                        (send gOwner:addHonor(20))
                    )
                    (send global2:setScript(giveItem))
                )(else
                    (send gQg3Messager:say(1 6 5))
                )
            )
            (case 48
                = local1 1
                (if (not proc0_6(138))
                    (send gOwner:addHonor(20))
                    proc0_4(138)
                    (send global2:setScript(giveItem))
                )(else
                    (send gQg3Messager:say(1 6 6))
                )
            )
            (case 4
                (if (== local0 0)
                    (send global2:setScript(climbOntoPlatform))
                )(else
                    (send global2:setScript(climbDownPlatform))
                )
            )
            (case 3
                (if (== local0 0)
                    (send global2:setScript(climbOntoPlatform))
                )(else
                    (send global2:setScript(climbDownPlatform))
                )
            )
            (default 
                (super:doVerb(theVerb))
            )
        )
    )

)
(instance stream of Feature
    (properties
        x 231
        y 173
        noun 2
        nsTop 157
        nsLeft 165
        nsBottom 189
        nsRight 298
        sightAngle 180
    )
)
(instance purpleLeaves of Feature
    (properties
        x 249
        y 21
        noun 3
        nsTop -2
        nsLeft 180
        nsBottom 45
        nsRight 319
        sightAngle 180
    )
)
(instance purpleTree of Feature
    (properties
        x 259
        y 95
        noun 9
        nsTop 48
        nsLeft 223
        nsBottom 142
        nsRight 295
        sightAngle 180
    )
)
(instance purpleBranch of Feature
    (properties
        x 177
        y 72
        noun 4
        nsTop 48
        nsLeft 132
        nsBottom 97
        nsRight 222
        sightAngle 180
    )
)
(instance orangeTree of Feature
    (properties
        x 99
        y 71
        noun 5
        nsTop 42
        nsLeft 71
        nsBottom 101
        nsRight 127
        sightAngle 180
    )
)
(instance fungi of Feature
    (properties
        x 82
        y 169
        noun 6
        nsTop 150
        nsLeft 38
        nsBottom 189
        nsRight 127
        sightAngle 180
    )
)
(instance flower of Feature
    (properties
        x 301
        y 147
        noun 7
        nsTop 138
        nsLeft 288
        nsBottom 157
        nsRight 315
        sightAngle 180
    )
)
(instance outChek of Code
    (properties)

    (method (doit)
        (if ((send gOwner:inRect(0 50 50 95)))
            (send global2:newRoom(760))
        )
    )

)
(instance downChek of Code
    (properties)

    (method (doit)
        (if (< (send gOwner:x) 174)
            (send gOwner:code(outChek))
            (send global2:setScript(climbDownPlatform))
        )
    )

)
