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


(local
    local0
    local1
    local2

)
(instance public rm069 of Rm
    (properties
        picture 69
        horizon 82
        north 66
        east 70
    )

    (method (init)
        (var temp0[50])
        proc0_3()
        (self:setRegions(600))
        Load(128 92)
        (if (not (send gEgo:has(9)))
            (anemo:init())
            (pole:init())
        )
        (if (not global253)
            Load(128 93)
            Load(132 38)
            Load(132 44)
            (pirate1:init())
            (pirate2:init())
            = local0 30
        )
        (super:init())
        (switch (gNorth)
            (case 66
                (send gEgo:
                    posn(81 84)
                    init()
                )
            )
            (case 70
                (send gEgo:
                    posn(317 
                        (if (< (send gEgo:y) 80)
                            83
                        )(else
                            (send gEgo:y)
                        )
)
                    init()
                )
            )
            (case 690
                (send gEgo:
                    view(0)
                    loop(0)
                    cel(0)
                    posn(70 155)
                    init()
                )
                (send gEgo:setLoop(-1))
            )
        )
        (TheMenuBar:draw())
        (SL:enable())
    )


    (method (doit)
        (var gEgoOnControl, temp1[50])
        (super:doit())
        (if (local1)
            (send global2:newRoom(690))
        )
        (if (global219)
            --local0
        )
        (if ((== local0 1) and not script)
            = local0 0
            (send global2:setScript(LeaveScript))
        )
        (if (not (send global2:script))
            = gEgoOnControl (send gEgo:onControl())
            (if (== gEgoOnControl 3)
                (send gEgo:
                    setPri(3)
                    illegalBits(0)
                )
                = global180 1
            )(else
                (if ((== gEgoOnControl 5) and not global253)
                    (send global2:setScript(shootScript))
                )
            )
        )
    )


    (method (handleEvent pEvent)
        (super:handleEvent(pEvent))
        (if ((<> (send pEvent:type) 128) or (send pEvent:claimed))
            return 
        )
        (if (Said('look>'))
            (if (Said('/gun'))
                (if (global253)
                    proc255_0(69 0)
                )(else
                    proc255_0(69 1)
                )
            )(else
                (if (Said('/[around,area]'))
                    (if (global253)
                        proc255_0(69 2)
                    )(else
                        proc255_0(69 3)
                    )
                )(else
                    (if (Said('/craft'))
                        (if (local2)
                            proc255_0(69 4)
                        )(else
                            (send pEvent:claimed(0))
                        )
                    )(else
                        (if (Said('/station,device,device,equipment[<seismic,research]'))
                            (if ((send gEgo:has(9)))
                                proc255_0(69 5)
                            )(else
                                proc255_0(69 6)
                            )
                        )(else
                            (if (Said('/pole'))
                                (if (proc0_13(9))
                                    proc255_0(69 7)
                                )(else
                                    (send pEvent:claimed(0))
                                )
                            )(else
                                (if (Said('/anemometer'))
                                    proc255_0(69 8)
                                )(else
                                    (if (Said('/antenna'))
                                        proc255_0(69 9)
                                    )(else
                                        (if (Said('/box'))
                                            (if ((send gEgo:inRect(220 141 254 155)))
                                                proc255_0(69 10)
                                            )(else
                                                proc255_0(69 11)
                                            )
                                        )(else
                                            (if (Said('<in,in,through/scope'))
                                                (if ((send gEgo:inRect(56 139 76 159)))
                                                    (send global2:setScript(ScopeScript))
                                                )(else
                                                    proc255_0(69 12)
                                                )
                                            )(else
                                                (if (Said('/scope'))
                                                    proc255_0(69 13)
                                                )(else
                                                    (if (Said('/rock,boulder'))
                                                        proc255_0(69 14)
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )
        )(else
            (if (Said('get>'))
                (if (Said('/antenna,station,device,equipment[<seismic,research]'))
                    proc255_0(69 15)
                )(else
                    (if (Said('/scope') or Said('/box'))
                        proc255_0(69 16)
                    )(else
                        (if (Said('/anemometer'))
                            (if ((send gEgo:has(9)))
                                proc255_0(69 17)
                            )(else
                                (if ((send gEgo:inRect(230 129 260 143)))
                                    proc255_0(69 18)
                                )(else
                                    proc0_5()
                                )
                            )
                        )(else
                            (if (Said('/pole'))
                                (if ((send gEgo:has(9)))
                                    proc255_0(69 19)
                                )(else
                                    (if ((send gEgo:inRect(230 129 260 143)))
                                        proc255_0(69 20)
                                        (send gEgo:get(9))
                                        (pole:dispose())
                                        (send global1:changeScore(10))
                                        (anemo:dispose())
                                    )(else
                                        proc0_5()
                                    )
                                )
                            )(else
                                (if (Said('/detonator'))
                                    (if ((send gEgo:has(10)))
                                        proc255_0(69 19)
                                    )(else
                                        (if ((send gEgo:inRect(220 141 254 155)))
                                            proc255_0(69 21)
                                            (send global1:changeScore(10))
                                            (send gEgo:get(10))
                                        )(else
                                            proc0_5()
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )(else
                (if (Said('conceal'))
                    proc255_0(69 22)
                )(else
                    (if (Said('use/scope'))
                        (if ((send gEgo:inRect(56 139 76 159)))
                            (send global2:setScript(ScopeScript))
                        )(else
                            proc255_0(69 12)
                        )
                    )(else
                        (if (Said('attack/man,flunky'))
                            (if (global253)
                                proc255_0(69 23)
                            )(else
                                proc255_0(69 24)
                            )
                        )(else
                            (if (Said('converse[/man,flunky]'))
                                (if (global253)
                                    proc255_0(69 25)
                                )(else
                                    proc255_0(69 26)
                                )
                            )(else
                                (if (Said('open/box'))
                                    proc255_0(69 27)
                                )
                            )
                        )
                    )
                )
            )
        )
    )


    (method (newRoom newRoomNumber)
        (if (not script)
            (send global7:eachElementDo(91))
            (if (global256)
                ++global593
            )
            (super:newRoom(newRoomNumber))
        )
    )

)
(instance ScopeScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:illegalBits(0))
                (if ((send gEgo:inRect(67 139 76 149)))
                    (send gEgo:setMotion(MoveTo 63 155 self))
                )(else
                    = cycles 2
                )
            )
            (case 1
                (send gEgo:setMotion(MoveTo 70 155 self))
            )
            (case 2
                (send gEgo:
                    view(92)
                    setLoop(4)
                    cel(0)
                    illegalBits(-32768)
                    setCycle(End self)
                )
            )
            (case 3
                = local1 1
                proc0_3()
                (send global2:setScript(0))
            )
        )
    )

)
(instance shootScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:setMotion(MoveTo 108 123 self))
                (pirate1:
                    setScript(0)
                    setLoop(3)
                    setCycle(End)
                )
            )
            (case 1
                (send gEgo:setCycle(0))
                (jello:play())
                (pirate1:
                    setLoop(4)
                    setCycle(End self)
                )
            )
            (case 2
                (blast:
                    init()
                    setCycle(End self)
                )
                (pirate1:
                    setLoop(3)
                    setCel(5)
                    setCycle(Beg)
                )
            )
            (case 3
                (pirate1:stopUpd())
                (blast:dispose())
                (send gEgo:
                    view(92)
                    setLoop(2)
                    setCycle(Fwd)
                )
                = seconds 5
            )
            (case 4
                proc255_0(69 28)
                proc0_17(0 0 7 15)
            )
        )
    )

)
(instance LeaveScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (User:
                    canControl(0)
                    canInput(1)
                )
                (send gEgo:
                    setCycle(0)
                    setMotion(0)
                )
                (pirate2:
                    setScript(0)
                    setLoop(0)
                    setCycle(Walk)
                    ignoreControl(1)
                    setMotion(MoveTo 71 158 self)
                )
                (pirate1:
                    setScript(0)
                    setLoop(0)
                    setCycle(Walk)
                    setMotion(MoveTo 329 (pirate1:y))
                )
            )
            (case 1
                (pirate2:setMotion(MoveTo 329 (pirate2:y) self))
            )
            (case 2
                (pirate1:dispose())
                (pirate2:dispose())
                proc255_0(69 29)
                (zoom:play())
                = global253 1
                = seconds 3
            )
            (case 3
                = local2 1
                (ship:
                    init()
                    setMotion(MoveTo 290 25 self)
                )
            )
            (case 4
                (ship:
                    setCel(1)
                    setMotion(MoveTo 241 25 self)
                )
            )
            (case 5
                (ship:
                    setCel(2)
                    setMotion(MoveTo 228 24 self)
                )
            )
            (case 6
                (ship:
                    setCel(3)
                    setMotion(MoveTo 230 17 self)
                )
            )
            (case 7
                (ship:
                    setCel(4)
                    setMotion(MoveTo 238 13 self)
                )
            )
            (case 8
                (ship:
                    setCel(5)
                    setMotion(MoveTo 245 10 self)
                )
            )
            (case 9
                (ship:
                    setCel(6)
                    setMotion(MoveTo 255 0 self)
                )
            )
            (case 10
                = local2 0
                (ship:dispose())
                (send gEgo:setCycle(Walk))
                proc0_3()
                (send global2:setScript(0))
            )
        )
    )

)
(instance p1Script of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = seconds Random(5 10)
            )
            (case 1
                (send client:setCycle(End self))
            )
            (case 2
                (send client:stopUpd())
                (self:changeState(0))
            )
        )
    )

)
(instance p2Script of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = seconds Random(5 10)
            )
            (case 1
                (send client:setCycle(End self))
            )
            (case 2
                (send client:stopUpd())
                (self:changeState(0))
            )
        )
    )

)
(instance pirate1 of Act
    (properties)

    (method (init)
        (super:init())
        (self:
            view(93)
            setLoop(2)
            setCel(0)
            setPri(-1)
            posn(215 126)
            ignoreActors(1)
            setScript(p1Script)
        )
    )

)
(instance pirate2 of Act
    (properties)

    (method (init)
        (super:init())
        (self:
            view(93)
            setLoop(6)
            setCel(0)
            setPri(-1)
            posn(75 154)
            ignoreActors(1)
            setScript(p2Script)
        )
    )


    (method (handleEvent pEvent)
        (super:handleEvent(pEvent))
        (if ((<> (send pEvent:type) 128) or (send pEvent:claimed))
            return 
        )
        (if (Said('look/flunky,man,clerk'))
            proc255_0(69 30)
        )
    )

)
(instance ship of Act
    (properties)

    (method (init)
        (super:init())
        (self:
            view(92)
            setLoop(3)
            setCel(0)
            setStep(10 5)
            setPri(15)
            x(332)
            y(25)
            ignoreActors(1)
            ignoreHorizon(1)
            ignoreControl(1)
        )
    )

)
(instance blast of Prop
    (properties)

    (method (init)
        (super:init())
        (self:
            view(93)
            setLoop(5)
            setCel(0)
            setPri(8)
            posn(153 110)
            ignoreActors(1)
        )
    )

)
(instance pole of Prop
    (properties)

    (method (init)
        (super:init())
        (self:
            view(92)
            posn(248 134)
            setLoop(1)
            setCel(0)
            setPri(10)
            ignoreActors(1)
        )
    )

)
(instance anemo of Prop
    (properties)

    (method (init)
        (super:init())
        (self:
            view(92)
            setLoop(0)
            setCel(0)
            setPri(11)
            posn(247 99)
            ignoreActors(1)
            setCycle(Fwd)
            cycleSpeed(0)
        )
    )

)
(instance jello of Sound
    (properties
        number 44
        priority 1
    )
)
(instance zoom of Sound
    (properties
        number 38
        priority 1
    )
)
