(include "sci.sh")
(use "Main")
(use "Scaler")
(use "Osc")
(use "PolyPath")
(use "Polygon")
(use "n958")
(use "Sound")
(use "Cycle")
(use "Sounds")
(use "View")
(use "Obj")
(script 1050)


(local
    local0
    local1
    theGCast

)
(instance public rm1050 of Rm
    (properties
        picture 129
        style 32778
    )

    (method (init)
        proc958_0(128 700 702 703 13 701 558 704)
        proc0_6(0)
        (westDoor:
            init()
            stopUpd()
        )
        (northDoor:
            init()
            stopUpd()
        )
        (eastDoor:
            init()
            stopUpd()
        )
        (cliffy:
            init()
            stopUpd()
        )
        (cliffyHand:
            init()
            stopUpd()
        )
        (energizeLight:
            init()
            stopUpd()
        )
        (ambiLight1:
            init()
            setCycle(Fwd)
        )
        (ambiLight2:
            init()
            setCycle(Fwd)
        )
        (ambiLight3:
            init()
            setCycle(Fwd)
        )
        (send gRoom:addObstacle((send ((Polygon:new())):
                type(3)
                init(247 133 282 133 282 127 202 127 203 153 304 153 290 144 257 144)
                yourself()
            )
))
        (super:init())
        (theMusic3:
            number(101)
            owner(self)
            flags(1)
            init()
            setLoop(-1)
            play(80)
        )
        (send gRoom:setScript(sRogEnters))
    )


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

)
(instance sRogEnters of Script
    (properties)

    (method (doit param1)
        (if ((< (wd40:x) 160) and (== state 2))
            (self:cue())
        )
        (super:doit(rest param1))
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((send gSQ5:handsOff()) = seconds 2  )
            )
            (case 1
                ((send gSq5Music2:
                    number(103)
                    setLoop(1)
                    play()
                )
 (eastDoor:setCycle(End self))  )
            )
            (case 2
                ((wd40:
                    setScale(Scaler 110 77 149 130)
                    init()
                    setCycle(Fwd)
                    setStep(5 3)
                    setMotion(MoveTo 65518 158)
                )
  )
            )
            (case 3
                ((send gSq5Music1:fade(0 20 20 1)) proc0_6(0) (send gEgo:
                    x(272)
                    y(127)
                    setScale(Scaler 110 77 149 130)
                    setLoop(-1)
                    setLoop(5)
                    init()
                    setMotion(PolyPath 215 153 self)
                )
  )
            )
            (case 4
                ((send gSq5Music2:
                    number(103)
                    setLoop(1)
                    play()
                )
 (eastDoor:setCycle(Beg self))  )
            )
            (case 5
                ((send gTestMessager:say(1 0 0 0 self))  )
            )
            (case 6
                (= seconds 2  )
            )
            (case 7
                ((send gEgo:
                    view(700)
                    setLoop(-1)
                    setLoop(10)
                    cel(0)
                    setCycle(End self)
                )
  )
            )
            (case 8
                ((send gTestMessager:say(4 0 0 0 self))  )
            )
            (case 9
                ((send gEgo:
                    setLoop(9)
                    cel(0)
                    setCycle(End self)
                )
 (cliffy:
                    setLoop(0)
                    setMotion(MoveTo 14 170)
                )
  )
            )
            (case 10
                (proc0_6(4) (send gEgo:
                    loop(0)
                    setMotion(MoveTo 279 146 self)
                )
  )
            )
            (case 11
                ((send gEgo:
                    view(0)
                    setLoop(8)
                    setCel(2)
                    setCycle(0)
                )
 = seconds 3  )
            )
            (case 12
                ((send gEgo:stopUpd()) (cliffy:stopUpd()) (send gSQ5:handsOn()) (send gSq5IconBar:disable(0)) (pukoidN1:init()) (pukoidN2:init()) (pukoidN3:init()) (send gSq5Music2:
                    number(103)
                    setLoop(1)
                    play()
                )
 (eastDoor:setCycle(End)) (westDoor:setCycle(End)) (northDoor:setCycle(End self))  )
            )
            (case 13
                ((pukoidN1:
                    setLoop(1)
                    setCycle(Fwd)
                    setMotion(MoveTo 180 136)
                )
 (pukoidN2:
                    setLoop(12)
                    setCycle(Fwd)
                    setMotion(MoveTo 188 129)
                )
 (pukoidN3:
                    setLoop(9)
                    setCycle(Fwd)
                    setMotion(MoveTo 154 130)
                )
 (pukoidE1:
                    setLoop(0)
                    init()
                    setCycle(Fwd)
                    setMotion(MoveTo 207 134)
                )
 (pukoidE2:
                    setLoop(6)
                    init()
                    setCycle(Fwd)
                    setMotion(MoveTo 137 134)
                )
 (pukoidW1:
                    setLoop(0)
                    init()
                    setCycle(Fwd)
                    setMotion(MoveTo 158 138 self)
                )
  )
            )
            (case 14
                (= local0 1 (send gSq5Music2:
                    number(103)
                    setLoop(1)
                    play()
                )
 (eastDoor:setCycle(Beg)) (westDoor:setCycle(Beg)) (northDoor:setCycle(Beg self))  )
            )
            (case 15
                ((eastDoor:stopUpd()) (westDoor:addToPic()) (northDoor:addToPic()) = seconds 10  )
            )
            (case 16
                ((send gSQ5:handsOff()) = local0 2 (pukoidW1:setScript(sRogPuked)) (self:dispose()) )
            )
        )
    )

)
(instance sRogPuked of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((pukoidW1:
                    view(678)
                    setCycle(Walk)
                    moveSpeed(2)
                    init()
                    setMotion(MoveTo 183 152 self)
                )
  )
            )
            (case 1
                ((pukoidW1:setMotion(MoveTo 216 155 self))  )
            )
            (case 2
                ((pukoidW1:setCycle(0)) (send gSq5Music2:
                    number(519)
                    setLoop(1)
                    play()
                )
 (thePuke:
                    init()
                    setCycle(End self)
                )
  )
            )
            (case 3
                ((thePuke:dispose()) (send gEgo:
                    view(650)
                    cel(0)
                    setCycle(End self)
                )
  )
            )
            (case 4
                (proc0_9(33) (self:dispose()) )
            )
        )
    )

)
(instance sPukoidsTransformed of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((send gTestMessager:say(2 0 0 0 self))  )
            )
            (case 1
                ((cliffyHand:setCel(1)) (energizeLight:setLoop(5)) = cycles 1  )
            )
            (case 2
                ((eView1:
                    init()
                    stopUpd()
                )
 = cycles 1  )
            )
            (case 3
                ((eView2:
                    init()
                    stopUpd()
                )
 = cycles 1  )
            )
            (case 4
                ((eView3:
                    init()
                    stopUpd()
                )
 = cycles 1  )
            )
            (case 5
                ((eView4:
                    init()
                    stopUpd()
                )
 = cycles 1  )
            )
            (case 6
                ((eView5:
                    init()
                    stopUpd()
                )
 = cycles 1  )
            )
            (case 7
                ((eView6:
                    init()
                    stopUpd()
                )
 = cycles 1  )
            )
            (case 8
                ((eView7:
                    init()
                    stopUpd()
                )
 (eView8:
                    init()
                    stopUpd()
                )
 = cycles 1  )
            )
            (case 9
                ((eView9:
                    init()
                    stopUpd()
                )
 = cycles 1  )
            )
            (case 10
                ((eProp1:
                    init()
                    setCycle(End self)
                )
  )
            )
            (case 11
                ((northDoor:
                    setCel(0)
                    setPri(1)
                    addToPic()
                )
 (pukoidN1:hide()) (pukoidN2:hide()) (pukoidN3:hide()) (pukoidE1:hide()) (pukoidE2:hide()) (head1:hide()) (head2:hide()) (head3:hide()) (head4:hide()) (head5:hide()) 
                (if (== local0 1)
                    (pukoidW1:hide())
                    proc0_10(249 20)
                    (pukeBeamOut:init())
                )(else
                    (pukoidW1:setScript(sRogPuked))
                    (pukeBeamOut:
                        loop(2)
                        cel(0)
                        init()
                    )
                )
 = cycles 1  )
            )
            (case 12
                ((send gCast:eachElementDo(299)) = cycles 1  )
            )
            (case 13
                (= theGCast gCast = gCast (EventHandler:new()) (send gCast:addToFront(pukeBeamOut)) (send gSq5Music2:
                    number(260)
                    setLoop(1)
                    play()
                )
 (pukeBeamOut:setCycle(Beg self))  )
            )
            (case 14
                ((pukeBeamOut:hide()) = seconds 3  )
            )
            (case 15
                (
                (if (== local0 2)
                    (self:dispose())
                )(else
                    (send gSq5Music2:
                        number(260)
                        setLoop(1)
                        play()
                    )
                    (pukeBeamOut:
                        loop(0)
                        cel(0)
                        show()
                        setCycle(End self)
                    )
                )
 )
            )
            (case 16
                ((send gSq5Music1:
                    number(45)
                    setLoop(-1)
                    play()
                )
 (pukeBeamOut:dispose()) (send gCast:dispose()) = gCast theGCast (pukoidN1:
                    view(703)
                    loop(0)
                    cel(0)
                    x(207)
                    y(134)
                    show()
                    addToPic()
                )
 (head1:
                    view(703)
                    loop(6)
                    cel(0)
                    x(210)
                    y(98)
                    show()
                    setCycle(Osc)
                )
 (pukoidN2:
                    view(703)
                    loop(1)
                    cel(0)
                    x(180)
                    y(136)
                    show()
                    addToPic()
                )
 (head2:
                    view(703)
                    loop(7)
                    cel(0)
                    x(180)
                    y(101)
                    show()
                    setCycle(Osc)
                )
 (pukoidN3:
                    view(703)
                    loop(2)
                    cel(0)
                    x(137)
                    y(134)
                    show()
                    addToPic()
                )
 (head3:
                    view(703)
                    loop(8)
                    cel(0)
                    x(136)
                    y(100)
                    show()
                    setCycle(Osc)
                )
 (pukoidE1:
                    view(703)
                    loop(3)
                    cel(0)
                    x(154)
                    y(130)
                    show()
                    addToPic()
                )
 (head4:
                    view(703)
                    loop(9)
                    cel(0)
                    x(152)
                    y(99)
                    show()
                    setCycle(Osc)
                )
 (pukoidE2:
                    view(703)
                    loop(4)
                    cel(0)
                    x(188)
                    y(129)
                    show()
                    addToPic()
                )
 (head5:
                    view(703)
                    loop(10)
                    cel(0)
                    x(188)
                    y(99)
                    show()
                    setCycle(Osc)
                )
 (pukoidW1:
                    view(703)
                    loop(5)
                    cel(0)
                    x(161)
                    y(136)
                    scaleX(128)
                    scaleY(128)
                    show()
                    addToPic()
                )
 (head6:
                    init()
                    setCycle(Osc)
                )
 = seconds 4  )
            )
            (case 17
                ((send gTestMessager:say(3 0 0 1 self))  )
            )
            (case 18
                ((send gSq5Music1:fade(0 10 10 1)) = seconds 4  )
            )
            (case 19
                ((send gSq5Music1:
                    number(28)
                    setLoop(-1)
                    play()
                )
 = seconds 2  )
            )
            (case 20
                ((send gTestMessager:say(3 0 0 2 self))  )
            )
            (case 21
                ((send gSq5Music2:
                    number(103)
                    setLoop(1)
                    play()
                )
 (eastDoor:setCycle(End)) proc0_6(4) (send gEgo:setMotion(PolyPath 270 123 self))  )
            )
            (case 22
                ((send gSq5Music2:
                    number(103)
                    setLoop(1)
                    play()
                )
 (eastDoor:setCycle(Beg self))  )
            )
            (case 23
                ((send gRoom:newRoom(1040)) (self:dispose()) )
            )
        )
    )

)
(instance sTooEarly of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((send gTestMessager:say(2 0 0 0 self))  )
            )
            (case 1
                ((cliffyHand:setCel(1)) (energizeLight:setLoop(5)) = cycles 2  )
            )
            (case 2
                ((energizeLight:
                    setLoop(3)
                    setCycle(Fwd)
                )
 (holdLight:init()) = cycles 1  )
            )
            (case 3
                ((pukoidW1:setScript(sRogPuked)) (self:dispose()) )
            )
        )
    )

)
(instance westDoor of Prop
    (properties
        x 58
        y 91
        view 700
        loop 6
        signal 16384
    )
)
(instance northDoor of Prop
    (properties
        x 166
        y 94
        view 700
        loop 7
        priority 9
        signal 16400
    )
)
(instance eastDoor of Prop
    (properties
        x 251
        y 91
        view 700
        loop 8
        signal 16384
    )
)
(instance wd40 of Actor
    (properties
        x 268
        y 127
        view 13
        signal 16384
    )

    (method (doit param1)
        (if (< (self:x) -10)
            UnLoad(128 13)
            (self:dispose())
        )
        (super:doit(rest param1))
    )

)
(instance cliffy of Actor
    (properties
        x 13
        y 144
        view 701
        priority 15
        signal 16400
    )

    (method (doVerb param1 param2)
        (switch (param1)
            (case 24
                ((send gSQ5:handsOff()) 
                (if (not local0)
                    (send gRoom:setScript(sTooEarly))
                )(else
                    (send gRoom:setScript(sPukoidsTransformed))
                )
 )
            )
            (case 2
                ((send gSQ5:handsOff()) 
                (if (not local0)
                    (send gRoom:setScript(sTooEarly))
                )(else
                    (send gRoom:setScript(sPukoidsTransformed))
                )
 )
            )
            (default 
                ((super:doVerb(param1 rest param2)) )
            )
        )
    )

)
(instance pukoidN1 of Actor
    (properties
        x 177
        y 121
        view 702
        loop 1
        signal 18432
    )

    (method (init param1)
        (super:init(rest param1))
        (self:setScale(Scaler 102 71 135 121))
    )


    (method (doit param1)
        (if (((== (self:mover) 0) and (== (self:loop) 1)) and (<> (self:x) 177))
            (self:
                setCycle(0)
                setLoop(2)
            )
            (head1:
                init()
                setPri((pukoidN1:priority))
                setCycle(Osc)
            )
        )
        (super:doit(rest param1))
    )

)
(instance pukoidN2 of Actor
    (properties
        x 180
        y 120
        view 702
        loop 12
        signal 18432
    )

    (method (init param1)
        (super:init(rest param1))
        (self:setScale(Scaler 102 82 130 121))
    )


    (method (doit param1)
        (if (((== (self:mover) 0) and (== (self:loop) 12)) and (<> (self:x) 180))
            (self:
                setCycle(0)
                setLoop(13)
            )
            (head2:
                init()
                setPri((pukoidN2:priority))
                setCycle(Osc)
            )
        )
        (super:doit(rest param1))
    )

)
(instance pukoidN3 of Actor
    (properties
        x 173
        y 121
        view 702
        loop 9
        signal 18432
    )

    (method (init param1)
        (super:init(rest param1))
        (self:setScale(Scaler 100 73 129 121))
    )


    (method (doit param1)
        (if (((== (self:mover) 0) and (== (self:loop) 9)) and (<> (self:x) 173))
            (self:
                setCycle(0)
                setLoop(10)
            )
            (head3:
                init()
                setPri((pukoidN3:priority))
                setCycle(Osc)
            )
        )
        (super:doit(rest param1))
    )

)
(instance pukoidE1 of Actor
    (properties
        x 253
        y 134
        view 702
        signal 18432
    )

    (method (doit param1)
        (if (((== (self:mover) 0) and (== (self:loop) 0)) and (<> (self:x) 253))
            (self:
                setCycle(0)
                setLoop(4)
            )
            (head4:
                init()
                setPri((pukoidE1:priority))
                setCycle(Osc)
            )
        )
        (super:doit(rest param1))
    )

)
(instance pukoidE2 of Actor
    (properties
        x 263
        y 134
        view 702
        loop 6
        signal 18432
    )

    (method (doit param1)
        (if (((== (self:mover) 0) and (== (self:loop) 6)) and (<> (self:x) 263))
            (self:
                setCycle(0)
                setLoop(7)
            )
            (head5:
                init()
                setPri((pukoidE2:priority))
                setCycle(Osc)
            )
        )
        (super:doit(rest param1))
    )

)
(instance pukoidW1 of Actor
    (properties
        x 57
        y 134
        view 678
        signal 18432
        scaleSignal 1
        scaleX 99
        scaleY 99
    )

    (method (init param1)
        (super:init(rest param1))
        (self:setScale(Scaler 103 73 152 136))
    )


    (method (doit param1)
        (if (== (self:mover) 0)
            (self:setCycle(0))
        )
        (super:doit(rest param1))
    )

)
(instance eProp1 of Prop
    (properties
        x 143
        y 47
        view 700
        loop 4
        signal 16384
    )
)
(instance head1 of Prop
    (properties
        x 177
        y 101
        view 702
        loop 3
        priority rm1050
        signal 16400
        cycleSpeed rm1050
    )
)
(instance head2 of Prop
    (properties
        x 187
        y 97
        view 702
        loop 14
        priority rm1050
        signal 16400
        cycleSpeed 11
    )
)
(instance head3 of Prop
    (properties
        x 152
        y 101
        view 702
        loop 11
        priority rm1050
        signal 16400
        cycleSpeed 12
    )
)
(instance head4 of Prop
    (properties
        x 203
        y 98
        view 702
        loop 5
        priority 9
        signal 16400
        cycleSpeed 12
    )
)
(instance head5 of Prop
    (properties
        x 132
        y 106
        view 702
        loop 8
        priority rm1050
        signal 16400
        cycleSpeed 11
    )
)
(instance head6 of Prop
    (properties
        x 162
        y 98
        view 703
        loop 11
        priority 15
        signal 16400
        cycleSpeed rm1050
    )
)
(instance thePuke of Prop
    (properties
        x 251
        y 118
        view wd40
        priority 15
        signal 16400
    )
)
(instance pukeBeamOut of Prop
    (properties
        x 163
        y 99
        view 704
        loop 1
        cel 7
        priority 15
        signal 16400
    )
)
(instance ambiLight1 of Prop
    (properties
        x 219
        y 100
        view 700
    )
)
(instance ambiLight2 of Prop
    (properties
        x 209
        y 104
        view 700
        loop 1
    )
)
(instance ambiLight3 of Prop
    (properties
        x 309
        y 106
        view 700
        loop 2
    )
)
(instance energizeLight of Prop
    (properties
        x 99
        y 169
        view 701
        loop 3
        priority 15
        signal 16400
    )
)
(instance holdLight of View
    (properties
        x 41
        y 159
        view 701
        loop 4
        priority 14
        signal 16400
    )
)
(instance cliffyHand of View
    (properties
        x 99
        y 189
        view 701
        loop 2
        priority 15
        signal 16
    )
)
(instance eView1 of View
    (properties
        x 95
        y 1
        view 700
        loop 3
        signal 16384
    )
)
(instance eView2 of View
    (properties
        x 108
        y rm1050
        view 700
        loop 3
        cel 1
        signal 16384
    )
)
(instance eView3 of View
    (properties
        x 129
        y 12
        view 700
        loop 3
        cel 4
        signal 16384
    )
)
(instance eView4 of View
    (properties
        x 126
        y 24
        view 700
        loop 3
        cel 2
        signal 16384
    )
)
(instance eView5 of View
    (properties
        x 145
        y 27
        view 700
        loop 3
        cel 5
        signal 16384
    )
)
(instance eView6 of View
    (properties
        x 135
        y 32
        view 700
        loop 3
        cel 3
        signal 16384
    )
)
(instance eView7 of View
    (properties
        x 177
        y 32
        view 700
        loop 3
        cel 7
        signal 16384
    )
)
(instance eView8 of View
    (properties
        x 121
        y 36
        view 700
        loop 3
        cel 6
        signal 16384
    )
)
(instance eView9 of View
    (properties
        x 200
        y 41
        view 700
        loop 3
        cel 8
        signal 16384
    )
)
(instance theMusic3 of Sound
    (properties
        flags 1
    )
)
