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


(local
    newProp
    newAct
    local2

)
(instance public Room68 of Rm
    (properties
        picture 68
        style 16
        south 17
    )

    (method (init)
        Load(rsVIEW 533)
        Load(rsVIEW 536)
        (super:init())
        (self:setRegions(603))
        (if (== global134 4)
            Load(rsVIEW 206)
            Load(rsVIEW 204)
        )
        (send ((View:new())):
            view(536)
            loop(7)
            cel(0)
            posn(77 110)
            setPri(8)
            addToPic()
        )
        (if (global100)
            (send ((Prop:new())):
                view(536)
                loop(4)
                posn(79 99)
                setPri(11)
                init()
                setCycle(Fwd)
            )
        )
        = global101 1
        (send (= newProp (Prop:new())):
            view(533)
            loop(0)
            posn(223 132)
            init()
            setPri(11)
            cycleSpeed(4)
            setCycle(Fwd)
        )
        (send gEgo:
            view(4)
            setLoop(-1)
            setCycle(Walk)
            illegalBits(32768)
            setStep(4 1)
        )
        (switch (gPicture)
            (case 67
                ((send gEgo:
                    posn(56 166)
                    loop(0)
                    init()
                    baseSetter(ScriptID(0 1))
                )
  )
            )
            (case 64
                ((send gEgo:
                    posn(262 168)
                    loop(1)
                    init()
                    baseSetter(ScriptID(0 1))
                )
  )
            )
            (case 62
                ((send gEgo:
                    posn(97 80)
                    loop(2)
                    init()
                    baseSetter(0)
                )
  )
            )
            (case 60
                ((send gEgo:
                    posn(198 82)
                    loop(2)
                    init()
                    baseSetter(0)
                )
  )
            )
            (case 17
                ((send gEgo:
                    posn(153 183)
                    loop(3)
                    init()
                    baseSetter(ScriptID(0 1))
                )
 )
            )
        )
        (send (= newAct (Act:new())):
            illegalBits(0)
            ignoreActors(1)
            setScript(mirrorTricks)
        )
        (if (((< 0 global134) and (< global134 255)) and (== global133 gGNewPropX))
            proc0_12(603 -1)
        )
    )


    (method (doit)
        (if (& (send gEgo:onControl(0)) $0040)
            (send gEgo:
                loop(2)
                baseSetter(0)
            )
            proc0_20()
            (send global2:newRoom(17))
        )
        (if (& (send gEgo:onControl(0)) $0020)
            (send gEgo:
                loop(1)
                baseSetter(0)
            )
            proc0_20()
            (send global2:newRoom(67))
        )
        (if (& (send gEgo:onControl(0)) $0010)
            (send gEgo:
                loop(3)
                baseSetter(0)
            )
            proc0_20()
            (send global2:newRoom(60))
        )
        (if (& (send gEgo:onControl(0)) $0008)
            (send gEgo:
                loop(3)
                baseSetter(0)
            )
            proc0_20()
            (send global2:newRoom(62))
        )
        (if (& (send gEgo:onControl(0)) $0004)
            (send gEgo:
                loop(0)
                baseSetter(0)
            )
            proc0_20()
            (send global2:newRoom(64))
        )
        (if ((& (send gEgo:onControl(0)) $0400) and not local2)
            = local2 1
            (send gEgo:setScript(moveOnTheStairs))
            (moveOnTheStairs:changeState(1))
        )
        (super:doit())
    )


    (method (handleEvent pEvent)
        return 
            (if ((send pEvent:claimed()))
                return 1
            )(else
                (if (== (send pEvent:type()) 128)
                    (if (Said('look[<around][/!*]') or Said('look[<around]/room'))
                        Print(68 0)
                    )(else
                        (if (((((Said('is<how<time') or Said('is<how/time')) or Said('read/time')) or Said('read/clock')) or Said('[!*]/time')) or Said('look/time'))
                            Print(Format(@global300 68 1 
                                    (if (% global160 12)
                                        % global160 12
                                    )(else
                                        12
                                    )
 global159 
                                    (if ((> global160 11) and (< global160 24))
                                        "P.M."
                                    )(else
                                        "A.M."
                                    )
) 160 "TAMIR TIME" 134 -1 30 66 global23)
                        )(else
                            (if (Said('look>'))
                                (if (Said('<behind/painting'))
                                    Print(68 2)
                                )(else
                                    (if (Said('/painting'))
                                        Print(68 3)
                                    )(else
                                        (if (Said('/mirror'))
                                            (if ((send gEgo:inRect(161 154 195 189)))
                                                (send gEgo:loop(3))
                                                Print(68 4)
                                            )(else
                                                Print(800 1)
                                            )
                                        )(else
                                            (if (Said('/chandelier'))
                                                Print(68 5)
                                            )(else
                                                (if (Said('/stair'))
                                                    Print(68 6)
                                                )(else
                                                    (if (Said('<in/clock'))
                                                        Print(68 7)
                                                    )(else
                                                        (if (Said('/clock'))
                                                            Print(68 8)
                                                        )(else
                                                            (if (Said('/door'))
                                                                Print(68 9)
                                                            )(else
                                                                (if (Said('/wall'))
                                                                    Print(68 10)
                                                                )(else
                                                                    (if (Said('/dirt') or Said('<down'))
                                                                        Print(68 11)
                                                                    )(else
                                                                        (if (Said('/carpet'))
                                                                            Print(68 12)
                                                                        )(else
                                                                            (if (Said('/table'))
                                                                                Print(68 13)
                                                                            )
                                                                        )
                                                                    )
                                                                )
                                                            )
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )(else
                                (if (Said('wind/clock'))
                                    Print(68 14)
                                )(else
                                    (if (Said('get/clock'))
                                        Print(68 15)
                                    )(else
                                        (if (Said('open/clock'))
                                            Print(68 7)
                                        )(else
                                            (if (Said('get/carpet'))
                                                Print(68 16)
                                            )(else
                                                (if (Said('get/painting'))
                                                    Print(68 17)
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )
    )


    (method (newRoom param1)
        (if (== param1 17)
            (send (ScriptID(603)):keep(0))
            = global189 0
        )
        (super:newRoom(param1))
    )

)
(instance mirrorTricks of Script
    (properties)

    (method (init param1)
        (super:init(param1))
        (send client:
            view((send gEgo:view()))
            setPri(0)
            init()
            hide()
        )
    )


    (method (doit)
        (if ((send gEgo:inRect(161 154 195 191)))
            (send client:
                show()
                loop(
                    (switch ((send gEgo:loop()))
                        (case 0
                            0
                        )
                        (case 1
                            1
                        )
                        (case 2
                            3
                        )
                        (case 3
                            2
                        )
                    )
)
                cel((send gEgo:cel()))
                posn((send gEgo:x()) - 160 (/ (- (send gEgo:y()) 160) 3))
                setCycle(Walk)
            )
        )(else
            (send client:hide())
        )
    )

)
(instance moveOnTheStairs of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 1
                (proc0_10() 
                (if (> (send gEgo:y()) 100)
                    (send gEgo:
                        illegalBits(0)
                        setMotion(MoveTo 196 81 self)
                    )
                )(else
                    (send gEgo:
                        illegalBits(0)
                        setMotion(MoveTo 99 137 self)
                    )
                )
 (send gEgo:setStep(3 3))  )
            )
            (case 2
                (= local2 0 proc0_9() proc0_11() = global189 1 (send gEgo:setScript(0)) 
                (if (< (send gEgo:y()) 130)
                    (send gEgo:baseSetter(0))
                )(else
                    (send gEgo:baseSetter(ScriptID(0 1)))
                )
 )
            )
        )
    )

)
