(version 2)
(include "sci.sh")
(exports
    0 rm11
)
(use "Main")
(use "Class_255_0")
(use "mwAvoider")
(use "TurnLooper")
(use "Blk")
(use "n958")
(use "DPath")
(use "Wander")
(use "Follow")
(use "Avoid")
(use "Cycle")
(use "Game")
(use "User")
(use "PicView")
(use "Obj")
(script 11)


(local
    local0

)
(instance public rm11 of Rm
    (properties
        picture 11
        horizon 57
        north 22
        east 12
        south 6
        west 10
    )

    (method (init)
        proc958_0(132 22 23)
        proc958_0(128 211 21 166)
        (self:style(
            (switch (gGNumber)
                (case north
                    5
                )
                (case west
                    41
                )
                (case east
                    2
                )
                (case south
                    4
                )
            )
))
        (super:init())
        (switch (gGNumber)
            (case north
                (send gEgo:posn(proc0_17(192 (send gEgo:x) 0) (+ horizon 2)))
            )
            (case south
                (send gEgo:posn(proc0_17(236 (send gEgo:x) 0) 188))
            )
            (case west
                (send gEgo:y(proc0_17(189 proc0_18(160 (send gEgo:y) 158) (+ horizon 2))))
            )
            (default 
                (send gEgo:posn(317 proc0_17(182 proc0_18(138 (send gEgo:y) 120) 99)))
            )
        )
        (send gEgo:init())
        proc0_1()
        (gate:init())
        (if (proc0_12(23))
            (gate:
                ignoreActors()
                cel(3)
            )
            (send gEgo:illegalBits(-16384))
            (if (((<> gGNumber 10) and not gGNumber_2) and not proc0_12(80))
                proc0_10(80)
                proc255_0(11 0)
            )(else
                (if ((not gGNumber_2 and not proc0_12(80)) and (== gGNumber_3 11))
                    proc0_10(80)
                    proc255_0(11 0)
                )
            )
        )
        (gate:stopUpd())
        (if ((not proc0_12(2) and not gGNumber_2) and not proc0_12(80))
            Load(rsVIEW 21)
            Load(rsVIEW 167)
            (goatLpr:viewChange(167))
            (if ((== gGNumber_3 10) and not proc0_12(36))
                (send gGoat:
                    view(165)
                    posn(-20 Random(120 140))
                    init()
                    looper(goatLpr)
                    setCycle(Walk)
                    setScript(changeGoatRoom)
                )
                = local0 Random(Random(100 140) Random(160 200))
            )(else
                (send gGoat:
                    view(165)
                    posn(Random(20 40) Random(120 140))
                    init()
                    looper(goatLpr)
                    setCycle(Walk)
                    observeBlocks(pen)
                    setScript(goatWander)
                )
                = local0 Random(Random(100 140) Random(160 200))
            )
        )
    )


    (method (doit)
        (var temp0)
        (if (script)
            (send script:doit())
        )(else
            = temp0 
                (switch ((send ((User:alterEgo)):edgeHit))
                    (case 1
                        north
                    )
                    (case 2
                        east
                    )
                    (case 3
                        south
                    )
                    (case 4
                        west
                    )
                )
            (if (temp0)
                (self:newRoom((= temp0 
                        (switch ((send ((User:alterEgo)):edgeHit))
                            (case 1
                                north
                            )
                            (case 2
                                east
                            )
                            (case 3
                                south
                            )
                            (case 4
                                west
                            )
                        )
)))
            )(else
                (if ((((proc0_12(2) and proc0_12(36)) and not (& (send gGoat:onControl(1)) $7000)) and (& (send gEgo:onControl(1)) $7000)) and ((>= (send gEgo:distanceTo(gate)) 107) or (< (send gEgo:y) 116)))
                    proc0_11(2)
                    (self:setScript(goatLeaves))
                )(else
                    (if (((((proc0_12(2) and not proc0_12(36)) and not (send gGoat:script)) and not (& (send gEgo:onControl(1)) $7000)) and proc0_12(23)) and not (< (send gEgo:y) (send gGoat:y)))
                        (if (not (send gEgo:inRect(81 157 160 177)))
                            (send gGoat:setScript(goatOutaGate))
                        )(else
                            (send gGoat:setMotion(0))
                        )
                    )(else
                        (if (proc0_12(36) and (& (send gGoat:onControl(1)) $1000))
                            proc0_11(36)
                        )(else
                            (if (not (send gGoat:script) and (<> (send gGoat:illegalBits) -8132))
                                (send gGoat:illegalBits(-8132))
                            )
                        )
                    )
                )
            )
        )
    )


    (method (handleEvent pEvent)
        (if (Said('rub/ring'))
            (if (proc0_12(1))
                proc255_0(11 1)
            )(else
                (if (not global134)
                    proc255_0(11 2)
                )(else
                    (if (proc0_12(17))
                        proc255_0(11 3)
                        proc0_10(1)
                        proc0_1()
                        (if (proc0_12(23))
                            (send gEgo:observeControl(16384))
                        )
                        (if (proc0_12(2) and not proc0_12(36))
                            proc255_0(11 4)
                            proc0_11(2)
                            proc0_11(80)
                            (goatLpr:viewChange(167))
                            (if (== gGNumber_3 10)
                                (send gGoat:
                                    posn(-20 Random(120 140))
                                    init()
                                    looper(goatLpr)
                                    setCycle(Walk)
                                    setScript(changeGoatRoom)
                                )
                                = local0 Random(Random(100 140) Random(160 200))
                            )(else
                                (send gGoat:
                                    init()
                                    looper(goatLpr)
                                    setCycle(Walk)
                                    observeBlocks(pen)
                                    setScript(goatWander)
                                )
                                = local0 Random(Random(100 140) Random(160 200))
                            )
                        )
                    )(else
                        proc255_0(11 5)
                    )
                )
            )
        )(else
            (if (Said('remove/ring') or Said('get<off/ring'))
                (if (== (send gEgo:view) 
                (if (proc0_12(0))
                    23
                )(else
                    16
                )
)
                    proc0_22()
                )(else
                    (if (not proc0_12(17))
                        proc255_0(11 6)
                    )(else
                        proc255_0(11 7)
                        proc0_11(17)
                        proc0_11(1)
                        proc0_1()
                    )
                )
            )(else
                (if (Said('look,look/bush') or proc0_14(pEvent 263 151 320 189))
                    proc255_0(11 8)
                )(else
                    (if ((Said('look,look/ceder') or proc0_14(pEvent 177 -1 319 51)) or proc0_14(pEvent 224 52 319 99))
                        proc255_0(11 9)
                    )(else
                        (if ((((Said('look,look/fence') or proc0_14(pEvent 0 133 86 159)) or proc0_14(pEvent 141 129 162 150)) or proc0_14(pEvent 0 64 99 83)) or proc0_14(pEvent 99 65 129 82))
                            proc255_0(11 10)
                        )(else
                            (if ((send gCast:contains(gGoat)))
                                (if (gGNumber_2)
                                    (send pEvent:claimed(0))
                                )(else
                                    (if (Said('talk,speak,say,call') or Said('/hello'))
                                        proc255_0(11 11)
                                    )(else
                                        (if (Said('capture,move,move,get,get/goat'))
                                            (if (proc0_12(2))
                                                proc255_0(11 12)
                                            )(else
                                                (if (& (send gEgo:onControl(1)) $7000)
                                                    proc255_0(11 13)
                                                )(else
                                                    proc255_0(11 14)
                                                )
                                            )
                                        )(else
                                            (if (Said('feed/goat[/!*]'))
                                                proc255_0(11 15)
                                            )(else
                                                (if (Said('pet,free/goat'))
                                                    proc255_0(11 16)
                                                )(else
                                                    (if (Said('ride/goat'))
                                                        proc255_0(11 17)
                                                    )(else
                                                        (if (Said('feed/carrot') or Said('give/carrot'))
                                                            (if (not (send gEgo:has(2)))
                                                                proc255_0(11 18)
                                                            )(else
                                                                (if (> (send gEgo:distanceTo(gGoat)) 32)
                                                                    proc255_0(11 19)
                                                                )(else
                                                                    (if (proc0_12(1))
                                                                        proc255_0(11 20)
                                                                    )(else
                                                                        (if (proc0_12(2))
                                                                            proc255_0(11 21)
                                                                        )(else
                                                                            proc255_0(11 22)
                                                                        )
                                                                        proc0_8(2 15)
                                                                        proc0_11(2)
                                                                        (if (not proc0_12(23) and (& (send gGoat:onControl(1)) $7000))
                                                                            proc0_11(80)
                                                                            (goatLpr:viewChange(167))
                                                                            (send gGoat:
                                                                                view(165)
                                                                                looper(goatLpr)
                                                                                setCycle(Walk)
                                                                                observeBlocks(pen)
                                                                                setScript(goatWander)
                                                                            )
                                                                        )(else
                                                                            (send gGoat:setScript(goatBobs))
                                                                        )
                                                                        proc0_11(64)
                                                                        (send gGame:changeScore(-2))
                                                                    )
                                                                )
                                                            )
                                                        )(else
                                                            (if (((Said('show/carrot') or Said('coax,coax/goat')) or Said('show/goat/carrot')) or Said('coax,coax/goat/carrot'))
                                                                (if (not (send gEgo:has(2)))
                                                                    proc0_6()
                                                                )(else
                                                                    (if (proc0_12(2))
                                                                        proc255_0(11 23)
                                                                    )(else
                                                                        (if ((& (send gGoat:onControl(1)) $7000) and not (& (send gEgo:onControl(1)) $7000))
                                                                            proc255_0(11 24)
                                                                        )(else
                                                                            (if (proc0_12(1))
                                                                                proc255_0(11 25)
                                                                            )(else
                                                                                (if (> (send gEgo:distanceTo(gGoat)) 36)
                                                                                    proc255_0(11 26)
                                                                                )(else
                                                                                    (if ((send global2:script))
                                                                                        proc0_22()
                                                                                    )(else
                                                                                        (if ((not proc0_12(36) and (& (send gEgo:onControl(1)) $7000)) and not (& (send gGoat:onControl()) $7000))
                                                                                            proc255_0(11 27)
                                                                                        )(else
                                                                                            (send global2:setScript(getGoat))
                                                                                        )
                                                                                    )
                                                                                )
                                                                            )
                                                                        )
                                                                    )
                                                                )
                                                            )(else
                                                                (if (Said('shoot/goat') or Said('kill/goat/shot'))
                                                                    (if (gGNumber_2)
                                                                        proc255_0(11 28)
                                                                    )(else
                                                                        (if ((send global2:script))
                                                                            proc0_22()
                                                                        )(else
                                                                            (if (proc0_12(1))
                                                                                proc255_0(11 29)
                                                                            )(else
                                                                                (if (not proc0_12(36) and not (& (send gGoat:onControl()) $7000))
                                                                                    proc255_0(11 27)
                                                                                )(else
                                                                                    (if (not (send gEgo:has(9)) or not (send gEgo:has(10)))
                                                                                        proc255_0(11 30)
                                                                                    )(else
                                                                                        proc255_0(11 31)
                                                                                    )
                                                                                )
                                                                            )
                                                                        )
                                                                    )
                                                                )(else
                                                                    (if (Said('stab,kill/goat') or Said('use,cast/dagger'))
                                                                        (if (gGNumber_2)
                                                                            proc255_0(11 28)
                                                                        )(else
                                                                            (if ((send global2:script))
                                                                                proc0_22()
                                                                            )(else
                                                                                (if ((< (send gGoat:x) 0) and not proc0_12(36))
                                                                                    proc255_0(11 27)
                                                                                )(else
                                                                                    (if (not (& (send gEgo:onControl(1)) $7000) and not proc0_12(36))
                                                                                        proc255_0(11 32)
                                                                                    )(else
                                                                                        (if (> (send gEgo:distanceTo(gGoat)) 35)
                                                                                            proc255_0(11 33)
                                                                                        )(else
                                                                                            (if (not (send gEgo:has(0)))
                                                                                                proc255_0(11 34)
                                                                                            )(else
                                                                                                (send global2:setScript(ScriptID(600 2)))
                                                                                            )
                                                                                        )
                                                                                    )
                                                                                )
                                                                            )
                                                                        )
                                                                    )
                                                                )
                                                            )
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )(else
                                (if (Said('/goat') or Said('show/carrot'))
                                    (if (proc0_12(1))
                                        proc255_0(11 35)
                                    )(else
                                        (if (proc0_12(2))
                                            proc255_0(11 23)
                                        )(else
                                            (if (proc0_12(80))
                                                proc255_0(11 36)
                                            )(else
                                                proc255_0(11 37)
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )
        )
        (if (Said('jump/fence'))
            proc255_0(11 38)
        )(else
            (if (Said('climb,climb/fence,gate'))
                (if (proc0_12(23))
                    proc255_0(11 39)
                )(else
                    proc255_0(11 40)
                )
            )(else
                (if (Said('look,look>'))
                    (if (Said('[<at,around][/room,fence]'))
                        (if (& (send gEgo:onControl(1)) $7000)
                            proc255_0(11 41)
                        )(else
                            proc255_0(11 42)
                        )
                    )(else
                        (if (Said('/fence'))
                            (if (& (send gEgo:onControl(1)) $7000)
                                proc255_0(11 43)
                            )(else
                                proc255_0(11 44)
                            )
                        )(else
                            (if (Said('/gate'))
                                (if (proc0_12(23))
                                    proc255_0(11 39)
                                )(else
                                    proc255_0(11 45)
                                )
                            )(else
                                (if (Said('/trough'))
                                    proc255_0(11 46)
                                )
                            )
                        )
                    )
                )(else
                    (if (Said('open,open/gate,door'))
                        (if (not (send gEgo:inRect(77 126 132 166)))
                            proc0_4()
                        )(else
                            (if (proc0_12(23))
                                proc255_0(11 47)
                            )(else
                                (gate:setScript(openIt))
                            )
                        )
                    )(else
                        (if (Said('close,close/gate,door'))
                            (if (proc0_12(2))
                                proc255_0(11 48)
                            )(else
                                (if (not (send gEgo:inRect(77 126 132 166)))
                                    proc0_4()
                                )(else
                                    (if (not proc0_12(23))
                                        proc255_0(11 49)
                                    )(else
                                        (gate:setScript(closeIt))
                                    )
                                )
                            )
                        )(else
                            (if (Said('attack,kick/goat'))
                                (if (gGNumber_2)
                                    proc255_0(11 50)
                                )(else
                                    proc255_0(11 51)
                                )
                            )
                        )
                    )
                )
            )
        )
    )

)
(instance gate of Prop
    (properties
        x 141
        y 158
        view 211
    )

    (method (handleEvent pEvent)
        (if ((send pEvent:claimed))
            return 
        )(else
            (if (proc255_5(self pEvent 3))
                (if (proc0_12(23))
                    proc255_0(11 39)
                )(else
                    proc255_0(11 45)
                )
            )(else
                (super:handleEvent(pEvent))
            )
        )
    )

)
(instance goatLpr of TurnLooper
    (properties)
)
(instance pen of Cage
    (properties
        top 85
        left 1
        bottom 156
        right 130
    )
)
(instance goatWander of Script
    (properties)

    (method (doit param1)
        (super:doit(rest param1))
        (if (not gGNumber_2 and (< (send gEgo:distanceTo(gGoat)) 30))
            = cycles 0
            (send gGoat:setScript(goatRuns))
        )(else
            (if (== --local0 0)
                (send gGoat:setScript(changeGoatRoom))
            )
        )
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gGoat:
                    setLoop(-1)
                    setMotion(Wander)
                    startUpd()
                )
                = cycles Random(14 30)
            )
            (case 1
                (send gGoat:setMotion(0))
                = cycles Random(8 17)
            )
            (case 2
                (self:changeState(0))
            )
        )
    )

)
(instance goatRuns of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gGoat:
                    setAvoider(mwAvoider)
                    setMotion(MoveTo -20 (send gGoat:y) self)
                )
                (if ((send gGoat:blocks))
                    (send gGoat:ignoreBlocks(pen))
                )
            )
            (case 1
                = gGNumber_3 10
                (send gGoat:
                    hide()
                    setScript(goatCounter)
                )
                (self:dispose())
            )
        )
    )

)
(instance openIt of Script
    (properties)

    (method (changeState newState)
        (asm
            lap     newState
            aTop    state
            push    
            dup     
            ldi     0
            eq?     
            bnt     code_1014
            pushi   0
            callb   proc0_2, 0
            pushi   #script
            pushi   0
            lag     global2
            send    4
            bnt     code_100c
            pushi   #view
            pushi   0
            lag     gEgo
            send    4
            push    
            pushi   1
            pushi   0
            callb   proc0_12, 2
            bnt     code_0ff3
            ldi     23
            jmp     code_0ff5
code_0ff3:  ldi     16
code_0ff5:  eq?     
            bnt     code_100c
            pushi   #cue
            pushi   0
            pushi   #script
            pushi   0
            lag     global2
            send    4
            send    4
            ldi     7
            aTop    cycles
            jmp     code_10e4
code_100c:  pushi   #cue
            pushi   0
            self    4
            jmp     code_10e4
code_1014:  dup     
            ldi     1
            eq?     
            bnt     code_105a
            pushi   #onControl
            pushi   1
            pushi   1
            lag     gEgo
            send    6
            push    
            ldi     8192
            and     
            bt      code_103d
            pushi   #onControl
            pushi   1
            pushi   1
            lag     gEgo
            send    6
            push    
            ldi     16384
            and     
            bnt     code_1052
code_103d:  pushi   #setMotion
            pushi   4
            class   MoveTo
            push    
            pushi   99
            pushi   139
            pushSelf
            lag     gEgo
            send    12
            jmp     code_10e4
code_1052:  pushi   #cue
            pushi   0
            self    4
            jmp     code_10e4
code_105a:  dup     
            ldi     2
            eq?     
            bnt     code_107c
            pushi   #number
            pushi   1
            pushi   22
            pushi   93
            pushi   0
            pushi   42
            pushi   0
            pushi   2
            pushi   0
            pushi   21
            callk   ScriptID, 4
            send    14
            ldi     3
            aTop    cycles
            jmp     code_10e4
code_107c:  dup     
            ldi     3
            eq?     
            bnt     code_10ac
            pushi   3
            lsg     gEgo
            pushi   100
            pushi   160
            callb   proc0_15, 6
            pushi   0
            callb   proc0_7, 0
            pushi   #cel
            pushi   1
            pushi   0
            pushi   168
            pushi   1
            pushi   2
            pushi   131
            pushi   2
            class   End
            push    
            pushSelf
            lofsa   gate
            send    20
            jmp     code_10e4
code_10ac:  dup     
            ldi     4
            eq?     
            bnt     code_10e4
            pushi   #ignoreActors
            pushi   1
            pushi   1
            pushi   226
            pushi   0
            lofsa   gate
            send    10
            pushi   1
            pushi   23
            callb   proc0_10, 2
            pushi   #illegalBits
            pushi   1
            pushi   49152
            lag     gEgo
            send    6
            pushi   #illegalBits
            pushi   1
            pushi   49152
            lag     gGoat
            send    6
            pushi   0
            callb   proc0_3, 0
            pushi   #dispose
            pushi   0
            self    4
code_10e4:  toss    
            ret     
        )
    )

)
(instance closeIt of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:setAvoider(Avoid))
                (if (& (send gEgo:onControl(1)) $2000)
                    (if (< (send gEgo:x) 114)
                        (send gEgo:setMotion(DPath 104 151 114 163 self))
                    )(else
                        (send gEgo:setMotion(DPath 114 (send gEgo:y) 104 151 114 163 self))
                    )
                )(else
                    (if ((& (send gEgo:onControl()) $7000) and (& (send gEgo:onControl()) $2000))
                        (send gEgo:setMotion(MoveTo (- (send gEgo:x) 8) (- (send gEgo:y) 3) self))
                    )(else
                        (self:cue())
                    )
                )
            )
            (case 1
                (send gEgo:setAvoider(0))
                (send (ScriptID(0 21)):
                    number(23)
                    init()
                    play()
                )
                = cycles 3
            )
            (case 2
                proc0_15(gEgo 100 160)
                proc0_7()
                (gate:
                    cel(3)
                    cycleSpeed(2)
                    setCycle(Beg self)
                )
            )
            (case 3
                (gate:
                    ignoreActors(0)
                    stopUpd()
                )
                proc0_11(23)
                (send gEgo:illegalBits(-32768))
                (send gGoat:illegalBits(-32768))
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance getGoat of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                proc0_15(gEgo gGoat)
                proc0_15(gGoat gEgo)
                (send gEgo:
                    view(21)
                    cel(0)
                    setCycle(End)
                )
                (send gGoat:
                    setMotion(0)
                    setScript(0)
                )
                = cycles 22
            )
            (case 1
                (send (ScriptID(0 21)):
                    number(60)
                    loop(1)
                    init()
                    play()
                )
                (if (proc0_12(4))
                    proc255_0(11 52)
                )(else
                    proc255_0(11 53)
                    proc0_19(80 5)
                )
                (send gEgo:setCycle(Beg self))
            )
            (case 2
                proc0_1()
                proc0_3()
                (if (proc0_12(23))
                    (send gEgo:illegalBits(-16384))
                )
                (if (not proc0_12(4))
                    (send gGoat:
                        setAvoider(Avoid)
                        setMotion(Follow gEgo 50)
                    )
                    proc0_10(2)
                )
                (self:dispose())
            )
        )
    )

)
(instance goatOutaGate of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                proc255_0(11 54)
                proc0_15(gEgo gGoat)
                (send gGoat:
                    illegalBits(0)
                    ignoreActors(1)
                    setPri(2)
                    setMotion(MoveTo 80 134 self)
                )
            )
            (case 1
                (send gGoat:
                    illegalBits(0)
                    ignoreActors(1)
                    setPri(11)
                    setMotion(MoveTo 122 165 self)
                )
                (if ((send gGoat:blocks))
                    (send gGoat:ignoreBlocks(pen))
                )
            )
            (case 2
                (send gGoat:setMotion(MoveTo 124 170 self))
            )
            (case 3
                proc0_15(gGoat gEgo)
                (send gGoat:
                    setPri(-1)
                    illegalBits(-16384)
                    ignoreActors(0)
                    setMotion(Follow gEgo 50)
                )
                proc0_10(36)
                proc0_3()
                (self:dispose())
            )
        )
    )

)
(instance changeGoatRoom of Script
    (properties)

    (method (doit)
        (super:doit())
        (if ((== state 0) and (& (send gGoat:onControl()) $7000))
            = gGNumber_3 11
        )(else
            = gGNumber_3 10
        )
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (if (== gGNumber_3 11)
                    (send gGoat:
                        setLoop(-1)
                        setAvoider(mwAvoider)
                        setMotion(MoveTo -20 (send gGoat:y) self)
                    )
                    (if ((send gGoat:blocks))
                        (send gGoat:ignoreBlocks(pen))
                    )
                )(else
                    (send gGoat:
                        show()
                        setLoop(-1)
                        setAvoider(0)
                        setMotion(MoveTo 30 (send gGoat:y) self)
                    )
                )
            )
            (case 1
                (if (<> gGNumber_3 11)
                    (self:changeState(2))
                )(else
                    (send gGoat:
                        observeBlocks(pen)
                        setScript(goatWander)
                    )
                    = local0 Random(Random(100 140) Random(160 200))
                    (self:dispose())
                )
            )
            (case 2
                = cycles 70
            )
            (case 3
                (self:changeState(0))
            )
        )
    )

)
(instance goatCounter of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                = cycles 70
            )
            (case 1
                (send client:setScript(changeGoatRoom))
                (self:dispose())
            )
        )
    )

)
(instance goatBobs of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (send gGoat:
                    setAvoider(0)
                    illegalBits(-16322)
                    setMotion(MoveTo Random(10 310) Random(+ (send global2:horizon) 2 180))
                )
                = cycles Random(20 40)
            )
            (case 1
                (self:changeState(0))
            )
        )
    )

)
(instance goatLeaves of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                proc0_2()
                (send gEgo:setMotion(0))
                proc0_15(gEgo gGoat)
                (send gGoat:setMotion(MoveTo (send gGoat:x) 220 self))
            )
            (case 1
                proc255_0(11 55)
                (self:cue())
            )
            (case 2
                proc0_3()
                (self:dispose())
            )
        )
    )

)
