(version 2)
(include "sci.sh")
(exports
    0 Room44
)
(use "Main")
(use "Class_255_0")
(use "Sound")
(use "Cycle")
(use "Game")
(use "Feature")
(use "Obj")
(script 44)



(instance lightning of Prop
    (properties)
)
(instance thunder of Sound
    (properties)
)
(instance public Room44 of Rm
    (properties
        picture 44
    )

    (method (init)
        = east 41
        = south 48
        = west 43
        = north 54
        = horizon 85
        = global591 0
        = global109 0
        Load(132 31)
        Load(132 32)
        (super:init())
        (lightning:
            view(69)
            loop(6)
            cel(0)
            posn(291 59)
            setScript(flash)
            init()
        )
        proc0_1()
        (send gEgo:looper(0))
        (switch (global12)
            (case 48
                proc0_1()
                = global104 0
                (send gEgo:
                    view(0)
                    posn((send gEgo:x) 188)
                    setStep(3 2)
                )
            )
            (case 43
                (send gEgo:posn(1 (send gEgo:y)))
            )
            (case 41
                (if (< (send gEgo:y) (+ horizon 2))
                    (send gEgo:posn(318 (+ horizon 2)))
                )(else
                    (send gEgo:posn(318 (send gEgo:y)))
                )
            )
            (case 54
                (send gEgo:
                    view(0)
                    posn((send gEgo:x) + horizon 2)
                    setStep(3 2)
                )
            )
            (default 
                (send gEgo:view(0))
            )
        )
        (send gEgo:init())
        (self:setRegions(501))
        (switch (global110)
            (case 1
                (if (== Random(1 4) 3)
                    = gNewAct (Act:new())
                    (send gNewAct:
                        posn(1000 1000)
                        init()
                    )
                    = gSeconds Random(2 12)
                )
            )
            (case 2
                = gNewAct (Act:new())
                (send gNewAct:
                    posn(1000 1000)
                    init()
                )
                = gSeconds 3
            )
        )
        (if ((send global5:contains(gNewAct)))
            (send gNewAct:
                view(106)
                setCycle(Walk)
                observeControl(2)
                posn(1000 1000)
                init()
            )
            (switch (global12)
                (case east
                    (send gNewAct:posn(359 130))
                )
                (case west
                    (send gNewAct:posn(-40 130))
                )
                (case south
                    (send gNewAct:posn(160 249))
                )
                (case north
                    (send gNewAct:posn(120 (+ horizon 2)))
                )
            )
            = global110 1
            (send (ScriptID(501 0)):notify(1))
        )(else
            (send (ScriptID(501 0)):notify(4))
        )
    )


    (method (doit)
        (super:doit())
    )


    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 1
        )
        return 
            (if (== (send pEvent:type) 128)
                (if (Said('read/sign'))
                    (if (== (send gEgo:onControl(1)) 8192)
                        (if ((== (send gEgo:loop) 1) or (== (send gEgo:loop) 3))
                            proc255_0(44 0)
                        )(else
                            proc255_0(44 1)
                        )
                    )(else
                        proc255_0(44 2)
                    )
                )(else
                    (if (Said('look/sign'))
                        proc255_0(44 3)
                    )(else
                        (if (Said('look>') and ((Said('/area') or Said('/around')) or Said('[<around][/!*]')))
                            proc255_0(44 4)
                        )
                    )
                )
            )(else
                0
            )
    )


    (method (newRoom newRoomNumber)
        (if ((send global5:contains(gNewAct)) and (< (send gEgo:distanceTo(gNewAct)) 120))
            = global110 2
        )
        (if (not global155)
            (super:newRoom(newRoomNumber))
        )
    )

)
(instance flash of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = seconds Random(8 30)
            )
            (case 1
                (lightning:
                    cel(255)
                    setCycle(End self)
                )
            )
            (case 2
                (lightning:cel(0))
                = seconds Random(2 5)
            )
            (case 3
                (thunder:
                    priority(2)
                    number(Random(31 32))
                    play(self)
                )
            )
            (case 4
                = state -1
            )
        )
    )

)
