(version 2)
(include "sci.sh")
(exports
    0 rm600
)
(use "Main")
(use "TellerIcon")
(use "PChase")
(use "PolyPath")
(use "Polygon")
(use "CueObj")
(use "Sound")
(use "Cycle")
(use "Game")
(use "View")
(use "Obj")
(script 600)


(local
    local0[6] = (0 7 -6 -14 -9 999 )
    local6[7] = (0 2 11 12 16 17 999 )
    local13[6]
    local19[5]
    local24
    local25
    local26 =     180
    local27[2]
    local29
    local30
    local31

)
(procedure (localproc_008e)
    return 
        (if (< local26 126)
            return 5
        )(else
            return - 20 (/ (- 190 local26) 4)
        )
)


(instance public rm600 of Rm
    (properties
        noun 4
        picture 600
        vanishingY 75
    )

    (method (init)
        (send global2:addObstacle((send ((Polygon:new())):
                type(2)
                init(0 1 319 2 319 151 247 137 229 139 208 130 152 129 140 127 0 120)
                yourself()
            )
 (send ((Polygon:new())):
                type(2)
                init(16 140 77 149 154 174 154 189 0 189)
                yourself()
            )
))
        (send (ScriptID(36 0)):
            x(200)
            y(2)
            textX(-175)
            textY(150)
        )
        = local13[0] @local0
        = local19[0] @local6
        (gate:init())
        (send gLongSong:
            number(600)
            setLoop(-1)
            play(127)
        )
        (switch (gGClientModNum)
            (case 620
                (send gOwner:
                    view(0)
                    x(309)
                    y(175)
                    loop(3)
                    cel(0)
                    init()
                    setScale(195)
                )
                (joHari:
                    x(290)
                    y(175)
                    signal(16384)
                    noun(1)
                    init()
                    moveSpeed((send gOwner:moveSpeed))
                    cycleSpeed((send gOwner:cycleSpeed))
                    origStep((send gOwner:origStep))
                    setScale(195)
                    setCycle(Walk)
                )
                (super:init())
                (send global2:setScript(eventThree))
            )
            (case 650
                (send gQg3Walkers:addToFront(self))
                (egoTell:init(gOwner @local0 @local13))
                (johariTell:init(joHari @local6 @local19))
                (send gOwner:
                    x(175)
                    y(185)
                    code(checkSouth)
                    noun(2)
                    signal(16384)
                    init()
                    normalize(3)
                    setScale(195)
                )
                (joHari:
                    x(200)
                    y(180)
                    noun(1)
                    origStep((send gOwner:origStep))
                    actions(johariTell)
                    init()
                    moveSpeed((send gOwner:moveSpeed))
                    cycleSpeed((send gOwner:cycleSpeed))
                    setScale(195)
                    setCycle(joHariStop 974)
                )
                (super:init())
                (send global2:setScript(eventFour))
            )
            (default 
                (if ((== gGClientModNum 170) and proc0_6(88))
                    proc0_5(88)
                    (send gQg3Walkers:addToFront(self))
                    (egoTell:init(egoPic @local0 @local13))
                    (johariTell:init(johariPic @local6 @local19))
                    (egoPic:init())
                    (johariPic:init())
                    (kissView:init())
                    (send gOwner:
                        view(0)
                        loop(3)
                        cel(0)
                        init()
                        setScale(195)
                        hide()
                    )
                    (joHari:
                        signal(16384)
                        init()
                        moveSpeed((send gOwner:moveSpeed))
                        cycleSpeed((send gOwner:cycleSpeed))
                        setScale(195)
                        setCycle(Walk)
                        hide()
                    )
                    = local29 1
                    (super:init())
                    proc0_3()
                    (send global2:setScript(eventOne))
                )(else
                    (send gOwner:
                        view(0)
                        x(190)
                        y(180)
                        code(checkSouth)
                        loop(3)
                        cel(0)
                        noun(2)
                        init()
                        setStep(2 2)
                        setScale(195)
                    )
                    (super:init())
                    (send global2:setScript(eventFive))
                )
            )
        )
    )


    (method (dispose param1)
        (send gQg3Walkers:delete(self))
        DisposeScript(36)
        (super:dispose(rest param1))
    )


    (method (doVerb theVerb)
        (switch (theVerb)
            (case 3
                (if (== gGClientModNum 650)
                    = local25 (send ((send gUser:curEvent)):x)
                    = local26 (send ((send gUser:curEvent)):y)
                    (send gOwner:setMotion(PolyPath local25 local26 joHari))
                    (joHari:setMotion(PFollow gOwner 12))
                )(else
                    (if (local24)
                        (send global2:setScript(kissing))
                    )(else
                        (send gQg3Messager:say(2 5 6 2))
                        = local24 1
                    )
                )
            )
            (case 74
                (if (== gGClientModNum 650)
                    (send gQg3Messager:say(3 6 25))
                )(else
                    (super:doVerb(theVerb))
                )
            )
            (default 
                (super:doVerb(theVerb))
            )
        )
    )

)
(instance eventOne of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = cycles 5
            )
            (case 1
                (send gQg3Messager:say(1 2 1 0 self))
            )
            (case 2
                (switch (global125)
                    (case 1
                        (send gQg3Messager:say(1 2 10 0 self))
                    )
                    (case 2
                        (send gQg3Messager:say(1 2 3 0 self))
                    )
                    (default 
                        (if ((send gOwner:has(46)))
                            (send gQg3Messager:say(1 2 4 0 self))
                        )(else
                            (self:dispose())
                        )
                    )
                )
            )
            (case 3
                (self:dispose())
            )
        )
    )

)
(instance eventTwo of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (kissView:dispose())
                (johariPic:dispose())
                (egoPic:dispose())
                PalVary(pvINIT 600 0)
                = seconds 2
            )
            (case 1
                DrawPic(600 dpCLOSEREOPEN_VCENTER)
                (gate:show())
                = seconds 2
            )
            (case 2
                (if (<> PalVary(pvGET_CURRENT_STEP) 64)
                    proc0_4(31)
                    proc0_4(81)
                    = global120 3200
                )
                (send gQg3Messager:say(1 2 8 0 self))
            )
            (case 3
                (send gOwner:
                    x(200)
                    y(280)
                    show()
                    setStep(2 2)
                    setLoop(-1)
                    setCycle(Walk)
                    setMotion(MoveTo 200 200 self)
                )
                (joHari:
                    x(170)
                    y(280)
                    show()
                    setCycle(Walk)
                    setMotion(MoveTo 170 200 self)
                )
            )
            (case 4
                0
            )
            (case 5
                (send gQg3Messager:say(1 2 15 0 self))
            )
            (case 6
                (send gOwner:setMotion(MoveTo (+ (send gOwner:x) 90) (send gOwner:y) self))
                (joHari:setMotion(MoveTo (+ (joHari:x) 100) (joHari:y) self))
            )
            (case 7
                0
            )
            (case 8
                (send global2:newRoom(620))
            )
        )
    )

)
(instance eventThree of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gOwner:setMotion(MoveTo 170 (+ (gate:y) 30) self))
                (joHari:setMotion(MoveTo 165 (+ (gate:y) 23) self))
            )
            (case 1
                0
            )
            (case 2
                (send gQg3Messager:say(1 2 18 0 self))
            )
            (case 3
                (if (== global125 1)
                    (send gQg3Messager:say(1 6 2 0 self))
                )(else
                    (self:cue())
                )
            )
            (case 4
                (if ((send gOwner:has(46)))
                    (send gQg3Messager:say(1 2 20 0 self))
                )(else
                    (self:cue())
                )
            )
            (case 5
                (joHari:setMotion(MoveTo 148 (+ (gate:y) 5) self))
                (send gOwner:setMotion(MoveTo 152 (+ (gate:y) 10) self))
            )
            (case 6
                0
            )
            (case 7
                (send gQg3Messager:say(1 2 21 0 self))
            )
            (case 8
                (gate:setMotion(MoveTo (- (gate:x) 15) (gate:y) self))
                (send gLongSong2:
                    number(602)
                    play(127)
                )
            )
            (case 9
                (send gOwner:setMotion(MoveTo 147 (- (gate:y) 2) self))
                (joHari:setMotion(MoveTo 143 (- (gate:y) 4) self))
            )
            (case 10
                (send global2:newRoom(620))
            )
        )
    )

)
(instance eventFour of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = cycles 5
            )
            (case 1
                (send gQg3Messager:say(1 6 22 0 self))
            )
            (case 2
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance eventFive of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gOwner:setMotion(MoveTo 147 (+ (gate:y) 5) self))
            )
            (case 1
                (send gQg3Messager:say(3 2 21 0 self))
            )
            (case 2
                (gate:setMotion(MoveTo (- (gate:x) 15) (gate:y) self))
                (send gLongSong2:
                    number(602)
                    play(127)
                )
            )
            (case 3
                (send gOwner:setMotion(MoveTo 145 120 self))
            )
            (case 4
                (if ((== gGClientModNum 170) and (send gOwner:has(46)))
                    (send global2:newRoom(620))
                )(else
                    (send global2:newRoom(650))
                )
            )
        )
    )

)
(instance kissing of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (kissView:
                    setLoop(0)
                    setCycle(End self)
                )
            )
            (case 1
                = seconds 3
            )
            (case 2
                (kissView:
                    cel(0)
                    setLoop(1)
                    cycleSpeed(10)
                    setCycle(End self)
                )
            )
            (case 3
                (sFx:
                    number(603)
                    play()
                )
                = seconds 2
            )
            (case 4
                (send gOwner:solvePuzzle(297 3))
                DrawPic(0 dpCLOSEREOPEN_VCENTER)
                (send gGQg3KDHandler:eachElementDo(102))
                = seconds 1
            )
            (case 5
                (send global2:setScript(eventTwo))
            )
        )
    )

)
(instance toVillage of Script
    (properties)

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

)
(instance toRm650 of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gOwner:
                    code(0)
                    setMotion(MoveTo 147 127 self)
                )
                (joHari:
                    signal(16384)
                    setMotion(MoveTo 143 132 self)
                )
            )
            (case 1
                0
            )
            (case 2
                (gate:setMotion(MoveTo 130 (gate:y) self))
                (send gLongSong2:
                    number(602)
                    play()
                )
            )
            (case 3
                (send gOwner:setMotion(MoveTo 147 (- (gate:y) 3) self))
                (joHari:setMotion(MoveTo 143 (- (gate:y) 2) self))
            )
            (case 4
                0
            )
            (case 5
                (send global2:newRoom(650))
            )
        )
    )

)
(instance toLeave of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gOwner:code(0))
                (send gQg3Messager:say(1 6 23 0 self))
            )
            (case 1
                (send global2:newRoom(170))
            )
        )
    )

)
(instance checkSouth of Code
    (properties)

    (method (doit)
        (if (> (send gOwner:y) 185)
            (send global2:setScript(toLeave))
        )(else
            (if (& (send gOwner:onControl()) $0008)
                (gate:dispose())
                (send global2:newRoom(650))
            )
        )
    )

)
(instance johariPic of Feature
    (properties
        x 50
        y 160
        noun 1
        onMeCheck $0002
    )
)
(instance egoPic of Feature
    (properties
        x 75
        y 160
        noun 2
        onMeCheck $0004
    )
)
(instance kissView of Actor
    (properties
        x 125
        y 159
        z -30
        view 601
        priority 15
        signal $1010
    )
)
(instance joHari of Actor
    (properties
        x 170
        y 280
        view 975
        loop 3
    )

    (method (doit param1)
        (super:doit(rest param1))
        (if (IsObject((self:mover)) and (send ((self:mover)):isMemberOf(PFollow)))
            (send ((self:mover)):distance(localproc_008e()))
            (self:moveSpeed((send gOwner:moveSpeed)))
            (self:cycleSpeed((send gOwner:cycleSpeed)))
        )
    )


    (method (cue)
        (send gOwner:normalize())
    )

)
(instance gate of Actor
    (properties
        x 146
        y 126
        view 600
        signal $4000
    )

    (method (doVerb theVerb)
        (switch (theVerb)
            (case 4
                (if (== gGClientModNum 650)
                    (send global2:setScript(toRm650))
                )
            )
            (default 
                (super:doVerb(theVerb))
            )
        )
    )

)
(instance egoTell of Teller
    (properties)

    (method (showDialog)
        (super:showDialog(-14 local29 -9 local29))
    )


    (method (doChild param1)
        return 
            (switch (param1)
                (case -6
                    (if (local29)
                        (if (local24)
                            (send global2:setScript(kissing))
                            return 0
                        )(else
                            = local24 1
                        )
                    )(else
                        (if (== gGClientModNum 650)
                            (send global2:setScript(toVillage))
                            return 0
                        )(else
                            return 1
                        )
                    )
                )
                (case -14
                    (if (local24)
                        (send global2:setScript(kissing))
                    )(else
                        = local24 1
                        (send gQg3Messager:say(2 5 6 2))
                    )
                    return 0
                )
                (case -9
                    (send gOwner:addHonor(10))
                    = local24 1
                )
            )
    )

)
(instance johariTell of Teller
    (properties)

    (method (showDialog)
        (super:showDialog(11 local29 12 local29 16 (== gGClientModNum 650) 17 (== gGClientModNum 650)))
    )


    (method (doVerb theVerb)
        (switch (theVerb)
            (case 4
                (if (<> gGClientModNum 650)
                    (if (local24)
                        (send global2:setScript(kissing))
                    )(else
                        (send gQg3Messager:say(1 2 13))
                        = local24 1
                    )
                )(else
                    (super:doVerb(theVerb))
                )
            )
            (default 
                (super:doVerb(theVerb))
            )
        )
    )

)
(instance joHariStop of Fwd
    (properties)

    (method (init theClient param2)
        (if (paramTotal)
            = local31 (send ((= client theClient)):view)
            (if (>= paramTotal 2)
                = local30 param2
            )
        )
        (super:init(client))
        (self:doit())
    )


    (method (doit)
        (var clientLoop, clientMover)
        (if ((send client:isStopped()))
            (if ((== local30 -1) and (<> (send client:loop) (- NumLoops(client) 1)))
                = clientLoop (send client:loop)
                = clientMover (send client:mover)
                (super:doit())
                (send client:
                    loop(- NumLoops(client) 1)
                    setCel(clientLoop)
                )
            )(else
                (if ((<> local30 -1) and (== (send client:view) local31))
                    (send client:
                        view(local30)
                        loop((send gOwner:loop))
                    )
                    = clientMover (send client:mover)
                    (super:doit())
                )(else
                    (if (<> local30 -1)
                        (super:doit())
                    )
                )
            )
        )(else
            (switch (local30)
                (case (send client:view)
                    (send client:view(local31))
                )
                (case -1
                    (send client:
                        setLoop(-1)
                        setCel(-1)
                    )
                )
            )
            (super:doit())
        )
    )


    (method (dispose)
        (if (== (send client:view) local30)
            (send client:view(local31))
        )
        (super:dispose())
    )

)
(instance sFx of Sound
    (properties)
)
