(version 2)
(include "sci.sh")
(exports
    0 rm550
)
(use "Main")
(use "FPRoom")
(use "Print")
(use "Scaler")
(use "Polygon")
(use "CueObj")
(use "n958")
(use "Path")
(use "Cycle")
(use "View")
(use "Obj")
(script 550)


(local
    local0
    local1
    local2
    theHitPoints
    local4
    local5
    local6
    theTicks
    local8
    local9
    local10
    local11
    local12
    local13[19] = (68 59 79 63 101 55 127 66 156 56 188 64 217 55 245 63 266 57 -32768 )

)
(procedure (localproc_1269 param1 param2 param3)
    return 
        (if (<= GetDistance(param2 (- param3 10) (send param1:x) (send param1:y)) local6)
            return 1
        )(else
            return 0
        )
)


(instance public rm550 of FPRoom
    (properties
        picture 780
    )

    (method (init)
        proc958_0(132 2552 2204 2800 2801 2802 2102 2751 560 2550 2549 548)
        proc958_0(128 550)
        (super:init())
        (if (not HaveMouse())
            = local2 2
            = local1 40
            = local0 4
        )(else
            = local2 0
            = local1 0
            = local0 0
        )
        (sriniHiderR:init())
        (sriniHiderL:init())
        (send gEgo:get(-1 44))
        (self:setScript(sStartRoom))
    )


    (method (dispose)
        = global119 24
        DisposeScript(983)
        (super:dispose())
    )


    (method (handleEvent pEvent)
        return 
            (if (& (send pEvent:type) $0040)
                return 0
            )(else
                (super:handleEvent(pEvent))
            )
    )


    (method (doVerb theVerb param2)
        return 
            (switch (theVerb)
                (case 47
                    (GunSound:play())
                    return 0
                )
                (default 
                    (super:doVerb(theVerb rest param2))
                )
            )
    )

)
(instance sStartRoom of Script
    (properties)

    (method (changeState newState)
        (var temp0[10], temp10)
        (switch (= state newState)
            (case 0
                = cycles 5
            )
            (case 1
                (send gGame:setCursor(999 1))
                (switch ((Print:
                    font(gFont)
                    mode(1)
                    addTitle(14 0 2 1 550)
                    addButton(1 15 0 0 1 0 0 550)
                    addButton(2 15 0 0 2 0 30 550)
                    addButton(3 15 0 0 3 0 60 550)
                    init()
                )
)
                    (case 0
                        = local12 1
                        = cycles 2
                    )
                    (case 1
                        = local12 0
                        = cycles 2
                    )
                    (case 2
                        = local12 2
                        = cycles 2
                    )
                    (case 3
                        = local12 1
                        = cycles 2
                    )
                )
            )
            (case 2
                (send gGame:handsOn())
                proc0_9(220)
                (send gIconBar:
                    curIcon((send gIconBar:useIconItem))
                    curInvIcon((send ((send gInv:at(44))):
                            cursor(10)
                            yourself()
                        )
)
                    enable((send gIconBar:at(5)))
                )
                (send ((send gIconBar:curIcon)):cursor(10))
                (send gGame:setCursor((send ((send gIconBar:at(5))):cursor)))
                (send gIconBar:select((send gIconBar:at(5))))
                (send gIconBar:disable(0 1 2 3 6))
                (send global2:drawPic(550))
                Format(@temp0 "%d" local10)
                Display("" 108 local11)
                = local11 Display(@temp0 100 152 173 102 44 105 global121 107)
                (switch (local12)
                    (case 1
                        = local4 2
                        = theHitPoints 1
                        = theTicks (+ 240 local1)
                        = local6 (+ 10 local0)
                        = local8 60
                        = local9 1
                    )
                    (case 2
                        = local4 4
                        = theHitPoints 3
                        = local6 (+ 7 local0)
                        = theTicks (+ 150 local1)
                        = local8 30
                        = local9 2
                    )
                    (case 0
                        = local4 6
                        = theHitPoints 5
                        = local6 (+ 5 local0)
                        = theTicks (+ 60 local1)
                        = local8 20
                        = local9 3
                    )
                )
                = temp10 1
                (while (<= temp10 local4)
                    (send ((shootTarget:new())):init())
                    ++temp10
                )
                (send gGameMusic1:
                    number(548)
                    loop(-1)
                    play()
                )
                (faller:
                    init()
                    hide()
                    setScale(Scaler 76 52 71 58)
                    setScript(sShowFallingGuy)
                )
                (srini:
                    init()
                    setLoop(4)
                    setScale(Scaler 64 50 46 45)
                    setScript(sFlyingSrini)
                )
                (corner1:
                    init()
                    ignoreActors()
                    ignoreHorizon()
                    stopUpd()
                    yStep(30)
                    setLoop(11)
                )
                (corner2:
                    init()
                    ignoreActors()
                    ignoreHorizon()
                    stopUpd()
                    yStep(30)
                    setLoop(11)
                )
                (corner3:
                    init()
                    ignoreActors()
                    ignoreHorizon()
                    stopUpd()
                    yStep(30)
                    setLoop(11)
                )
                (corner4:
                    init()
                    ignoreActors()
                    ignoreHorizon()
                    stopUpd()
                    yStep(30)
                    setLoop(11)
                )
                (lever1:init(1))
                (lever2:init(1))
                (lever3:init(1))
                (lever4:init(1))
                (tntShed:init())
                (rope:
                    init()
                    stopUpd()
                )
                (self:dispose())
            )
        )
    )

)
(instance sShowFallingGuy of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = seconds Random(4 10)
            )
            (case 1
                (send client:
                    cel(0)
                    show()
                )
            )
            (case 2
                (self:dispose())
            )
        )
    )

)
(instance sHitFaller of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send client:setCycle(End self))
            )
            (case 1
                (send client:hide())
                = next sShowFallingGuy
                (self:dispose())
            )
        )
    )

)
(instance sFlyingSrini of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send client:stopUpd())
                = seconds Random(2 10)
            )
            (case 1
                (send client:setMotion(sriniPath self))
            )
            (case 2
                (send client:posn(23 49))
                (self:changeState(0))
            )
        )
    )

)
(instance sKillSrini of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (srini:
                    setMotion(0)
                    setCycle(End self)
                )
            )
            (case 1
                = global122 12
                (send global2:newRoom(99))
            )
        )
    )

)
(instance sMoveShed of Script
    (properties)

    (method (dispose)
        (if (IsObject(client))
            (send client:myTravelScript(0))
        )
        (super:dispose())
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send client:
                    setMotion(MoveTo Random(104 205) (send client:y) self)
                    shootable(1)
                )
            )
            (case 1
                (send client:
                    myRow(5)
                    setMotion(MoveTo 
                        (if ((send client:dirToGo))
                            -20
                        )(else
                            340
                        )
 (send client:y) self)
                )
            )
            (case 2
                (send client:shootable(0))
                (send client:timeToMove(1))
            )
        )
    )

)
(instance sGotShed of Script
    (properties)

    (method (dispose)
        (if (IsObject(client))
            (send client:
                myDeathScript(0)
                init(1)
            )
        )
        (super:dispose())
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send client:setCycle(End self))
                (GunSound:play(2751))
            )
            (case 1
                (send client:setMotion(0))
                = ticks 60
            )
            (case 2
                (send client:
                    cel(0)
                    posn(0 0)
                    timeToMove(1)
                )
                (self:dispose())
            )
        )
    )

)
(instance sMoveTarget of Script
    (properties)

    (method (dispose)
        (if (IsObject(client))
            (send client:myTravelScript(0))
        )
        (super:dispose())
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send client:
                    setLoop(Random(5 9))
                    setMotion(MoveTo Random(104 205) (send client:y) self)
                )
                (switch ((send client:loop))
                    (case 5
                        (send client:
                            name("Vulture")
                            worthPoints(10)
                            deathSound(2552)
                        )
                    )
                    (case 6
                        (send client:
                            name("Sheep")
                            worthPoints(-10)
                            deathSound(2800)
                        )
                    )
                    (case 7
                        (send client:
                            name("Snail")
                            worthPoints(1)
                            deathSound(2204)
                        )
                    )
                    (case 8
                        (send client:
                            name("Old Man")
                            worthPoints(-25)
                            deathSound(2801)
                        )
                    )
                    (case 9
                        (send client:
                            name("Old Lady")
                            worthPoints(-50)
                            deathSound(2802)
                        )
                    )
                )
            )
            (case 1
                (send client:
                    myRow(5)
                    setCycle(CT 2 1 self)
                    setMotion(MoveTo 
                        (if ((send client:dirToGo))
                            -20
                        )(else
                            340
                        )
 (send client:y) self)
                )
            )
            (case 2
                (send client:shootable(1))
                = ticks theTicks
            )
            (case 3
                (send client:
                    shootable(0)
                    setCycle(CT 0 -1 self)
                )
            )
            (case 4
                0
            )
            (case 5
                = seconds 3
            )
            (case 6
                (send client:timeToMove(1))
            )
        )
    )

)
(instance sGotTarget of Script
    (properties)

    (method (dispose param1)
        (if ((paramTotal and param1) and IsObject(client))
            (send client:
                myDeathScript(0)
                script(0)
                dispose()
            )
        )
        (super:dispose())
    )


    (method (changeState newState)
        (var temp0[10])
        (switch (= state newState)
            (case 0
                (send client:shootable(0))
                = local10 (+ local10 (send client:worthPoints))
                = cycles 2
            )
            (case 1
                Format(@temp0 "%d" local10)
                Display("" 108 local11)
                = local11 Display(@temp0 100 152 173 102 44 105 global121 107)
                (send client:setCycle(End self))
            )
            (case 2
                (send client:setMotion(0))
                = ticks 60
            )
            (case 3
                (if (< local10 0)
                    = global122 6
                    (send global2:newRoom(99))
                )(else
                    (send ((shootTarget:new())):init())
                    (self:dispose(1))
                )
            )
        )
    )

)
(instance sMoveLever of Script
    (properties)

    (method (changeState newState)
        (var temp0)
        (switch (= state newState)
            (case 0
                (send client:setMotion(MoveTo Random(104 205) (send client:y) self))
            )
            (case 1
                (send client:
                    myRow(5)
                    setCycle(CT 2 1 self)
                    setMotion(MoveTo 
                        (if ((send client:dirToGo))
                            -20
                        )(else
                            340
                        )
 (send client:y) self)
                )
                (flipSound:
                    number(2549)
                    play()
                )
            )
            (case 2
                (send client:shootable(1))
                = ticks theTicks
            )
            (case 3
                (send client:shootable(0))
                (flash:
                    posn((send client:x) (send client:y))
                    cel(0)
                    setPri(13)
                    init()
                    setScale(-1 lever1)
                    show()
                )
                = cycles 1
            )
            (case 4
                = temp0 Random(0 2)
                (flash:dispose())
                (if (== temp0 2)
                    (breakSound:play())
                    (send ((bulletHole:new())):
                        posn(Random(10 310) Random(10 180))
                        cel(Random(0 3))
                        setPri(15)
                        ignoreActors()
                        addToPic()
                    )
                )
                (send client:setCycle(CT 0 -1 self))
                (if (proc999_5(--local8 0 5 10 15 20 25 30 35 40 45 50 55 60))
                    (rope:
                        cel(+ (rope:cel) local9)
                        stopUpd()
                    )
                )
                (if (== (rope:cel) 12)
                    = global122 6
                    (send global2:newRoom(99))
                )
            )
            (case 5
                0
            )
            (case 6
                (send client:timeToMove(1))
            )
        )
    )

)
(instance sGotLever of Script
    (properties)

    (method (dispose param1)
        (if ((paramTotal and param1) and IsObject(client))
            (if (not (send client:hitPoints))
                (send client:
                    myDeathScript(0)
                    script(0)
                    dispose()
                )
            )(else
                (send client:init(0))
            )
        )
        (super:dispose())
    )


    (method (changeState newState)
        (var temp0[10])
        (switch (= state newState)
            (case 0
                (send client:shootable(0))
                = local10 (+ local10 (send client:worthPoints))
                = cycles 2
            )
            (case 1
                Format(@temp0 "%d" local10)
                Display("" 108 local11)
                = local11 Display(@temp0 100 152 173 102 44 105 global121 107)
                (send client:setCycle(End self))
            )
            (case 2
                (send client:
                    setMotion(0)
                    hitPoints(- (send client:hitPoints) 1)
                )
                = ticks 60
            )
            (case 3
                (if ((send client:hitPoints))
                    (send client:
                        posn(0 0)
                        timeToMove(1)
                        myDeathScript(0)
                    )
                    (self:dispose(1))
                )(else
                    (if (== ++local5 4)
                        (send gGameMusic1:
                            number(560)
                            loop(1)
                            play()
                        )
                        (send gGame:
                            handsOff()
                            points(20)
                        )
                        (send global2:newRoom(220))
                    )(else
                        (self:dispose(1))
                    )
                )
            )
        )
    )

)
(instance sShootCorner of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send client:setMotion(MoveTo (send client:x) (+ (send client:y) 200) self))
            )
            (case 1
                (send client:dispose())
            )
        )
    )

)
(class Target of Actor
    (properties
        x 0
        y 0
        z 0
        heading 0
        noun 0
        modNum -1
        nsTop 0
        nsLeft 0
        nsBottom 0
        nsRight 0
        sightAngle 26505
        actions 0
        onMeCheck $6789
        state $0000
        approachX 0
        approachY 0
        approachDist 0
        _approachVerbs 0
        yStep 2
        view -1
        loop 0
        cel 0
        priority 0
        underBits 0
        signal $0000
        lsTop 0
        lsLeft 0
        lsBottom 0
        lsRight 0
        brTop 0
        brLeft 0
        brBottom 0
        brRight 0
        scaleSignal $0000
        scaleX 128
        scaleY 128
        maxScale 128
        cycleSpeed 6
        script 0
        cycler 0
        timer 0
        detailLevel 0
        scaler 0
        illegalBits $8000
        xLast 0
        yLast 0
        xStep 3
        origStep 770
        moveSpeed 6
        blocks 0
        baseSetter 0
        mover 0
        looper 0
        viewer 0
        avoider 0
        code 0
        shootable 0
        worthPoints 0
        myRow 5
        dirToGo 0
        timeToMove 1
        myTravelScript 0
        myDeathScript 0
        deathSound 0
    )

    (method (init)
        (self:ignoreActors())
        (super:init())
    )


    (method (doit)
        (var theMyRow, temp1)
        (super:doit())
        (if (timeToMove)
            = theMyRow Random(0 3)
            = temp1 (send gOldCast:firstTrue(#perform whosInThisRow theMyRow))
            (if (not temp1)
                = timeToMove 0
                = myRow theMyRow
                (switch (myRow)
                    (case 0
                        = x -20
                        = y 101
                        (self:setSpeed((+ 1 local2)))
                        = dirToGo 0
                        (self:setPri(-1))
                        (self:setScale(Scaler 66 55 105 104))
                    )
                    (case 1
                        = x 340
                        = y 110
                        (self:setSpeed((+ 2 local2)))
                        (self:setPri(8))
                        = dirToGo 1
                        (self:setScale(Scaler 87 69 114 112))
                    )
                    (case 2
                        = x 340
                        = y 123
                        (self:setSpeed((+ 3 local2)))
                        (self:setPri(10))
                        = dirToGo 1
                        (self:setScale(Scaler 90 77 127 121))
                    )
                    (case 3
                        = x -20
                        = y 140
                        (self:setSpeed((+ 4 local2)))
                        (self:setPri(11))
                        (self:setScale(0))
                        = dirToGo 0
                    )
                )
                (if (== script myTravelScript)
                    (send script:changeState(0))
                )(else
                    (self:setScript(myTravelScript))
                )
            )
        )
    )


    (method (dispose)
        (if (IsObject(myDeathScript) and (send myDeathScript:isKindOf(Script)))
            (send myDeathScript:dispose())
            = myDeathScript 0
        )
        (if (IsObject(myTravelScript) and (send myTravelScript:isKindOf(Script)))
            (send myTravelScript:dispose())
            = myTravelScript 0
        )
        (super:dispose())
    )


    (method (handleEvent pEvent)
        (if (shootable and localproc_1269(self gOrigX gPEventY))
            (GunSound:play(deathSound))
            (send pEvent:claimed(1))
            (self:setScript(myDeathScript))
        )
    )

)
(class LeverBrother of Target
    (properties
        x 0
        y 0
        z 0
        heading 0
        noun 0
        modNum -1
        nsTop 0
        nsLeft 0
        nsBottom 0
        nsRight 0
        sightAngle 26505
        actions 0
        onMeCheck $6789
        state $0000
        approachX 0
        approachY 0
        approachDist 0
        _approachVerbs 0
        yStep 2
        view -1
        loop 0
        cel 0
        priority 0
        underBits 0
        signal $0000
        lsTop 0
        lsLeft 0
        lsBottom 0
        lsRight 0
        brTop 0
        brLeft 0
        brBottom 0
        brRight 0
        scaleSignal $0000
        scaleX 128
        scaleY 128
        maxScale 128
        cycleSpeed 6
        script 0
        cycler 0
        timer 0
        detailLevel 0
        scaler 0
        illegalBits $8000
        xLast 0
        yLast 0
        xStep 3
        origStep 770
        moveSpeed 6
        blocks 0
        baseSetter 0
        mover 0
        looper 0
        viewer 0
        avoider 0
        code 0
        shootable 0
        worthPoints 0
        myRow 5
        dirToGo 0
        timeToMove 1
        myTravelScript 0
        myDeathScript 0
        deathSound 0
        hitPoints 0
    )

    (method (init param1)
        (if (param1)
            = hitPoints theHitPoints
        )
        = cel 0
        = myTravelScript (sMoveLever:new())
        = myDeathScript (sGotLever:new())
        = deathSound 2801
        (super:init())
    )

)
(instance srini of Actor
    (properties
        x 23
        y 49
        view 550
        cel 2
        signal $1000
    )

    (method (handleEvent pEvent)
        (GunSound:play())
        (send pEvent:claimed(1))
        (self:setScript(sKillSrini))
    )

)
(instance corner1 of Actor
    (properties
        x 23
        y 71
        view 550
        priority 15
        signal $0010
    )

    (method (handleEvent pEvent)
        (GunSound:play())
        (send pEvent:claimed(1))
        (self:setScript((sShootCorner:new())))
    )

)
(instance corner2 of Actor
    (properties
        x 297
        y 72
        view 550
        cel 1
        priority 15
        signal $0010
    )

    (method (handleEvent pEvent)
        (GunSound:play())
        (send pEvent:claimed(1))
        (self:setScript((sShootCorner:new())))
    )

)
(instance corner3 of Actor
    (properties
        x 298
        y 132
        view 550
        cel 2
        priority 14
        signal $0010
    )

    (method (handleEvent pEvent)
        (GunSound:play())
        (send pEvent:claimed(1))
        (self:setScript((sShootCorner:new())))
    )

)
(instance corner4 of Actor
    (properties
        x 22
        y 134
        view 550
        cel 3
        priority 14
        signal $0010
    )

    (method (handleEvent pEvent)
        (GunSound:play())
        (send pEvent:claimed(1))
        (self:setScript((sShootCorner:new())))
    )

)
(instance faller of Prop
    (properties
        x 250
        y 78
        view 550
        loop 12
        priority 8
        signal $0010
    )

    (method (handleEvent pEvent)
        (GunSound:play(2102))
        (send pEvent:claimed(1))
        (if (<> script sHitFaller)
            (self:setScript(sHitFaller))
        )
    )

)
(instance flash of Prop
    (properties
        view 550
        loop 14
    )

    (method (handleEvent pEvent)
        (send global2:handleEvent(pEvent))
    )

)
(instance rope of Prop
    (properties
        x 111
        y 159
        view 550
        loop 13
        priority 14
        signal $0010
    )
)
(instance shootTarget of Target
    (properties
        view 550
    )

    (method (init)
        (var temp0)
        = myTravelScript (sMoveTarget:new())
        = myDeathScript (sGotTarget:new())
        (super:init())
    )

)
(instance tntShed of Target
    (properties
        view 550
    )

    (method (init param1)
        (if (not paramTotal or not param1)
            (super:init())
        )
        (self:setLoop(10))
        = myTravelScript sMoveShed
        = myDeathScript sGotShed
    )


    (method (handleEvent pEvent)
        (if (shootable and localproc_1269(self gOrigX gPEventY))
            (self:shootable(0))
            (send pEvent:claimed(1))
            (send gOldCast:eachElementDo(#perform killEmAll))
            (self:setScript(myDeathScript))
        )
    )

)
(instance lever1 of LeverBrother
    (properties
        view 550
    )

    (method (init param1)
        (self:setLoop(0))
        = worthPoints 75
        (super:init(rest param1))
    )

)
(instance lever2 of LeverBrother
    (properties
        view 550
    )

    (method (init param1)
        (self:setLoop(1))
        = worthPoints 100
        (super:init(rest param1))
    )

)
(instance lever3 of LeverBrother
    (properties
        view 550
    )

    (method (init param1)
        (self:setLoop(2))
        = worthPoints 125
        (super:init(rest param1))
    )

)
(instance lever4 of LeverBrother
    (properties
        view 550
    )

    (method (init param1)
        (self:setLoop(3))
        = worthPoints 150
        (super:init(rest param1))
    )

)
(instance bulletHole of View
    (properties
        view 550
        loop 15
    )

    (method (handleEvent pEvent)
        (send global2:handleEvent(pEvent))
    )

)
(instance sriniHiderR of Feature
    (properties
        x 300
        y 70
    )

    (method (init)
        (super:init())
        (self:setOnMeCheck(2 (send ((Polygon:new())):
                type(0)
                init(247 0 319 0 319 79 226 79 226 61 222 47 247 22)
                yourself()
            )
))
    )


    (method (handleEvent pEvent)
        (send pEvent:claimed(1))
        (send global2:doVerb(47))
    )

)
(instance sriniHiderL of Feature
    (properties
        x 30
        y 70
    )

    (method (init)
        (super:init())
        (self:setOnMeCheck(2 (send ((Polygon:new())):
                type(0)
                init(0 70 0 0 113 0 113 36 79 36 84 70)
                yourself()
            )
))
    )


    (method (handleEvent pEvent)
        (send pEvent:claimed(1))
        (send global2:doVerb(47))
    )

)
(instance whosInThisRow of Code
    (properties)

    (method (doit param1 param2)
        return 
            (if ((send param1:respondsTo(#myRow)))
                return == (send param1:myRow) param2
            )(else
                return 0
            )
    )

)
(instance killEmAll of Code
    (properties)

    (method (doit param1)
        (if ((((send param1:respondsTo(#worthPoints)) and (send param1:worthPoints)) and (send param1:shootable)) and (<> (send param1:script) (send param1:myDeathScript)))
            (send param1:setScript((send param1:myDeathScript)))
        )
    )

)
(instance hitTargetSound of FPSound
    (properties
        flags $0001
        number 2552
    )
)
(instance shedSound of FPSound
    (properties
        flags $0001
        number 2751
    )
)
(instance flipSound of FPSound
    (properties
        flags $0001
    )
)
(instance breakSound of FPSound
    (properties
        flags $0001
        number 2542
    )
)
(class GunSound of FPSound
    (properties
        nodePtr 0
        handle 0
        flags $0001
        number 0
        vol 127
        priority 0
        loop 1
        signal $0000
        prevSignal 0
        dataInc 0
        min 0
        sec 0
        frame 0
        client 0
        owner 0
        next 0
    )

    (method (play theNext)
        (if (not next)
            = number 2101
        )
        (if (paramTotal)
            = next theNext
            (super:play(self))
        )(else
            (super:play())
            = next 0
        )
    )


    (method (cue)
        = number next
        (self:play())
    )

)
(instance sriniPath of Path
    (properties)

    (method (at param1)
        return local13[param1]
    )

)
