(include "sci.sh")
(use "Main")
(use "Class_255_0")
(use "Sound")
(use "Cycle")
(use "Game")
(use "PV")
(use "Obj")
(script 63)


(local
    local0
    newProp
    newView
    newView_2

)
(instance public Room63 of Rm
    (properties
        picture 63
        style 16
    )

    (method (init)
        Load(rsPIC 60)
        Load(rsVIEW 44)
        Load(rsVIEW 40)
        Load(rsVIEW 77)
        Load(rsVIEW 42)
        Load(rsVIEW 537)
        Load(rsVIEW 529)
        Load(rsVIEW 648)
        Load(rsSCRIPT 991)
        Load(rsSOUND 52)
        (self:setRegions(603))
        (super:init())
        (send ((View:new())):
            view(648)
            loop(5)
            cel(0)
            posn(280 105)
            setPri(6)
            addToPic()
        )
        (send ((Prop:new())):
            view(536)
            loop(1)
            cel(0)
            posn(224 124)
            init()
            setPri(15)
            setCycle(Fwd)
        )
        (send ((View:new())):
            view(537)
            loop(3)
            cel(0)
            posn(167 126)
            addToPic()
        )
        (send (= newProp (Prop:new())):
            view(537)
            loop(0)
            cel(0)
            posn(167 116)
            init()
            stopUpd()
        )
        (send ((View:new())):
            view(537)
            loop(1)
            cel(0)
            posn(165 158)
            setPri(11)
            ignoreActors(1)
            addToPic()
        )
        (if (== global134 5)
            Load(rsVIEW 209)
        )
        (send gEgo:setScript(climbIn))
        (if (((< 0 global134) and (< global134 255)) and (== global133 gGNewPropX))
            proc0_12(603 -1)
        )
    )


    (method (doit)
        (super:doit())
        (if ((& (send gEgo:onControl(1)) $0004) and not (send gEgo:script()))
            (send gEgo:setScript(fallDead))
        )
    )


    (method (dispose)
        DisposeScript(991)
        (send gSounds:eachElementDo(172))
        (super:dispose())
    )


    (method (handleEvent pEvent)
        return 
            (if ((send pEvent:claimed()))
                return 1
            )(else
                (if (== (send pEvent:type()) 128)
                    (if (Said('/box'))
                        Print(63 0)
                    )(else
                        (if (Said('get,open,look/birdcage,birdcage'))
                            Print(63 1)
                        )(else
                            (if (Said('look>'))
                                (if (Said('<in/chest'))
                                    (if ((send gEgo:inRect(141 120 193 129)))
                                        (send gEgo:setMotion(0))
                                        (if (not local0)
                                            (if (== global134 5)
                                                Print(63 2)
                                            )(else
                                                Print(63 3)
                                            )
                                        )(else
                                            (if (== (send ((send gInv:at(26))):owner()) 63)
                                                Print(63 4)
                                                (send gEgo:get(26))
                                                = global182 1
                                                (send gGame:changeScore(2))
                                            )(else
                                                Print(63 5)
                                            )
                                        )
                                    )(else
                                        Print(800 1)
                                    )
                                )(else
                                    (if (Said('/chest'))
                                        (if (== global134 5)
                                            Print(63 2)
                                        )(else
                                            Print(63 6)
                                        )
                                    )(else
                                        (if (Said('<in/trapdoor'))
                                            (if ((send gEgo:inRect(135 138 182 148)))
                                                Print(63 7)
                                            )(else
                                                Print(63 8)
                                            )
                                        )(else
                                            (if (Said('/trapdoor') or Said('<down'))
                                                Print(63 9)
                                            )(else
                                                (if (Said('/ladder'))
                                                    Print(63 10)
                                                )(else
                                                    (if (Said('/window'))
                                                        Print(63 11)
                                                    )(else
                                                        (if (Said('/junk'))
                                                            Print(63 12)
                                                        )(else
                                                            (if (Said('/wall'))
                                                                Print(63 13)
                                                            )(else
                                                                (if (Said('/dirt'))
                                                                    Print(63 14)
                                                                )(else
                                                                    (if (Said('/ghost'))
                                                                        (if (== global133 gGNewPropX)
                                                                            Print(63 15)
                                                                        )(else
                                                                            Print(63 16)
                                                                        )
                                                                    )(else
                                                                        (if (Said('[<around][/room]'))
                                                                            Print(63 17)
                                                                        )
                                                                    )
                                                                )
                                                            )
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )(else
                                (if (Said('climb[/ladder,down]'))
                                    (if ((send gEgo:inRect(131 138 205 159)))
                                        (send gEgo:setScript(climbDown))
                                    )(else
                                        Print(800 1)
                                    )
                                )(else
                                    (if (Said('close/trapdoor'))
                                        Print(63 18)
                                    )(else
                                        (if (Said('open/trapdoor'))
                                            Print(63 19)
                                        )(else
                                            (if (Said('get/chest'))
                                                Print(63 20)
                                            )(else
                                                (if (Said('get,move,detach/ghost'))
                                                    (if (== global133 gGNewPropX)
                                                        Print(63 21)
                                                    )(else
                                                        Print(63 16)
                                                    )
                                                )(else
                                                    (if (Said('close/chest'))
                                                        (if (local0)
                                                            (send newProp:setCycle(Beg))
                                                            = local0 0
                                                        )(else
                                                            Print(63 22)
                                                        )
                                                    )(else
                                                        (if (Said('open/chest'))
                                                            (if (local0)
                                                                Print(63 23)
                                                            )(else
                                                                (if (== global134 5)
                                                                    Print(63 24)
                                                                )(else
                                                                    (if ((send gEgo:inRect(141 120 193 129)))
                                                                        (send gEgo:setMotion(0))
                                                                        (send newProp:setCycle(End))
                                                                        = local0 1
                                                                    )(else
                                                                        Print(800 1)
                                                                    )
                                                                )
                                                            )
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )
    )

)
(instance climbDown of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (proc0_10() (send gEgo:
                    illegalBits(0)
                    setMotion(MoveTo 196 149 self)
                )
  )
            )
            (case 1
                ((send gEgo:
                    setMotion(0)
                    view(40)
                    loop(1)
                    cel(0)
                    setCycle(End self)
                )
  )
            )
            (case 2
                ((send gEgo:
                    view(77)
                    loop(2)
                    cel(0)
                    setPri(12)
                    setCycle(End self)
                )
  )
            )
            (case 3
                (= global204 0 = global205 1 (send global2:newRoom(60)) )
            )
        )
    )

)
(instance climbIn of Script
    (properties)

    (method (init param1)
        (super:init(param1))
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (proc0_10() (send gEgo:
                    posn(196 151)
                    view(77)
                    loop(2)
                    setStep(4 3)
                    setPri(12)
                    setCycle(Beg self)
                    init()
                )
  )
            )
            (case 1
                ((send gEgo:
                    view(40)
                    loop(1)
                    setStep(4 1)
                    setPri(-1)
                    setCel(255)
                    setCycle(Beg self)
                )
  )
            )
            (case 2
                ((send gEgo:
                    view(4)
                    setCycle(Walk)
                    illegalBits(32768)
                )
 (send client:setScript(0)) proc0_11() )
            )
        )
    )

)
(instance fallDead of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (proc0_10() (send ((Sound:new())):
                    number(52)
                    play()
                )
 (send gEgo:
                    view(44)
                    illegalBits(0)
                    ignoreActors(1)
                    setPri(
                        (if (>= (send gEgo:priority()) 12)
                            11
                        )(else
                            (send gEgo:priority())
                        )
)
                    setCycle(Fwd)
                    setStep(5 5)
                    setLoop(
                        (if (> (send gEgo:x()) 155)
                            1
                        )(else
                            0
                        )
)
                    setMotion(MoveTo 155 155 self)
                )
  )
            )
            (case 1
                ((send gEgo:
                    setLoop(+ 2 (send gEgo:loop()))
                    setMotion(MoveTo 155 222 self)
                )
  )
            )
            (case 2
                ((send gAddToPics:eachElementDo(172)) (send gCast:eachElementDo(256)) (send global2:drawPic(60 6)) (send (= newView (View:new())):
                    view(529)
                    loop(1)
                    cel(0)
                    posn(161 138)
                    ignoreActors(1)
                    addToPic()
                )
 (send (= newView_2 (View:new())):
                    view(529)
                    loop(0)
                    cel(0)
                    posn(161 34)
                    setPri(- (send newView:priority()) 1)
                    addToPic()
                )
 
                (if (global100)
                    (send ((View:new())):
                        view(648)
                        loop(1)
                        posn(163 91)
                        setPri(5)
                        addToPic()
                    )
                    (send ((Prop:new())):
                        view(536)
                        loop(2)
                        posn(267 76)
                        init()
                        setPri(13)
                        setCycle(Fwd)
                    )
                )
 (send gEgo:
                    posn(156 60)
                    setStep(1 10)
                    show()
                    setMotion(MoveTo 161 150 self)
                )
  )
            )
            (case 3
                ((send gEgo:
                    view(40)
                    setLoop(- 2 (send gEgo:loop()))
                    setCel(2)
                )
 = cycles 1  )
            )
            (case 4
                ((send gSounds:eachElementDo(172)) (send gEgo:view(42)) proc0_20() kernel[106](10) = seconds 5  )
            )
            (case 5
                (= global127 1 )
            )
        )
    )

)
