(version 2)
(include "sci.sh")
(exports
    0 rgMenace
    1 startScript
    2 waitAFew
)
(use "Main")
(use "n958")
(use "Game")
(use "Obj")
(script 602)


(local
    local0
    local1

)
(instance public rgMenace of Rgn
    (properties)

    (method (init)
        (self:keep(0))
        (super:init())
        proc958_0(130 985 982 972)
        (switch (gGNumber)
            (case (send global2:north)
                0
            )
            (case (send global2:south)
                0
            )
            (case (send global2:west)
                0
            )
            (case (send global2:east)
                0
            )
            (default 
                = local1 1
            )
        )
        = global138 0
        = global139 0
        (switch (
        (if (local1)
            (switch (gNumber)
                (case 29
                    0
                )
                (case 46
                    2
                )
                (case 35
                    1
                )
            )
        )(else
            (if ((send gEgo:has(16)))
                Random(0 1)
            )(else
                Random(0 2)
            )
        )
)
            (case 0
                proc958_0(132 34 26 90)
                proc958_0(128 100 101 28 102)
                Load(rsSCRIPT 800)
                = global125 800
                (if (not 
                (if ((send gEgo:has(14)) and (send gEgo:has(16)))
                    (send gEgo:has(1))
                )
)
                    (switch (Random(0 3))
                        (case 1
                            Load(rsVIEW 135)
                            Load(rsSOUND 93)
                            Load(rsSCRIPT 804)
                            = global138 804
                        )
                        (case 3
                            proc958_0(128 130 20)
                            Load(rsSOUND 35)
                            Load(rsSCRIPT 803)
                            = global138 803
                        )
                        (default 
                            = global138 0
                        )
                    )
                )
            )
            (case 1
                Load(rsVIEW 135)
                Load(rsSOUND 93)
                Load(rsSCRIPT 804)
                = global125 804
            )
            (case 2
                proc958_0(128 130 20)
                Load(rsSOUND 35)
                Load(rsSCRIPT 803)
                = global125 803
            )
        )
        (send gMenace:
            illegalBits(-16384)
            setLoop(-1)
            setCel(-1)
            setPri(-1)
            cycleSpeed(0)
            moveSpeed(0)
        )
        (self:setScript(waitOne))
    )


    (method (dispose)
        DisposeScript(global125)
        (if (global138)
            DisposeScript(global138)
        )
        (super:dispose())
    )


    (method (handleEvent pEvent)
        (super:handleEvent(pEvent))
        (if ((send pEvent:claimed) or (<> (send pEvent:type) 128))
            return 
        )
    )


    (method (newRoom newRoomNumber)
        (super:newRoom(newRoomNumber))
    )

)
(instance waitOne of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = seconds Random(2 4)
            )
            (case 1
                (if ((((((send gEgo:inRect(20 (+ (send global2:horizon) 12) 300 176)) and not proc0_12(1)) and not global124) and not (send global2:script)) and not (send gEgo:script)) and (== gNewRoomNumber gNumber))
                    (send global2:setScript(startScript))
                )(else
                    (self:changeState(0))
                )
            )
        )
    )

)
(instance public startScript of Script
    (properties)

    (method (dispose param1)
        (super:dispose(rest param1))
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (self:setScript(ScriptID(global125 0) self))
            )
            (case 1
                (if (global138)
                    0
                )(else
                    (self:dispose())
                )
            )
            (case 2
                (self:dispose())
            )
        )
    )

)
(instance public waitAFew of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = seconds 3
            )
            (case 1
                (self:setScript(ScriptID(global138 0) self))
            )
            (case 2
                (startScript:cue())
                (send (ScriptID(global125 0)):cue())
                (self:dispose())
            )
        )
    )

)
