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


(local
    newProp

)
(instance babySound of Sound
    (properties)
)
(instance public Room59 of Rm
    (properties
        picture 59
        style 16
    )

    (method (init)
        (self:setRegions(603))
        Load(rsVIEW 527)
        Load(rsVIEW 519)
        Load(rsVIEW 648)
        Load(rsVIEW 510)
        Load(rsVIEW 536)
        (super:init())
        (send ((View:new())):
            view(510)
            loop(1)
            cel(0)
            posn(80 104)
            setPri(10)
            addToPic()
        )
        (if (global100)
            (send ((View:new())):
                view(648)
                loop(0)
                cel(0)
                posn(51 104)
                setPri(6)
                addToPic()
            )
            (send ((Prop:new())):
                view(536)
                loop(2)
                cel(1)
                posn(80 98)
                init()
                setPri(11)
                setCycle(Fwd)
            )
        )
        (send (= newProp (Prop:new())):
            view(527)
            loop(1)
            posn(147 118)
            setPri(1)
            init()
            stopUpd()
        )
        (send gEgo:
            posn(270 130)
            view(4)
            xStep(4)
            yStep(1)
            init()
        )
        (self:setScript(rm59Script))
        (if ((== global133 59) and (== global134 1))
            (rockAgain:cue())
            (rm59Script:changeState(1))
        )
    )


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


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


    (method (handleEvent pEvent)
        (var gInvSaidMe)
        return 
            (if ((send pEvent:claimed()))
                return 1
            )(else
                (if (== (send pEvent:type()) 128)
                    (if (Said('look>'))
                        (if (Said('[<around][/room,bedroom,nursery]'))
                            Print(59 0)
                        )(else
                            (if (Said('<in/chest,dresser,drawer'))
                                Print(59 1)
                            )(else
                                (if (Said('/chest,dresser'))
                                    Print(59 2)
                                )(else
                                    (if (Said('/chair,rocker'))
                                        Print(59 3)
                                    )(else
                                        (if (Said('/window'))
                                            (if ((send gEgo:inRect(76 125 109 147)))
                                                Print(59 4)
                                            )(else
                                                Print(800 1)
                                            )
                                        )(else
                                            (if (Said('<in/cradle') or Said('ghost[<ghost]'))
                                                (if (< (send gEgo:distanceTo(newProp)) 15)
                                                    (if (<> global134 1)
                                                        Print(59 5)
                                                    )(else
                                                        Print(59 6)
                                                    )
                                                )(else
                                                    Print(800 1)
                                                )
                                            )(else
                                                (if (Said('/cradle'))
                                                    (if (<> global134 1)
                                                        Print(59 7)
                                                    )(else
                                                        Print(59 8)
                                                    )
                                                )(else
                                                    (if (Said('/wall'))
                                                        Print(59 9)
                                                    )(else
                                                        (if (Said('/dirt') or Said('<down'))
                                                            Print(59 10)
                                                        )(else
                                                            (if (Said('/horse,toy'))
                                                                Print(59 11)
                                                            )(else
                                                                (if (Said('/carpet'))
                                                                    Print(59 12)
                                                                )(else
                                                                    (send pEvent:claimed(0))
                                                                )
                                                            )
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )(else
                        (if (Said('open/chest,dresser,drawer'))
                            Print(59 1)
                        )(else
                            (if (Said('sit'))
                                Print(59 13)
                            )(else
                                (if (Said('boulder[/cradle]'))
                                    (if (== global134 1)
                                        Print(59 14)
                                    )(else
                                        (if (< (send gEgo:distanceTo(newProp)) 10)
                                            (rockAgain:changeState(0))
                                            (send pEvent:claimed(1))
                                        )(else
                                            Print(800 1)
                                        )
                                    )
                                )(else
                                    (if (Said('(get<on),mount,play/horse,toy'))
                                        Print(59 15)
                                    )(else
                                        (if (Said('get/horse,toy'))
                                            Print(59 16)
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
                (if (((send pEvent:claimed()) or (<> (send pEvent:type()) 128)) or (<> global134 1))
                    return <> global134 1
                )
                (if (Said('look<in/cradle') or Said('look,(feel[<in,around]),find/cradle,(ghost[<ghost])'))
                    (if (< (send gEgo:distanceTo(newProp)) 15)
                        (if (<> global134 1)
                            Print(59 5)
                        )(else
                            Print(59 6)
                        )
                    )(else
                        Print(800 1)
                    )
                )(else
                    (if (Said('converse,calm,calm'))
                        Print(59 17)
                    )(else
                        (if (Said('kiss'))
                            Print(59 18)
                        )(else
                            (if (Said('/ghost[<ghost]>'))
                                (if (Said('get,hold,capture,(get<up)'))
                                    Print(59 19)
                                )(else
                                    (if (Said('kill'))
                                        Print(59 20)
                                    )(else
                                        (if (Said('help,,'))
                                            Print(59 21)
                                        )(else
                                            (if (Said('feed'))
                                                Print(59 22)
                                            )
                                        )
                                    )
                                )
                            )(else
                                (if (Said('hum[/ghost,lullaby]'))
                                    Print(59 23)
                                )(else
                                    (if (Said('deliver,fling,place,drop>'))
                                        (if (not (= gInvSaidMe (send gInv:saidMe())) or not (send gEgo:has((send gInv:indexOf(gInvSaidMe)))))
                                            (send pEvent:claimed(0))
                                        )(else
                                            (if (>= (send gEgo:distanceTo(newProp)) 17)
                                                proc0_15()
                                            )(else
                                                (if (<> (send gInv:indexOf(gInvSaidMe)) 12)
                                                    Print(59 24)
                                                )(else
                                                    Print(59 25)
                                                    (send gEgo:put(12 59))
                                                    (send gGame:changeScore(2))
                                                    proc0_12(603 2)
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )
    )

)
(instance rockMeBaby of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((send newProp:
                    cycleSpeed(1)
                    setCycle(Fwd)
                    brTop(- (send newProp:y()) 2)
                )
  )
            )
            (case 1
                ((send newProp:
                    stopUpd()
                    brTop(- (send newProp:y()) 2)
                    setCel(0)
                )
 = state -1 )
            )
        )
    )

)
(instance rockAgain of Script
    (properties)

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


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((rockMeBaby:changeState(0)) (babySound:
                    number(22)
                    loop(1)
                    play(self)
                )
  )
            )
            (case 1
                ((rockMeBaby:cue()) 
                (if (== global134 1)
                    (self:changeState(0))
                )
 )
            )
        )
    )

)
(instance rm59Script of Script
    (properties)

    (method (changeState newState)
        (var temp0[102])
        (switch (= state newState)
            (case 1
                (= seconds 5  )
            )
            (case 2
                (Print(59 26) )
            )
        )
    )

)
