(include "sci.sh")
(use "Main")
(use "Scaler")
(use "PolyPath")
(use "Polygon")
(use "CueObj")
(use "n958")
(use "Cycle")
(use "Sounds")
(use "View")
(use "Obj")
(script 310)



(instance public rm310 of Rm
    (properties
        noun 7
        picture 61
    )

    (method (init)
        (self:setRegions(350))
        proc958_0(128 419 402 401)
        proc0_6(0)
        (send gEgo:actions(ScriptID(350 1)))
        (switch (gGModNum)
            (case 300
                (= style 32778 (send gRoom:setScript(sEnterFromTunnelA))  )
            )
            (case 305
                (= style 11 (send gEgo:
                    setScale(Scaler 100 48 172 123)
                    init()
                    edgeHit(0)
                    posn(308 159)
                )
 (send gSQ5:handsOn())  )
            )
            (default 
                (= style 32778 (send gRoom:setScript(sEnterFromTunnelB)) )
            )
        )
        (tunnelA:
            init()
            setOnMeCheck(1 2)
        )
        (tunnelB:
            init()
            setOnMeCheck(1 4)
        )
        (bush:
            init()
            setOnMeCheck(1 32)
        )
        (fern:
            init()
            setOnMeCheck(1 64)
        )
        (outcrop:
            init()
            setOnMeCheck(1 128)
        )
        (path:
            init()
            setOnMeCheck(1 256)
        )
        (wd40:init())
        (super:init())
        (send gRoom:addObstacle((send ((Polygon:new())):
                type(3)
                init(180 122 164 129 146 148 146 176 227 182 290 173 319 149 319 138 307 145 269 125 253 132 276 147 278 150 269 154 244 159 215 159 205 150 204 135 197 127 186 123 185 98 176 105)
                yourself()
            )
))
    )


    (method (doit)
        (var temp0)
        (super:doit())
        (if ((((== (= temp0 (send gEgo:onControl(1))) 8) and not (wd40:script)) and not (== gGModNum 315)) and (not proc0_1(14) or proc0_1(15)))
            (wd40:setScript(sWD40Appear))
        )(else
            (if ((== temp0 2) and not (send gRoom:script))
                (send gRoom:setScript(sExitViaTunnelB))
            )(else
                (if ((== temp0 4) and not (send gRoom:script))
                    (send gRoom:setScript(sExitViaTunnelA))
                )(else
                    (if ((== temp0 16384) and not (send gRoom:script))
                        (send gRoom:setScript(sExitViaScroll))
                    )
                )
            )
        )
    )


    (method (doVerb param1 param2)
        (switch (param1)
            (case 1
                (
                (if (proc0_1(16))
                    (send gTestMessager:say(noun param1 2 0))
                )(else
                    (send gTestMessager:say(noun param1 1 0))
                )
 )
            )
            (default 
                ((super:doVerb(param1 rest param2)) )
            )
        )
    )

)
(instance sEnterFromTunnelA of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((send gSQ5:handsOff()) (send gEgo:
                    x(255)
                    y(125)
                    setScale(Scaler 100 48 172 123)
                    init()
                    setMotion(MoveTo 298 152 self)
                )
  )
            )
            (case 1
                ((send gSQ5:handsOn()) (self:dispose()) )
            )
        )
    )

)
(instance sExitViaTunnelA of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((send gSQ5:handsOff()) (send gEgo:setMotion(MoveTo 255 135 self))  )
            )
            (case 1
                ((send gRoom:newRoom(300)) (self:dispose()) )
            )
        )
    )

)
(instance sEnterFromTunnelB of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((send gSQ5:handsOff()) (send gEgo:
                    x(178)
                    y(110)
                    setScale(Scaler 100 48 172 123)
                    init()
                    setMotion(MoveTo 186 131 self)
                )
  )
            )
            (case 1
                ((send gSQ5:handsOn()) (self:dispose()) )
            )
        )
    )

)
(instance sExitViaTunnelB of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((send gSQ5:handsOff()) (send gEgo:setMotion(PolyPath 182 109 self))  )
            )
            (case 1
                ((send gRoom:newRoom(315)) (self:dispose()) )
            )
        )
    )

)
(instance sExitViaScroll of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((send gSQ5:handsOff()) (send gEgo:setMotion(MoveTo 335 144 self))  )
            )
            (case 1
                ((send gRoom:newRoom(305)) )
            )
        )
    )

)
(instance sWD40Appear of Script
    (properties)

    (method (doit)
        (if (> (send gEgo:y) 144)
            (if ((< 2 state) and (< state 6))
                = ticks (= seconds 0)
                = state 5
                (self:cue())
            )(else
                (if (== state 0)
                    (self:dispose())
                )
            )
        )
        (super:doit())
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (= seconds 7  )
            )
            (case 1
                ((send gSQ5:handsOff()) (send gSq5Music1:
                    number(35)
                    loop(-1)
                    play()
                )
 
                (if (proc0_1(15))
                    (wd40:
                        view(419)
                        cel(5)
                        x(253)
                        y(0)
                        setLoop(-1)
                        setLoop(0)
                        setCycle(0)
                        setMotion(MoveTo 255 43 self)
                    )
                )(else
                    (send gSq5Music2:
                        number(404)
                        setLoop(1)
                        play()
                    )
                    (wd40:
                        loop(0)
                        cel(0)
                        setCycle(CT 5 1 self)
                    )
                )
 )
            )
            (case 2
                ((wd40:setCycle(End self))  )
            )
            (case 3
                ((send gSQ5:handsOn()) 
                (if (== (send gRoom:script) sExitViaTunnelB)
                    (self:dispose())
                )(else
                    proc0_2(66)
                    (send gSq5Music2:
                        number(402)
                        setLoop(1)
                        play()
                    )
                    (fireBall:
                        view(402)
                        loop(0)
                        cel(0)
                        x(245)
                        y(19)
                        setStep(15 5)
                        moveSpeed(0)
                        init()
                        setMotion(MoveTo + (send gEgo:x) 7 - (send gEgo:y) 10 self)
                    )
                )
 )
            )
            (case 4
                ((send gSq5Music2:
                    number(4021)
                    setLoop(1)
                    play()
                )
 (fireBall:
                    view(401)
                    loop(4)
                    cel(0)
                    setCycle(End self)
                )
  )
            )
            (case 5
                ((fireBall:dispose()) = seconds 7  )
            )
            (case 6
                (
                (if (== (send gRoom:script) sExitViaTunnelB)
                    (self:dispose())
                )(else
                    (send gSq5Music2:
                        number(402)
                        setLoop(1)
                        play()
                    )
                    (fireBall:
                        view(402)
                        loop(0)
                        cel(0)
                        x(245)
                        y(19)
                        setStep(15 5)
                        moveSpeed(0)
                        init()
                        setMotion(MoveTo + (send gEgo:x) 2 - (send gEgo:y) 18 self)
                    )
                )
 )
            )
            (case 7
                ((fireBall:dispose()) 
                (if ((<= 45 (send gEgo:heading)) and (<= (send gEgo:heading) 135))
                    (send gEgo:loop(3))
                )(else
                    (if ((<= 136 (send gEgo:heading)) and (<= (send gEgo:heading) 225))
                        (send gEgo:loop(0))
                    )(else
                        (if ((<= 226 (send gEgo:heading)) and (<= (send gEgo:heading) 315))
                            (send gEgo:loop(2))
                        )(else
                            (send gEgo:loop(1))
                        )
                    )
                )
 (send gEgo:
                    view(401)
                    cel(0)
                    setCycle(End self)
                )
  )
            )
            (case 8
                (proc0_9(17) (self:dispose()) )
            )
        )
    )

)
(instance wd40 of Actor
    (properties
        x 257
        y 43
        yStep 6
        view 419
        priority 14
        signal 16
    )

    (method (doVerb param1 param2)
        (if (not 
        (if ((== (self:view) 419) and (== (self:loop) 0))
            == (self:cel) 0
        )
)
            (send gTestMessager:say(4 param1 0 0 0 301))
        )(else
            (super:doVerb(param1 rest param2))
        )
    )

)
(instance fireBall of Actor
    (properties
        x 245
        y 19
        view 402
    )
)
(instance tunnelA of Feature
    (properties
        x 303
        y 128
        noun 3
        onMeCheck 2
    )
)
(instance tunnelB of Feature
    (properties
        x 186
        y 114
        noun 2
        onMeCheck rm310
    )
)
(instance bush of Feature
    (properties
        x 174
        y 54
        noun 1
        onMeCheck 32
    )
)
(instance fern of Feature
    (properties
        x 267
        y 166
        noun rm310
        onMeCheck sEnterFromTunnelA
    )
)
(instance outcrop of Feature
    (properties
        x 259
        y 41
        noun 5
        onMeCheck 128
    )
)
(instance path of Feature
    (properties
        x 206
        y 161
        noun 6
        onMeCheck 256
    )
)
