(version 2)
(include "sci.sh")
(exports
    0 rm76
)
(use "Main")
(use "Class_255_0")
(use "n958")
(use "Chase")
(use "RFeature")
(use "Avoid")
(use "Sound")
(use "Cycle")
(use "Game")
(use "User")
(use "PicView")
(use "Obj")
(script 76)


(local
    local0

)
(instance public rm76 of Rm
    (properties
        picture 76
        east 75
        west 77
    )

    (method (init)
        proc958_0(128 55 276)
        (if ((send gEgo:has(6)))
            Load(rsVIEW 170)
        )
        (self:style(
            (switch (gGNumber)
                (case west
                    3
                )
                (case east
                    2
                )
            )
))
        (super:init())
        (send gEgo:init())
        proc0_1()
        (send gAddToPics:
            add(door)
            eachElementDo(#init)
            doit()
        )
        (statue:
            init()
            stopUpd()
        )
        (switch (gGNumber)
            (case west
                (send gEgo:posn(3 proc0_17(187 (send gEgo:x) 154)))
            )
            (default 
                (send gEgo:posn(279 118))
                (if (not proc0_12(33))
                    proc958_0(132 47 42 27)
                    (send global2:setScript({getHim!}))
                )
            )
        )
        = local0 proc0_12(1)
    )


    (method (doit)
        (var temp0)
        (if (((== script {getHim!}) and proc0_12(1)) and not local0)
            = local0 1
            proc255_0(76 0)
        )(else
            (if (script and (<> script {getHim!}))
                (send script:doit())
            )(else
                = temp0 
                    (switch ((send ((User:alterEgo)):edgeHit))
                        (case 1
                            north
                        )
                        (case 2
                            east
                        )
                        (case 3
                            south
                        )
                        (case 4
                            west
                        )
                    )
                (if (temp0)
                    (self:newRoom((= temp0 
                            (switch ((send ((User:alterEgo)):edgeHit))
                                (case 1
                                    north
                                )
                                (case 2
                                    east
                                )
                                (case 3
                                    south
                                )
                                (case 4
                                    west
                                )
                            )
)))
                )(else
                    (if (script)
                        (send script:doit())
                    )
                )
            )
        )
    )


    (method (dispose)
        DisposeScript(985)
        DisposeScript(972)
        (super:dispose())
    )


    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )(else
            (if ((super:handleEvent(pEvent)))
                return 
            )(else
                (if (Said('eat,consume/mushroom'))
                    (if ((send gEgo:has(19)))
                        (if ((send global2:script))
                            proc255_0(76 1)
                        )(else
                            (send pEvent:claimed(0))
                        )
                    )(else
                        (send pEvent:claimed(0))
                    )
                )(else
                    (if ((Said('look,look/lep,guard') or proc255_5(g1 pEvent 3)) or proc255_5(g2 pEvent 3))
                        (if (proc0_12(33))
                            proc255_0(76 2)
                        )(else
                            proc255_0(76 3)
                        )
                    )(else
                        (if (Said('look,look/door') or proc255_5(door pEvent 3))
                            proc255_0(76 4)
                        )(else
                            (if (Said('look,look>'))
                                (if (Said('[<at,around][/room,cave]'))
                                    proc255_0(76 5)
                                    (if (not proc0_12(33))
                                        proc255_0(76 6)
                                    )
                                )
                            )(else
                                (if (Said('close,close/door'))
                                    proc255_0(76 7)
                                )(else
                                    (if ((Said('talk,speak/lep,guard') or Said('hello')) or Said('say/hello'))
                                        (if (proc0_12(33))
                                            proc255_0(76 8)
                                        )(else
                                            proc255_0(76 9)
                                        )
                                    )(else
                                        (if (Said('kill/lep,guard'))
                                            (if (proc0_12(33))
                                                proc255_0(76 2)
                                            )(else
                                                proc255_0(76 10)
                                            )
                                        )(else
                                            (if (((== (send pEvent:type) 1) and (& (send pEvent:modifiers) $0003)) and (== OnControl(2 (send pEvent:x) (send pEvent:y)) -32768))
                                                proc255_0(76 11)
                                            )(else
                                                (if (Said('/stalactite,stalactite>'))
                                                    (if (Said('get,bend'))
                                                        proc255_0(76 12)
                                                    )(else
                                                        (if (Said('look,look'))
                                                            proc255_0(76 11)
                                                        )
                                                    )
                                                )(else
                                                    (if ((send global2:script) and Said('use/shot'))
                                                        (if (Random(0 1))
                                                            proc255_0(76 13)
                                                        )(else
                                                            proc255_0(76 14)
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )
        )
    )

)
(instance {getHim!} of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (User:canControl(0))
                (send (ScriptID(0 21)):
                    number(47)
                    loop(1)
                    play()
                )
                (if (proc0_12(1))
                    proc255_0(76 0)
                )
                (send gEgo:
                    loop(1)
                    setMotion(0)
                )
                (g1:
                    setLoop(2)
                    setCycle(Walk)
                    setMotion(MoveTo 149 119)
                    init()
                )
                (g2:
                    setLoop(2)
                    setCycle(Walk)
                    setMotion(MoveTo 200 148 self)
                    init()
                )
            )
            (case 1
                (if ((send gEgo:has(6)))
                    proc255_0(76 15)
                )(else
                    proc255_0(76 16)
                )
                (User:canControl(1))
                = seconds 2
            )
            (case 2
                (g1:
                    setCycle(Walk)
                    setAvoider(Avoid)
                    setMotion(Chase gEgo 
                        (if ((send gEgo:has(6)))
                            30
                        )(else
                            20
                        )
 self)
                )
                (g2:
                    setCycle(Walk)
                    setAvoider(Avoid)
                    setMotion(Chase gEgo 
                        (if ((send gEgo:has(6)))
                            30
                        )(else
                            20
                        )
 self)
                )
            )
            (case 3
                (if ((send gEgo:has(6)))
                    proc255_0(76 17)
                    (g1:
                        stopUpd()
                        setMotion(0)
                    )
                    (g2:
                        stopUpd()
                        setMotion(0)
                    )
                    (send global2:setScript(poofGuards))
                )(else
                    (send (ScriptID(0 21)):stop())
                    proc0_16(76 18)
                )
            )
        )
    )


    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )(else
            (if ((super:handleEvent(pEvent)))
                return 
            )(else
                (if (Said('fiddle,play/fiddle,jig'))
                    (if (proc0_12(1))
                        proc255_0(76 19)
                    )(else
                        (if (not (send gEgo:has(17)))
                            proc0_6()
                        )(else
                            (send global2:setScript(fiddler))
                        )
                    )
                )
            )
        )
    )

)
(instance fiddler of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send (ScriptID(0 21)):
                    number(42)
                    loop(1)
                    play(self)
                )
                (send gEgo:
                    view(55)
                    cycleSpeed(1)
                    setCycle(Fwd)
                )
                (g1:setMotion(0))
                (g2:setMotion(0))
                = seconds 3
            )
            (case 1
                (g1:
                    loop(3)
                    setCycle(Fwd)
                )
                (g2:
                    loop(4)
                    setCycle(Fwd)
                )
                = seconds 5
            )
            (case 2
                proc255_0(76 20)
                = seconds 4
            )
            (case 3
                proc255_0(76 21)
                (self:setScript(poofGuards self))
            )
            (case 4
                (send gEgo:setCycle(Fwd))
            )
            (case 5
                proc0_1()
                (send gEgo:loop(2))
                proc0_3()
                proc0_19(103 3)
                (self:dispose())
            )
        )
    )

)
(instance poofGuards of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gEgo:stopUpd())
                (poof:
                    posn((g1:x) (g1:y))
                    init()
                    setCycle(CT 7 1 self)
                )
                (TempSound:
                    number(27)
                    loop(1)
                    init()
                    play()
                )
            )
            (case 1
                (g1:dispose())
                (poof:setCycle(End self))
            )
            (case 2
                (poof:
                    cel(0)
                    posn((g2:x) (g2:y))
                    setCycle(CT 7 1 self)
                )
                (TempSound:
                    number(27)
                    loop(1)
                    play()
                )
            )
            (case 3
                (g2:dispose())
                proc0_10(33)
                (poof:setCycle(End self))
            )
            (case 4
                (poof:dispose())
                (self:dispose())
            )
        )
    )

)
(instance door of RPicView
    (properties
        x 286
        y 109
        view 276
    )

    (method (handleEvent)
    )

)
(instance statue of View
    (properties
        x 194
        y 128
        noun 3017
        sightAngle 360
        longRangeDist 500
        shiftClick 1
        view 276
        cel 1
    )

    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )(else
            (if ((super:handleEvent(pEvent)))
                return 
            )(else
                (if (Said('look,look/pillar,beam'))
                    (self:doVerb(1))
                )
            )
        )
    )


    (method (doVerb theVerb)
        (switch (theVerb)
            (case 1
                proc255_0(76 22)
            )
        )
    )

)
(instance g1 of Actor
    (properties
        x 113
        y 157
        description 3090
        view 276
        cel 2
    )
)
(instance g2 of Actor
    (properties
        x 125
        y 183
        description 3090
        view 276
        cel 2
    )
)
(instance poof of Prop
    (properties
        view 170
        loop 2
    )

    (method (doVerb)
    )

)
(instance TempSound of Sound
    (properties
        priority 6
    )
)
