(version 2)
(include "sci.sh")
(exports
    0 rm852
    1 paladinEndScript
    2 crankUpSword
    3 chuckSwordAtWiz
    4 lightnin1
    5 lightnin2
    6 orbTempts
)
(use "Main")
(use "n026")
(use "Sound")
(use "Cycle")
(use "Game")
(use "View")
(use "Obj")
(script 852)



(instance public rm852 of Rm
    (properties
        modNum 850
        noun 18
        picture 850
    )

    (method (init)
        = global125 3
        proc0_4(124)
        (super:init())
        (self:setRegions(850))
        (if (== gGClientModNum 550)
            (self:setScript(killedGarg))
        )(else
            (self:setScript(paladinEndScript))
        )
        (if (not == global155 0)
            (send gGame:save(1))
        )
    )

)
(instance public paladinEndScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send (ScriptID(850 2)):view(863))
                (send gOwner:setMotion(MoveTo 20 183 self))
            )
            (case 1
                (if (proc0_6(150))
                    (send gQg3Messager:say(2 6 62 0 self 850))
                )(else
                    (self:cue())
                )
            )
            (case 2
                (send gQg3Messager:say(3 6 13 0 self 850))
            )
            (case 3
                (send (ScriptID(850 2)):
                    view(863)
                    loop(6)
                    setCycle(End self)
                )
            )
            (case 4
                (send (ScriptID(850 3)):setCycle(End self))
            )
            (case 5
                (send (ScriptID(850 3)):
                    loop(1)
                    setCycle(CT 3 1 self)
                )
            )
            (case 6
                = global365 855
                (send global2:newRoom(550))
            )
        )
    )

)
(instance killedGarg of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send (ScriptID(850 3)):
                    loop(2)
                    cel(0)
                    noun(4)
                )
                (send gOwner:
                    x(20)
                    y(183)
                    solvePuzzle(342 3 9)
                )
                (send (ScriptID(850 2)):
                    view(863)
                    loop(Random(0 6))
                    cel(0)
                )
                = seconds 2
            )
            (case 1
                (if (== global155 0)
                    proc26_0(59 850)
                )(else
                    (self:cue())
                )
            )
            (case 2
                (send (ScriptID(850 3)):
                    cycleSpeed(3)
                    setCycle(End self)
                )
            )
            (case 3
                (send (ScriptID(850 3)):
                    view(854)
                    setLoop(1)
                )
                (send gQg3Messager:say(3 6 7 0 self 850))
            )
            (case 4
                (send (ScriptID(850 2)):setScript(ScriptID(850 8)))
                proc0_3()
                (send gMainIconBar:disable(1 5 6))
                (self:dispose())
            )
        )
    )

)
(instance public crankUpSword of Script
    (properties)

    (method (doit)
        (if (((== (self:script) ScriptID(850 12)) and (== (send (ScriptID(850 12)):state) 0)) and (== (self:state) 0))
            (send (ScriptID(850 12)):cue())
        )
        (super:doit())
    )


    (method (dispose)
        proc0_5(82)
        (super:dispose())
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gMainIconBar:disable(1 4 5 6))
                proc0_4(89)
                (send (ScriptID(850 8)):dispose())
                (send gOwner:setMotion(MoveTo 42 178 self))
            )
            (case 1
                (send gMainIconBar:disable(1 4 5 6))
                (if (IsObject((send gOwner:looper)))
                    (send ((send gOwner:looper)):dispose())
                    (send gOwner:looper(0))
                )
                (send gOwner:
                    setMotion(0)
                    setCycle(0)
                )
                proc0_12(gOwner ScriptID(850 2))
                (send (ScriptID(850 2)):
                    view(863)
                    cel(0)
                    loop(Random(0 6))
                    setCycle(End self)
                )
            )
            (case 2
                (send (ScriptID(850 2)):
                    view(863)
                    loop(0)
                    setCycle(CT 6 1 self)
                )
            )
            (case 3
                (send (ScriptID(850 9)):
                    setLoop(Random(0 4))
                    x(186)
                    y(60)
                    cycleSpeed(0)
                    moveSpeed(0)
                    setScale()
                    setStep(8 7)
                    init()
                    setMotion(MoveTo 61 111 self)
                )
                (send (ScriptID(850 2)):setCycle(End self))
            )
            (case 4
                (send gOwner:
                    view(38)
                    loop(0)
                    cel(0)
                    setCycle(End)
                )
                (sFx2:
                    number(240)
                    play()
                )
            )
            (case 5
                (sFx2:
                    number(10)
                    play()
                )
                (send (ScriptID(850 9)):dispose())
                (send gOwner:setCycle(Beg self))
            )
            (case 6
                (send gOwner:normalize())
                = state 0
                (if (== (self:script) ScriptID(850 12))
                    (send (ScriptID(850 12)):cue())
                )
                (if (== (send (ScriptID(850 3)):script) ScriptID(850 7))
                    (send (ScriptID(850 7)):cue())
                )
                (send gMainIconBar:enable(1 4))
                (switch (global209)
                    (case 1
                        = seconds 15
                    )
                    (case 2
                        = seconds 10
                    )
                    (case 3
                        = seconds 5
                    )
                )
            )
        )
    )

)
(instance public chuckSwordAtWiz of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send (ScriptID(850 8)):dispose())
                (crankUpSword:dispose())
                (self:setScript(ScriptID(32 0) self 11))
                (send gOwner:drop(1))
                proc0_4(91)
            )
            (case 1
            )
            (case 2
                (sFx2:
                    number(910)
                    play()
                )
                (send (ScriptID(850 2)):
                    view(865)
                    loop(0)
                    cel(0)
                    cycleSpeed(10)
                    setCycle(End self)
                )
                (if (== (send gOwner:script) ScriptID(850 11))
                    (send (ScriptID(850 11)):cue())
                )
                (if (== (send (ScriptID(850 16)):state) 0)
                    (send (ScriptID(850 16)):cue())
                )
            )
            (case 3
                (send (ScriptID(850 2)):
                    loop(1)
                    cel(0)
                    setPri(14)
                    setCycle(End self)
                )
            )
            (case 4
                (send (ScriptID(850 2)):
                    view(865)
                    setLoop(3)
                    cycleSpeed(0)
                    setPri(2)
                    setCycle(Fwd)
                )
                (lightnin2:
                    init()
                    setPri(1)
                    cycleSpeed(0)
                    setCycle(Fwd)
                )
                (sFx2:
                    number(7)
                    play()
                )
                (self:setScript(ScriptID(850 10)))
                (send (ScriptID(850 10)):setScript(orbTempts))
                (if (== (send gOwner:script) ScriptID(850 11))
                    (send gQg3Messager:say(2 6 31 0 0 850))
                    (send (ScriptID(850 11)):cue())
                )
                (if (== (send (ScriptID(850 16)):state) 0)
                    (send (ScriptID(850 16)):cue())
                )
            )
        )
    )

)
(instance public orbTempts of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = seconds 7
            )
            (case 1
                (send gQg3Messager:say(2 6 32 0 self 850))
            )
            (case 2
                = seconds 7
            )
            (case 3
                (send gQg3Messager:say(2 6 51 0 self 850))
            )
            (case 4
                = seconds 7
            )
            (case 5
                (send gQg3Messager:say(2 6 52 0 self 850))
            )
            (case 6
                = seconds 7
            )
            (case 7
                (send gQg3Messager:say(2 6 53 0 self 850))
            )
            (case 8
                (send gQg3Messager:say(2 6 54 0 self 850))
            )
            (case 9
                = seconds 7
            )
            (case 10
                (send gQg3Messager:say(2 6 55 0 self 850))
            )
            (case 11
                (self:dispose())
            )
        )
    )

)
(instance public lightnin1 of Prop
    (properties
        x 265
        view 855
        loop 1
        priority 13
        signal $4010
    )

    (method (doVerb theVerb)
        (send (ScriptID(850 4)):doVerb(theVerb))
    )

)
(instance public lightnin2 of Prop
    (properties
        x 204
        view 855
        loop 1
        cel 1
        priority 13
        signal $4010
    )
)
(instance sFx2 of Sound
    (properties)
)
