(version 2)
(include "sci.sh")
(exports
    0 rm066
)
(use "Main")
(use "Class_255_0")
(use "Sound")
(use "Jump")
(use "Cycle")
(use "Game")
(use "User")
(use "TheMenuBar")
(use "Feature")
(use "Obj")
(script 66)


(local
    local0
    local1
    local2
    local3
    local4
    local5
    local6

)
(instance public rm066 of Rm
    (properties
        picture 66
        horizon 88
        north 60
        east 67
        south 69
    )

    (method (init)
        (var temp0[50], theJumpTo)
        (User:
            canInput(1)
            canControl(1)
        )
        (self:setRegions(600))
        Load(132 33)
        (if (global256)
            Load(129 65)
            Load(128 87)
            Load(130 991)
            = theJumpTo JumpTo
        )(else
            Load(128 90)
            Load(128 95)
            Load(132 78)
        )
        (super:init())
        (if (global256)
            (send global2:drawPic(65))
        )(else
            (rock1:
                init()
                stopUpd()
            )
            (rock2:
                init()
                stopUpd()
            )
        )
        (switch (gNorth)
            (case 60
                (send gEgo:
                    posn(
                        (if (> (send gEgo:x) 159)
                            159
                        )(else
                            (send gEgo:x)
                        )
 + (send global2:horizon) 2)
                    init()
                )
            )
            (case 61
                (send gEgo:
                    posn(240 + (send global2:horizon) 2)
                    init()
                )
            )
            (case 67
                (send gEgo:
                    posn(317 
                        (if (< (send gEgo:y) (send global2:horizon))
                            + (send global2:horizon) 2
                        )(else
                            (send gEgo:y)
                        )
)
                    init()
                )
            )
            (case 69
                (send gEgo:
                    posn(169 187)
                    init()
                )
                (if (global256 and not global172)
                    (self:setScript(MyMy))
                )
            )
        )
        (TheMenuBar:draw())
        (SL:enable())
    )


    (method (doit)
        (var gEgoOnControl, temp1[50])
        (super:doit())
        (if (== (send gEgo:view) 95)
            = local4 
                (if (((== (send gEgo:heading) 315) or (== (send gEgo:heading) 0)) or (== (send gEgo:heading) 45))
                    0
                )(else
                    (if ((== (send gEgo:heading) 90) or (== (send gEgo:heading) 270))
                        2
                    )(else
                        (if (((== (send gEgo:heading) 135) or (== (send gEgo:heading) 180)) or (== (send gEgo:heading) 225))
                            1
                        )
                    )
                )
            (if (<> local5 local4)
                (switch (local4)
                    (case 0
                        (send gEgo:setLoop(1))
                    )
                    (case 1
                        (send gEgo:setLoop(0))
                    )
                    (case 2
                        (send gEgo:setLoop(
                            (if (== local5 0)
                                1
                            )(else
                                0
                            )
))
                    )
                )
            )
            = local5 local4
        )
        (if (not (send global2:script))
            = gEgoOnControl (send gEgo:onControl())
            (if (== gEgoOnControl 3)
                (send gEgo:
                    setPri(3)
                    posn((send gEgo:x) + (send gEgo:y) 2)
                )
                = global180 1
            )(else
                (if (((((== gEgoOnControl 5) or (== gEgoOnControl 7)) or (== gEgoOnControl 69)) or (== gEgoOnControl 133)) or (== gEgoOnControl 197))
                    (send gEgo:
                        setPri(3)
                        posn(+ (send gEgo:x) 6 (send gEgo:y))
                    )
                    = global180 1
                )(else
                    (if ((== gEgoOnControl 9) or (== gEgoOnControl 13))
                        (send gEgo:
                            setPri(5)
                            posn((send gEgo:x) - (send gEgo:y) 2)
                        )
                        = global180 1
                    )(else
                        (if (((== gEgoOnControl 17) or (== gEgoOnControl 49)) or (== gEgoOnControl 273))
                            (send gEgo:
                                setPri(7)
                                posn((send gEgo:x) + (send gEgo:y) 2)
                            )
                            = global180 1
                        )(else
                            (if ((== gEgoOnControl 33) or (== gEgoOnControl 161))
                                (send gEgo:
                                    setPri(7)
                                    posn(- (send gEgo:x) 12 (send gEgo:y))
                                )
                                = global180 1
                            )(else
                                (if ((== gEgoOnControl 257) or (== gEgoOnControl 769))
                                    (send gEgo:
                                        setPri(5)
                                        posn(- (send gEgo:x) 12 (send gEgo:y))
                                    )
                                    = global180 1
                                )(else
                                    (if ((== gEgoOnControl 513) or (== gEgoOnControl 1537))
                                        (send gEgo:
                                            setPri(5)
                                            posn(- (send gEgo:x) 6 (send gEgo:y))
                                        )
                                        = global180 1
                                    )(else
                                        (if (((== gEgoOnControl 2049) or (== gEgoOnControl 2065)) or (== gEgoOnControl 2053))
                                            (send gEgo:
                                                setPri(5)
                                                posn((send gEgo:x) + (send gEgo:y) 2)
                                            )
                                            = global180 1
                                        )(else
                                            (if (== gEgoOnControl 1025)
                                                (send gEgo:
                                                    setPri(3)
                                                    posn(- (send gEgo:x) 6 - (send gEgo:y) 2)
                                                )
                                                = global180 1
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )
        )
        (if (global219 and local6)
            --local6
        )
        (if (== local6 1)
            = local6 -1
            (send global2:setScript(DeadMeat))
        )
    )


    (method (dispose)
        (if (global256)
            DisposeScript(991)
        )
        (super:dispose())
    )


    (method (handleEvent pEvent)
        (super:handleEvent(pEvent))
        (if ((<> (send pEvent:type) 128) or (send pEvent:claimed))
            return 
        )
        (if (Said('leap,jump/canyon[<across,above]'))
            (if (not global256)
                proc255_0(66 0)
            )(else
                (if ((send gEgo:has(9)))
                    (self:setScript(PoleVault))
                )(else
                    proc255_0(66 1)
                )
            )
        )(else
            (if (Said('pole/leap'))
                (if (not global256)
                    proc255_0(66 0)
                )(else
                    (if ((send gEgo:has(9)))
                        (self:setScript(PoleVault))
                    )(else
                        proc255_0(66 1)
                    )
                )
            )(else
                (if (Said('use/pole'))
                    (if (not global256)
                        proc255_0(66 2)
                    )(else
                        (if ((send gEgo:has(9)))
                            (self:setScript(PoleVault))
                        )(else
                            proc0_9()
                        )
                    )
                )(else
                    (if (Said('drop/pole/canyon[<across,above]'))
                        (if (not global256)
                            proc255_0(66 3)
                        )(else
                            (if ((send gEgo:has(9)))
                                proc255_0(66 4)
                            )(else
                                proc0_9()
                            )
                        )
                    )
                )
            )
        )
    )


    (method (newRoom newRoomNumber)
        (if (== (send global2:script) 0)
            (switch ((send gEgo:edgeHit))
                (case 1
                    (if (< (send gEgo:x) 159)
                        = newRoomNumber 60
                    )(else
                        = newRoomNumber 61
                    )
                )
                (case 2
                    = newRoomNumber 67
                )
                (case 3
                    = newRoomNumber 69
                )
            )
            (if (global256)
                ++global593
            )
            (super:newRoom(newRoomNumber))
        )
    )

)
(instance MyMy of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc255_0(66 5)
                = global172 1
                (send global2:setScript(0))
            )
        )
    )

)
(instance PoleVault of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                = global159 1
                (send gEgo:setMotion(MoveTo 229 206 self))
            )
            (case 1
                (send gEgo:
                    view(87)
                    setLoop(0)
                    setCel(0)
                    setMotion(0)
                    setCycle(Fwd)
                )
                proc255_0(66 6)
                = seconds 2
            )
            (case 2
                (send gEgo:setMotion(MoveTo 195 172 self))
            )
            (case 3
                (send gEgo:
                    setLoop(1)
                    setCel(0)
                    setCycle(End self)
                )
            )
            (case 4
                (pole:
                    init()
                    setCycle(End)
                )
                (send gEgo:
                    setLoop(3)
                    setCel(0)
                    posn(177 152)
                    setCycle(0)
                    setMotion(JumpTo 108 143 self)
                )
            )
            (case 5
                (if ((send gEgo:has(10)))
                    proc0_2()
                    (kaboom:play())
                    (blast:
                        init()
                        setCycle(End self)
                    )
                    (send gEgo:dispose())
                )(else
                    (self:changeState(7))
                )
            )
            (case 6
                proc255_0(66 7)
                proc0_17(0 0 16 20)
            )
            (case 7
                (send gEgo:
                    view(0)
                    setLoop(-1)
                    loop(1)
                    setCycle(Walk)
                    setMotion(MoveTo 98 133 self)
                )
            )
            (case 8
                (pole:dispose())
                (send gEgo:put(9))
                (send global1:changeScore(20))
                proc255_0(66 8)
                proc0_3()
                = global159 0
                (send client:setScript(0))
            )
        )
    )

)
(instance DeadMeat of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (kaboom:play())
                (blast:
                    init()
                    setCycle(End self)
                )
                (send gEgo:dispose())
            )
            (case 1
                proc255_0(66 9)
                proc0_17(0 0 16 20)
            )
        )
    )

)
(instance pole of Prop
    (properties)

    (method (init)
        (super:init())
        (self:
            view(87)
            setLoop(2)
            setCel(0)
            setPri((send gEgo:priority))
            posn(177 172)
            ignoreActors()
        )
    )

)
(instance blast of Prop
    (properties)

    (method (init)
        (super:init())
        (self:
            view(87)
            setLoop(4)
            setCel(0)
            setPri(+ (send gEgo:priority) 1)
            posn((send gEgo:x) (send gEgo:y))
            ignoreActors()
        )
    )

)
(instance rock1 of Prop
    (properties)

    (method (init)
        (super:init())
        (self:
            view(90)
            setLoop(1)
            setCel(0)
            setPri(6)
            posn(158 153)
            ignoreActors()
        )
    )


    (method (doit)
        (super:doit())
        (if ((== (send gEgo:onControl(1)) 64) and not (send global2:script))
            (if (not (send gEgo:mover))
                (if (not local2)
                    = local2 1
                    (send gEgo:setCycle(Fwd))
                )
            )(else
                (if (local2)
                    = local2 0
                    (send gEgo:setCycle(Walk))
                )
            )
            (if (not local0)
                = local0 1
                (quake:play())
                (self:setCycle(Fwd))
                (send gEgo:
                    view(95)
                    setStep(1 1)
                )
            )
        )(else
            (if (local0)
                = local0 0
                (self:
                    setCel(0)
                    setCycle(0)
                    stopUpd()
                )
                (if (not local1 and not (send global2:script))
                    (send gEgo:
                        view(0)
                        setStep(3 2)
                        loop(
                            (switch ((send gEgo:heading))
                                (case 0
                                    3
                                )
                                (case 45
                                    0
                                )
                                (case 90
                                    0
                                )
                                (case 135
                                    0
                                )
                                (case 180
                                    2
                                )
                                (case 225
                                    1
                                )
                                (case 270
                                    1
                                )
                                (case 315
                                    1
                                )
                            )
)
                    )
                    proc0_10()
                    (send gEgo:setLoop(-1))
                )
            )
        )
    )

)
(instance rock2 of Prop
    (properties)

    (method (init)
        (super:init())
        (self:
            view(90)
            setLoop(2)
            setCel(0)
            setPri(6)
            posn(162 170)
            ignoreActors()
        )
    )


    (method (doit)
        (super:doit())
        (if ((== (send gEgo:onControl(1)) 128) and not (send global2:script))
            (if (not (send gEgo:mover))
                (if (not local3)
                    = local3 1
                    (send gEgo:setCycle(Fwd))
                )
            )(else
                (if (local3)
                    = local3 0
                    (send gEgo:setCycle(Walk))
                )
            )
            (if (not local1)
                = local1 1
                (quake:play())
                (self:setCycle(Fwd))
                (send gEgo:
                    view(95)
                    setStep(1 1)
                )
            )
            (if ((send gEgo:has(10)) and not local6)
                proc0_2()
                = local6 2
            )
        )(else
            (if (local1)
                = local1 0
                (self:
                    setCel(0)
                    setCycle(0)
                    stopUpd()
                )
                (if (not local0 and not (send global2:script))
                    (send gEgo:
                        view(0)
                        setStep(3 2)
                        loop(
                            (switch ((send gEgo:heading))
                                (case 0
                                    3
                                )
                                (case 45
                                    0
                                )
                                (case 90
                                    0
                                )
                                (case 135
                                    0
                                )
                                (case 180
                                    2
                                )
                                (case 225
                                    1
                                )
                                (case 270
                                    1
                                )
                                (case 315
                                    1
                                )
                            )
)
                    )
                    proc0_10()
                    (if (not global183)
                        proc255_0(66 10)
                        = global183 1
                    )
                    (send gEgo:setLoop(-1))
                )
            )
        )
    )

)
(instance kaboom of Sound
    (properties
        number 33
        priority 3
    )
)
(instance quake of Sound
    (properties
        number 78
        priority 2
    )
)
