(include "sci.sh")
(use "Main")
(use "Class_255_0")
(use "PolyPath")
(use "Class_950_0")
(use "Sound")
(use "Cycle")
(use "Game")
(use "User")
(use "PicView")
(use "Obj")
(script 705)


(local
    local0
    local1
    theBunnyLoop
    local3[8] = (4 7 5 6 2 1 0 3 )
    local11[180] = (69 126 89 163 88 210 0 40 0 329 101 286 101 286 210 2 40 30 1 213 65526 188 94 188 65526 188 4 25 0 320 188 236 188 320 188 2 35 0 1 160 29 210 29 88 65526 88 4 30 0 315 169 220 166 220 210 0 50 0 1 90 329 54 263 54 301 65534 2 25 45 172 210 219 145 280 210 3 55 0 0 110 65526 155 94 155 65526 155 4 40 0 320 160 236 158 320 160 2 50 0 1 160 65526 50 67 40 52 65534 0 35 0 118 210 98 160 50 210 0 65 0 0 110 306 65534 265 54 329 54 2 60 0 329 180 276 166 329 97 2 60 0 0 92 65526 155 94 155 65526 155 4 55 0 320 160 236 158 320 160 2 65 0 1 160 0 65534 29 71 65526 71 4 60 0 65526 130 36 176 65526 176 4 60 0 0 109 )
    local191[63] = (245 138 188 167 2 30 3 96 185 242 188 4 25 2 73 121 104 154 4 30 3 214 165 255 122 3 55 2 68 166 250 166 4 40 2 196 168 70 115 3 65 4 295 35 250 107 1 40 2 87 132 256 132 4 55 2 14 44 65 148 1 50 4 )
    local254[18] = (76 160 0 0 188 147 171 142 0 0 143 140 210 50 0 0 105 69 )
    local272[36] = (123 210 154 164 185 210 118 210 111 152 50 210 219 210 247 148 274 210 78 210 66 146 20 210 327 20 287 52 327 52 65529 27 29 73 65529 73 )

)
(class bunny of Rgn
    (properties
        script 0
        number 0
        timer 0
        keep 0
        initialized 0
        lookStr 0
        bunnyWait 300
        bunnyRoom 0
        followTimer 0
        followFlag 0
    )

    (method (init)
        (super:init())
        Load(rsVIEW 105)
        (drumBeat:init())
        (if (followFlag and not (send gEgo:has(3)))
            (theBunny:
                init()
                setCycle(Walk)
                setScript(buzzOff)
            )
        )
    )


    (method (doit)
        (super:doit())
        (if ((send global2:script))
            0
        )(else
            (if (> followTimer 0)
                = followTimer (- followTimer 1)
            )(else
                (if ((> bunnyWait 0) and not (theBunny:script))
                    = bunnyWait (- bunnyWait 1)
                    (if (not (send gEgo:has(3)) and (== bunnyWait 60))
                        (theBunny:
                            init()
                            setCycle(Fwd)
                            z(1000)
                        )
                    )
                )(else
                    (if (not (theBunny:script) and (== (send ((send gInv:at(3))):owner) 0))
                        (self:bunnyWait(300))
                        (theBunny:
                            init()
                            z(0)
                            setCycle(Walk)
                            setScript(bunnyScript)
                        )
                    )
                )
            )
        )
    )


    (method (newRoom param1 param2)
        = keep proc999_5(param1 25 30 35 40 45 50 55 60 65)
        = initialized 0
        (theBunny:cel(0))
        (if ((== (self:bunnyRoom) param1) and followTimer)
            (self:followFlag(1))
        )(else
            (self:followFlag(0))
        )
        (super:newRoom(param1 rest param2))
    )

)
(instance bunnyScript of Script
    (properties)

    (method (doit)
        (super:doit())
        (if (< register 22)
            ++register
        )
        (if ((((not (& (send gEgo:onControl(1)) $0100) and not (& (send gEgo:onControl(1)) $1000)) and (== (send global2:script) ropeScript)) and local1) or (((> register 20) and (send gEgo:mover)) and local1))
            (theBunny:setScript(runAway))
        )
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = local0 (* (- (/ gNumber 5) 5) 20)
                (if (local11[+ local0 18])
                    (if (< (send gEgo:x) local11[(+ local0 19)])
                        = local0 (+ local0 9)
                    )
                )(else
                    (if (< (send gEgo:y) local11[(+ local0 19)])
                        = local0 (+ local0 9)
                    )
                )
                (bunny:bunnyRoom(local11[(+ local0 7)]))
                = cycles 1
            )
            (case 1
                = local1 local11[(+ local0 6)]
                (theBunny:
                    x(local11[local0])
                    y(local11[+ local1 1])
                    setMotion(MoveTo local11[+ local0 2] local11[+ local0 3] self)
                )
            )
            (case 2
                (theBunny:setMotion(MoveTo local11[(+ local0 4)] local11[(+ local0 5)] self))
            )
            (case 3
                (bunny:followTimer(60))
                (theBunny:
                    z(1000)
                    setCycle(Fwd)
                )
                (send client:setScript(0))
            )
        )
    )

)
(instance runAway of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (switch (local1)
                    (case 1
                        (theBunny:setMotion(MoveTo (theBunny:x) 65534 self))
                    )
                    (case 2
                        (theBunny:setMotion(MoveTo 329 (theBunny:y) self))
                    )
                    (case 3
                        (theBunny:setMotion(MoveTo (theBunny:x) 210 self))
                    )
                    (case 4
                        (theBunny:setMotion(MoveTo 65526 (theBunny:y) self))
                    )
                )
            )
            (case 1
                (if (local11[+ local0 8])
                    (bunny:bunnyRoom(local11[(+ local0 8)]))
                )(else
                    (bunny:bunnyRoom(local11[(+ local0 7)]))
                )
                (bunny:followTimer(60))
                (theBunny:
                    z(1000)
                    setCycle(Fwd)
                )
                = local1 0
                (send client:setScript(0))
            )
        )
    )

)
(instance buzzOff of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = register (* (- (/ gNumber 5) 5) 7)
                (if (== local191[(+ register 5)] gWest)
                    = register (+ register 2)
                )
                (self:cue())
            )
            (case 1
                (theBunny:
                    init()
                    x(local191[register])
                    y(local191[+ register 1])
                    z(0)
                    setCycle(Walk)
                )
                (switch (local191[+ register 4])
                    (case 1
                        (theBunny:setMotion(MoveTo (theBunny:x) 65534 self))
                    )
                    (case 2
                        (theBunny:setMotion(MoveTo 329 (theBunny:y) self))
                    )
                    (case 3
                        (theBunny:setMotion(MoveTo (theBunny:x) 210 self))
                    )
                    (case 4
                        (theBunny:setMotion(MoveTo 65526 (theBunny:y) self))
                    )
                )
            )
            (case 2
                (bunny:
                    bunnyWait(300)
                    followTimer(60)
                    bunnyRoom(0)
                )
                (theBunny:
                    z(1000)
                    setCycle(Fwd)
                )
                (send client:setScript(0))
            )
        )
    )

)
(instance public ropeScript of Script
    (properties)

    (method (changeState newState)
        (var temp0)
        (switch (= state newState)
            (case 0
                Load(rsVIEW 23)
                (if ((& (send gEgo:onControl(1)) $0100) or (& (send gEgo:onControl(1)) $1000))
                    = temp0 (* (- (/ gNumber 5) 5) 2)
                    (send gEgo:setMotion(PolyPath local254[temp0] local254[(+ temp0 1)] self))
                )(else
                    = cycles 1
                )
            )
            (case 1
                (if ((((== gNumber 25) or (== gNumber 40)) or (== gNumber 55)) or ((< (send gEgo:x) 160) and (((== gNumber 30) or (== gNumber 45)) or (== gNumber 60))))
                    (self:register(1))
                )(else
                    (self:register(0))
                )
                (if (& (send gEgo:onControl(1)) $0080)
                    (if (register)
                        = register 0
                        (send gEgo:setHeading(270))
                    )(else
                        = register 1
                        (send gEgo:setHeading(90))
                    )
                )
                = cycles 4
            )
            (case 2
                = cycles 1
            )
            (case 3
                (send gEgo:
                    setMotion(0)
                    normal(0)
                    view(23)
                    setLoop(+ register 2)
                    cel(0)
                )
                (theRope:
                    init()
                    setLoop(register)
                    cel(0)
                    x(
                        (if (register)
                            - (send gEgo:x) 6
                        )(else
                            + (send gEgo:x) 6
                        )
)
                    y(- (send gEgo:y) 23)
                    z(0)
                    cycleSpeed(3)
                    setCycle(End)
                    setMotion(MoveTo 
                        (if (register)
                            + (send gEgo:x) 19
                        )(else
                            - (send gEgo:x) 19
                        )
 - (send gEgo:y) 3 self)
                )
            )
            (case 4
                (send gEgo:
                    cycleSpeed(2)
                    setCycle(CT 2 1 self)
                )
            )
            (case 5
                (send gEgo:setCycle(End))
                = cycles 3
            )
            (case 6
                (tempHead:
                    init()
                    setLoop(+ register 4)
                    x(
                        (if (register)
                            + (send gEgo:x) 9
                        )(else
                            - (send gEgo:x) 9
                        )
)
                    y((send gEgo:y))
                    cycleSpeed(8)
                    setCycle(Fwd)
                )
                (if ((& (send gEgo:onControl(1)) $1000) or (& (send gEgo:onControl(1)) $0100))
                    (send global2:setScript(bunnySnare))
                )(else
                    = cycles 50
                )
            )
            (case 7
                (if (<> (send (ScriptID(701 1)):script) ScriptID(701 4))
                    Print("Don't you feel dumb standing out in plain sight while trying to trick something into your snare?")
                    = cycles 1
                )
            )
            (case 8
                (ropeScript:start(0))
                (theRope:
                    cycleSpeed(0)
                    setCycle(Beg self)
                )
            )
            (case 9
                (send gEgo:setCel(0))
                (theRope:
                    setCel(0)
                    x(
                        (if (register)
                            + (send gEgo:x) 11
                        )(else
                            - (send gEgo:x) 11
                        )
)
                    y(- (send gEgo:y) 20)
                    setMotion(MoveTo 
                        (if (register)
                            - (send gEgo:x) 7
                        )(else
                            + (send gEgo:x) 7
                        )
 - (send gEgo:y) 23 self)
                )
            )
            (case 10
                (ropeScript:start(0))
                (theRope:z(1000))
                (tempHead:dispose())
                proc0_1(
                    (if (register)
                        0
                    )(else
                        1
                    )
 0)
                = cycles 3
            )
            (case 11
                (theRope:dispose())
                proc0_3()
                (send client:setScript(0))
            )
        )
    )

)
(instance bunnySnare of Script
    (properties)

    (method (doit)
        (super:doit())
        (if (> (bunny:bunnyWait) 0)
            (bunny:bunnyWait((- (bunny:bunnyWait) 1)))
        )
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (User:canInput(1))
                (send gIconBar:enable(2))
                (send gIconBar:curIcon((send gIconBar:at(2))))
                (send gGame:setCursor((send ((send gIconBar:curIcon)):cursor)))
                = seconds 3
            )
            (case 1
                (if (> (bunny:bunnyWait) 60)
                    (bunny:bunnyWait(60))
                )
                (theBunny:
                    init()
                    z(1000)
                    setCycle(Fwd)
                )
                = seconds 7
            )
            (case 2
                (theBunny:
                    init()
                    x(local272[register])
                    y(local272[+ (= register 
                            (switch (gNumber)
                                (case 25
                                    0
                                )
                                (case 35
                                    6
                                )
                                (case 40
                                    12
                                )
                                (case 50
                                    18
                                )
                                (case 55
                                    24
                                )
                                (case 65
                                    30
                                )
                            )
) 1])
                    z(0)
                    setCycle(Walk)
                    setMotion(MoveTo local272[+ register 2] local272[+ register 3] self)
                )
                = theBunnyLoop (theBunny:loop)
            )
            (case 3
                (theBunny:
                    setCycle(Fwd)
                    setLoop(local3[(theBunny:loop)])
                )
                (if (<> (theBunny:loop) theBunnyLoop)
                    --state
                )
                = cycles 1
            )
            (case 4
                (theBunny:
                    setLoop(-1)
                    setCycle(Walk)
                    setMotion(MoveTo local272[+ register 4] local272[+ register 5] self)
                )
            )
            (case 5
                proc0_2()
                Print("Those sure are some finely honed reactions you've got there. Perhaps you're still suffering from time lag.")
                (bunny:
                    bunnyWait(300)
                    followTimer(60)
                    bunnyRoom(0)
                )
                (theBunny:
                    z(1000)
                    setLoop(-1)
                    setCycle(Fwd)
                )
                (ropeScript:start(8))
                (send global2:setScript(ropeScript))
            )
        )
    )

)
(instance catchBunny of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gLongSong2:
                    number(835)
                    loop(1)
                    vol(127)
                    play()
                )
                (theBunny:setMotion(0))
                (drumBeat:
                    number(0)
                    stop()
                )
                (theRope:
                    cel(0)
                    setLoop(+ (theRope:loop) 6)
                    cycleSpeed(1)
                    setCycle(End)
                )
                = cycles 2
            )
            (case 1
                (theBunny:dispose())
                (theRope:setCycle(End self))
            )
            (case 2
                (theRope:dispose())
                proc0_11(41 10)
                Print("That was without a doubt one of the finest examples of bunny snatching we've ever seen!")
                (send gEgo:get(3))
                (send gEgo:put(1 0))
                Print("The stress placed on the rope during the bunny snatching was too much. You cast the useless fibers aside.")
                (ropeScript:start(10))
                (send global2:setScript(ropeScript))
            )
        )
    )

)
(instance public theBunny of Actor
    (properties
        description "hare."
        lookStr "A brightly colored mechanical hare wanders about."
        view 105
        signal 24576
        illegalBits 0
    )

    (method (doit)
        (var temp0)
        (super:doit())
        (if (== (send global2:curPic) 31)
            (self:z(1000))
            (bunny:bunnyWait(300))
            (bunny:followTimer(0))
        )
        (if (((<> (send global2:script) catchBunny) and (<> (send global2:script) ScriptID(705 3))) and (== (self:cel) 2))
            = temp0 
                (if (not (self:z))
                    127
                )(else
                    (if ((bunny:followTimer))
                        (* (bunny:followTimer) 2)
                    )(else
                        (if (< (bunny:bunnyWait) 61)
                            (* Abs((- (bunny:bunnyWait) 60)) 2)
                        )(else
                            0
                        )
                    )
                )
            (if (= temp0 
                (if (not (self:z))
                    127
                )(else
                    (if ((bunny:followTimer))
                        (* (bunny:followTimer) 2)
                    )(else
                        (if (< (bunny:bunnyWait) 61)
                            (* Abs((- (bunny:bunnyWait) 60)) 2)
                        )(else
                            0
                        )
                    )
                )
)
                (drumBeat:
                    vol(= temp0 
                            (if (not (self:z))
                                127
                            )(else
                                (if ((bunny:followTimer))
                                    (* (bunny:followTimer) 2)
                                )(else
                                    (if (< (bunny:bunnyWait) 61)
                                        (* Abs((- (bunny:bunnyWait) 60)) 2)
                                    )(else
                                        0
                                    )
                                )
                            )
)
                    play()
                )
            )
        )
    )


    (method (doVerb param1)
        (asm
            lsp     param1
            dup     
            ldi     2
            eq?     
            bnt     code_0de3
            pushi   3
            dup     
            pushi   0
            lofsa   theBunny
            send    4
            push    
            pushi   #y
            pushi   0
            lofsa   theRope
            send    4
            sub     
            lt?     
            bnt     code_0dd6
            pprev   
            ldi     12
            lt?     
            bnt     code_0dd6
            pushi   60
            pushi   #x
            pushi   0
            lofsa   theRope
            send    4
            push    
            pushi   #x
            pushi   0
            lofsa   theBunny
            send    4
            sub     
            gt?     
            bnt     code_0da4
            pprev   
            ldi     54
            gt?     
            bt      code_0dc3
code_0da4:  pushi   60
            pushi   #x
            pushi   0
            lofsa   theBunny
            send    4
            push    
            pushi   #x
            pushi   0
            lofsa   theRope
            send    4
            sub     
            gt?     
            bnt     code_0dd6
            pprev   
            ldi     54
            gt?     
            bnt     code_0dd6
code_0dc3:  pushi   0
            callb   proc0_2, 0
            pushi   #setScript
            pushi   1
            lofsa   catchBunny
            push    
            lag     global2
            send    6
            jmp     code_0e00
code_0dd6:  pushi   2
            pushi   705
            pushi   4
            calle   Print, 4
            jmp     code_0e00
code_0de3:  dup     
            ldi     4
            eq?     
            bnt     code_0df7
            pushi   2
            pushi   705
            pushi   5
            calle   Print, 4
            jmp     code_0e00
code_0df7:  pushi   #doVerb
            pushi   1
            lsp     param1
            super   Actor, 6
code_0e00:  toss    
            ret     
        )
    )

)
(instance theRope of Actor
    (properties
        description "snare"
        lookStr "The rope is configured to function as a snare."
        yStep 12
        view 23
        signal 24576
        xStep 12
    )

    (method (doit)
        (super:doit())
        (if (== (send global2:curPic) 31)
            (self:hide())
        )(else
            (self:show())
        )
    )


    (method (doVerb param1 param2)
        (asm
            lsp     param1
            dup     
            ldi     2
            eq?     
            bnt     code_102a
            pushi   3
            dup     
            pushi   0
            lofsa   theBunny
            send    4
            push    
            pushi   #y
            pushi   0
            lofsa   theRope
            send    4
            sub     
            lt?     
            bnt     code_0fe7
            pprev   
            ldi     12
            lt?     
            bnt     code_0fe7
            pushi   60
            pushi   #x
            pushi   0
            lofsa   theRope
            send    4
            push    
            pushi   #x
            pushi   0
            lofsa   theBunny
            send    4
            sub     
            gt?     
            bnt     code_0fb5
            pprev   
            ldi     54
            gt?     
            bt      code_0fd4
code_0fb5:  pushi   60
            pushi   #x
            pushi   0
            lofsa   theBunny
            send    4
            push    
            pushi   #x
            pushi   0
            lofsa   theRope
            send    4
            sub     
            gt?     
            bnt     code_0fe7
            pprev   
            ldi     54
            gt?     
            bnt     code_0fe7
code_0fd4:  pushi   0
            callb   proc0_2, 0
            pushi   #setScript
            pushi   1
            lofsa   catchBunny
            push    
            lag     global2
            send    6
            jmp     code_1035
code_0fe7:  pushi   #z
            pushi   0
            pushi   2
            pushi   701
            pushi   5
            callk   ScriptID, 4
            send    4
            not     
            bnt     code_101d
            pushi   #distanceTo
            pushi   1
            pushi   2
            pushi   701
            pushi   5
            callk   ScriptID, 4
            push    
            self    6
            push    
            ldi     60
            lt?     
            bnt     code_101d
            pushi   2
            pushi   705
            pushi   6
            calle   Print, 4
            jmp     code_1035
code_101d:  pushi   2
            pushi   705
            pushi   7
            calle   Print, 4
            jmp     code_1035
code_102a:  pushi   #doVerb
            pushi   1
            lsp     param1
            &rest   param2
            super   Actor, 6
code_1035:  toss    
            ret     
        )
    )

)
(instance public tempHead of Prop
    (properties
        z 33
        view 23
        signal 16384
    )

    (method (doit)
        (super:doit())
        (if (== (send global2:curPic) 31)
            (self:z(1000))
        )(else
            (self:z(33))
        )
    )

)
(instance public theRoom of Feature
    (properties
        nsBottom 200
        nsRight 320
        description "area"
    )

    (method (doVerb param1 param2)
        (switch (param1)
            (case 3
                (switch (param2)
                    (case 1
                        (if (<> (send ((send gInv:at(3))):owner) 0)
                            0
                        )(else
                            (if (Btest(0))
                                Print("You don't have time for that now!")
                            )(else
                                (if (& (send gEgo:onControl(1)) $0020)
                                    Print("There's not enough room for that here!")
                                )(else
                                    (if (not (send global2:script))
                                        proc0_2()
                                        (send global2:setScript(ropeScript))
                                    )(else
                                        0
                                    )
                                )
                            )
                        )
                    )
                    (default 
                        (super:doVerb(param1))
                    )
                )
            )
            (default 
                0
            )
        )
    )

)
(instance drumBeat of Sound
    (properties
        number 116
    )
)
