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


(local
    newProp

)
(instance fallMusic of Sound
    (properties)
)
(instance public Room80 of Rm
    (properties
        picture 80
    )

    (method (init)
        Load(rsVIEW 603)
        Load(rsSOUND 52)
        (super:init())
        = global101 0
        (send (= newProp (Prop:new())):
            view(603)
            posn(288 117)
            init()
            stopUpd()
        )
        (if ((== gPicture 79) or (== gPicture 0))
            (send gEgo:
                posn(279 167)
                view(2)
                xStep(2)
                yStep(1)
                init()
            )
        )
        (if (== gPicture 92)
            (send gEgo:
                view(2)
                posn(266 123)
                xStep(2)
                yStep(1)
                init()
            )
        )
        (if (== gPicture 94)
            (send gEgo:
                view(2)
                posn(185 135)
                xStep(2)
                yStep(1)
                init()
            )
        )
    )


    (method (doit)
        (super:doit())
        (if (& (send gEgo:onControl()) $0010)
            (send global2:newRoom(94))
        )
        (if (& (send gEgo:onControl()) $1000)
            (send global2:newRoom(79))
        )
        (if (& (send gEgo:onControl(1)) $0004)
            (self:setScript(falling))
        )
    )


    (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('open/door'))
                        (if (< (send gEgo:distanceTo(newProp)) 25)
                            proc0_10()
                            (send gEgo:setMotion(0))
                            (send newProp:
                                ignoreActors(1)
                                setCycle(End doDoor)
                            )
                        )(else
                            Print(800 1)
                        )
                    )(else
                        (if (Said('look>'))
                            (if (Said('/around,room'))
                                Print(80 0)
                            )(else
                                (if (Said('/castle'))
                                    Print(80 1)
                                )(else
                                    (if (Said('/barn'))
                                        Print(80 2)
                                    )(else
                                        (if (Said('/cliff'))
                                            Print(80 3)
                                        )(else
                                            (if (Said('/path'))
                                                Print(80 4)
                                            )(else
                                                (if (Said('/door'))
                                                    Print(80 5)
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )
    )

)
(instance doDoor of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (proc0_11() (send global2:newRoom(92)) )
            )
        )
    )

)
(instance falling of Script
    (properties)

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


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((User:
                    canControl(0)
                    canInput(0)
                )
 (send gEgo:
                    view(17)
                    setStep(5 6)
                    setLoop(3)
                    setMotion(MoveTo - (send gEgo:x()) 15 230 self)
                )
 (fallMusic:
                    number(52)
                    loop(1)
                    play()
                )
  )
            )
            (case 1
                (= seconds 3  )
            )
            (case 2
                ((fallMusic:dispose()) kernel[106](6) = seconds 3  )
            )
            (case 3
                (= global127 1 )
            )
        )
    )

)
