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


(local
    newView
    newProp_2
    newProp
    gEgoView

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


(instance public Room71 of Rm
    (properties
        picture 71
        style 16
    )

    (method (init)
        Load(rsVIEW 800)
        Load(rsVIEW 511)
        Load(rsVIEW 40)
        (super:init())
        = south 74
        (self:setRegions(605))
        = global101 1
        (send (= newProp (Prop:new())):
            view(511)
            loop(0)
            cel(0)
            posn(72 122)
            stopUpd()
            init()
        )
        (if (== (send ((send gInv:at(23))):owner()) 71)
            (send (= newProp_2 (Prop:new())):
                view(511)
                ignoreActors(1)
                loop(0)
                cel(1)
                posn(72 117)
                stopUpd()
                init()
            )
        )
        (send gEgo:
            view(4)
            xStep(4)
            yStep(1)
        )
        (switch (gPicture)
            (case 72
                ((send gEgo:posn(208 105))  )
            )
            (case 74
                ((send gEgo:posn(170 184))  )
            )
            (default 
                ((send gEgo:posn(78 113)) = global126 0 
                (if (not proc0_22())
                    localproc_045e(1)
                )
 )
            )
        )
        (send gEgo:
            priority(kernel[101]((send gEgo:y())))
            init()
        )
        (if (proc0_22())
            proc0_12(605 1)
        )
    )


    (method (doit)
        (super:doit())
        (if (& (send gEgo:onControl(0)) $0040)
            (send global2:newRoom(70))
        )(else
            (if (& (send gEgo:onControl(0)) $0020)
                (send global2:newRoom(72))
            )
        )
        (if (newView and proc0_22())
            localproc_045e(0)
        )(else
            (if (not newView and not proc0_22())
                localproc_045e(1)
            )
        )
    )


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


    (method (handleEvent pEvent)
        (if ((send pEvent:claimed()))
            return 1
        )
        return 
            (if (== (send pEvent:type()) 128)
                (if (Said('look>'))
                    (if (Said('/falls') or Said('<out'))
                        Print(71 0)
                    )(else
                        (if (Said('/<'))
                            Print(71 1)
                        )(else
                            (if (not (send gEgo:has(23)) and ((Said('/[') or Said('/dirt')) or Said('<down')))
                                Print(71 1)
                            )(else
                                (if (Said('<around') or Said('/room,cave'))
                                    Print(Format(@global300 71 2 
                                            (if (proc0_22())
                                                "Even the lantern does little good."
                                            )(else
                                                " "
                                            )
))
                                    (if (not (send gEgo:has(23)))
                                        Print(71 3)
                                    )
                                )
                            )
                        )
                    )
                )(else
                    (if (Said('get/['))
                        (if (<> (send ((send gInv:at(23))):owner()) 71)
                            Print(71 4)
                        )(else
                            (if ((< (send gEgo:distanceTo(newProp_2)) 15) and (== (send ((send gInv:at(23))):owner()) 71))
                                (send gEgo:get(23))
                                (send gEgo:setScript(getDown))
                                (send newProp_2:hide())
                                = global182 1
                                (send gGame:changeScore(2))
                            )(else
                                proc0_15()
                            )
                        )
                    )
                )
            )(else
                0
            )
    )


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

)
(instance getDown of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (proc0_10() = gEgoView (send gEgo:view()) (send gEgo:
                    setMotion(0)
                    view(40)
                    cel(0)
                    loop(
                        (if (< (send gEgo:heading()) 180)
                            0
                        )(else
                            1
                        )
)
                    setCycle(End)
                )
 = seconds 2  )
            )
            (case 1
                ((send gEgo:setCycle(Beg self))  )
            )
            (case 2
                ((send gEgo:
                    view(gEgoView)
                    setCycle(Walk)
                )
 proc0_11() )
            )
        )
    )

)
