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


(local
    newAct

)
(instance theMusic of Sound
    (properties)
)
(instance public Room91 of Rm
    (properties
        picture 91
        style 16
    )

    (method (init)
        Load(rsVIEW 141)
        Load(rsVIEW 636)
        (self:setRegions(604))
        (super:init())
        proc0_12(604 0)
        (send ((Prop:new())):
            view(636)
            loop(0)
            posn(133 61)
            setPri(15)
            init()
            setCycle(Fwd)
        )
        (if ((== gPicture 92) or (== gPicture 0))
            (send gEgo:
                posn(291 153)
                view(4)
                setStep(4 1)
                init()
            )
            (if (global175)
                (send gEgo:x(275))
                (send (= newAct (Act:new())):
                    view(141)
                    posn(+ (send gEgo:x()) 25 (send gEgo:y()))
                    illegalBits(0)
                    setStep(6 4)
                    setCycle(Walk)
                    init()
                    setScript(henchChase)
                )
            )
        )
        (if (== gPicture 89)
            (send gEgo:
                posn(253 124)
                view(4)
                xStep(4)
                yStep(1)
                init()
            )
        )
        (if (== gPicture 90)
            (send gEgo:
                posn(27 154)
                view(4)
                setStep(4 1)
                init()
            )
            (if (global175)
                (send (= newAct (Act:new())):
                    view(141)
                    posn(- (send gEgo:x()) 30 (send gEgo:y()))
                    illegalBits(0)
                    setStep(6 4)
                    setCycle(Walk)
                    init()
                    setScript(henchChase)
                )
            )
        )
    )


    (method (doit)
        (super:doit())
        (if (& (send gEgo:onControl(0)) $0040)
            (send global2:newRoom(90))
        )
        (if (& (send gEgo:onControl(0)) $0020)
            (send global2:newRoom(92))
        )
        (if (& (send gEgo:onControl(0)) $0010)
            (send global2:newRoom(89))
        )
    )


    (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('look[/!*]') or Said('look[<around][/room,castle]'))
                        Print(91 0)
                    )(else
                        (if (Said('look>'))
                            (if (Said('<under/table'))
                                Print(91 1)
                            )(else
                                (if (Said('/table'))
                                    Print(91 2)
                                )(else
                                    (if (Said('<behind,under/tapestries'))
                                        Print(91 3)
                                    )(else
                                        (if (Said('/tapestries,painting'))
                                            Print(91 4)
                                        )(else
                                            (if (Said('/chandelier,candle,candelabra'))
                                                Print(91 5)
                                            )(else
                                                (if (Said('/door'))
                                                    Print(91 6)
                                                )(else
                                                    (if (Said('/wall'))
                                                        Print(91 7)
                                                    )(else
                                                        (if (Said('/dirt') or Said('<down'))
                                                            Print(91 8)
                                                        )(else
                                                            (send pEvent:claimed(0))
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )(else
                            (if (Said('sit>'))
                                Print(91 9)
                                (send pEvent:claimed(1))
                            )
                        )
                    )
                )
            )
    )


    (method (newRoom param1)
        (if (<> param1 81)
            = global175 0
        )
        (super:newRoom(param1))
    )

)
(instance henchChase of Script
    (properties)

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


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((theMusic:
                    number(41)
                    loop(1)
                    play()
                )
 (send client:setMotion(Chase gEgo 15 self))  )
            )
            (case 1
                ((User:
                    canControl(0)
                    canInput(0)
                )
 (send gEgo:
                    moveSpeed(0)
                    setMotion(0)
                )
 (theMusic:
                    number(42)
                    loop(1)
                    play()
                )
 = seconds 4  )
            )
            (case 2
                (= global205 1 (send global2:newRoom(81)) )
            )
        )
    )

)
