(version 2)
(include "sci.sh")
(exports
    0 rm410
)
(use "Main")
(use "TellerIcon")
(use "PolyPath")
(use "Polygon")
(use "CueObj")
(use "n958")
(use "StopWalk")
(use "Cycle")
(use "Game")
(use "User")
(use "Obj")
(script 410)


(local
    local0[5] = (0 -10 -13 -15 999 )
    local5[6] = (0 59 60 58 57 999 )
    local11[7] = (0 13 -10 -14 14 15 999 )
    local18[4] = (0 16 12 999 )
    local22[4] = (0 17 18 999 )
    local26[4] = (0 12 -19 999 )
    local30[3] = (0 20 999 )
    local33[7]
    local40[2]
    local42[2]
    local44[5] = (0 -10 -14 -19 999 )
    local49[6] = (0 -1 27 10 37 999 )
    local55[5] = (0 21 3 -4 999 )
    local60[5] = (0 5 6 -7 999 )
    local65[3] = (0 8 999 )
    local68[5] = (0 -1 -4 -7 999 )
    local73[6] = (0 -1 27 28 26 999 )
    local79[4] = (0 -21 52 999 )
    local83[4] = (0 -23 -24 999 )
    local87[3] = (0 22 999 )
    local90[3] = (0 25 999 )
    local93[6] = (0 -1 -21 -23 -24 999 )
    local99[6] = (0 -30 34 32 38 999 )
    local105[4] = (0 35 -39 999 )
    local109[3] = (0 40 999 )
    local112[4] = (0 -30 -39 999 )
    local116[6] = (0 30 -34 -32 31 999 )
    local122[4] = (0 35 36 999 )
    local126[3] = (0 33 999 )
    local129[4] = (0 -34 -32 999 )
    local133[5] = (0 42 43 44 999 )
    local138[5] = (0 42 -46 45 999 )
    local143[3] = (0 47 999 )
    local146[3] = (0 -46 999 )
    local149[6] = (0 -13 51 52 53 999 )
    local155[4] = (0 49 50 999 )
    local159[3] = (0 -13 999 )
    local162[3]
    local165
    local166
    local167
    local168
    local169
    local170
    local171
    local172
    local173

)
(procedure (localproc_0d4b param1)
    (if (local171)
        (send gQg3Messager:say(1 6 41 0 param1))
    )(else
        (if (local172)
            (send gQg3Messager:say(2 6 41 0 param1))
        )(else
            (if (local169)
                (send gQg3Messager:say(1 6 29 0 param1))
            )(else
                (if (local170)
                    (send gQg3Messager:say(2 6 29 0 param1))
                )(else
                    (if (local168)
                        (send gQg3Messager:say(2 6 1 0 param1))
                    )(else
                        (if (local167)
                            (send gQg3Messager:say(1 6 1 0 param1))
                        )(else
                            (if (local165)
                                (send gQg3Messager:say(2 6 9 0 param1))
                            )(else
                                (send gQg3Messager:say(1 6 9 0 param1))
                            )
                        )
                    )
                )
            )
        )
    )
)


(instance public rm410 of Rm
    (properties
        noun 6
        picture 410
    )

    (method (init)
        (send global2:addObstacle((send ((Polygon:new())):
                type(2)
                init(0 0 319 0 319 189 237 189 132 171 90 148 69 142 69 153 27 153 27 129 0 129)
                yourself()
            )
))
        Load(143 410)
        = local165 global121
        = local40[0] @local5
        (egoTell:init(gOwner @local5 @local40))
        (leftTreeTop:init())
        (leftTreeTrunk:init())
        (rightTreeTop:init())
        (rightTreeTrunk:init())
        (rightTreeBot:init())
        (pens:init())
        (bridge:init())
        (village:init())
        (outCrop:init())
        (super:init())
        (if (not proc0_6(18))
            (send (ScriptID(58 1)):
                noun(
                    (if (local165)
                        2
                    )(else
                        1
                    )
)
                setScale()
                scaleX(102)
                scaleY(102)
                loop(0)
                x(48)
                y(150)
                init()
            )
            (if (proc0_6(29))
                = local166 1
            )
            (switch (global362)
                (case 0
                    (if (not proc0_6(29) and proc0_6(64))
                        = local166 1
                    )
                )
                (case 1
                    (if (not proc0_6(29) and ((send gOwner:has(44)) or gGOwnerMaxStamina[31]))
                        = local166 1
                    )
                )
                (case 2
                    (if (not proc0_6(29) and proc0_6(63))
                        = local166 1
                    )
                )
            )
            (if ((local166 and not proc0_6(68)) and local165)
                proc0_4(68)
                = local168 1
            )
            (if ((local166 and not proc0_6(67)) and not local165)
                proc0_4(67)
                = local167 1
            )
            (if ((proc0_6(38) and not proc0_6(70)) and not local165)
                proc0_4(70)
                = local169 1
            )
            (if ((proc0_6(38) and not proc0_6(71)) and local165)
                proc0_4(71)
                = local170 1
            )
            (if ((global406 and not proc0_6(72)) and not local165)
                proc0_4(72)
                = local171 1
            )
            (if ((global406 and not proc0_6(73)) and local165)
                proc0_4(73)
                = local172 1
            )
            (if (local171)
                = local33[0] @local133
                (elderTell:init(ScriptID(58 1) @local133 @local33))
            )(else
                (if (local172)
                    = local33[0] @local138
                    = local33[1] @local143
                    (elderTell:init(ScriptID(58 1) @local138 @local33 @local146))
                )(else
                    (if (local169)
                        = local33[0] @local99
                        = local33[1] @local105
                        = local33[2] @local109
                        (elderTell:init(ScriptID(58 1) @local99 @local33 @local112))
                    )(else
                        (if (local170)
                            = local33[0] @local116
                            = local33[1] @local122
                            = local33[2] @local126
                            (elderTell:init(ScriptID(58 1) @local116 @local33 @local129))
                        )(else
                            (if (local167)
                                = local33[0] @local49
                                = local33[1] @local55
                                = local33[2] @local60
                                = local33[3] @local65
                                (elderTell:init(ScriptID(58 1) @local49 @local33 @local68))
                            )(else
                                (if (local168)
                                    = local33[0] @local73
                                    = local33[1] @local79
                                    = local33[2] @local83
                                    = local33[3] @local87
                                    = local33[4] @local90
                                    (elderTell:init(ScriptID(58 1) @local73 @local33 @local93))
                                )(else
                                    (if (local165)
                                        = local33[0] @local11
                                        = local33[1] @local22
                                        = local33[2] @local26
                                        = local33[3] @local30
                                        (elderTell:init(ScriptID(58 1) @local11 @local33 @local44))
                                    )(else
                                        = local33[0] @local11
                                        = local33[1] @local18
                                        (elderTell:init(ScriptID(58 1) @local11 @local33 @local44))
                                    )
                                )
                            )
                        )
                    )
                )
            )
            (if (local165)
                (send (ScriptID(58 0)):view(416))
                (send (ScriptID(58 2)):
                    view(416)
                    nsLeft(45)
                    nsTop(38)
                )
                (send (ScriptID(58 4)):
                    view(416)
                    nsLeft(41)
                    nsTop(30)
                )
                (send (ScriptID(58 3)):
                    view(416)
                    nsLeft(45)
                    nsTop(38)
                )
            )
        )
        (if (== gGClientModNum 420)
            (send gOwner:
                normalize()
                noun(4)
                x(120)
                y(200)
                setScale()
                scaleX(102)
                scaleY(102)
                init()
            )
        )(else
            (send gOwner:
                normalize()
                noun(4)
                x(-10)
                y(180)
                setScale()
                scaleX(102)
                scaleY(102)
                init()
            )
        )
        (if (not proc0_6(86))
            = local42[0] @local0
            (rakeeshTell:init(ScriptID(35 1) @local0 @local42))
            (send (ScriptID(35 1)):
                x(-10)
                y(160)
                setScale()
                scaleX(102)
                scaleY(102)
                noun(5)
                actions(rakeeshTell)
                init()
                setCycle(StopWalk 962)
                setMotion(PolyPath 15 160)
            )
        )
        (if (<> (send gLongSong:number) 160)
            (send gLongSong:
                number(160)
                setLoop(-1)
                play(127)
            )
        )
        (send gLongSong:hold(0))
        (send gQg3Walkers:addToFront(village))
        (if (== gGClientModNum 420)
            (self:setScript(enterFromVillage))
        )(else
            (if (proc0_6(18))
                (self:setScript(postConf))
            )(else
                (if (not proc0_6(86))
                    (self:setScript(enterWRakeesh))
                )(else
                    (self:setScript(enterRoom))
                )
            )
        )
    )


    (method (doit)
        (if (script)
            0
        )(else
            (if (<= (send gOwner:x) 10)
                (self:setScript(exitToMap))
            )(else
                (if (>= (send gOwner:y) 178)
                    (if (proc0_6(18))
                        (self:setScript(subHonor))
                    )(else
                        (self:setScript(walkOut))
                    )
                )
            )
        )
        (super:doit())
    )


    (method (dispose)
        (send gQg3Walkers:delete(global2))
        (send gQg3Walkers:delete(village))
        proc958_0(0 35 34 58)
        (super:dispose())
    )


    (method (doVerb theVerb param2)
        (switch (theVerb)
            (case 3
                (egoTell:doVerb(theVerb))
            )
            (default 
                (super:doVerb(theVerb rest param2))
            )
        )
    )

)
(instance egoTell of Teller
    (properties)

    (method (showDialog)
        (super:showDialog(59 
            (if (proc0_6(86) and not local165)
                not proc0_6(18)
            )(else
                0
            )
 58 
            (if (proc0_6(86) and not local165)
                not proc0_6(18)
            )(else
                0
            )
 60 
            (if (local165)
                not proc0_6(18)
            )(else
                0
            )
 57 
            (if (local165)
                not proc0_6(18)
            )(else
                0
            )
 -61 not proc0_6(86) -62 not proc0_6(86) 55 proc0_6(18) 56 proc0_6(18) -54 proc0_6(18)))
    )


    (method (doChild)
        return 
            (switch (query)
                (case -54
                    (if (not local173)
                        ++local173
                        (send gOwner:addHonor(30))
                    )
                )
                (case -62
                    (send gQg3Messager:say(4 5 62))
                    (send global2:setScript(goToVillage))
                    return 0
                )
                (case -61
                    (send gQg3Messager:say(4 5 61))
                    (send global2:setScript(goToVillage))
                    return 0
                )
            )
    )


    (method (doVerb theVerb param2)
        (switch (theVerb)
            (case 3
                (send gQg3Messager:say(5 6 63))
                (send global2:setScript(goToVillage))
                (send ((User:curEvent)):claimed(1))
            )
            (default 
                (super:doVerb(theVerb rest param2))
            )
        )
    )

)
(instance elderTell of Teller
    (properties)

    (method (showDialog)
        (super:showDialog(-14 local165 14 not local165))
    )


    (method (doVerb theVerb param2)
        (switch (theVerb)
            (case 2
                (if (not proc0_6(86))
                    (send global2:setScript(goToVillage))
                    (super:doVerb(theVerb rest param2))
                )(else
                    (super:doVerb(theVerb rest param2))
                )
            )
            (case 3
                (send ((User:curEvent)):claimed(1))
            )
            (default 
                (super:doVerb(theVerb rest param2))
            )
        )
    )

)
(instance rakeeshTell of Teller
    (properties)

    (method (doChild)
        return 
            (switch (query)
                (case -10
                    (send gQg3Messager:say(5 5 10))
                    (send global2:setScript(goToVillage))
                    return 0
                )
                (case -13
                    (send gQg3Messager:say(5 5 13))
                    (send global2:setScript(goToVillage))
                    return 0
                )
                (case -15
                    (send gQg3Messager:say(5 5 15))
                    (send global2:setScript(goToVillage))
                    return 0
                )
            )
    )

)
(instance uhuraTell of Teller
    (properties)
)
(instance goToVillage of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send (ScriptID(58 1)):
                    loop(2)
                    cel(0)
                    setCycle(End self)
                )
            )
            (case 1
                (send gQg3Messager:say(1 6 13 0 self))
            )
            (case 2
                (send gOwner:setMotion(PolyPath 129 200 self))
                (send (ScriptID(35 1)):setMotion(PolyPath 125 190))
            )
            (case 3
                (send gGQg3KDHandler:eachElementDo(102))
                (send global2:drawPic(0 9))
                = cycles 12
            )
            (case 4
                (send global2:newRoom(420))
            )
        )
    )

)
(instance enterWRakeesh of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                proc0_4(86)
                (send gOwner:setMotion(PolyPath 55 170 self))
            )
            (case 1
                proc0_12(gOwner ScriptID(58 1) self)
            )
            (case 2
                (send (ScriptID(58 1)):setCycle(End self))
            )
            (case 3
                (send (ScriptID(58 1)):
                    cel(0)
                    loop(1)
                    setCycle(End self)
                )
            )
            (case 4
                (send gQg3Messager:say(5 6 9 0 self))
            )
            (case 5
                proc0_3()
                (send gQg3Walkers:addToFront(global2))
                = seconds 5
            )
            (case 6
                (send gQg3Walkers:delete(global2))
                (send client:setScript(goToVillage self))
            )
        )
    )

)
(instance exitToMap of Script
    (properties)

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

)
(instance enterFromVillage of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gOwner:setMotion(MoveTo 90 165 self))
            )
            (case 1
                (send (ScriptID(58 1)):setCycle(End self))
            )
            (case 2
                (send (ScriptID(58 1)):
                    cel(0)
                    loop(1)
                    setCycle(End self)
                )
            )
            (case 3
                localproc_0d4b(self)
            )
            (case 4
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance walkOut of Script
    (properties)

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

)
(instance enterRoom of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gOwner:setMotion(PolyPath 65 160 self))
            )
            (case 1
                (send gOwner:setHeading(345))
                = cycles 18
            )
            (case 2
                (send (ScriptID(58 1)):setCycle(End self))
            )
            (case 3
                (send (ScriptID(58 1)):
                    cel(0)
                    loop(1)
                    setCycle(End self)
                )
            )
            (case 4
                localproc_0d4b(self)
            )
            (case 5
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance postConf of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                = local162[0] @local149
                = local162[1] @local155
                (uhuraTell:init(ScriptID(34 1) @local149 @local162 @local159))
                (send (ScriptID(34 1)):
                    setScale(220)
                    x(90)
                    y(160)
                    setHeading(270)
                    noun(3)
                    init()
                )
                (send gOwner:setMotion(PolyPath 50 150 self))
            )
            (case 1
                (send gQg3Messager:say(3 6 9))
                = cycles 1
            )
            (case 2
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance subHonor of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gOwner:setMotion(0))
                (send gQg3Messager:say(3 6 48))
            )
            (case 1
                (send gOwner:
                    setMotion(MoveTo (send gOwner:x) + (send gOwner:y) 10 self)
                    addHonor(-20)
                )
            )
            (case 2
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance leftTreeTop of Feature
    (properties
        x 58
        y 28
        noun 11
        nsTop -2
        nsBottom 59
        nsRight 117
        sightAngle 180
    )
)
(instance leftTreeTrunk of Feature
    (properties
        x 20
        y 93
        noun 12
        nsTop 57
        nsBottom 129
        nsRight 41
        sightAngle 180
    )
)
(instance rightTreeTop of Feature
    (properties
        x 261
        y 29
        noun 13
        nsLeft 203
        nsBottom 58
        nsRight 319
        sightAngle 180
    )
)
(instance rightTreeTrunk of Feature
    (properties
        x 302
        y 124
        noun 14
        nsTop 59
        nsLeft 285
        nsBottom 189
        nsRight 319
        sightAngle 180
    )
)
(instance rightTreeBot of Feature
    (properties
        x 236
        y 168
        noun 15
        nsTop 148
        nsLeft 186
        nsBottom 189
        nsRight 286
        sightAngle 180
    )
)
(instance pens of Feature
    (properties
        x 77
        y 70
        noun 7
        nsTop 60
        nsLeft 33
        nsBottom 81
        nsRight 122
        sightAngle 180
    )
)
(instance bridge of Feature
    (properties
        x 269
        y 93
        noun 8
        nsTop 83
        nsLeft 256
        nsBottom 104
        nsRight 283
        sightAngle 180
    )
)
(instance village of Feature
    (properties
        x 163
        y 59
        noun 10
        nsTop 58
        nsLeft 24
        nsBottom 134
        nsRight 303
        sightAngle 180
    )

    (method (doVerb theVerb)
        (switch (theVerb)
            (case 3
                (if ((send gQg3Walkers:contains(global2)))
                    (super:doVerb(3))
                )(else
                    (if (not (send global2:script))
                        (send global2:setScript(walkOut))
                        (send ((User:curEvent)):claimed(1))
                    )(else
                        (super:doVerb(3))
                    )
                )
            )
            (default 
                (super:doVerb(theVerb))
            )
        )
    )

)
(instance outCrop of Feature
    (properties
        x 117
        y 129
        noun 9
        nsTop 128
        nsBottom 189
        nsRight 234
        sightAngle 180
    )
)
