(version 2)
(include "sci.sh")
(exports
    0 rm851
    1 fighterEndScript
    2 crankUpShield
    3 spearWiz
)
(use "Main")
(use "n026")
(use "Sound")
(use "Cycle")
(use "Game")
(use "User")
(use "Obj")
(script 851)



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

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

)
(instance public fighterEndScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send (ScriptID(850 6)):
                    init()
                    stopUpd()
                )
                (send gOwner:setMotion(MoveTo 20 183 self))
            )
            (case 1
                (send gQg3Messager:say(1 6 4 0 self 850))
            )
            (case 2
                (send gQg3Messager:say(1 6 5 0 self 850))
            )
            (case 3
                (send (ScriptID(850 6)):dispose())
                DrawPic(850 dpCLOSEREOPEN_HCENTER)
                = seconds 2
            )
            (case 4
                (send (ScriptID(850 2)):
                    loop(1)
                    setCycle(End self)
                )
            )
            (case 5
                (send gQg3Messager:say(3 6 6 0 self 850))
            )
            (case 6
                (send (ScriptID(850 2)):
                    view(863)
                    loop(6)
                    setCycle(End self)
                )
            )
            (case 7
                (sFx2:
                    number(944)
                    play()
                )
                (send (ScriptID(850 3)):setCycle(End self))
            )
            (case 8
                (send (ScriptID(850 3)):
                    loop(1)
                    setCycle(CT 3 1 self)
                )
            )
            (case 9
                = global365 855
                (send global2:newRoom(550))
            )
        )
    )

)
(instance killedGarg of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gOwner:
                    normalize()
                    x(20)
                    y(183)
                    solvePuzzle(342 3)
                )
                (send (ScriptID(850 3)):
                    loop(2)
                    cel(0)
                    noun(4)
                )
                (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 crankUpShield 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(82)
                (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
                (sFx2:
                    number(13)
                    play()
                )
                (send (ScriptID(850 9)):
                    setLoop(Random(0 4))
                    x(186)
                    y(60)
                    cycleSpeed(0)
                    moveSpeed(0)
                    setScale()
                    setStep(8 7)
                    init()
                    setMotion(MoveTo + (send gOwner:x) 20 - (send gOwner:y) 34 self)
                )
                (send (ScriptID(850 2)):setCycle(End self))
            )
            (case 4
                (send gOwner:
                    view(36)
                    loop(0)
                    cel(0)
                    setCycle(CT 4 1)
                )
            )
            (case 5
                (sFx2:
                    number(10)
                    play()
                )
                (send (ScriptID(850 9)):dispose())
                (send gOwner:setCycle(End self))
            )
            (case 6
                (send gOwner:normalize())
                (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())
                )
                = state 0
                proc0_3()
                (send gMainIconBar:enable(1 4))
                (switch (global209)
                    (case 1
                        = seconds 15
                    )
                    (case 2
                        = seconds 10
                    )
                    (case 3
                        = seconds 5
                    )
                )
            )
        )
    )

)
(instance public spearWiz of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (if (not == (send (ScriptID(850 16)):state) -1)
                    0
                )(else
                    (self:cue())
                )
            )
            (case 1
                proc0_2()
                proc0_4(84)
                (if ((send (ScriptID(850 2)):script))
                    (send (ScriptID(850 2)):setScript(0))
                )
                (send (ScriptID(32 0)):start(1))
                proc0_14((send ((User:curEvent)):x) (send ((User:curEvent)):y))
                (self:setScript(ScriptID(32 0) 0 56))
                (send gOwner:drop(45))
                (send gMainIconBar:advanceCurIcon())
            )
            (case 2
                (sFx2:
                    number(931)
                    play(127)
                )
                (send (ScriptID(850 2)):
                    setPri(14)
                    moveSpeed(0)
                    setStep(6 5)
                    setCycle(Walk)
                    setMotion(MoveTo 243 89 self)
                )
                (send (ScriptID(850 5)):setPri(0))
            )
            (case 3
                (sFx2:
                    number(101)
                    play()
                )
                (send (ScriptID(850 2)):dispose())
                (send gOwner:solvePuzzle(340 10))
                = seconds 1
            )
            (case 4
                (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())
                )
                (self:setScript(ScriptID(850 10)))
            )
        )
    )

)
(instance sFx2 of Sound
    (properties)
)
