(version 2)
(include "sci.sh")
(exports
    0 panorama
)
(use "Main")
(use "PolyPath")
(use "Timer")
(use "Cycle")
(use "Game")
(use "User")
(use "Obj")
(script 50)


(local
    local0
    local1
    local2 =     1
    local3
    gOwnerMoveSpeed

)
(procedure (localproc_04a8 param1)
    (if (Random(0 1) and proc0_6(3))
        = global365 11
        return 
    )
    (switch (param1)
        (case 4
            (if (proc0_6(65) and not proc0_6(102))
                = global365 6
            )(else
                (if (== gClientModNum 180)
                    (if (not proc0_6(109))
                        = global365 8
                    )(else
                        (switch (Random(0 2))
                            (case 0
                                = global365 575
                            )
                            (case 1
                                = global365 590
                            )
                            (default 
                                = global365 595
                            )
                        )
                    )
                )(else
                    (if (proc0_6(102))
                        (if (Random(0 1))
                            = global365 6
                        )(else
                            (switch (Random(0 2))
                                (case 0
                                    = global365 580
                                )
                                (case 1
                                    = global365 565
                                )
                                (default 
                                    = global365 585
                                )
                            )
                        )
                    )(else
                        (if (global121)
                            (switch (Random(0 7))
                                (case 0
                                    = global365 580
                                )
                                (case 1
                                    = global365 565
                                )
                                (case 2
                                    = global365 585
                                )
                                (case 3
                                    (if (== gClientModNum 180)
                                        (if (Random(0 1))
                                            = global365 575
                                        )(else
                                            = global365 590
                                        )
                                    )(else
                                        = global365 595
                                    )
                                )
                                (default 
                                    = global365 595
                                )
                            )
                        )(else
                            (switch (Random(0 6))
                                (case 0
                                    = global365 580
                                )
                                (case 1
                                    = global365 565
                                )
                                (case 2
                                    = global365 585
                                )
                                (case 3
                                    (if (== gClientModNum 180)
                                        (if (Random(0 1))
                                            = global365 575
                                        )(else
                                            = global365 590
                                        )
                                    )(else
                                        = global365 595
                                    )
                                )
                                (default 
                                    (if ((proc0_6(132) and proc0_6(133)) and not proc0_6(116))
                                        = global365 10
                                    )(else
                                        = global365 580
                                    )
                                )
                            )
                        )
                    )
                )
            )
        )
        (case 2
            (if (Random(0 3))
                = global365 585
            )(else
                (switch (Random(0 1))
                    (case 0
                        = global365 565
                    )
                    (case 1
                        = global365 560
                    )
                )
            )
            (if (== param1 4)
                proc0_4(34)
            )
        )
        (case 4096
            (switch (Random(0 1))
                (case 0
                    = global365 590
                )
                (case 1
                    = global365 575
                )
            )
            proc0_4(34)
        )
        (case 16384
            (if ((proc999_5(gClientModNum 150 160) and proc0_6(83)) and not proc0_6(99))
                (switch (Random(0 7))
                    (case 0
                        = global365 565
                    )
                    (case 1
                        = global365 585
                    )
                    (default 
                        (if (((send gOwner:inRect(171 85 313 115)) and (== gClientModNum 150)) or ((send gOwner:inRect(6 62 101 146)) and (== gClientModNum 160)))
                            = gGClientModNum_2 gClientModNum
                            = global365 2
                            = gGOwnerX_3 (send gOwner:x)
                            = gGOwnerY_3 (send gOwner:y)
                        )(else
                            (if (Random(0 1))
                                = global365 565
                            )(else
                                = global365 585
                            )
                        )
                    )
                )
            )(else
                (switch (Random(0 1))
                    (case 0
                        = global365 565
                    )
                    (case 1
                        = global365 560
                    )
                )
            )
        )
    )
)


(procedure (localproc_07df param1)
    (if (Random(0 1) and proc0_6(3))
        = global365 11
        return 
    )
    = global365 
        (switch (Random(0 50))
            (case 0
                4
            )
            (case 1
                (if (== param1 16384)
                    0
                )(else
                    4
                )
            )
            (case 2
                (if (== param1 16384)
                    3
                )(else
                    4
                )
            )
            (case 3
                (if ((proc0_6(2) and not (send ((send gInv:at(24))):amount)) and not Random(0 9))
                    11
                )(else
                    4
                )
            )
            (case 4
                5
            )
            (case 5
                5
            )
            (default 
                999
            )
        )
)


(class PanoRoom of Rm
    (properties
        script 0
        number 0
        modNum -1
        noun 0
        timer 0
        keep 0
        initialized 0
        picture 0
        style $ffff
        horizon 0
        controls 0
        north 0
        east 0
        south 0
        west 0
        curPic 0
        picAngle 0
        vanishingX 160
        vanishingY 0
        obstacles 0
        inset 0
        toX 0
        toY 0
    )

    (method (init param1)
        (send gQg3Walkers:addToFront(self))
        (super:init(rest param1))
    )


    (method (dispose)
        (send gQg3Walkers:delete(self))
        (super:dispose())
    )


    (method (doVerb theVerb)
        (switch (theVerb)
            (case 3
                (self:toX((send ((User:curEvent)):x)))
                (self:toY((send ((User:curEvent)):y)))
                (send gOwner:setMotion(PolyPath toX toY global2))
            )
            (case 74
                proc0_4(143)
                = global365 74
                = gGOwnerX (send gOwner:x)
                = gGOwnerY (send gOwner:y)
                (send global2:newRoom(0))
            )
            (default 
                (super:doVerb(theVerb))
            )
        )
    )


    (method (newRoom newRoomNumber)
        (if (not newRoomNumber and not proc0_6(130))
            (if ((== (send gOwner:onControl(1)) 4) or (== (send gOwner:onControl(1)) 4096))
                (if (not global365)
                    = global365 999
                )
                = newRoomNumber 700
            )(else
                = newRoomNumber 400
            )
        )(else
            (if (proc0_6(130))
                = newRoomNumber 310
            )
        )
        proc0_2()
        (super:newRoom(newRoomNumber))
    )

)
(instance public panorama of Rgn
    (properties)

    (method (init param1)
        (var temp0, temp1)
        proc0_5(143)
        = global365 999
        = global411 3
        = temp0 PalVary(pvGET_CURRENT_STEP)
        (if (temp0)
            = temp1 (/ (- 64 (= temp0 PalVary(pvGET_CURRENT_STEP))) 10)
            PalVary(pvCHANGE_TICKS temp1)
        )
        (switch ((send gOwner:moveSpeed))
            (case 0
                = gOwnerMoveSpeed 3
            )
            (case 1
                = gOwnerMoveSpeed 4
            )
            (case 2
                = gOwnerMoveSpeed 5
            )
            (default 
                = gOwnerMoveSpeed (send gOwner:moveSpeed)
            )
        )
        (send gOwner:
            view(151)
            setLoop(0)
            cel(0)
            setCycle(Walk)
            cycleSpeed(gOwnerMoveSpeed)
            moveSpeed(gOwnerMoveSpeed)
            setStep(1 1)
            setScale(0)
            init()
        )
        = local0 
            (switch (gGClientModNum)
                (case 400
                    50
                )
                (case 150
                    50
                )
                (case 280
                    12
                )
                (case 410
                    15
                )
                (case 420
                    25
                )
                (case 390
                    12
                )
                (case 600
                    22
                )
                (case 750
                    10
                )
                (case 720
                    16
                )
                (default 
                    9
                )
            )
        = local0 (/ 60 global209)
        (if ((((== gGClientModNum 400) or (== gGClientModNum 380)) or (== gGClientModNum 700)) and not proc0_6(92))
            (Timer:setTicks(30 self))
        )
        (super:init(rest param1))
    )


    (method (doit param1)
        (var temp0, temp1, temp2)
        (super:doit(rest param1))
        (if (<> (send gOwner:moveSpeed) gOwnerMoveSpeed)
            (switch ((send gOwner:moveSpeed))
                (case 0
                    = gOwnerMoveSpeed 3
                )
                (case 1
                    = gOwnerMoveSpeed 4
                )
                (case 2
                    = gOwnerMoveSpeed 5
                )
                (default 
                    = gOwnerMoveSpeed (send gOwner:moveSpeed)
                )
            )
            (send gOwner:
                moveSpeed(gOwnerMoveSpeed)
                cycleSpeed(gOwnerMoveSpeed)
            )
        )
        (if ((<> (send gOwner:xLast) gGOwnerX) or (<> (send gOwner:yLast) gGOwnerY))
            = gGOwnerX (send gOwner:xLast)
            = gGOwnerY (send gOwner:yLast)
            (if (not --local2)
                DrawCel(151 8 0 gGOwnerX gGOwnerY 2)
                = local2 2
            )
            (if (proc0_6(6))
                = global120 (+ global120 4)
                (if (proc0_6(131))
                    proc0_5(131)
                    = temp2 PalVary(pvGET_CURRENT_STEP)
                    (if ((temp2 and (<> (= temp2 PalVary(pvGET_CURRENT_STEP)) 0)) and (<> temp2 64))
                        = temp1 (/ (- 64 temp2) 24)
                        PalVary(pvCHANGE_TICKS temp1)
                    )
                )
                = global411 3
                (if (not --local0 and not proc0_6(88))
                    = local0 (- (/ 60 global209) 10)
                    = temp0 (send gOwner:onControl(1))
                    (if (& temp0 $0400)
                        0
                    )(else
                        (if (not Random(0 5))
                            = local3 1
                            (send global2:newRoom(0))
                        )
                    )
                )
            )
        )(else
            (if (not (send gOwner:mover))
                = global411 1
                (if (not proc0_6(131) and proc0_6(6))
                    proc0_4(131)
                    = temp2 PalVary(pvGET_CURRENT_STEP)
                    (if (temp2)
                        = temp1 (- 64 (= temp2 PalVary(pvGET_CURRENT_STEP)))
                        PalVary(pvCHANGE_TICKS temp1)
                    )
                )
            )
        )
    )


    (method (dispose)
        (var temp0, temp1)
        = temp1 PalVary(pvGET_CURRENT_STEP)
        (if (temp1)
            = temp0 (- 64 (= temp1 PalVary(pvGET_CURRENT_STEP)))
            PalVary(pvCHANGE_TICKS temp0)
        )
        = local1 (- 11 (* 3 global209))
        (if (proc0_6(143))
            0
        )(else
            (if ((>= local1 Random(0 100)) or local3)
                localproc_04a8((send gOwner:onControl(1)))
            )(else
                localproc_07df((send gOwner:onControl(1)))
            )
        )
        = global411 1
        proc0_3()
        (super:dispose())
    )


    (method (cue)
        (send (ScriptID(7 3)):init())
    )

)
