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


(local
    local0
    newProp_2
    newProp_3
    newProp_4
    newProp_5
    newProp

)
(instance door of Prop
    (properties)

    (method (cue)
        proc0_11()
        (send global2:newRoom(54))
    )

)
(instance public Room22 of Rm
    (properties
        picture 22
    )

    (method (init)
        = north 16
        = south 28
        = east 23
        = west 21
        = horizon 75
        = global101 0
        (if (global100)
            = picture 122
        )
        (send gEgo:edgeHit(0))
        (super:init())
        (self:setRegions(501 512 508))
        Load(rsVIEW 612)
        = newProp (Prop:new())
        (send newProp:
            view(627)
            loop(0)
            cel(3)
            posn(158 26)
            setPri(0)
            cycleSpeed(2)
            setCycle(Fwd)
            ignoreActors()
            init()
        )
        = newProp_2 (Prop:new())
        = newProp_3 (Prop:new())
        = newProp_4 (Prop:new())
        = newProp_5 (Prop:new())
        (send newProp_2:
            isExtra(1)
            view(656)
            loop(0)
            cel(2)
            posn(23 111)
            setPri(0)
            setCycle(Fwd)
            ignoreActors()
            init()
        )
        (send newProp_3:
            isExtra(1)
            view(656)
            loop(1)
            cel(1)
            posn(309 157)
            setPri(0)
            setCycle(Fwd)
            ignoreActors()
            init()
        )
        (send newProp_4:
            isExtra(1)
            view(656)
            loop(2)
            cel(2)
            posn(226 169)
            setPri(0)
            setCycle(Fwd)
            ignoreActors()
            init()
        )
        (send newProp_5:
            isExtra(1)
            view(656)
            loop(3)
            cel(1)
            posn(41 126)
            setPri(0)
            setCycle(Fwd)
            ignoreActors()
            init()
        )
        (door:
            view(612)
            loop(0)
            cel(0)
            posn(189 113)
            setPri(6)
            stopUpd()
            init()
        )
        (if (global100)
            (door:loop(1))
        )
        (switch (gPicture)
            (case 21
                (
                (if (<= (send gEgo:y()) horizon)
                    (send gEgo:posn(1 (+ horizon 2)))
                )
 
                (if ((>= (send gEgo:y()) 126) and (< (send gEgo:y()) 130))
                    (send gEgo:posn(1 128))
                )(else
                    (send gEgo:posn(1 (send gEgo:y())))
                )
 )
            )
            (case 16
                ((send gEgo:
                    x(27)
                    y(+ horizon (+ (send gEgo:yStep()) 1))
                )
  )
            )
            (case 28
                ((send gEgo:
                    x(171)
                    y(188)
                )
  )
            )
            (case 23
                ((send gEgo:posn(317 (send gEgo:y())))  )
            )
            (case 53
                ((send gEgo:
                    view(2)
                    loop(2)
                    x(188)
                    y(115)
                )
 
                (if (== global102 2)
                    (send global2:setScript(doorActions))
                )
 )
            )
            (case 54
                (
                (if (== global102 2)
                    (send global2:setScript(doorActions))
                )
 (send gEgo:
                    view(2)
                    x(188)
                    y(115)
                )
  )
            )
            (case 0
                ((send gEgo:
                    x(318)
                    y(123)
                )
 )
            )
        )
        (send gEgo:
            xStep(2)
            yStep(1)
            init()
        )
    )


    (method (doit)
        (super:doit())
        (if ((send gEgo:inRect(167 140 201 149)) and (<> (send gEgo:view()) 2))
            (send gEgo:setPri(11))
        )(else
            (send gEgo:setPri(-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/cottage'))
                    Print(22 0)
                )(else
                    (if (Said('look/window'))
                        (if ((send gEgo:inRect(140 112 170 124)) or (send gEgo:inRect(170 112 202 120)))
                            Print(22 1)
                        )(else
                            Print(800 1)
                        )
                    )(else
                        (if (Said('look/blossom'))
                            Print(22 2)
                        )(else
                            (if (Said('get/blossom'))
                                Print(22 3)
                            )(else
                                (if (Said('look/door'))
                                    Print(22 4)
                                )(else
                                    (if (Said('break/window'))
                                        Print(22 5)
                                    )(else
                                        (if (Said('break/door'))
                                            Print(22 6)
                                        )(else
                                            (if (Said('open/window'))
                                                Print(22 7)
                                            )(else
                                                (if (Said('open/door'))
                                                    (if ((send gEgo:inRect(170 112 202 120)))
                                                        (if (== local0 1)
                                                            Print(22 8)
                                                        )(else
                                                            (if (not global100)
                                                                proc0_10()
                                                                (send gEgo:loop(3))
                                                                (send ((Sound:new())):
                                                                    number(300)
                                                                    loop(1)
                                                                    play(door)
                                                                )
                                                                (door:setCycle(End))
                                                            )(else
                                                                Print(22 9)
                                                            )
                                                        )
                                                    )(else
                                                        Print(800 1)
                                                    )
                                                )(else
                                                    (if (Said('unlatch/door'))
                                                        (if ((send gEgo:inRect(170 112 202 120)))
                                                            (if (not global100)
                                                                Print(22 10)
                                                            )(else
                                                                Print(22 11)
                                                            )
                                                        )(else
                                                            Print(800 1)
                                                        )
                                                    )(else
                                                        (if (Said('bang/door'))
                                                            (if ((send gEgo:inRect(170 112 202 120)))
                                                                (if (== local0 1)
                                                                    Print(22 12)
                                                                )(else
                                                                    (if (global100)
                                                                        Print(22 13)
                                                                    )(else
                                                                        Print(22 14)
                                                                    )
                                                                )
                                                            )(else
                                                                Print(800 1)
                                                            )
                                                        )(else
                                                            (if (Said('look/wheel'))
                                                                Print(22 15)
                                                            )(else
                                                                (if (Said('look[<around][/room]'))
                                                                    Print(22 16)
                                                                )
                                                            )
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )(else
                0
            )
    )


    (method (newRoom param1)
        (User:
            canControl(1)
            canInput(1)
        )
        (super:newRoom(param1))
    )

)
(instance doorActions of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (= global102 0 = local0 1 (door:
                    ignoreActors(0)
                    setCycle(Beg self)
                )
  )
            )
            (case 1
                (Print(22 17) )
            )
        )
    )

)
