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


(local
    local0

)
(instance door of Act
    (properties)
)
(instance guard of Act
    (properties)
)
(instance guard2 of Act
    (properties)
)
(instance guard3 of Act
    (properties)
)
(instance guard4 of Act
    (properties)
)
(instance public Room81 of Rm
    (properties
        picture 81
    )

    (method (init)
        (super:init())
        (door:
            view(135)
            setLoop(0)
            setCel(0)
            posn(266 116)
            setPri(4)
            init()
        )
        (guard:
            view(135)
            loop(2)
            cel(0)
            posn(254 117)
            setPri(3)
            init()
        )
        (if (global129)
            (guard4:
                view(135)
                setPri(8)
                setLoop(2)
                posn(297 121)
                init()
                stopUpd()
            )
            (guard:
                view(135)
                setPri(8)
                setLoop(2)
                posn(238 122)
                stopUpd()
            )
            (door:view(777))
            (send global2:setScript(Actions))
            (Actions:state(7))
            (Actions:seconds(12))
        )(else
            (send global2:setScript(Actions))
        )
        (send gLongSong:
            number(86)
            loop(-1)
            play()
        )
    )


    (method (doit)
        (super:doit())
        (if (<> global11 global13)
            return 
        )
        (if ((== global105 1) and (== global120 1))
            --global121
        )
        (if (((== global105 1) and (== global120 1)) and (<= global121 0))
            (send global2:drawPic(81 8))
            proc255_0(81 0)
            = global105 0
            = global120 2
        )
    )


    (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(81 1)
                    )(else
                        (if (Said('/guard,man,flunky'))
                            proc255_0(81 2)
                        )(else
                            (if (Said('/sign,soft,dog,scumsoft'))
                                proc255_0(81 3)
                            )(else
                                (if (Said('/door,entrance'))
                                    (if (< (door:y) 142)
                                        proc255_0(81 4)
                                    )(else
                                        proc255_0(81 5)
                                    )
                                )
                            )
                        )
                    )
                )(else
                    (if ((((Said('turn<on/belt') or Said('switch<on/belt')) or Said('activate/belt')) or Said('use/belt')) or Said('press/button'))
                        (if (not (send gEgo:has(16)))
                            proc255_0(81 6)
                        )(else
                            (if (<> global126 1)
                                proc255_0(81 7)
                            )(else
                                (if (== global120 2)
                                    proc255_0(81 8)
                                )(else
                                    (if (== global120 1)
                                        proc255_0(81 9)
                                    )(else
                                        = global105 1
                                        = global120 1
                                        (send global2:drawPic(82 8))
                                        proc0_10()
                                        proc255_0(81 10)
                                        = global121 350
                                    )
                                )
                            )
                        )
                    )(else
                        (if (Said('turn<off/belt') or Said('deactivate/belt'))
                            (if (not (send gEgo:has(16)))
                                proc0_9()
                            )(else
                                (if (not global126)
                                    proc255_0(81 11)
                                )(else
                                    (if (<> global105 1)
                                        proc255_0(81 12)
                                    )(else
                                        proc255_0(81 13)
                                        = global105 0
                                        = global120 0
                                        (send global2:drawPic(81 8))
                                    )
                                )
                            )
                        )(else
                            (if (((Said('enter/soft,scumsoft,dog,sign,building') or Said('go<in/soft,scumsoft,dog,sign,building')) or Said('go<to/soft,scumsoft,dog,sign,building')) or Said('enter/door'))
                                (send global2:newRoom(85))
                            )(else
                                (if (Said('disembark,disembark/'))
                                    (switch (= local0 proc255_0(81 14 81 "Ship" 1 81 "ScumSoft" 2))
                                        (case 1
                                            (send global2:newRoom(80))
                                        )
                                        (case 2
                                            (send global2:newRoom(85))
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )(else
                0
            )
    )


    (method (newRoom newRoomNumber)
        (send gLongSong:fade())
        (super:newRoom(newRoomNumber))
    )

)
(instance Actions of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = seconds 1
            )
            (case 1
                proc255_0(81 15)
                = global129 1
                (door:
                    illegalBits(0)
                    ignoreActors()
                    setMotion(MoveTo 266 142 self)
                )
            )
            (case 2
                (guard:
                    setLoop(1)
                    setCycle(Walk)
                    setStep(2 2)
                    setPri(8)
                    setMotion(MoveTo 238 122 self)
                )
            )
            (case 3
                (guard:setLoop(2))
                (guard2:
                    view(135)
                    setLoop(4)
                    setPri(3)
                    posn(249 133)
                    setCycle(Walk)
                    ignoreActors()
                    setMotion(MoveTo 269 117 self)
                    init()
                )
            )
            (case 4
                (guard3:
                    view(135)
                    setLoop(4)
                    setCycle(Walk)
                    setPri(3)
                    posn(249 133)
                    setStep(2 2)
                    setMotion(MoveTo 269 117 self)
                    init()
                )
                (guard2:
                    setPri(8)
                    setPri(9)
                    setMotion(MoveTo 323 150)
                )
            )
            (case 5
                (guard4:
                    view(135)
                    setLoop(4)
                    setCycle(Walk)
                    setPri(3)
                    posn(249 133)
                    setStep(2 2)
                    setMotion(MoveTo 269 117 self)
                    init()
                )
                (guard3:
                    setPri(8)
                    setMotion(MoveTo 323 150)
                )
            )
            (case 6
                (guard4:
                    setPri(8)
                    setMotion(MoveTo 297 121 self)
                )
            )
            (case 7
                (guard4:setLoop(2))
                proc0_10()
                proc255_0(81 16)
                = seconds 12
            )
            (case 8
                (switch (= local0 proc255_0(81 17 81 "Stay Here" 1 81 "Return to Ship" 2 81 "Enter ScumSoft" 3))
                    (case 1
                        = seconds 20
                        --state
                    )
                    (case 2
                        (send global2:newRoom(80))
                    )
                    (case 3
                        (send global2:newRoom(85))
                    )
                    (default 
                        = seconds 20
                        --state
                    )
                )
            )
        )
    )

)
