(version 2)
(include "sci.sh")
(exports
    0 Room85
)
(use "Main")
(use "Class_255_0")
(use "Cycle")
(use "Game")
(use "Feature")
(use "Obj")
(script 85)


(local
    local0
    local1
    theGuard

)
(instance guard of Prop
    (properties)
)
(instance guard2 of Prop
    (properties)
)
(instance force of View
    (properties)
)
(instance blast of Act
    (properties)
)
(instance public Room85 of Rm
    (properties
        picture 85
    )

    (method (init)
        = north (= west (= south 80))
        Load(128 123)
        Load(128 593)
        Load(128 134)
        Load(128 92)
        (super:init())
        proc0_1()
        (guard:
            view(124)
            loop(4)
            cel(0)
            posn(132 153)
            init()
        )
        (guard2:
            view(124)
            loop(4)
            cel(0)
            posn(221 122)
            init()
        )
        (switch (gNorth)
            (case 81
                proc0_2()
                (send gEgo:
                    view(0)
                    posn(324 166)
                    init()
                )
                (send global2:setScript(Actions))
            )
            (case 86
                proc0_2()
                (send gEgo:
                    view(0)
                    posn(123 169)
                    setPri(4)
                    init()
                )
                (send global2:setScript(Actions))
                (Actions:changeState(2))
            )
        )
        (if ((send gEgo:has(12)))
            (send gEgo:view(113))
        )
    )


    (method (doit)
        (super:doit())
        (if (<> global11 global13)
            return 
        )
        (if (== (Actions:state) 1)
            (if ((not global155 and ((> (send gEgo:x) 313) or ((> (send gEgo:y) 186) and (> (send gEgo:x) 174)))) and (== (send gEgo:script) 0))
                (send gEgo:setScript(turnVisible))
            )
            = local0 (send gEgo:onControl(0))
            --global121
            (if (((== global120 1) and not global155) and (<= global121 0))
                (send gEgo:setScript(turnVisible))
                = global120 2
            )
            (if (& local0 $0004)
                (Actions:changeState(5))
            )(else
                (if (& local0 $1000)
                    (Actions:changeState(6))
                )(else
                    (if (& local0 $2000)
                        (Actions:changeState(7))
                    )(else
                        (if (& local0 $0040)
                            (send global2:setScript(walkDown))
                        )
                    )
                )
            )
            (if (== global105 0)
                (Actions:changeState(8))
            )
        )
    )


    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 1
        )
        return 
            (if (== (send pEvent:type) 128)
                (if (Said('look>'))
                    (if ((Said('/area') or Said('/around')) or Said('[<around][/!*]'))
                        proc255_0(85 0)
                    )(else
                        (if (Said('/guard'))
                            proc255_0(85 1)
                        )(else
                            (if (Said('/beam'))
                                proc255_0(85 2)
                            )(else
                                proc255_0(85 3)
                                (send pEvent:claimed(1))
                            )
                        )
                    )
                )(else
                    (if (Said('turn<off/belt') or Said('deactivate/belt'))
                        proc255_0(85 4)
                    )(else
                        (if (Said('attack,beat,converse,kiss/guard,man,flunky') or Said('get/gun'))
                            proc255_0(85 5)
                        )(else
                            (if (Said('turn<off/beam'))
                                proc255_0(85 6)
                            )
                        )
                    )
                )
            )(else
                0
            )
    )


    (method (newRoom newRoomNumber)
        (if ((>= (send gEgo:y) 189) and (<= (send gEgo:x) 188))
            ++local1
        )(else
            (super:newRoom(newRoomNumber))
        )
    )

)
(instance Actions of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (if (== global120 1)
                    (send gEgo:view(123))
                )
                (send gEgo:setMotion(MoveTo 303 166 self))
            )
            (case 1
                proc0_3()
                (send global2:east(80))
            )
            (case 2
                (send gEgo:
                    setLoop(0)
                    illegalBits(0)
                    ignoreActors()
                    setMotion(MoveTo 159 129 self)
                )
            )
            (case 3
                (send gEgo:
                    setPri(-1)
                    setMotion(MoveTo 204 150 self)
                )
            )
            (case 4
                proc0_1()
                (self:changeState(1))
            )
            (case 5
                proc0_2()
                (force:
                    view(124)
                    setLoop(1)
                    setCel(0)
                    setPri(1)
                    ignoreActors()
                    posn(253 116)
                    init()
                    addToPic()
                )
                (send gEgo:
                    view(124)
                    setLoop(3)
                    setCycle(Fwd)
                )
                = state 13
                = seconds 7
            )
            (case 6
                proc0_2()
                (force:
                    view(124)
                    setLoop(1)
                    setCel(1)
                    setPri(12)
                    ignoreActors()
                    posn(75 174)
                    init()
                    addToPic()
                )
                (send gEgo:
                    view(124)
                    setLoop(3)
                    setCycle(Fwd)
                )
                = state 13
                = seconds 7
            )
            (case 7
                proc0_2()
                (force:
                    view(124)
                    setLoop(1)
                    setCel(2)
                    setPri(14)
                    ignoreActors()
                    posn(99 187)
                    init()
                    addToPic()
                )
                (send gEgo:
                    view(124)
                    setLoop(2)
                    setCycle(Fwd)
                )
                = state 13
                = seconds 7
            )
            (case 8
                = seconds 1
                (send gEgo:
                    view(
                        (if ((send gEgo:has(12)))
                            113
                        )(else
                            0
                        )
)
                    loop(2)
                )
            )
            (case 9
                proc0_2()
                proc0_10()
                (send gLongSong:
                    number(44)
                    loop(1)
                    priority(2)
                    play()
                )
                (if ((send gEgo:inRect(24 41 125 184)))
                    (guard:
                        setLoop(5)
                        cel(0)
                        setCycle(End self)
                    )
                    = theGuard guard
                )(else
                    (if (> (send gEgo:y) 142)
                        (guard:setCycle(End self))
                        = theGuard guard
                    )(else
                        (if ((send gEgo:inRect(107 118 209 147)))
                            (guard2:
                                setLoop(5)
                                cel(0)
                                setCycle(End self)
                            )
                            = theGuard guard2
                        )(else
                            (guard2:setCycle(End self))
                            = theGuard guard2
                        )
                    )
                )
            )
            (case 10
                proc0_2()
                (blast:
                    view(593)
                    setLoop(
                        (if (== (send theGuard:loop) 4)
                            6
                        )(else
                            7
                        )
)
                    cel(0)
                    setCycle(End)
                    setStep(30 10)
                    ignoreActors()
                    illegalBits(0)
                    setPri((send gEgo:priority))
                    x(
                        (if (== (send theGuard:loop) 4)
                            + (send theGuard:x) 30
                        )(else
                            - (send theGuard:x) 30
                        )
)
                    y(- (send theGuard:y) 18)
                    init()
                )
                proc0_10()
                (blast:setMotion(MoveTo (send gEgo:x) (- (send gEgo:y) 18) self))
            )
            (case 11
                (blast:dispose())
                (send gEgo:
                    setLoop(
                        (if ((send gEgo:has(12)))
                            5
                        )(else
                            2
                        )
)
                    view(92)
                    cel(0)
                    setCycle(Fwd)
                )
                = seconds 7
            )
            (case 12
                proc0_17(901 0 7 99)
            )
            (case 14
                proc255_0(85 7)
                (self:changeState(16))
            )
            (case 16
                proc0_17(901 0 11 18)
            )
        )
    )

)
(instance turnVisible of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:
                    setMotion(0)
                    view(134)
                    setLoop(4)
                    setCycle(Fwd)
                )
                proc0_10()
                = seconds 2
            )
            (case 1
                proc255_0(85 8)
                (send gEgo:setLoop(3))
                = seconds 2
            )
            (case 2
                proc255_0(85 9)
                (send gEgo:setLoop(1))
                = seconds 3
            )
            (case 3
                (send gEgo:
                    setCycle(0)
                    setCel(0)
                )
                = global105 0
            )
        )
    )

)
(instance walkDown of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:
                    setPri(4)
                    setLoop(1)
                    illegalBits(0)
                    ignoreActors()
                    setMotion(MoveTo 123 169 self)
                )
            )
            (case 1
                (send global2:newRoom(86))
            )
        )
    )

)
