(include "sci.sh")
(use "Main")
(use "Class_255_0")
(use "Sound")
(use "Cycle")
(use "Game")
(use "InvI")
(use "PV")
(use "Obj")
(script 15)


(local
    local0
    local1
    local2
    newAct
    newProp_5
    local5
    newView
    newProp
    newProp_2
    newProp_3
    newProp_4

)
(instance frogTheme of Sound
    (properties)
)
(instance public Room15 of Rm
    (properties
        picture 15
    )

    (method (init)
        = north 9
        = south 21
        = east 16
        = west 14
        = horizon 75
        (if (global100)
            = picture 115
        )
        = global101 0
        (if (<= (send gEgo:y()) horizon)
            (send gEgo:posn((send gEgo:x()) (- horizon 2)))
        )
        (if (< (send gEgo:x()) 29)
            (send gEgo:x(29))
        )
        (super:init())
        (self:setRegions(507))
        (send gEgo:
            view(2)
            setStep(2 1)
            init()
        )
        Load(rsVIEW 518)
        Load(rsVIEW 375)
        Load(rsVIEW 376)
        Load(rsVIEW 377)
        Load(rsVIEW 370)
        Load(rsVIEW 378)
        Load(rsVIEW 26)
        Load(rsVIEW 27)
        Load(rsVIEW 29)
        Load(rsVIEW 21)
        Load(rsVIEW 6)
        Load(rsVIEW 27)
        Load(rsVIEW 28)
        Load(rsVIEW 680)
        Load(rsVIEW 225)
        Load(rsVIEW 226)
        Load(rsVIEW 227)
        Load(rsVIEW 2)
        = newProp (Prop:new())
        = newProp_2 (Prop:new())
        = newProp_3 (Prop:new())
        = newProp_4 (Prop:new())
        (send newProp:
            isExtra(1)
            view(650)
            loop(2)
            cel(0)
            posn(242 154)
            setPri(11)
            ignoreActors()
            cycleSpeed(1)
            setCycle(Fwd)
            init()
        )
        (send newProp_2:
            isExtra(1)
            view(650)
            loop(3)
            cel(0)
            posn(187 147)
            setPri(10)
            ignoreActors()
            cycleSpeed(1)
            setCycle(Fwd)
            init()
        )
        (send newProp_3:
            isExtra(1)
            view(650)
            loop(4)
            cel(0)
            posn(89 142)
            setPri(10)
            ignoreActors()
            cycleSpeed(1)
            setCycle(Fwd)
            init()
        )
        (send newProp_4:
            isExtra(1)
            view(650)
            loop(5)
            cel(1)
            posn(220 139)
            setPri(10)
            ignoreActors()
            cycleSpeed(1)
            setCycle(Fwd)
            init()
        )
        (if (== gPicture 0)
            (send gEgo:
                x(1)
                y(150)
            )
        )
        (send ((View:new())):
            view(518)
            loop(0)
            cel(
                (if (global100)
                    1
                )(else
                    0
                )
)
            setPri(10)
            posn(204 148)
            init()
            addToPic()
        )
        (if ((send ((Inv:at(10))):ownedBy(200)))
            = newAct (Act:new())
            (frogTheme:
                number(28)
                play()
            )
            = global110 0
            (send newAct:
                view(370)
                cycleSpeed(2)
                setCycle(Fwd)
                x(206)
                y(145)
                ignoreActors()
                init()
            )
        )
        (if ((send ((Inv:at(5))):ownedBy(15)))
            (send (= newView (View:new())):
                view(518)
                loop(1)
                cel(0)
                posn(265 135)
                ignoreActors()
                stopUpd()
                init()
            )
        )
        (send global2:setScript(frogActions))
    )


    (method (doit)
        (super:doit())
        (if ((== (= local0 (send gEgo:onControl(1))) 512) and (== global110 0))
            (frogActions:changeState(1))
        )
        (if (<> local1 local0)
            = local1 local0
            (switch (local0)
                (case 1
                    (if (not (send gEgo:has(11)))
                        = global105 0
                        (send gEgo:view(2))
                    )
                )
                (case 512
                    (if (not (send gEgo:has(11)))
                        (send gEgo:view(6))
                        = global105 2
                    )
                )
            )
        )
    )


    (method (dispose)
        (send gSounds:eachElementDo(172))
        (super:dispose())
    )


    (method (handleEvent pEvent)
        (var gInvSaidMe)
        (if ((== global110 4) and ((((<> (send gEgo:xLast()) (send gEgo:x())) or (<> (send gEgo:yLast()) (send gEgo:y()))) or (== (send pEvent:type()) 64)) or (== (send pEvent:type()) 1)))
            (send ((Inv:at(11))):moveTo(15))
            = global110 3
            (frogActions:changeState(60))
        )
        (if ((send pEvent:claimed()))
            return 1
        )
        return 
            (if (== (send pEvent:type()) 128)
                (if (Said('/prince>'))
                    (if ((== global110 5) and (send gCast:contains(newAct)))
                        (if (Said('look'))
                            Print(15 0)
                        )(else
                            (if (Said('converse'))
                                Print(15 1)
                            )(else
                                (if (Said('get'))
                                    Print(15 2)
                                )(else
                                    (if (Said('kiss'))
                                        Print(15 3)
                                    )
                                )
                            )
                        )
                    )(else
                        Print(15 4)
                        (send pEvent:claimed(1))
                    )
                )(else
                    (if ((Said('fish<enter') or Said('capture/fish')) or Said('cast/pole'))
                        Print(15 5)
                    )(else
                        (if (Said('look,find,look/frog'))
                            (if ((send gEgo:has(11)))
                                (send ((Inv:at(11))):showSelf())
                            )(else
                                (if ((== global110 0) or (== global110 3))
                                    Print(15 6)
                                )(else
                                    (if (== global110 1)
                                        Print(15 7)
                                    )(else
                                        (if (== global110 2)
                                            Print(15 8)
                                        )(else
                                            (if (== global110 4)
                                                Print(15 9)
                                            )(else
                                                Print(15 10)
                                            )
                                        )
                                    )
                                )
                            )
                        )(else
                            (if (Said('look>'))
                                (if (Said('<under,in/water'))
                                    Print(15 7)
                                )(else
                                    (if (Said('/lake,water'))
                                        Print(Format(@global300 15 11 
                                                (if (== global110 0)
                                                    "You spy a large frog sitting on top of a big lily pad, and YES!...it's wearing a little gold crown!"
                                                )(else
                                                    " "
                                                )
))
                                    )(else
                                        (if (Said('<down[/dirt]') or Said('/dirt'))
                                            (if ((send ((Inv:at(5))):ownedBy(15)) and (== global110 3))
                                                Print(15 12)
                                            )(else
                                                (if ((send ((Inv:at(5))):ownedBy(15)))
                                                    Print(15 13)
                                                )(else
                                                    (if (== global110 3)
                                                        Print(15 14)
                                                    )(else
                                                        Print(15 15)
                                                    )
                                                )
                                            )
                                        )(else
                                            (if (Said('/lilies,pad'))
                                                Print(Format(@global300 15 16 
                                                        (if (== global110 0)
                                                            "Atop one large lily pad, sits a big frog."
                                                        )(else
                                                            ""
                                                        )
))
                                            )(else
                                                (if (Said('/crown'))
                                                    (if (== global110 4)
                                                        Print(15 17)
                                                    )(else
                                                        (if ((send gEgo:has(10)))
                                                            (send ((Inv:at(10))):showSelf())
                                                        )(else
                                                            Print(800 1)
                                                        )
                                                    )
                                                )(else
                                                    (if (Said('/blossom'))
                                                        Print(15 18)
                                                    )(else
                                                        (if (Said('[<around][/room]'))
                                                            Print(Format(@global300 15 19 
                                                                    (if (== global110 0)
                                                                        "Atop one of the bigger lily pads, you notice a rather large frog...wearing a little gold crown!"
                                                                    )(else
                                                                        ""
                                                                    )
))
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )(else
                                (if (Said('get/blossom'))
                                    Print(15 20)
                                )(else
                                    (if (Said('bathe,dive'))
                                        Print(15 21)
                                    )(else
                                        (if (Said('wade'))
                                            Print(15 22)
                                        )(else
                                            (if (Said('get/drink') or Said('drink[/water]'))
                                                = local2 proc0_2(gEgo 12)
                                                (if (== (send gEgo:view()) 2)
                                                    (if (& local2 $0200)
                                                        = gGEgoScript (send gEgo:script())
                                                        (send gEgo:setScript(drinking))
                                                    )(else
                                                        Print(800 1)
                                                    )
                                                )(else
                                                    (if (== (send gEgo:view()) 6)
                                                        Print(15 23)
                                                    )(else
                                                        Print(15 24)
                                                    )
                                                )
                                            )(else
                                                (if (Said('get,get,capture/frog'))
                                                    (if (== global110 4)
                                                        Print(800 0)
                                                    )(else
                                                        (if (== global110 1)
                                                            Print(15 25)
                                                        )(else
                                                            (if (== global110 5)
                                                                Print(15 26)
                                                            )(else
                                                                (if (<> global110 3)
                                                                    Print(15 27)
                                                                )(else
                                                                    (if (== (send gEgo:view()) 6)
                                                                        Print(15 28)
                                                                    )(else
                                                                        (if ((send gEgo:inRect(249 133 266 139)))
                                                                            Print(15 29)
                                                                        )(else
                                                                            (if (== global110 3)
                                                                                (if (< (send gEgo:distanceTo(newAct)) 13)
                                                                                    proc0_3(gEgo newAct)
                                                                                    Print(15 30)
                                                                                    (frogActions:changeState(10))
                                                                                )(else
                                                                                    Print(15 31)
                                                                                )
                                                                            )
                                                                        )
                                                                    )
                                                                )
                                                            )
                                                        )
                                                    )
                                                )(else
                                                    (if (Said('get/lilies,pad'))
                                                        Print(15 32)
                                                    )(else
                                                        (if (Said('converse[/frog]'))
                                                            (if (((== global110 0) or (== global110 3)) or (== global110 4))
                                                                Print(15 33)
                                                                Print(15 34)
                                                            )(else
                                                                Print(15 35)
                                                            )
                                                        )(else
                                                            (if (Said('fling,drop,place,deliver/ball'))
                                                                (if ((send gEgo:has(5)))
                                                                    (if (== global110 0)
                                                                        (if ((send ((Inv:at(10))):ownedBy(200)))
                                                                            (if ((& (= local2 proc0_2(gEgo 15)) $0200) and (== (send gEgo:view()) 2))
                                                                                proc0_10()
                                                                                proc0_3(gEgo newAct)
                                                                                Print(15 36 166)
                                                                                = global110 2
                                                                                (frogActions:changeState(3))
                                                                            )(else
                                                                                Print(15 37)
                                                                            )
                                                                        )(else
                                                                            Print(15 38)
                                                                        )
                                                                    )(else
                                                                        (if (<> (send gEgo:view()) 2)
                                                                            Print(15 39)
                                                                        )(else
                                                                            Print(15 40)
                                                                        )
                                                                    )
                                                                )(else
                                                                    Print(15 41)
                                                                )
                                                            )(else
                                                                (if (Said('kiss/frog') or Said('kiss[/!*]'))
                                                                    (if (== global110 4)
                                                                        Print(15 42)
                                                                        (frogActions:changeState(50))
                                                                        = global110 5
                                                                    )(else
                                                                        Print(15 43)
                                                                    )
                                                                )(else
                                                                    (if (Said('get/ball'))
                                                                        (if (== (send gEgo:view()) 2)
                                                                            (if ((send ((Inv:at(5))):ownedBy(15)))
                                                                                (if (< (send gEgo:distanceTo(newView)) 10)
                                                                                    (send gEgo:setScript(ballActions))
                                                                                    (ballActions:changeState(1))
                                                                                )(else
                                                                                    Print(800 1)
                                                                                )
                                                                            )(else
                                                                                (if ((send gEgo:has(5)))
                                                                                    Print(800 0)
                                                                                )(else
                                                                                    Print(15 44)
                                                                                )
                                                                            )
                                                                        )(else
                                                                            proc0_18()
                                                                        )
                                                                    )(else
                                                                        (if (Said('deliver>'))
                                                                            (if (= gInvSaidMe (send gInv:saidMe()))
                                                                                (if ((send gEgo:has((send gInv:indexOf((= gInvSaidMe (send gInv:saidMe())))))))
                                                                                    (if ((send gCast:contains(newAct)))
                                                                                        Print(15 45)
                                                                                    )(else
                                                                                        Print(15 46)
                                                                                    )
                                                                                )(else
                                                                                    proc0_19()
                                                                                )
                                                                            )
                                                                        )(else
                                                                            (if (Said('get,rob/crown'))
                                                                                (if ((send gEgo:has(10)))
                                                                                    Print(800 0)
                                                                                )(else
                                                                                    (if (== global110 4)
                                                                                        Print(15 47)
                                                                                        (send ((Inv:at(10))):moveTo(gEgo))
                                                                                        = global182 1
                                                                                        (send gEgo:
                                                                                            view(2)
                                                                                            loop(1)
                                                                                            cycleSpeed(0)
                                                                                            setCycle(Walk)
                                                                                            put(11 999)
                                                                                        )
                                                                                        (send gGame:changeScore(2))
                                                                                        = global110 6
                                                                                        (frogActions:changeState(70))
                                                                                    )(else
                                                                                        Print(15 43)
                                                                                    )
                                                                                )
                                                                            )
                                                                        )
                                                                    )
                                                                )
                                                            )
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )(else
                0
            )
    )

)
(instance frogActions of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 1
                (= global110 1 Print(15 48 50 3) (send newAct:
                    view(373)
                    cycleSpeed(0)
                    loop(0)
                    cel(0)
                    setCycle(End)
                    illegalBits(0)
                    setMotion(MoveTo + (send newAct:x()) 10 - (send newAct:y()) 5 self)
                )
  )
            )
            (case 2
                ((send newAct:hide()) (frogActions:changeState(100))  )
            )
            (case 3
                (= seconds 2 Load(rsVIEW 377) Load(rsVIEW 372) Load(rsVIEW 373)  )
            )
            (case 4
                ((send gEgo:setMotion(0)) (send newAct:
                    view(373)
                    show()
                    cycleSpeed(0)
                    setLoop(0)
                    cel(0)
                    xStep(2)
                    yStep(2)
                    illegalBits(0)
                    ignoreActors(0)
                    setCycle(End self)
                    setMotion(MoveTo + (send newAct:x()) 8 (send newAct:y()))
                )
 (send ((Inv:at(5))):moveTo(15))  )
            )
            (case 5
                ((send newAct:
                    ignoreActors()
                    hide()
                )
 = seconds 4  )
            )
            (case 6
                (
                (if ((send gEgo:inRect(247 132 278 140)))
                    (send gEgo:setScript(ballActions))
                    (ballActions:changeState(10))
                )
 (send newAct:
                    view(377)
                    setLoop(0)
                    cel(0)
                    xStep(2)
                    setAvoider((Avoid:new()))
                    setCycle(Fwd)
                    illegalBits(0)
                    cycleSpeed(0)
                    moveSpeed(0)
                    show()
                    setMotion(MoveTo 250 139 self)
                )
  )
            )
            (case 7
                ((send newAct:
                    view(372)
                    xStep(2)
                    setLoop(-1)
                    cel(0)
                    cycleSpeed(1)
                    moveSpeed(1)
                    setMotion(MoveTo 265 137 self)
                )
  )
            )
            (case 8
                ((send newAct:
                    view(370)
                    cel(0)
                    ignoreActors(0)
                    cycleSpeed(2)
                    setCycle(Fwd)
                )
 = global110 3 = newView (View:new()) (send newView:
                    view(518)
                    loop(1)
                    cel(0)
                    posn(+ (send newAct:x()) 5 (send newAct:y()))
                    ignoreActors()
                    stopUpd()
                    init()
                )
 proc0_11()  )
            )
            (case 10
                (proc0_10() proc0_3(gEgo newAct) (send gEgo:
                    view(21)
                    ignoreActors()
                    setCycle(End self)
                )
  )
            )
            (case 11
                ((send newAct:dispose()) (send ((Inv:at(11))):moveTo(gEgo)) (send gEgo:
                    view(27)
                    ignoreActors(0)
                    setCycle(End self)
                )
  )
            )
            (case 12
                ((send gEgo:
                    view(28)
                    setCycle(Walk)
                    setMotion(MoveTo 294 134 self)
                )
  )
            )
            (case 13
                ((send gEgo:
                    view(30)
                    loop(0)
                    cycleSpeed(1)
                    setCycle(Fwd)
                )
 = global110 4 proc0_11()  )
            )
            (case 50
                (proc0_10() (send gEgo:
                    view(29)
                    loop(1)
                    cel(0)
                    cycleSpeed(0)
                    setCycle(End self)
                    put(11 999)
                )
 (send gGame:changeScore(3))  )
            )
            (case 51
                ((send gEgo:
                    loop(3)
                    cel(0)
                    setCycle(End self)
                )
  )
            )
            (case 52
                ((send ((Sound:new())):
                    number(59)
                    play()
                )
 (send (= newProp_5 (Prop:new())):
                    posn(- (send gEgo:x()) 15 (send gEgo:y()))
                    setPri(+ (send gEgo:priority()) 1)
                    view(680)
                    cel(0)
                    loop(0)
                    ignoreActors()
                    setCycle(CT 5 1 self)
                    init()
                )
  )
            )
            (case 53
                ((send newProp_5:setCycle(End self)) = newAct (Act:new()) (send newAct:
                    posn(- (send gEgo:x()) 19 (send gEgo:y()))
                    view(225)
                    cel(0)
                    setLoop(2)
                    illegalBits(33280)
                    init()
                )
 (send gEgo:view(2)) proc0_3(gEgo newAct 1)  )
            )
            (case 54
                ((send newProp_5:dispose()) Print(15 49 134 -1 20) Print(15 50 134 -1 20) (send newAct:
                    cycleSpeed(1)
                    setAvoider((Avoid:new()))
                )
 Print(15 51) (send ((Inv:at(10))):moveTo(gEgo)) = global182 1 (send gGame:changeScore(2)) 
                (if (< (send newAct:x()) (send gEgo:x()))
                    = local5 0
                )(else
                    = local5 1
                )
 (send newAct:
                    view(226)
                    setStep(2 1)
                    setLoop(-1)
                    loop(local5)
                    setCycle(End self)
                )
  )
            )
            (case 55
                ((send newAct:
                    view(227)
                    cycleSpeed(0)
                    setCycle(Walk)
                    setAvoider((Avoid:new()))
                )
 
                (if (< (send newAct:x()) 150)
                    (send newAct:setMotion(MoveTo 65526 150 self))
                )(else
                    (send newAct:setMotion(MoveTo 330 150 self))
                )
 )
            )
            (case 56
                (proc0_11() (send gEgo:setCycle(Walk)) (send newAct:dispose())  )
            )
            (case 60
                ((send gEgo:
                    view(2)
                    setLoop(-1)
                    cycleSpeed(0)
                    setCycle(Walk)
                )
 = newAct (Act:new()) (send newAct:
                    view(372)
                    setCycle(Walk)
                    posn(- (send gEgo:x()) 10 (send gEgo:y()))
                    setMotion(MoveTo - (send newView:x()) 3 (send newView:y()) self)
                    init()
                )
  )
            )
            (case 61
                ((send newAct:
                    view(370)
                    loop(0)
                    cycleSpeed(3)
                    setCycle(Fwd)
                )
  )
            )
            (case 70
                (= global110 1 = newAct (Act:new()) (send newAct:
                    view(378)
                    posn(- (send gEgo:x()) 6 + (send gEgo:y()) 4)
                    illegalBits(0)
                    setAvoider((Avoid:new()))
                    setCycle(Walk)
                    setMotion(MoveTo 244 142 self)
                    init()
                )
  )
            )
            (case 71
                ((send newAct:dispose())  )
            )
            (case 100
                (= seconds Random(3 8)  )
            )
            (case 101
                (
                (if (== (send gEgo:onControl(1)) 512)
                    (self:changeState(100))
                )(else
                    (send newAct:
                        view(378)
                        loop(1)
                        posn(216 140)
                        cel(0)
                        cycleSpeed(1)
                        setCycle(End self)
                        setMotion(MoveTo 206 145)
                        show()
                    )
                )
 )
            )
            (case 102
                ((send newAct:
                    view(370)
                    loop(0)
                    illegalBits(32768)
                    cycleSpeed(2)
                    setCycle(Fwd)
                )
 = global110 0 )
            )
        )
    )

)
(instance ballActions of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 1
                (proc0_10() proc0_3(gEgo newView) (send gEgo:
                    view(21)
                    cel(0)
                    setCycle(End self)
                )
  )
            )
            (case 2
                ((send newView:dispose()) (send gEgo:get(5)) (send gEgo:setCycle(Beg self))  )
            )
            (case 3
                ((send gEgo:
                    view(2)
                    setCycle(Walk)
                )
 proc0_11() 
                (if ((== global110 4) or (== global110 3))
                    (send newAct:
                        illegalBits(0)
                        ignoreActors()
                        view(373)
                        cel(0)
                        setLoop(1)
                        setMotion(MoveTo 244 142)
                        cycleSpeed(1)
                        setCycle(End self)
                    )
                )
 )
            )
            (case 4
                (= global110 1 (frogActions:changeState(100)) (send newAct:hide())  )
            )
            (case 10
                (proc0_10() (send gEgo:setMotion(MoveTo (+ (send gEgo:x()) 10) (- (send gEgo:y()) 10) self))  )
            )
            (case 11
                (proc0_11() (send gEgo:loop(1)) )
            )
        )
    )

)
(instance drinking of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (proc0_10() (send gEgo:
                    view(21)
                    cel(0)
                    setCycle(End self)
                )
  )
            )
            (case 1
                (= seconds 5 = global120 Print(15 52 134 -1 20 172)  )
            )
            (case 2
                ((send gEgo:setCycle(Beg self))  )
            )
            (case 3
                (proc0_11() proc0_23() (send gEgo:
                    view(2)
                    setCycle(Walk)
                )
 (send gEgo:script(gGEgoScript)) )
            )
        )
    )

)
