(include "sci.sh")
(use "Main")
(use "Class_255_0")
(use "ulence")
(use "SQRoom")
(use "Polygon")
(use "Cycle")
(use "Obj")
(script 612)



(instance public rm612 of SQRoom
    (properties
        picture 612
        east 613
        south 609
    )

    (method (init)
        (ulence:roomVer(22891))
        (switch (gWest)
            (case 609
                (send gEgo:x((- (send gEgo:x) 30)))
                (if (< (send gEgo:x) 95)
                    (send gEgo:x(95))
                )
            )
            (case 613
                (if (< (send gEgo:y) 144)
                    (send gEgo:y(132))
                )
            )
            (default 
                (send gEgo:
                    x(280)
                    y(164)
                )
            )
        )
        (send gEgo:
            init()
            illegalBits(0)
            ignoreActors(1)
        )
        (super:init())
        Load(rsVIEW 636)
        (self:
            setRegions(706)
            addObstacle((send ((Polygon:new())):
                    type(2)
                    init(0 189 59 189 59 182 186 120 194 118 319 118 319 0 0 0)
                    yourself()
                )
)
        )
        (if (== (ulence:status) 1)
            (ulence:
                status(2)
                bikerComing(1)
            )
            Load(rsVIEW 632)
            Load(rsVIEW 635)
            Load(rsVIEW 634)
            Load(rsSOUND 50)
        )(else
            (ulence:bikerComing(0))
        )
        (send (ScriptID(706 7)):
            init()
            nsLeft(0)
            nsTop(87)
            nsBottom(189)
            nsRight(319)
        )
        (send (ScriptID(706 8)):
            init()
            nsLeft(0)
            nsTop(0)
            nsBottom(87)
            nsRight(319)
        )
    )


    (method (doit param1)
        (if ((== (ulence:status) 4) and (< (send (ScriptID(706 1)):distanceTo(gEgo)) 15))
            proc0_2()
            (ulence:status(6))
            (ulence:deathLoop(0))
            (send gEgo:setScript(0))
            (send global2:setScript(ScriptID(706 3)))
        )
        (if (script)
            0
        )(else
            (if (((> Random(0 100) 95) and (== (ulence:status) 2)) and (send gEgo:inRect(90 160 152 182)))
                proc0_2()
                (ulence:
                    status(3)
                    fieldOff(1)
                )
                (send (ScriptID(706 1)):
                    init()
                    hide()
                    posn(320 116)
                    setLoop(5)
                    setScript(runOver)
                )
                (send gEgo:setScript(ScriptID(706 4)))
            )(else
                (if (((> Random(0 100) 95) and (== (ulence:status) 2)) and (send gEgo:inRect(261 172 284 182)))
                    proc0_2()
                    (ulence:
                        status(3)
                        fieldOff(1)
                    )
                    (send (ScriptID(706 1)):
                        view(634)
                        init()
                        hide()
                        setLoop(6)
                        posn(39 226)
                        setScript(runOver2)
                    )
                    (send gEgo:setScript(ScriptID(706 5)))
                )
            )
        )
        (super:doit(rest param1))
    )

)
(instance runOver of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                (ulence:egoBusy(1))
                (send gLongSong:
                    vol(25)
                    number(50)
                    loop(-1)
                    playBed()
                    fade(127 10 10 0)
                )
                = seconds 3
            )
            (case 1
                (send (ScriptID(706 6)):
                    init()
                    play()
                )
                (send (ScriptID(706 1)):
                    show()
                    setMotion(MoveTo 218 - (send gEgo:y) 5 self)
                )
            )
            (case 2
                (ulence:status(4))
                proc0_3()
                (send (ScriptID(706 1)):
                    setLoop(1)
                    setPri(+ (send gEgo:priority) 1)
                    setMotion(MoveTo 104 - (send gEgo:y) 5 self)
                )
            )
            (case 3
                (send (ScriptID(706 1)):
                    setLoop(5)
                    setMotion(MoveTo 90 160 self)
                )
            )
            (case 4
                (send (ScriptID(706 1)):
                    posn(81 168)
                    setLoop(2)
                    setMotion(MoveTo 81 197 self)
                )
            )
            (case 5
                (send gLongSong:fade())
                (send (ScriptID(706 6)):fade())
                (send (ScriptID(706 1)):hide())
                = seconds 3
            )
            (case 6
                (if (<> (ulence:status) 6)
                    (ulence:
                        status(1)
                        fieldOff(0)
                        bikerComing(0)
                        egoBusy(0)
                    )
                    (send gEgo:setScript(0))
                    proc0_3()
                    Print("Boy, that was close!")
                )
                (self:dispose())
            )
        )
    )

)
(instance runOver2 of Script
    (properties)

    (method (changeState newState)
        (var temp0[2])
        (switch (= state newState)
            (case 0
                (ulence:egoBusy(1))
                (send gLongSong:
                    vol(25)
                    number(50)
                    loop(-1)
                    playBed()
                    fade(127 20 10 0)
                )
                = seconds 3
            )
            (case 1
                (send (ScriptID(706 6)):
                    init()
                    play()
                )
                (send (ScriptID(706 1)):
                    show()
                    setMotion(MoveTo 122 171 self)
                )
            )
            (case 2
                (send (ScriptID(706 1)):
                    setLoop(0)
                    setMotion(MoveTo 176 171 self)
                )
            )
            (case 3
                (ulence:status(4))
                proc0_3()
                (send (ScriptID(706 1)):
                    setPri(+ (send gEgo:priority) 1)
                    setMotion(MoveTo 341 - (send gEgo:y) 5 self)
                )
            )
            (case 4
                (send gLongSong:fade())
                (send (ScriptID(706 6)):fade())
                (send (ScriptID(706 1)):hide())
                = seconds 3
            )
            (case 5
                (if (<> (ulence:status) 6)
                    (ulence:
                        status(1)
                        fieldOff(0)
                        bikerComing(0)
                        egoBusy(0)
                    )
                    (send gEgo:setScript(0))
                    proc0_3()
                    Print("Boy, that was close!")
                )
                (self:dispose())
            )
        )
    )

)
