(version 2)
(include "sci.sh")
(exports
    0 rm180
)
(use "Main")
(use "PanoRoom")
(use "PolyPath")
(use "Polygon")
(use "CueObj")
(use "Cycle")
(use "View")
(use "Obj")
(script 180)


(local
    local0
    local1
    local2
    local3
    local4
    theGLastTicks
    theState
    local7

)
(procedure (localproc_04a4)
    (switch (local1)
        (case 0
            (send gQg3Messager:say(1 6 10))
        )
        (case 1
            (send gQg3Messager:say(1 6 11))
        )
    )
    ++local1
    = local0 0
)


(instance public rm180 of PanoRoom
    (properties
        noun 2
        picture 180
        west 170
    )

    (method (init param1)
        proc0_4(63)
        (self:setRegions(50))
        (send gOwner:solvePuzzle(211 8))
        (switch (gGClientModNum)
            (case 400
                (send gOwner:posn(gGOwnerX gGOwnerY))
                proc0_3(6 3)
            )
            (case 800
                (send global2:setScript(fromLostCity))
            )
            (case 700
                (send gOwner:
                    x(gGOwnerX)
                    y(gGOwnerY)
                )
                (if (proc0_6(93))
                    proc0_4(88)
                    (send gOwner:view(154))
                    = local7 (/ GetDistance((send gOwner:x) (send gOwner:y) 162 72) 3)
                    proc0_2()
                    (send global2:setScript(goVillage))
                )(else
                    (if (proc0_6(134))
                        proc0_5(134)
                        proc0_2()
                        proc0_4(88)
                        (send gOwner:view(154))
                        (send global2:setScript(leadEgo))
                    )(else
                        proc0_3(6 3)
                    )
                )
            )
            (case 740
                (send gOwner:
                    x(175)
                    y(112)
                )
                (send gOwner:view(154))
                (send global2:setScript(afterWater))
            )
            (case west
                = style 12
                (send global2:setScript(fromTreePanorama))
            )
            (default 
                (send gOwner:
                    x(158)
                    y(75)
                )
                (send gOwner:view(154))
                (send global2:setScript(fromMonkeys))
            )
        )
        ({wtrfll#1}:
            init()
            setCycle(Fwd)
        )
        ({wtrfll#2}:
            init()
            setCycle(Fwd)
        )
        ({wtrfll#3}:
            init()
            setCycle(Fwd)
        )
        ({wtrfll#4}:
            init()
            setCycle(Fwd)
        )
        (lostCity:init())
        (upperWaterfall:init())
        (pool:init())
        (mountains:init())
        (lowerCut:init())
        (eastCut:init())
        (lowerWaterfall:init())
        (lowerPool:init())
        (upperWaterfall:init())
        (upperCut:init())
        (if (proc0_6(88))
            (send global2:addObstacle((send ((Polygon:new())):
                    type(2)
                    init(0 157 92 136 142 121 153 113 162 114 168 109 141 111 84 115 77 105 122 99 115 88 162 76 161 71 105 88 0 69 0 0 319 0 319 189 0 189)
                    yourself()
                )
 (send ((Polygon:new())):
                    type(2)
                    init(56 121 80 114 87 126)
                    yourself()
                )
 (send ((Polygon:new())):
                    type(2)
                    init(47 103 72 104 73 110 52 114 41 118)
                    yourself()
                )
))
        )(else
            (send global2:addObstacle((send ((Polygon:new())):
                    type(2)
                    init(0 157 92 136 142 121 153 113 162 114 168 109 141 111 84 115 77 105 142 96 103 89 0 69 0 0 319 0 319 189 0 189)
                    yourself()
                )
 (send ((Polygon:new())):
                    type(2)
                    init(56 121 80 114 87 126)
                    yourself()
                )
 (send ((Polygon:new())):
                    type(2)
                    init(47 103 72 104 73 110 52 114 41 118)
                    yourself()
                )
))
        )
        (super:init(rest param1))
        (send gLongSong:
            number(180)
            setLoop(-1)
            play()
        )
    )


    (method (doit param1)
        (super:doit(rest param1))
        (if (> Abs((- gLastTicks theGLastTicks)) 10)
            = theGLastTicks gLastTicks
            Palette(palANIMATE 232 235 -1)
        )
    )


    (method (dispose)
        (super:dispose())
        DisposeScript(41)
    )


    (method (cue)
        (if ((send gOwner:inRect(146 69 181 93)))
            (self:newRoom(720))
        )(else
            (if ((send gOwner:inRect(246 99 284 118)))
                (self:newRoom(800))
            )(else
                (if (< (send gOwner:x) 5)
                    (self:setScript(toJungle))
                )(else
                    (self:newRoom(0))
                )
            )
        )
    )

)
(instance toJungle of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gOwner:setMotion(PolyPath 1 (send gOwner:y) self))
            )
            (case 1
                (send global2:newRoom(170))
            )
        )
    )

)
(instance fromLostCity of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gOwner:
                    x(251)
                    y(111)
                    setMotion(PolyPath 239 110 self)
                )
            )
            (case 1
                proc0_3(6 3)
                (self:dispose())
            )
        )
    )

)
(instance fromMonkeys of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (if (proc0_6(95))
                    proc0_5(95)
                    proc0_4(88)
                    proc0_2()
                    (send global2:setScript(toWaterFall))
                )(else
                    (send gOwner:
                        x(164)
                        y(75)
                        setMotion(PolyPath 138 82 self)
                    )
                )
            )
            (case 1
                proc0_3(6 3)
                (self:dispose())
            )
        )
    )

)
(instance toWaterFall of Script
    (properties)

    (method (doit)
        (super:doit())
        (if (((> global120 2750) and proc0_6(81)) and not local0)
            = local0 1
            (send gOwner:setMotion(0))
            = local4 1
            (send global2:setScript(campOutManu 0 state))
        )
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                = cycles 5
            )
            (case 1
                (send gOwner:
                    cycleSpeed(6)
                    moveSpeed(6)
                    setMotion(PolyPath 110 98 self)
                )
            )
            (case 2
                (send gQg3Messager:say(1 6 1 0 self))
            )
            (case 3
                (send gOwner:setMotion(PolyPath 77 110 self))
            )
            (case 4
                (send gQg3Messager:say(1 6 2 0 self))
            )
            (case 5
                (send gOwner:setMotion(PolyPath 120 117 self))
            )
            (case 6
                (send gQg3Messager:say(1 6 3 0 self))
            )
            (case 7
                (send gOwner:setMotion(PolyPath 165 112 self))
            )
            (case 8
                = local0 1
                (send gQg3Messager:say(1 6 6 0 self))
            )
            (case 9
                (send global2:newRoom(740))
            )
        )
    )

)
(instance afterWater of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                proc0_4(88)
                (send gOwner:
                    cycleSpeed(6)
                    moveSpeed(6)
                    setMotion(MoveTo + (send gOwner:x) 7 (send gOwner:y) self)
                )
            )
            (case 1
                (send gQg3Messager:say(1 6 7 0 self))
            )
            (case 2
                (send gOwner:setMotion(MoveTo (+ (send gOwner:x) 5) (send gOwner:y) self))
            )
            (case 3
                = global365 590
                proc0_4(143)
                proc0_4(96)
                proc0_4(134)
                (send global2:newRoom(700))
            )
        )
    )

)
(instance leadEgo of Script
    (properties)

    (method (doit param1)
        (super:doit(rest param1))
        (if ((> global120 2750) and proc0_6(81))
            = local0 1
            (send gOwner:setMotion(0))
            = local4 0
            (send global2:setScript(campOutManu 0 state))
        )
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_4(88)
                (send gOwner:
                    cycleSpeed(6)
                    moveSpeed(6)
                    setMotion(MoveTo 193 113 self)
                )
            )
            (case 1
                (send gQg3Messager:say(1 6 4 0 self))
            )
            (case 2
                (send gOwner:setMotion(MoveTo 232 108 self))
            )
            (case 3
                (send gQg3Messager:say(1 6 5 0 self))
            )
            (case 4
                (send gOwner:setMotion(MoveTo 260 112 self))
            )
            (case 5
                (send gQg3Messager:say(1 6 8 0 self))
            )
            (case 6
                proc0_5(88)
                (send global2:newRoom(800))
            )
        )
    )

)
(instance campOutManu of Script
    (properties)

    (method (changeState newState)
        (var temp0)
        (switch (= state newState)
            (case 0
                (send gQg3Messager:say(1 6 14 0 self))
            )
            (case 1
                PalVary(pvCHANGE_TICKS 3)
                (fire:
                    x(+ (send gOwner:x) 5)
                    y((send gOwner:y))
                    init()
                    setCycle(Fwd)
                )
                = cycles 5
            )
            (case 2
                = seconds 9
            )
            (case 3
                PalVary(pvREVERSE 5)
                proc0_5(81)
                (fire:dispose())
                = global120 800
                ++global122
                = gGOwnerMaxStamina[17] (send gOwner:maxStamina())
                (send gOwner:
                    takeDamage(-16)
                    useMana(-16)
                )
                = cycles 5
            )
            (case 4
                = seconds 7
            )
            (case 5
                (send gQg3Messager:say(1 6 13 0 self))
            )
            (case 6
                = local0 0
                (if (> register 0)
                    = temp0 (- register 1)
                )(else
                    = temp0 0
                )
                (if (local4)
                    (toWaterFall:start(temp0))
                    (send global2:setScript(toWaterFall))
                )(else
                    (leadEgo:start(temp0))
                    (send global2:setScript(leadEgo))
                )
            )
        )
    )

)
(instance fromTreePanorama of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gOwner:
                    x(2)
                    setMotion(PolyPath 10 (send gOwner:y) self)
                )
            )
            (case 1
                (if (proc0_6(88))
                    (send gOwner:view(154))
                    (send global2:setScript(manuWalk))
                )(else
                    proc0_3(6 3)
                    (self:dispose())
                )
            )
        )
    )

)
(instance manuWalk of Script
    (properties)

    (method (doit param1)
        (super:doit(rest param1))
        (if (== PalVary(pvGET_CURRENT_STEP) 20)
            = theState state
            (send global2:setScript(campOut 0 0))
        )
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gOwner:
                    cycleSpeed(6)
                    moveSpeed(6)
                    setMotion(PolyPath 50 92 self)
                )
            )
            (case 1
                (send gQg3Messager:say(1 6 10 0 self))
            )
            (case 2
                (send gOwner:setMotion(PolyPath 105 86 self))
            )
            (case 3
                (send gQg3Messager:say(1 6 11 0 self))
            )
            (case 4
                (send gOwner:setMotion(PolyPath 160 72 self))
            )
            (case 5
                (send gQg3Messager:say(1 6 12 0 self))
            )
            (case 6
                (send global2:newRoom(720))
            )
        )
    )

)
(instance campOut of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gQg3Messager:say(1 6 14 0 self))
            )
            (case 1
                PalVary(pvCHANGE_TICKS 2)
                (fire:
                    x(+ (send gOwner:x) 5)
                    y((send gOwner:y))
                    init()
                    setCycle(Fwd)
                )
                = cycles 5
            )
            (case 2
                = seconds 9
            )
            (case 3
                PalVary(pvREVERSE 5)
                proc0_5(81)
                (fire:dispose())
                = global120 800
                ++global122
                = gGOwnerMaxStamina[17] (send gOwner:maxStamina())
                (send gOwner:
                    takeDamage(-16)
                    useMana(-16)
                )
                = cycles 5
            )
            (case 4
                = seconds 7
            )
            (case 5
                (send gQg3Messager:say(1 6 13 0 self))
            )
            (case 6
                (if (register)
                    (send global2:setScript(goVillage))
                )(else
                    (send global2:setScript(manuWalk))
                    (manuWalk:changeState(theState))
                )
            )
        )
    )

)
(instance goVillage of Script
    (properties)

    (method (doit)
        (super:doit())
        (if (not (% GetDistance((send gOwner:x) (send gOwner:y) local2 local3) local7) and not local0)
            = local0 1
            localproc_04a4()
        )(else
            (if (== PalVary(pvGET_CURRENT_STEP) 20)
                (send gOwner:setMotion(0))
                (send global2:setScript(campOut 0 1))
            )
        )
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gOwner:setMotion(PolyPath 160 72 self))
            )
            (case 1
                (send gQg3Messager:say(1 6 12 0 self))
            )
            (case 2
                (send global2:newRoom(720))
            )
        )
    )

)
(instance fire of Prop
    (properties
        x 115
        y 113
        view 986
        loop 4
    )
)
(instance {wtrfll#1} of Prop
    (properties
        x 181
        y 95
        view 160
        cel 6
    )

    (method (doVerb theVerb)
        (upperWaterfall:doVerb(theVerb))
    )

)
(instance {wtrfll#2} of Prop
    (properties
        x 171
        y 110
        view 160
        loop 1
        cel 1
    )

    (method (doVerb theVerb)
        (upperWaterfall:doVerb(theVerb))
    )

)
(instance {wtrfll#3} of Prop
    (properties
        x 166
        y 121
        view 160
        loop 2
        cel 2
    )

    (method (doVerb theVerb)
        (lowerWaterfall:doVerb(theVerb))
    )

)
(instance {wtrfll#4} of Prop
    (properties
        x 163
        y 157
        view 160
        loop 3
        cel 7
    )

    (method (doVerb theVerb)
        (lowerWaterfall:doVerb(theVerb))
    )

)
(instance lostCity of Feature
    (properties
        x 259
        y 109
        noun 4
        nsTop 97
        nsLeft 241
        nsBottom 121
        nsRight 278
    )
)
(instance upperWaterfall of Feature
    (properties
        x 184
        y 88
        noun 5
        nsTop 80
        nsLeft 178
        nsBottom 97
        nsRight 190
    )
)
(instance pool of Feature
    (properties
        x 174
        y 98
        noun 7
        nsTop 93
        nsLeft 161
        nsBottom 104
        nsRight 188
    )
)
(instance lowerWaterfall of Feature
    (properties
        x 163
        y 132
        noun 6
        nsTop 104
        nsLeft 159
        nsBottom 160
        nsRight 168
    )
)
(instance lowerPool of Feature
    (properties
        x 147
        y 165
        noun 8
        nsTop 155
        nsLeft 116
        nsBottom 176
        nsRight 179
    )
)
(instance upperRiver of Feature
    (properties
        x 207
        y 67
        noun 9
        nsTop 59
        nsLeft 180
        nsBottom 76
        nsRight 234
    )
)
(instance mountains of Feature
    (properties
        x 179
        y 8
        noun 10
        nsTop 3
        nsLeft 104
        nsBottom 14
        nsRight 254
    )
)
(instance lowerCut of Feature
    (properties
        x 96
        y 78
        noun 11
        nsTop 71
        nsLeft 37
        nsBottom 85
        nsRight 155
    )
)
(instance upperCut of Feature
    (properties
        x 76
        y 40
        noun 12
        nsTop 36
        nsBottom 44
        nsRight 153
    )
)
(instance eastCut of Feature
    (properties
        x 218
        y 93
        noun 13
        nsTop 86
        nsLeft 189
        nsBottom 100
        nsRight 248
    )
)
