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


(local
    newView

)
(procedure (localproc_03fa param1)
    (if (param1)
        (send (= newView (View:new())):
            view(800)
            loop(1)
            posn(108 133)
            init()
            setPri(15)
            stopUpd()
        )
    )(else
        (send newView:dispose())
        = newView 0
    )
)


(instance public Room73 of Rm
    (properties
        picture 73
        style 16
    )

    (method (init)
        Load(rsVIEW 800)
        Load(rsVIEW 4)
        Load(rsVIEW 50)
        (super:init())
        (self:setRegions(605))
        = global101 1
        = south 76
        (send gEgo:
            view(4)
            xStep(4)
            yStep(1)
        )
        (if (<> gPicture 77)
            (send gEgo:
                posn(138 180)
                init()
                priority(kernel[101]((send gEgo:y())))
            )
            proc0_12(605 1)
        )(else
            (send gEgo:
                view(50)
                posn(290 164)
                init()
            )
            (if (not proc0_22())
                localproc_03fa(1)
            )
            = global126 0
            (send gEgo:setScript(crawl))
        )
    )


    (method (doit)
        (super:doit())
        (if (((& (send gEgo:onControl()) $0002) and (< (send gEgo:heading()) 180)) and (<> (send gEgo:script()) crawl))
            (send gEgo:setScript(crawl))
        )
        (if (newView and proc0_22())
            localproc_03fa(0)
        )(else
            (if (not newView and not proc0_22())
                localproc_03fa(1)
            )
        )
    )


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


    (method (handleEvent pEvent)
        return 
            (if ((send pEvent:claimed()))
                return 1
            )(else
                (if (== (send pEvent:type()) 128)
                    (if (Said('crawl,(/cave') or Said('crawl[/!*]'))
                        (if (not & (send gEgo:onControl()) $0002)
                            Print(800 1)
                        )
                    )(else
                        (if (Said('look,find/(,('))
                            Print(73 0)
                        )(else
                            (if (Said('look<out'))
                                Print(73 1)
                            )(else
                                (if (Said('look/sky') or Said('look<up[/!*]'))
                                    (if (global100)
                                        Print(73 2)
                                    )(else
                                        Print(73 3)
                                    )
                                )
                            )
                        )
                    )
                )
            )
    )


    (method (newRoom param1)
        (if (== param1 77)
            (send (ScriptID(605)):keep(0))
            = global189 0
        )
        (super:newRoom(param1))
    )

)
(instance crawl of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (proc0_10() (send gEgo:illegalBits(0)) 
                (if (> (send gEgo:heading()) 180)
                    (self:changeState(10))
                )(else
                    (self:changeState(20))
                )
 )
            )
            (case 10
                ((send gEgo:
                    view(50)
                    setLoop(3)
                    xStep(2)
                    setCycle(Walk)
                    setMotion(MoveTo 255 164 self)
                )
  )
            )
            (case 11
                ((send gEgo:
                    cel(5)
                    setLoop(1)
                    cycleSpeed(1)
                    setCycle(Beg self)
                )
  )
            )
            (case 12
                ((send gEgo:
                    view(4)
                    setLoop(-1)
                    xStep(4)
                    cycleSpeed(0)
                    setCycle(Walk)
                    illegalBits(32768)
                )
 proc0_11() (send client:setScript(0)) 
                (if (proc0_22())
                    proc0_12(605 3)
                )
 )
            )
            (case 20
                (
                (if (proc0_22())
                    proc0_12(605 2)
                )
 (send gEgo:
                    view(50)
                    setLoop(0)
                    cel(0)
                    xStep(2)
                    setCycle(End self)
                )
  )
            )
            (case 21
                ((send gEgo:
                    illegalBits(0)
                    setLoop(2)
                    setCycle(Walk)
                    setMotion(MoveTo 296 160 self)
                )
  )
            )
            (case 22
                ((send gEgo:illegalBits(32768)) proc0_11() (send global2:newRoom(77)) )
            )
        )
    )

)
