(include "sci.sh")
(use "Main")
(use "Class_255_0")
(use "rmnScript")
(use "SQRoom")
(use "MCyc")
(use "PolyPath")
(use "Polygon")
(use "Class_950_0")
(use "n958")
(use "StopWalk")
(use "Sound")
(use "Cycle")
(use "InvI")
(use "IconI")
(use "PicView")
(use "Obj")
(script 540)


(local
    local0[37] = (0 0 155 138 0 1 155 138 0 1 155 138 0 1 155 138 0 2 155 138 0 3 155 138 0 4 155 138 0 5 155 138 0 6 155 138 32768 )
    local37[33] = (0 0 0 0 1 0 145 108 1 1 145 108 1 2 145 108 1 3 145 108 1 4 145 107 1 5 149 101 0 0 0 0 32768 )
    local70

)
(procedure (localproc_0044 param1 param2 param3 param4)
    (var temp0, temp1, temp2)
    (aSound:
        number(105)
        loop(1)
        vol(127)
        play()
    )
    (if (< param1 param3)
        = temp0 (- param1 1)
        = temp1 (+ param3 1)
    )(else
        = temp0 (- param3 1)
        = temp1 (+ param1 1)
    )
    = temp2 Graph(7 temp0 (- param2 1) temp1 (+ param4 1) 1)
    Graph(4 param1 param2 param3 param4 global143 -1 -1)
    Graph(13 temp0 - param2 1 temp1 + param4 1)
    Wait(1)
    Wait(4)
    Graph(8 temp2)
    Graph(13 temp0 - param2 1 temp1 + param4 1)
)


(instance aSound of Sound
    (properties)
)
(instance public rm540 of SQRoom
    (properties
        picture 540
        north 541
        west 535
        vanishingX 0
        vanishingY 65476
    )

    (method (init)
        proc958_0(128 515 300 7 13 511)
        proc958_0(132 105 131 124 154 155 820 825)
        (tunnel:init())
        (switch (gWest)
            (case 541
                (self:setScript(enterScript))
            )
            (case 556
                proc958_0(128 558 556)
                (send gEgo:
                    moveHead(0)
                    setLoop(0)
                    x(115)
                    y(142)
                    init()
                )
                proc0_1(0 0 4)
                proc0_9(4)
                (rogerJr:init())
                (send gLongSong2:
                    number(871)
                    vol(127)
                    loop(-1)
                    flags(1)
                )
                (self:setScript(endScript))
            )
            (case west
                (self:
                    style(41)
                    setScript(enterFromWest 0 proc0_6(32))
                )
            )
            (default 
                (send gEgo:
                    x(160)
                    y(160)
                )
            )
        )
        (if (<> gWest 541)
            (doorBottom:
                init()
                stopUpd()
            )
            (doorTop:
                init()
                stopUpd()
            )
        )
        (send gEgo:
            view(0)
            headView(4)
            normal(1)
            moveHead(1)
            setCycle(StopWalk 4)
            init()
        )
        (super:init())
        (self:setRegions(709))
        (send global2:addObstacle((send ((Polygon:new())):
                type(2)
                init(0 151 53 151 59 189 0 189)
                yourself()
            )
 (send ((Polygon:new())):
                type(2)
                init(0 0 319 0 319 189 241 135 254 135 231 121 271 108 210 56 193 56 215 86 163 86 159 78 136 78 147 88 87 88 62 53 0 53)
                yourself()
            )
))
    )


    (method (doit)
        (super:doit())
        (if (script)
        )(else
            (if (< (send gEgo:x) 28)
                (send global2:newRoom(535))
            )
        )
    )

)
(instance police of Actor
    (properties
        x 259
        y 147
        description "sequel police"
        lookStr "You look briefly, careful not to attract any attention."
        view 7
        loop 2
        cel 2
    )

    (method (init)
        (super:init())
        = local70 75
    )


    (method (doit)
        (super:doit())
        (if (not --local70 and (<> (send global2:script) ScriptID(709 1)))
            (send global2:setScript(0))
            (self:setScript(policeScript))
        )
    )


    (method (doVerb param1 param2)
        (switch (param1)
            (case 4
                = local70 1
            )
            (default 
                (super:doVerb(param1 rest param2))
            )
        )
    )

)
(instance doorTop of Actor
    (properties
        x 141
        y 77
        z aSound
        description "door"
        sightAngle 90
        view 515
        priority 3
        signal 26640
        illegalBits 0
    )

    (method (doVerb param1 param2)
        (switch (param1)
            (case 1
                (if (proc0_6(7))
                    Print("Thanks to your janitorial ingenuity, the doorlock is now destroyed and you may enter and leave at will.")
                )(else
                    Print("Your inate sense of curiosity makes you wish you knew the way to open this thing.")
                )
            )
            (case 2
                proc0_2()
                (send global2:setScript(doorScript))
            )
            (case 3
                (switch (param2)
                    (case 5
                        (if ((== (send ((Inv:at(5))):cel) 2) and not proc0_6(7))
                            proc0_2()
                            (send global2:setScript(acidScript))
                        )(else
                            (if (== (send ((Inv:at(5))):cel) 2)
                                Print("There is no reason to do that again.")
                            )(else
                                (super:doVerb(param1))
                            )
                        )
                    )
                    (default 
                        (super:doVerb(param1))
                    )
                )
            )
            (default 
                (super:doVerb(param1))
            )
        )
    )

)
(instance doorBottom of Actor
    (properties
        x 141
        y 76
        description "door"
        view 515
        cel 1
        priority 2
        signal 26640
        illegalBits 0
    )

    (method (doVerb param1)
        (switch (param1)
            (case 1
                (if (proc0_6(7))
                    Print("Thanks to your janitorial ingenuity, the doorlock is now destroyed and you may enter and leave at will.")
                )(else
                    Print("Your inate sense of curiosity makes you wish you knew the way to open this thing.")
                )
            )
        )
    )

)
(instance enterFromWest of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:
                    x(5)
                    setMotion(MoveTo 50 (send gEgo:y) self)
                )
                (if (not register)
                    (police:init())
                )
            )
            (case 1
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance enterScript of Script
    (properties)

    (method (changeState newState)
        (var temp0[4])
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gLongSong2:
                    number(535)
                    loop(-1)
                    playBed()
                )
                (send gEgo:
                    x(129)
                    y(70)
                    setLoop(4)
                    illegalBits(0)
                    setMotion(PolyPath 165 96 self)
                )
            )
            (case 1
                (blopSound:
                    init()
                    number(154)
                    vol(127)
                    loop(-1)
                    play()
                )
                (doorTop:
                    init()
                    y(35)
                    setMotion(MoveTo (doorTop:x) 77 self)
                )
                (doorBottom:
                    init()
                    y(95)
                    setMotion(MoveTo (doorBottom:x) 76)
                )
            )
            (case 2
                (blopSound:
                    number(155)
                    vol(127)
                    loop(0)
                    play()
                )
                proc0_3()
                (send gEgo:setLoop(-1))
                (send client:setScript(0))
            )
        )
    )

)
(instance policeScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (police:setHeading(315))
                = cycles 4
            )
            (case 1
                Print("Uh oh...")
                (police:
                    view(13)
                    setLoop(1)
                    setCel(0)
                )
                = cycles 1
            )
            (case 2
                (police:setCycle(End self))
                localproc_0044(- (send gEgo:y) 32 (send gEgo:x) - (police:y) 27 (police:x))
            )
            (case 3
                (send gEgo:
                    view(511)
                    setLoop(0)
                    setMotion(0)
                    setCel(0)
                    setCycle(End self)
                )
            )
            (case 4
                proc0_10(8)
            )
        )
    )

)
(instance doorScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gEgo:setMotion(PolyPath 155 78 self))
            )
            (case 1
                = cycles 5
            )
            (case 2
                (if (proc0_6(7))
                    = cycles 1
                )(else
                    Print("Try as you might, none of the codes you punch in seem to have any effect on the door.")
                    proc0_3()
                    (self:dispose())
                )
            )
            (case 3
                (send gLongSong:
                    number(124)
                    loop(0)
                    play(self)
                )
            )
            (case 4
                (blopSound:
                    init()
                    number(154)
                    vol(127)
                    loop(-1)
                    play()
                )
                (doorTop:setMotion(MoveTo (doorTop:x) 37 self))
                (doorBottom:setMotion(MoveTo (doorBottom:x) 107 self))
            )
            (case 5
                0
            )
            (case 6
                (blopSound:
                    stop()
                    loop(0)
                )
                (send gEgo:setMotion(MoveTo 148 73 self))
            )
            (case 7
                (send gEgo:setMotion(MoveTo 90 35 self))
            )
            (case 8
                (blopSound:
                    number(154)
                    vol(127)
                    loop(-1)
                    play()
                )
                (doorBottom:setMotion(MoveTo (doorBottom:x) 76))
                (doorTop:setMotion(MoveTo (doorTop:x) 77 self))
            )
            (case 9
                (blopSound:
                    number(155)
                    vol(127)
                    loop(0)
                    play(self)
                )
            )
            (case 10
                (send gLongSong2:fade())
                (send global2:newRoom(541))
            )
        )
    )

)
(instance acidScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gEgo:setMotion(PolyPath 155 78 self))
            )
            (case 1
                (send gLongSong:
                    number(825)
                    loop(1)
                    play()
                )
                (blopSound:
                    init()
                    vol(127)
                    loop(0)
                    play(self)
                )
                (send gEgo:
                    normal(0)
                    view(515)
                    loop(1)
                    cel(0)
                    cycleSpeed(1)
                )
            )
            (case 2
                (send gEgo:setCycle(End self))
            )
            (case 3
                = local70 1
                = cycles 5
            )
            (case 4
                (send gLongSong:stop())
                (blopSound:dispose())
                proc0_1(3 0)
                = cycles 2
            )
            (case 5
                Print("Well, I don't think there's much left of the lock now.")
                proc0_11(7 10)
                (send ((Inv:at(5))):
                    cel(1)
                    cursor(15)
                )
                (send ((IconBar:at(6))):cursor(15))
                proc0_3()
                (send client:setScript(0))
            )
        )
    )

)
(instance endScript of rmnScript
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gLongSong:fade())
                = cycles 10
            )
            (case 1
                proc0_2()
                (send gLongSong2:playBed())
                (rogerJr:setCycle(MCyc @local0))
                = cycles 1
            )
            (case 2
                (blast:
                    init()
                    setCycle(MCyc @local37)
                )
                = cycles 4
            )
            (case 3
                (rip:
                    init()
                    setCycle(End self)
                )
            )
            (case 4
                (blast:dispose())
                (rip:
                    setLoop(4)
                    setCycle(Fwd)
                )
                = cycles 1
            )
            (case 5
                (send gEgo:setMotion(MoveTo 101 124 self))
            )
            (case 6
                (self:save1(proc0_12("\"Dad?\"" 67 2 2 28 global150 29 global129 30 1 70 315)))
                (send gEgo:setLoop(4))
                = seconds 3
            )
            (case 7
                (self:restore())
                = cycles 1
            )
            (case 8
                (self:save1(proc0_12("\"I'm glad I got to see you, even if for only a few minutes. Xenon owes you a lot. Goodbye, Dad.\"" 67 2 2 28 global150 29 global129 30 1 70 315)))
                = seconds 10
            )
            (case 9
                (self:restore())
                (send gEgo:setLoop(3))
                = cycles 1
            )
            (case 10
                (send gEgo:
                    view(558)
                    setCel(0)
                    cycleSpeed(1)
                    setCycle(End self)
                )
            )
            (case 11
                (send global2:newRoom(21))
            )
        )
    )

)
(instance rogerJr of Prop
    (properties
        x 155
        y 139
        view 556
    )
)
(instance blast of Prop
    (properties
        x 156
        y 110
        view 556
        loop 1
    )
)
(instance rip of Prop
    (properties
        x 99
        y 93
        view 556
        loop 3
    )
)
(instance tunnel of Feature
    (properties
        nsBottom 189
        nsRight 319
        description "tunnel"
        sightAngle 180
        onMeCheck 16
        lookStr "This tunnel extends out over pipes and beams and toward the center of the structure."
    )
)
(instance blopSound of Sound
    (properties
        number 820
        priority 5
    )
)
