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


(local
    newAct
    newProp
    newProp_2

)
(instance public Room94 of Rm
    (properties
        picture 94
        style 16
    )

    (method (init)
        Load(rsVIEW 380)
        Load(rsVIEW 386)
        Load(rsVIEW 609)
        (super:init())
        = global101 1
        (send gEgo:
            posn(149 167)
            view(2)
            setStep(2 1)
            init()
        )
        (send (= newProp (Prop:new())):
            view(609)
            loop(0)
            cel(0)
            posn(154 148)
            setPri(10)
            init()
            stopUpd()
        )
        (send (= newProp_2 (Prop:new())):
            view(609)
            loop(1)
            cel(0)
            posn(163 148)
            setPri(10)
            init()
            stopUpd()
        )
        (if (== global123 99)
            (send (= newAct (Act:new())):
                view(380)
                loop(0)
                cel(0)
                posn(203 145)
                illegalBits(0)
                cycleSpeed(2)
                setPri(9)
                init()
                setScript(uniStuff)
            )
        )
    )


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


    (method (handleEvent pEvent)
        return 
            (if ((send pEvent:claimed()))
                return 1
            )(else
                (if (<> (send pEvent:type()) 128)
                    return 1
                )(else
                    (if (Said('open/gate'))
                        (if (<> (send newProp_2:cel()) 0)
                            Print(94 0)
                        )(else
                            (if (>= (send gEgo:distanceTo(newProp_2)) 20)
                                Print(800 1)
                            )(else
                                (if (>= (send gEgo:x()) 156)
                                    Print(94 1)
                                )(else
                                    (send newProp_2:
                                        ignoreActors(1)
                                        setCycle(End gateScript)
                                    )
                                    (if (== global123 99)
                                        (uniStuff:changeState(4))
                                    )
                                )
                            )
                        )
                    )(else
                        (if (Said('close/gate'))
                            (if (== (send newProp_2:cel()) 0)
                                Print(94 2)
                            )(else
                                (if (>= (send gEgo:distanceTo(newProp_2)) 20)
                                    Print(800 1)
                                )(else
                                    (if (>= (send gEgo:x()) 156)
                                        Print(94 1)
                                    )(else
                                        (send newProp_2:
                                            ignoreActors(0)
                                            setCycle(Beg gateScript)
                                        )
                                    )
                                )
                            )
                        )(else
                            (if (Said('converse[/unicorn,horse]'))
                                (if ((<> global123 99) or not (send gCast:contains(newAct)))
                                    Print(94 3)
                                )(else
                                    Print(94 4)
                                )
                            )(else
                                (if (Said('kiss'))
                                    (if (== global123 99)
                                        Print(94 5)
                                    )(else
                                        Print(94 6)
                                    )
                                )(else
                                    (if (Said('/unicorn,horse>'))
                                        (if (<> global123 99)
                                            Print(94 6)
                                            (send pEvent:claimed(1))
                                        )(else
                                            (if (Said('look/*'))
                                                (if (== global123 99)
                                                    Print(94 7)
                                                    Print(94 8)
                                                )(else
                                                    Print(94 9)
                                                )
                                            )(else
                                                (if (Said('pat'))
                                                    Print(94 10)
                                                )(else
                                                    (if (Said('mount'))
                                                        Print(94 11)
                                                    )(else
                                                        (if (Said('get,capture,guide'))
                                                            Print(94 12)
                                                        )(else
                                                            (if (Said('free'))
                                                                Print(94 13)
                                                            )(else
                                                                Print(94 14)
                                                                (send pEvent:claimed(1))
                                                            )
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )(else
                                        (if (Said('look>'))
                                            (if (Said('/gate'))
                                                Print(94 15)
                                            )(else
                                                (if (Said('/wall'))
                                                    Print(94 16)
                                                )(else
                                                    (if (Said('[<around][/room,barn]'))
                                                        Print(94 17)
                                                        (if (== global123 99)
                                                            Print(94 18)
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )
    )

)
(instance gateScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 1
                ((send newProp_2:stopUpd()) = state 0 )
            )
        )
    )

)
(instance uniStuff of Script
    (properties)

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


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((send newAct:setCycle(End self))  )
            )
            (case 1
                ((send newAct:setCycle(End self))  )
            )
            (case 2
                (= state -1 
                (if (not (send newProp_2:cel()))
                    = seconds Random(2 5)
                )
 )
            )
            (case 4
                (proc0_10() = seconds 1  )
            )
            (case 5
                ((User:canControl(0)) (send gEgo:loop(0)) (send gGame:changeScore(4)) (send newAct:
                    view(386)
                    loop(0)
                    cel(0)
                    cycleSpeed(0)
                    setCycle(End self)
                )
 Print(94 19 134 -1 15 140 290)  )
            )
            (case 6
                ((send newAct:
                    setLoop(2)
                    illegalBits(0)
                    setCycle(Fwd)
                    setMotion(MoveTo 150 230 self)
                )
  )
            )
            (case 7
                (proc0_11() (send newAct:dispose()) = global123 999 = global124 27 )
            )
        )
    )

)
