(include "sci.sh")
(use "Main")
(use "Class_255_0")
(use "SQRoom")
(use "ForwardCounter")
(use "DPath")
(use "Cycle")
(use "PicView")
(use "Obj")
(script 900)


(local
    local0[4]

)
(procedure (localproc_1160 param1)
    TextSize(@local0 param1 0 122)
    return / (- 180 (- local0[2] local0[0])) 2
)


(procedure (localproc_1180 param1)
    (var temp0)
    = temp0 localproc_1160(param1)
    Display(param1 100 168 temp0 106 122 105 0 101 0)
)


(instance public rm900 of SQRoom
    (properties
        picture 900
        style 30
    )

    (method (init)
        proc0_2()
        (send gLongSong:prevSignal(0))
        (super:init())
        localproc_1180(
            (switch (global187)
                (case 0
                    "We're glad you could play SQIV.  As usual, you've been a real pantload."
                )
                (case 1
                    "Smoking is bad for your health."
                )
                (case 2
                    "It looks like shoplifting is taken seriously around here!"
                )
                (case 3
                    "Next time, don't dilly-dally, dude!"
                )
                (case 4
                    "Anyway, we hope you'll get yourself together and rejoin us. Isn't this a blast?"
                )
                (case 5
                    "The formatting sequence times out, the computer brain does its thing, and you suddenly realize you've lost the game because you weren't there to see it."
                )
                (case 6
                    "THWUMP! Nice Reactions, Roger! Life is pounded loose from your body by the impact of the sand bike."
                )
                (case 7
                    "Your musculature spasms for the last time as the Force Field shock causes you to give up the ghost."
                )
                (case 8
                    "Oh, well. Just think proudly of your accomplishmen... On second thought, just think - it happens to even IMPORTANT people!"
                )
                (case 9
                    "Why'd you just STAND there?! I guess you just enjoy a laser buzz once in awhile."
                )
                (case 10
                    "Now, you KNEW he was coming, didn't you?!"
                )
                (case 11
                    "Well, that's just great!  Now Vohaul's on the loose again, disguised as your SON!  You lose 3 out of 2."
                )
                (case 12
                    "Gee, Zero IQ, Zero-G might be for you."
                )
                (case 13
                    "As the green slime dissolves the flesh from your bones, you think, \"Hey! This stuff consumes 47 times its weight in acid!\""
                )
                (case 14
                    "Hint: hitting a moving target is more difficult than hitting a stationary LUMP!"
                )
                (case 15
                    "Were you looking for trouble?  Maybe you thought you could beat them senseless with your pink bunny rabbit?"
                )
                (case 16
                    "This is Roger.\n\nThis is Roger on Ortega.\n\n\nAny questions?"
                )
                (case 17
                    "Zap zap, you're dead."
                )
                (case 18
                    "Well... maybe.  It's worth a try."
                )
                (case 19
                    "As you leave the laser tunnel, you hear a metallic voice announce that the formatting program is beginning, erasing all data in the super computer and dashing all hopes of regaining your son!"
                )
                (case 20
                    "For a fleeting moment, you are impressed with the droid's accuracy."
                )
                (case 21
                    "OW! Now this is a pain that'll linger! All the Ben Gay in Florida won't relieve this stiffness."
                )
                (case 22
                    "That was a LOOoooong first step."
                )
                (case 23
                    "While you were busy staring blankly at your PocketPal(tm) screen, a droid clumsily snuck up to you and tapped you on the shoulder. \"Zap,\" it said in its droning metallic voice, \"you're it.\""
                )
                (case 24
                    "It's not over 'till the fat lady Orat spits... EEE-UCK! Well, I guess it's over. All over. All over everything!"
                )
                (case 25
                    "Boy, these guys manage to be in the most inconvenient places! They seem to have this area secured. Your extra crispy parts surely will provide no threat."
                )
                (case 26
                    "Boy, is that typical. Isn't it just like a Sequel Police cyborg to guard the main entrances and exits."
                )
                (case 27
                    "I'm sure the Babes appreciate your sacrifice, too bad you can't experience just how appreciative they are."
                )
                (case 28
                    "Just as you fade from the living organism club you think, in amazement,\"So that's what my spleen looks like!\""
                )
                (case 29
                    "You were warned not to try to break into the change machine, but did you listen?"
                )
                (case 30
                    "The word \"Laser\" came to mind after each of the first six shots, but only after the seventh blast were you convinced."
                )
            )
)
        (switch (global186)
            (case 0
                (self:setScript(deadScript))
            )
            (case 1
                (self:setScript(lightningScript))
            )
            (case 2
                (self:setScript(spearScript))
            )
            (case 3
                (self:setScript(slimeScript))
            )
            (case 4
                (self:setScript(slugScript))
            )
            (case 5
                (self:setScript(meltedScript))
            )
            (case 6
                (self:setScript(explodeScript))
            )
            (case 7
                (self:setScript(deadScript 0 4))
            )
            (case 8
                (self:setScript(laserScript))
            )
            (case 9
                (self:setScript(laserScript 0 4))
            )
        )
        (send gLongSong2:stop())
        (send gLongSong:
            number(826)
            vol(127)
            loop(1)
            flags(1)
            playBed()
        )
    )


    (method (cue)
        (asm
            pushi   #cue
            pushi   0
            super   SQRoom, 4
            pushi   #curIcon
            pushi   1
            pushi   #at
            pushi   1
            pushi   7
            lag     gIconBar
            send    6
            push    
            lag     gIconBar
            send    6
            pushi   #setCursor
            pushi   1
            pushi   #cursor
            pushi   0
            pushi   #curIcon
            pushi   0
            lag     gIconBar
            send    4
            send    4
            push    
            lag     gGame
            send    6
            pushi   0
            callb   proc0_3, 0
code_02e2:  pushi   16
            pushi   900
            pushi   0
            pushi   67
            pushi   83
            pushi   150
            pushi   30
            pushi   1
            pushi   81
            lofsa   "Restore"
            push    
            pushi   1
            pushi   81
            lofsa   "Restart"
            push    
            pushi   2
            pushi   81
            lofsa   "Quit"
            push    
            pushi   3
            calle   Print, 32
            push    
            dup     
            ldi     1
            eq?     
            bnt     code_031e
            pushi   #restore
            pushi   0
            lag     gGame
            send    4
            jmp     code_033e
code_031e:  dup     
            ldi     2
            eq?     
            bnt     code_0330
            pushi   #restart
            pushi   0
            lag     gGame
            send    4
            jmp     code_033e
code_0330:  dup     
            ldi     3
            eq?     
            bnt     code_033e
            ldi     1
            sag     global4
            jmp     code_0342
code_033e:  toss    
            jmp     code_02e2
code_0342:  ret     
        )
    )

)
(instance deadScript of Script
    (properties)

    (method (changeState newState)
        (var temp0[100])
        (switch (= state newState)
            (case 0
                (egoView:
                    loop(+ (egoView:loop) register)
                    x(+ (egoView:x) -2)
                    y(+ (egoView:y) 10)
                    init()
                )
                (egosHead:
                    loop(+ (egosHead:loop) register)
                    x(+ (egosHead:x) -2)
                    y(+ (egosHead:y) 10)
                    init()
                )
                (leftHand:
                    x(+ (leftHand:x) -2)
                    y(+ (leftHand:y) 10)
                    init()
                )
                (rightHand:
                    x(+ (rightHand:x) -2)
                    y(+ (rightHand:y) 10)
                    init()
                )
                = cycles 1
            )
            (case 1
                (egosHead:setCycle(CT 1 1 self))
                (leftHand:setCycle(End))
                (rightHand:setCycle(End))
            )
            (case 2
                (egosHead:setCycle(Beg self))
            )
            (case 3
                (egosHead:setCycle(End self))
                (rightHand:setCycle(Beg))
            )
            (case 4
                (rightHand:setCycle(End self))
            )
            (case 5
                (send global2:cue())
            )
        )
    )

)
(instance lightningScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (egoView:
                    x(+ (egoView:x) -2)
                    y(+ (egoView:y) 10)
                    init()
                )
                (egosHead:
                    x(+ (egosHead:x) -2)
                    y(+ (egosHead:y) 10)
                    init()
                )
                (leftHand:
                    x(+ (leftHand:x) -2)
                    y(+ (leftHand:y) 10)
                    init()
                )
                (rightHand:
                    x(+ (rightHand:x) -2)
                    y(+ (rightHand:y) 10)
                    init()
                )
                (send ((lightningProp:new())):
                    init()
                    x(67)
                    y(100)
                )
                (send ((lightningProp:new())):
                    init()
                    x(152)
                    y(99)
                    loop(1)
                )
                (send ((lightningProp:new())):
                    init()
                    x(126)
                    y(90)
                    loop(1)
                    cel(2)
                )
                (send ((lightningProp:new())):
                    init()
                    x(93)
                    y(86)
                    cel(2)
                )
                (send ((lightningProp:new())):
                    init()
                    x(55)
                    y(87)
                    loop(1)
                    cel(4)
                )
                = cycles 1
            )
            (case 1
                (send gLongSong2:
                    number(135)
                    loop(-1)
                    vol(105)
                    play()
                )
                (egosHead:setCycle(CT 1 1 self))
                (leftHand:setCycle(End))
                (rightHand:setCycle(End))
            )
            (case 2
                (egosHead:setCycle(Beg self))
            )
            (case 3
                (egosHead:setCycle(End self))
                (rightHand:setCycle(Beg))
            )
            (case 4
                (rightHand:setCycle(End self))
            )
        )
    )

)
(instance spearScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (egoView:
                    x(+ (egoView:x) -2)
                    y(+ (egoView:y) 10)
                    init()
                )
                (egosHead:
                    x(+ (egosHead:x) -2)
                    y(+ (egosHead:y) 10)
                    init()
                )
                (leftHand:
                    x(+ (leftHand:x) -2)
                    y(+ (leftHand:y) 10)
                    init()
                )
                (rightHand:
                    x(+ (rightHand:x) -2)
                    y(+ (rightHand:y) 10)
                    init()
                )
                (deathProp:
                    view(995)
                    x(90)
                    y(85)
                    priority(12)
                    init()
                )
                = cycles 1
            )
            (case 1
                (egosHead:setCycle(CT 1 1 self))
                (leftHand:setCycle(End))
                (rightHand:setCycle(End))
            )
            (case 2
                (egosHead:setCycle(Beg self))
            )
            (case 3
                (egosHead:setCycle(End self))
                (rightHand:setCycle(Beg))
            )
            (case 4
                (rightHand:
                    cycleSpeed(0)
                    setCycle(End self)
                )
            )
            (case 5
                (leftHand:
                    cycleSpeed(0)
                    setCycle(Beg self)
                )
            )
            (case 6
                (send global2:cue())
            )
        )
    )

)
(instance slimeScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (deathProp:
                    init()
                    view(996)
                    cel(0)
                    x(96)
                    y(127)
                )
                = cycles 1
            )
            (case 1
                (send global2:cue())
            )
        )
    )

)
(instance slugScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (deathProp:
                    init()
                    view(996)
                    cel(1)
                    x(96)
                    y(127)
                )
                = cycles 1
            )
            (case 1
                (send global2:cue())
            )
        )
    )

)
(instance meltedScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (egoView:
                    init()
                    x(106)
                    y(116)
                    view(997)
                )
                (deathProp:
                    init()
                    view(997)
                    loop(1)
                    x(92)
                    y(99)
                    setCycle(Fwd)
                )
                = cycles 1
            )
            (case 1
                (send gLongSong2:
                    number(90)
                    loop(-1)
                    vol(105)
                    play()
                )
                = cycles 39
            )
            (case 2
                (deathProp:setCycle(End self))
            )
            (case 3
                (send global2:cue())
            )
        )
    )

)
(instance explodeScript of Script
    (properties)

    (method (changeState newState)
        (var temp0[100])
        (switch (= state newState)
            (case 0
                (egosHead:
                    init()
                    x(83)
                    y(102)
                    cel(2)
                    setCycle(End)
                )
                (leftHand:
                    init()
                    x(49)
                    y(60)
                    setCycle(Walk)
                    setMotion(DPath 53 72 39 93 76 80 86 90 self)
                )
                (rightHand:
                    init()
                    x(98)
                    y(80)
                    setCycle(Walk)
                    setMotion(DPath 118 65 141 78 131 94 157 124 self)
                )
            )
            (case 1
                0
            )
            (case 2
                (send global2:cue())
            )
        )
    )

)
(instance laserScript of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (egoView:
                    loop(+ (egoView:loop) register)
                    x(+ (egoView:x) -2)
                    y(+ (egoView:y) 10)
                    init()
                )
                (egosHead:
                    loop(+ (egosHead:loop) register)
                    x(+ (egosHead:x) -2)
                    y(+ (egosHead:y) 10)
                    init()
                )
                (leftHand:
                    x(+ (leftHand:x) -2)
                    y(+ (leftHand:y) 10)
                    init()
                )
                (rightHand:
                    x(+ (rightHand:x) -2)
                    y(+ (rightHand:y) 10)
                    init()
                )
                (deathProp:
                    view(995)
                    x(100)
                    y(83)
                    setCel(+ 1 
                        (if (register)
                            1
                        )(else
                            0
                        )
)
                    setPri(7)
                    init()
                )
                (smoke:
                    x(+ (smoke:x) -2)
                    y(+ (smoke:y) 10)
                    setCycle(Fwd)
                    init()
                )
                = cycles 1
            )
            (case 1
                (egosHead:setCycle(CT 1 1 self))
                (leftHand:setCycle(End))
                (rightHand:setCycle(End))
            )
            (case 2
                (egosHead:setCycle(Beg self))
            )
            (case 3
                (egosHead:setCycle(End self))
                (rightHand:setCycle(Beg))
            )
            (case 4
                (rightHand:
                    cycleSpeed(0)
                    setCycle(End self)
                )
            )
            (case 5
                (leftHand:
                    cycleSpeed(0)
                    setCycle(Beg self)
                )
            )
            (case 6
                = cycles 10
            )
            (case 7
                (send global2:cue())
            )
        )
    )

)
(instance egoView of View
    (properties
        x 97
        y 115
        view 805
        priority 6
        signal 16400
    )
)
(instance egosHead of Prop
    (properties
        x 104
        y 80
        view 805
        loop 1
        priority 8
        signal 16400
        cycleSpeed 1
    )
)
(instance rightHand of Actor
    (properties
        x 84
        y 111
        yStep 1
        view 805
        loop 2
        priority 10
        signal 18448
        cycleSpeed 1
        illegalBits 0
        xStep 1
    )
)
(instance leftHand of Actor
    (properties
        x 146
        y 104
        yStep 1
        view 805
        loop 3
        priority 10
        signal 18448
        cycleSpeed 1
        xStep 1
    )
)
(instance deathProp of Prop
    (properties
        priority 12
        signal 16400
    )
)
(class Shocks of Prop
    (properties
        x 0
        y 0
        z 0
        heading 0
        noun 0
        nsTop 0
        nsLeft 0
        nsBottom 0
        nsRight 0
        description 0
        sightAngle 26505
        actions 26505
        onMeCheck 26505
        lookStr 0
        yStep 2
        view 994
        loop 0
        cel 0
        priority 14
        underBits 0
        signal 16400
        lsTop 0
        lsLeft 0
        lsBottom 0
        lsRight 0
        brTop 0
        brLeft 0
        brBottom 0
        brRight 0
        palette 0
        cycleSpeed 0
        script 0
        cycler 0
        timer 0
    )

    (method (init)
        (super:init())
        (self:setCycle(ForwardCounter 10 self))
    )


    (method (cue)
        (self:
            hide()
            dispose()
        )
        (send gLongSong2:stop())
        (super:cue())
        (send global2:cue())
    )

)
(instance lightningProp of Shocks
    (properties)
)
(instance smoke of Prop
    (properties
        x 102
        y 73
        view 995
        loop 1
        priority 14
        signal 16400
    )
)
