(include "sci.sh")
(use "Main")
(use "PriorityTalker")
(use "Osc")
(use "RandCycle")
(use "MoveFwd")
(use "n958")
(use "Grooper")
(use "Cycle")
(use "Sounds")
(use "View")
(use "Obj")
(script 104)


(local
    local0
    local1
    local2
    local3
    local4
    local5
    local6 = 160
    local7 = 100
    local8 = 4
    local9
    local10
    local11
    local12
    local13[400]
    local413
    local414
    local415 = 1
    local416 = 6
    local417
    local418
    local419
    local420
    local421
    local422
    local423[15] = (2 2 2 2 2 2 2 2 3 2 2 2 2 2 2 )
    local438[15] = (2 2 2 2 2 2 2 0 0 0 1 1 1 1 1 )
    local453[15] = (146 152 161 170 186 213 230 240 258 253 229 196 154 114 75 )
    local468[15] = (88 82 77 68 55 32 22 22 20 28 24 45 75 115 134 )
    local483[15] = (33 43 38 43 53 78 83 128 128 128 60 80 91 103 128 )

)
(procedure public (proc104_15)
)


(instance public rm104 of Rm
    (properties
        picture 1
        style 32778
    )

    (method (init)
        proc958_0(128 97 99 100 101 102 103)
        proc958_0(129 1 5 7 8)
        (super:init())
        (send gRoom:setScript(sGo))
        (send gKeyDownHandler:addToFront(self))
        (send gMouseDownHandler:addToFront(self))
    )


    (method (doit)
        (switch (local417)
            (case 1
                (Palette(6 224 226 1 226 228 1 228 230 1 232 234 1 234 236 1 240 241 1 128 144 1)  )
            )
            (case 2
                (Palette(6 236 238 10) )
            )
        )
        (super:doit())
    )


    (method (dispose param1)
        DrawPic(0 100 1)
        (super:dispose(rest param1))
    )


    (method (handleEvent pEvent)
        (if (((== (send gRoom:script) sCaptainsLog) and (== (sCaptainsLog:state) 0)) and (& (send pEvent:type) $4005))
            (sCaptainsLog:changeState(1))
            (send pEvent:claimed(1))
            return 
        )(else
            (super:handleEvent(pEvent))
        )
    )


    (method (newRoom param1)
        (send gKeyDownHandler:delete(self))
        (send gMouseDownHandler:delete(self))
        FlushResources(param1)
        (super:newRoom(param1))
    )

)
(instance sWaitNow of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (= cycles Random(0 7)  )
            )
            (case 1
                ((self:dispose()) )
            )
        )
    )

)
(instance sGo of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((send gSQ5:handsOff()) (send gSq5Music1:
                    number(1)
                    setLoop(-1)
                    play()
                )
 = seconds 3  )
            )
            (case 1
                ((space:
                    init()
                    setCycle(CT 3 1 self)
                )
  )
            )
            (case 2
                (= seconds 2  )
            )
            (case 3
                (GetMessage(0 104 3 0 0 1 @local13) Display(@local13 100 65 180 102 207 105 1605 106 200) = seconds 3  )
            )
            (case 4
                (Display(@local13 100 65 180 102 1 105 1605 106 200) = seconds 3  )
            )
            (case 5
                ((theComet:init()) (space:setCycle(CT 10 1)) = local421 1 = cycles 1  )
            )
            (case 6
                ((theComet:
                    setLoop(local423[local421])
                    setCel(local438[local421])
                    x(local453[local421])
                    y(local468[local421])
                    scaleX(local483[local421])
                    scaleY(local483[local421])
                )
 
                (if (== ++local421 8)
                    (theComet:setPri(15))
                )
 
                (if (< local421 15)
                    (if (== local421 8)
                        (space:setCycle(CT 9 -1))
                    )
                    --state
                )
 = ticks 5  )
            )
            (case 7
                ((theComet:dispose()) (space:setCycle(End self))  )
            )
            (case 8
                ((space:dispose()) = local417 1 Palette(4 1 175 0) Palette(4 240 242 0) Palette(4 182 208 0) = cycles 5  )
            )
            (case 9
                ((head:init()) (lArm:init()) (rArm:init()) (ego1:init()) (ego1:addToPic()) (lArm:addToPic()) (rArm:addToPic()) (head:addToPic()) (send ((commetStar:new())):init()) (send ((medStar:new())):init()) (send ((fastStar:new())):init()) = cycles 1  )
            )
            (case 10
                ((send ((medStar:new())):init()) (send ((slowStar:new())):init()) (send ((fastStar:new())):init()) = cycles 1  )
            )
            (case 11
                ((send ((commetStar:new())):init()) (send ((medStar:new())):init()) (send ((fastStar:new())):init()) = cycles 1  )
            )
            (case 12
                ((send ((medStar:new())):init()) (send ((fastStar:new())):init()) = cycles 1  )
            )
            (case 13
                ((send ((medStar:new())):init()) (send ((fastStar:new())):init()) = cycles 1  )
            )
            (case 14
                ((send ((commetStar:new())):init()) (send ((medStar:new())):init()) (send ((fastStar:new())):init()) = cycles 1  )
            )
            (case 15
                ((send ((commetStar:new())):init()) (send ((medStar:new())):init()) (send ((fastStar:new())):init()) = cycles 1  )
            )
            (case 16
                ((send ((commetStar:new())):init()) (send ((medStar:new())):init()) (send ((fastStar:new())):init()) = cycles 1  )
            )
            (case 17
                ((send ((medStar:new())):init()) (send ((fastStar:new())):init()) = cycles 1  )
            )
            (case 18
                ((send ((commetStar:new())):init()) (send ((medStar:new())):init()) (send ((fastStar:new())):init()) = cycles 1  )
            )
            (case 19
                ((send ((commetStar:new())):init()) (send ((medStar:new())):init()) (send ((slowStar:new())):init()) (send ((fastStar:new())):init()) = cycles 1  )
            )
            (case 20
                (= seconds 4  )
            )
            (case 21
                (= next sPixelIn (self:dispose()) )
            )
        )
    )

)
(instance sPixelIn of Script
    (properties)

    (method (doit param1)
        (super:doit(rest param1))
        (switch (local420)
            (case 1
                (Palette(4 144 152 100) Palette(4 152 160 0) = local420 2  )
            )
            (case 2
                (Palette(4 144 152 0) Palette(4 152 160 100) = local420 1 )
            )
        )
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((send gCast:eachElementDo(63 1)) = local8 2 = local420 1 Palette(4 1 175 10) Palette(4 240 242 10) Palette(4 182 208 10) Palette(4 1 175 20) Palette(4 240 242 20) Palette(4 182 208 20) Palette(4 1 175 30) Palette(4 240 242 30) Palette(4 182 208 30) Palette(4 1 175 40) Palette(4 240 242 40) Palette(4 182 208 40) Palette(4 1 175 50) Palette(4 240 242 50) Palette(4 182 208 50) Palette(4 1 175 60) Palette(4 240 242 60) Palette(4 182 208 60) Palette(4 1 175 70) Palette(4 240 242 70) Palette(4 182 208 70) Palette(4 1 175 80) Palette(4 240 242 80) Palette(4 182 208 80) Palette(4 1 175 90) Palette(4 240 242 90) Palette(4 182 208 90) Palette(4 1 175 100) Palette(4 240 242 100) Palette(4 182 208 100) = cycles 25  )
            )
            (case 1
                ((headA:init()) (lArmA:init()) (rArmA:init()) (ego1P:
                    init()
                    addToPic()
                )
 (logo:
                    init()
                    addToPic()
                )
 (mutation:
                    init()
                    addToPic()
                )
 (enext:
                    init()
                    addToPic()
                )
 DrawPic(1 3) = cycles 1  )
            )
            (case 2
                ((rArmA:
                    setCycle(End)
                    cycleSpeed(10)
                )
 (lArmA:
                    setCycle(End self)
                    cycleSpeed(10)
                )
  )
            )
            (case 3
                ((rArmA:setCycle(CT 2 -1)) (lArmA:setCycle(CT 2 -1 self))  )
            )
            (case 4
                ((rArmA:setCycle(CT 3 1)) (lArmA:setCycle(CT 3 1 self))  )
            )
            (case 5
                ((rArmA:setCycle(Beg)) (lArmA:setCycle(Beg self))  )
            )
            (case 6
                ((mutating2:init()) (send gSq5Music2:
                    number(708)
                    setLoop(1)
                    play()
                )
 (mutating:
                    init()
                    setCycle(End self)
                )
  )
            )
            (case 7
                ((headA:
                    cycleSpeed(10)
                    setCycle(End self)
                )
  )
            )
            (case 8
                ((headA:addToPic()) (lArmA:addToPic()) (rArmA:addToPic()) = seconds 6  )
            )
            (case 9
                (Palette(4 144 160 0) (mutating:dispose()) (mutating2:dispose()) DrawPic(1 3) = seconds 3  )
            )
            (case 10
                (= local417 0 = next sCredits (self:dispose()) )
            )
        )
    )

)
(instance sCredits of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (Palette(4 8 16 0) = ticks 5  )
            )
            (case 1
                ((creditName:
                    setLoop(local9)
                    init()
                )
 = cycles 1  )
            )
            (case 2
                (Palette(4 8 16 local12) 
                (if (< (= local12 (+ local12 10)) 101)
                    --state
                )
 = ticks 5  )
            )
            (case 3
                (= seconds 2  )
            )
            (case 4
                (Palette(4 8 16 local12) 
                (if (> (= local12 (- local12 10)) 0)
                    --state
                )
 = ticks 5  )
            )
            (case 5
                (
                (if (< ++local9 local10)
                    = state (- state 6)
                )
 = seconds 2  )
            )
            (case 6
                ((send gSq5Music1:fade()) (creditName:dispose()) = seconds 3  )
            )
            (case 7
                ((send gSq5Music1:
                    number(2)
                    loop(-1)
                    play(0)
                    fade(127 10 5 0)
                )
 = next sCaptainsLog Palette(4 8 16 100) (self:dispose()) )
            )
        )
    )


    (method (handleEvent pEvent)
        (if ((< state 6) and (& (send pEvent:type) $4005))
            (self:changeState(6))
            (send pEvent:claimed(1))
            return 
        )(else
            (super:handleEvent(pEvent))
        )
    )

)
(instance sCaptainsLog of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (GetMessage(0 104 1 0 0 local415 @local13) = local413 StrLen(@local13) = local414 0 = cycles 1  )
            )
            (case 1
                ((do StrAt(@local65493 local414 StrAt(@local13 local414)) StrAt(@local65493 ++local414 0) ) while (not (== StrAt(@local13 (- local414 1)) 32) or (== StrAt(@local13 (- local414 1)) 0))  Display(@local65493 100 40 10 102 254 105 1307 106 250) 
                (if (< local414 local413)
                    --state
                    = ticks 15
                )
 )
            )
            (case 2
                (= seconds 0 Display(@local65493 100 40 10 102 0 105 1307 106 250) 
                (if (> ++local415 local416)
                    = cycles 1
                )(else
                    = state -1
                    = seconds 1
                )
 )
            )
            (case 3
                (Palette(4 0 175 0) Palette(4 181 255 0) = next sAttack (self:dispose()) )
            )
        )
    )


    (method (handleEvent pEvent)
        (if ((== state 1) and (& (send pEvent:type) $4005))
            (self:changeState(2))
            (send pEvent:claimed(1))
            return 
        )(else
            (super:handleEvent(pEvent))
        )
    )

)
(instance sAttack of Script
    (properties)

    (method (doit)
        Palette(4 0 175 / (* 5 (- 220 (rogInChair:y))) 4)
        Palette(4 181 255 / (* 5 (- 220 (rogInChair:y))) 4)
        (super:doit())
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((rogInChair:
                    init()
                    setCycle(0)
                    setLoop(-1)
                    setLoop(1)
                    setMotion(MoveTo 160 140 self)
                )
  )
            )
            (case 1
                ((rogInChair:
                    loop(0)
                    cel(0)
                    setCycle(Osc 1 self)
                )
  )
            )
            (case 2
                (= seconds 3  )
            )
            (case 3
                ((send gSq5Music1:
                    number(3)
                    setLoop(-1)
                    play()
                )
 (talkBubble:init()) = seconds 4  )
            )
            (case 4
                ((talkBubble:hide()) (send gSq5Music2:
                    number(202)
                    setLoop(1)
                    play()
                )
 ShakeScreen(5 2) = cycles 1  )
            )
            (case 5
                ((rogInChair:
                    loop(2)
                    cel(2)
                    setCycle(Beg self)
                )
  )
            )
            (case 6
                ((rogInChair:hide()) DrawPic(5 100 1) = local417 2 = local419 1 Palette(4 144 160 100) (send gSq5Music2:
                    number(105)
                    setLoop(-1)
                    play()
                )
 = seconds 5  )
            )
            (case 7
                ((rogCloseup:init()) (rogMouth:
                    init()
                    setCycle(RTRandCycle)
                )
 (talkBubble:
                    view(101)
                    loop(2)
                    cel(0)
                    x(80)
                    y(10)
                    show()
                )
 = seconds 4  )
            )
            (case 8
                ((rogMouth:hide()) (talkBubble:
                    view(101)
                    loop(3)
                    cel(0)
                    x(20)
                    y(10)
                )
 = seconds 4  )
            )
            (case 9
                ((rogCloseup:view(97)) (rogMouth:
                    view(97)
                    x(123)
                    y(89)
                    show()
                    setCycle(RTRandCycle)
                )
 (talkBubble:
                    view(97)
                    loop(3)
                    cel(0)
                    x(80)
                    y(6)
                )
 = seconds 4  )
            )
            (case 10
                ((rogCloseup:dispose()) (rogMouth:dispose()) (talkBubble:dispose()) (send gSq5Music2:
                    number(202)
                    setLoop(1)
                    play()
                )
 DrawCel(97 2 0 81 38 15) ShakeScreen(10 2) = seconds 2  )
            )
            (case 11
                (DrawPic(1 100 1) (rogInChair:
                    loop(2)
                    cel(2)
                    show()
                    stopUpd()
                    ignoreActors()
                )
 = local417 0 = seconds 2  )
            )
            (case 12
                ((send gSq5Music2:stop()) (send gSq5Music1:
                    number(10)
                    setLoop(-1)
                    play()
                )
 DrawPic(7 9 1) = seconds 2  )
            )
            (case 13
                ((send gTestMessager:say(2 0 0 5 self))  )
            )
            (case 14
                ((send gTestMessager:say(2 0 0 6 self))  )
            )
            (case 15
                ((send gTestMessager:say(2 0 0 7 self))  )
            )
            (case 16
                (DrawPic(8 9 1) = local417 0 = seconds 6  )
            )
            (case 17
                ((send gRoom:newRoom(110)) (self:dispose()) )
            )
        )
    )

)
(instance space of Prop
    (properties
        x 120
        y 74
        view 96
    )

    (method (init param1)
        (super:init(rest param1))
        (quest:init())
    )


    (method (doit param1)
        (super:doit(rest param1))
        (quest:cel((self:cel)))
    )


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

)
(instance quest of Prop
    (properties
        x 148
        y 79
        view 96
        loop 1
    )
)
(instance rogInChair of Actor
    (properties
        x 160
        y 220
        view 100
        loop 1
    )
)
(instance lArm of Prop
    (properties
        x 125
        y 85
        view 99
        priority 3
        signal 16400
    )
)
(instance lArmA of Actor
    (properties
        x 125
        y 85
        view 99
        priority 15
        signal 16400
    )
)
(instance rArm of Prop
    (properties
        x 214
        y 75
        view 99
        loop 1
        priority 3
        signal 16400
    )
)
(instance rArmA of Actor
    (properties
        x 214
        y 75
        view 99
        loop 1
        priority 15
        signal 16400
    )
)
(instance head of Prop
    (properties
        x 162
        y 72
        view 99
        loop 2
        cel 2
        priority 3
        signal 16400
    )
)
(instance headA of Actor
    (properties
        x 162
        y 72
        view 99
        loop 2
        cel 2
        priority 15
        signal 16400
    )
)
(instance ego1P of Prop
    (properties
        x 41
        y 72
        view 99
        loop 3
        priority 12
        signal 16400
    )
)
(instance commetStar of Actor
    (properties
        view 103
        signal 24592
        moveSpeed 0
    )

    (method (init)
        (self:setScript(sWaitNow))
        = local4 20
        = local5 Random(0 7)
        (while ((== local5 local2) or (== local5 local3))
            = local5 Random(0 7)
        )
        = local3 local2
        = local2 local5
        = local0 (+ local6 CosMult((= local5 (* local5 45)) local4))
        = local1 (+ local7 SinMult(local5 local4))
        (self:
            setHeading(+ local5 90)
            posn(local0 local1)
            cycleSpeed(10)
            setStep(8 8)
            setCycle(End)
            setLoop(Grooper)
            setCel(0)
            setPri(local8)
            setMotion(MoveFwd 150 self)
        )
        (super:init())
    )


    (method (cue)
        (self:setScript(sWaitNow))
        (if (not local419)
            (send ((commetStar:new())):init())
        )
        (self:dispose())
    )

)
(instance fastStar of Actor
    (properties
        view 103
        priority 4
        signal 24592
        moveSpeed 0
    )

    (method (init)
        (self:setScript(sWaitNow))
        = local4 20
        = local0 (+ local6 CosMult((= local5 Random(0 359)) local4))
        = local1 (+ local7 SinMult(local5 local4))
        (self:
            setHeading(+ local5 90)
            posn(local0 local1)
            setStep(5 5)
            setLoop(0)
            setCycle(0)
            setCel(2)
            setPri(local8)
            setMotion(MoveFwd 150 self)
        )
        (super:init())
    )


    (method (cue)
        (if (not local419)
            (send ((fastStar:new())):init())
        )
        (self:dispose())
    )

)
(instance medStar of Actor
    (properties
        view 103
        priority 4
        signal 24592
        moveSpeed 4
    )

    (method (init)
        (self:setScript(sWaitNow))
        = local4 20
        = local0 (+ local6 CosMult((= local5 Random(0 359)) local4))
        = local1 (+ local7 SinMult(local5 local4))
        (self:
            setHeading(+ local5 90)
            posn(local0 local1)
            setCycle(0)
            setLoop(0)
            setPri(local8)
            setCel(1)
            setMotion(MoveFwd 100 self)
        )
        (super:init())
    )


    (method (cue)
        (if (not local419)
            (send ((medStar:new())):init())
        )
        (self:dispose())
    )

)
(instance slowStar of Actor
    (properties
        view 103
        priority 4
        signal 24592
        moveSpeed 10
    )

    (method (init)
        (self:setScript(sWaitNow))
        = local4 Random(30 40)
        = local0 (+ local6 CosMult((= local5 Random(0 359)) local4))
        = local1 (+ local7 SinMult(local5 local4))
        (self:
            setHeading(+ local5 90)
            posn(local0 local1)
            setPri(local8)
            setLoop(0)
            setCycle(0)
            setMotion(MoveFwd 100 self)
        )
        (super:init())
    )


    (method (cue)
        (if (not local419)
            (send ((slowStar:new())):init())
        )
        (self:dispose())
    )

)
(instance quirkMouth of Prop
    (properties
        nsTop 69
        nsLeft 14
        view 102
        priority 6
        signal 16400
    )
)
(instance public quirkTalker of PriorityTalker
    (properties
        x 100
        y 20
        view 102
        loop 2
        priority 6
        talkWidth 280
        textX 65376
        textY 65456
    )

    (method (init param1)
        = font gFont
        (send (= gSq5Win gNewSpeakWindow):
            tailX(171)
            tailY(38)
            xOffset(0)
        )
        (super:init(0 0 quirkMouth rest param1))
    )


    (method (dispose param1)
        = gSq5Win gSq5Win_2
        (super:dispose(rest param1))
    )

)
(instance talkBubble of View
    (properties
        x 160
        y 8
        view 100
        loop 3
        cel 1
        priority 14
        signal 16400
    )
)
(instance rogCloseup of View
    (properties
        x 81
        y 38
        view 101
        priority 14
        signal 16400
    )
)
(instance rogMouth of Prop
    (properties
        x 134
        y 89
        view 101
        loop 1
        priority 15
        signal 16400
    )
)
(instance theComet of Prop
    (properties
        x 146
        y 88
        view 96
        loop 2
        cel 2
        priority 1
        signal 16
        scaleSignal 1
        scaleX 33
        scaleY 33
    )
)
(instance ego1 of View
    (properties
        x 41
        y 72
        view 99
        loop 3
        priority 3
        signal 16400
    )
)
(instance creditName of View
    (properties
        x 160
        y 85
        view 29
        signal 16384
    )
)
(instance logo of View
    (properties
        x 56
        y 5
        view 99
        loop 3
        cel 1
        priority 15
        signal 16400
    )
)
(instance enext of Actor
    (properties
        x 50
        y 169
        view 99
        loop 4
        priority 15
        signal 16400
        xStep 14
    )
)
(instance mutation of Actor
    (properties
        x 155
        y 172
        view 99
        loop 4
        cel 1
        priority 13
        signal 16400
    )
)
(instance mutating of Prop
    (properties
        x 155
        y 172
        view 99
        loop 5
        priority 15
        signal 16400
    )
)
(instance mutating2 of View
    (properties
        x 154
        y 172
        view 99
        loop 6
        priority 14
        signal 16400
    )
)
