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


(local
    newView_2
    local1
    newView

)
(instance public Room60 of Rm
    (properties
        picture 60
        style 16
    )

    (method (init)
        Load(rsVIEW 648)
        Load(rsVIEW 529)
        (self:setRegions(603))
        (super:init())
        (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)
            )
        )
        (if (> global134 4)
            Load(rsVIEW 529)
            Load(rsVIEW 77)
            (send (= newView (View:new())):
                view(529)
                loop(1)
                cel(0)
                posn(161 138)
                init()
                stopUpd()
            )
            (send (= newView_2 (View:new())):
                view(529)
                loop(0)
                cel(0)
                posn(161 34)
                init()
                stopUpd()
                setPri(- (send newView:priority()) 1)
            )
            = local1 1
        )
        (if (== gPicture 68)
            (send gEgo:
                posn(68 160)
                view(4)
                setStep(4 1)
                init()
            )
        )(else
            (send gEgo:
                posn(161 60)
                view(77)
                setStep(4 1)
                init()
            )
            (self:setScript(climbDown))
        )
        (if (((< 0 global134) and (< global134 255)) and (== global133 gGNewPropX))
            proc0_12(603 -1)
        )
    )


    (method (doit)
        (super:doit())
        (if (& (send gEgo:onControl(0)) $0040)
            (send global2:newRoom(68))
        )
    )


    (method (handleEvent pEvent)
        (var gInvSaidMe)
        return 
            (if ((send pEvent:claimed()))
                return 1
            )(else
                (if (== (send pEvent:type()) 128)
                    (if (Said('look[<around][/!*]') or Said('look[<around]/room'))
                        Print(60 0)
                        (if (== global134 3)
                            Print(60 1)
                        )
                    )(else
                        (if (Said('look>'))
                            (if (Said('<under/bed'))
                                Print(60 2)
                            )(else
                                (if (Said('/bed'))
                                    Print(60 3)
                                )(else
                                    (if (Said('/window'))
                                        (if ((send gEgo:inRect(137 114 191 124)))
                                            Print(60 4)
                                        )(else
                                            Print(800 1)
                                        )
                                    )(else
                                        (if (Said('/fireplace'))
                                            Print(60 5)
                                        )(else
                                            (if (Said('/carpet,carpet'))
                                                Print(60 6)
                                            )(else
                                                (if (Said('<in/chest,dresser,drawer'))
                                                    Print(60 7)
                                                )(else
                                                    (if (Said('/chandelier'))
                                                        Print(60 8)
                                                    )(else
                                                        (if (Said('/chest,dresser'))
                                                            Print(60 9)
                                                        )(else
                                                            (if (Said('/wall'))
                                                                Print(60 10)
                                                            )(else
                                                                (if (Said('/dirt') or Said('<down'))
                                                                    Print(60 11)
                                                                )(else
                                                                    (if (Said('/ceiling'))
                                                                        (if (local1)
                                                                            Print(60 12)
                                                                        )(else
                                                                            Print(60 13)
                                                                        )
                                                                    )(else
                                                                        (if (Said('<in,up/trapdoor'))
                                                                            (if (local1)
                                                                                Print(60 14)
                                                                            )(else
                                                                                Print(60 15)
                                                                            )
                                                                        )(else
                                                                            (if (Said('<up'))
                                                                                (if (local1)
                                                                                    Print(60 16)
                                                                                )(else
                                                                                    proc0_17()
                                                                                )
                                                                            )(else
                                                                                (if (Said('/ladder'))
                                                                                    (if (local1)
                                                                                        Print(60 17)
                                                                                    )(else
                                                                                        Print(60 18)
                                                                                    )
                                                                                )(else
                                                                                    (if (Said('/trapdoor'))
                                                                                        (if (local1)
                                                                                            Print(60 19)
                                                                                        )(else
                                                                                            Print(60 20)
                                                                                        )
                                                                                    )
                                                                                )
                                                                            )
                                                                        )
                                                                    )
                                                                )
                                                            )
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )(else
                            (if (Said('open/trapdoor'))
                                (if (local1)
                                    Print(60 21)
                                )(else
                                    Print(60 22)
                                )
                            )(else
                                (if (Said('close/trapdoor'))
                                    (if (local1)
                                        Print(60 23)
                                    )(else
                                        Print(60 24)
                                    )
                                )(else
                                    (if (Said('open/chest,dresser,drawer'))
                                        Print(60 7)
                                    )(else
                                        (if (Said('lay,sleep[<in,down,on][/bed]') or Said('get<in,in/bed'))
                                            Print(60 25)
                                        )(else
                                            (if (Said('climb[/ladder]'))
                                                (if (local1)
                                                    (if (< (send gEgo:distanceTo(newView)) 10)
                                                        (if (>= (send gEgo:y()) (send newView:y()))
                                                            (send gEgo:setScript(climbLadder))
                                                        )(else
                                                            Print(60 26)
                                                        )
                                                    )(else
                                                        Print(800 1)
                                                    )
                                                )(else
                                                    Print(60 27)
                                                )
                                            )(else
                                                (if (Said('climb'))
                                                    Print(60 28)
                                                )(else
                                                    (if (Said('move>'))
                                                        Print(60 29)
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                    (if ((== global134 3) and (send pEvent:claimed(0)))
                        (if (Said('look/ghost,fishwife,fishwife,fishwife'))
                            Print(60 1)
                        )(else
                            (if (Said('look/chair'))
                                Print(60 30)
                            )(else
                                (if (Said('converse/ghost,fishwife,fishwife,fishwife') or Said('converse[/!*]'))
                                    Print(60 31)
                                )(else
                                    (if (Said('get/ghost,fishwife,fishwife,fishwife'))
                                        Print(60 32)
                                    )(else
                                        (if (Said('get,capture/ghost,fishwife,fishwife,fishwife'))
                                            Print(60 33)
                                        )(else
                                            (if (Said('kill/ghost,fishwife,fishwife,fishwife'))
                                                Print(60 34)
                                            )(else
                                                (if (Said('kiss/ghost,fishwife,fishwife,fishwife') or Said('kiss[/!*]'))
                                                    Print(60 35)
                                                )(else
                                                    (if (Said('help/ghost,fishwife,fishwife,fishwife'))
                                                        Print(60 36)
                                                    )(else
                                                        (if (Said('deliver>'))
                                                            (if ((send gEgo:inRect(70 118 100 152)))
                                                                (if ((= gInvSaidMe (send gInv:saidMe())) and (send gEgo:has((send gInv:indexOf((= gInvSaidMe (send gInv:saidMe())))))))
                                                                    (if (== (send gInv:indexOf(gInvSaidMe)) 28)
                                                                        (send gEgo:put(28 -1))
                                                                        (send gGame:changeScore(2))
                                                                        Print(60 37)
                                                                        proc0_12(603 -1)
                                                                    )(else
                                                                        Print(60 38)
                                                                    )
                                                                )(else
                                                                    (if (gInvSaidMe)
                                                                        (send pEvent:claimed(0))
                                                                    )
                                                                )
                                                            )(else
                                                                Print(800 1)
                                                                (send pEvent:claimed(1))
                                                            )
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )
    )

)
(instance climbLadder of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (proc0_10() (send gEgo:
                    ignoreActors(1)
                    illegalBits(0)
                    setMotion(MoveTo 161 140 self)
                )
  )
            )
            (case 1
                ((send gEgo:
                    view(77)
                    loop(0)
                    setStep(4 3)
                    setCycle(End self)
                )
  )
            )
            (case 2
                ((send gEgo:
                    loop(1)
                    cel(0)
                    setPri(12)
                    setCycle(Walk)
                    setMotion(MoveTo 161 48 self)
                )
  )
            )
            (case 3
                (= global204 0 = global205 1 (send client:setScript(0)) (send global2:newRoom(63)) )
            )
        )
    )

)
(instance climbDown of Script
    (properties)

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


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (proc0_10() (send gEgo:
                    view(77)
                    loop(1)
                    illegalBits(0)
                    setStep(3 3)
                    setPri(10)
                    setCycle(Rev)
                    setMotion(MoveTo 161 140 self)
                )
  )
            )
            (case 1
                ((send gEgo:
                    view(4)
                    loop(3)
                    illegalBits(32768)
                    setCycle(Walk)
                    setPri(-1)
                    setStep(4 1)
                )
 proc0_11() = global205 0 )
            )
        )
    )

)
