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


(local
    local0
    local1
    local2
    local3
    newAct_2
    newAct
    local6[2]
    newProp
    newProp_2
    newProp_3
    local11
    local12

)
(instance fisherTheme of Sound
    (properties)
)
(instance public Room95 of Rm
    (properties
        picture 95
    )

    (method (init)
        (if (global100)
            = picture 195
        )
        Load(rsVIEW 2)
        Load(rsVIEW 8)
        Load(rsVIEW 19)
        Load(rsVIEW 12)
        Load(rsVIEW 13)
        Load(rsVIEW 14)
        Load(rsVIEW 17)
        Load(rsVIEW 234)
        Load(rsVIEW 230)
        Load(rsVIEW 327)
        (super:init())
        (self:setRegions(504))
        = local1 0
        = south (= north 31)
        = east 7
        = west 31
        = horizon 72
        (send gEgo:edgeHit(0))
        = local0 0
        = global189 1
        = newProp (Prop:new())
        (send newProp:
            view(650)
            loop(1)
            cel(1)
            posn(155 58)
            setPri(0)
            ignoreActors()
            setCycle(Fwd)
            init()
        )
        = newProp_2 (Prop:new())
        = newProp_3 (Prop:new())
        (send newProp_2:
            view(667)
            loop(3)
            cel(2)
            posn(216 179)
            setPri(0)
            setCycle(Fwd)
            ignoreActors()
            cycleSpeed(2)
            init()
        )
        (send newProp_3:
            view(667)
            loop(6)
            cel(3)
            posn(209 170)
            setPri(0)
            setCycle(Fwd)
            ignoreActors()
            cycleSpeed(2)
            init()
        )
        (if (== global116 0)
            = global116 1
        )
        (switch (gPicture)
            (case 0
                ((send gEgo:
                    loop(1)
                    setPri(13)
                )
 = global105 0 (send gEgo:
                    view(2)
                    posn(317 145)
                )
 = global107 9  )
            )
            (case 7
                (
                (if (== global107 9)
                    (send gEgo:
                        x(318)
                        y(144)
                    )
                    (send gEgo:illegalBits(49152))
                    (send gEgo:setPri(13))
                )(else
                    (send gEgo:
                        view(8)
                        setCycle(Fwd)
                    )
                    (send gEgo:x(318))
                )
 )
            )
            (case 31
                (
                (if (<= (send gEgo:y()) gHorizon)
                    (send gEgo:posn((send gEgo:x()) (+ horizon (+ (send gEgo:yStep()) 1))))
                )(else
                    (if (>= (send gEgo:y()) 189)
                        (send gEgo:y(188))
                    )(else
                        (if (>= (send gEgo:x()) 319)
                            (send gEgo:x(1))
                        )
                    )
                )
 
                (if (<= (send gEgo:y()) horizon)
                    (send gEgo:y((+ horizon 2)))
                )
 (send gEgo:
                    view(8)
                    setCycle(Fwd)
                )
 )
            )
        )
        (if (not global100)
            = newAct (Act:new())
            (send newAct:
                posn(278 125)
                view(327)
                loop(0)
                cel(0)
                xStep(8)
                yStep(6)
                illegalBits(0)
                ignoreActors()
                ignoreHorizon()
                setPri(13)
                setAvoider((Avoid:new()))
                init()
            )
            (send newAct:setScript(gullActions))
        )
        (if (== global116 1)
            = newAct_2 (Act:new())
            (fisherTheme:
                number(14)
                play()
            )
            (send newAct_2:
                view(233)
                posn(177 146)
                setPri(13)
                loop(0)
                setCycle(Fwd)
                xStep(2)
                yStep(1)
                setScript(manActions)
                init()
            )
            = local3 1
        )
        (send gEgo:
            xStep(2)
            yStep(1)
            init()
        )
        (if ((== global107 9) and (== local3 1))
            (send gEgo:observeControl(32))
        )
    )


    (method (doit)
        (super:doit())
        (if ((((send gCast:contains(newAct_2)) and (send newAct_2:inRect(249 138 305 148))) or ((== global107 9) and (send gEgo:inRect(249 138 305 148)))) and (== (gullActions:state()) 0))
            (gullActions:changeState(1))
        )
        = local2 (send gEgo:onControl(0))
        (if ((== global107 9) and (<> global105 15))
            (if (& local2 $0010)
                (send gEgo:setScript(fallNorth))
            )(else
                (if (& local2 $0004)
                    (send gEgo:setScript(fallSouth))
                )(else
                    (if (& local2 $0008)
                        (send gEgo:setScript(fallWest))
                    )
                )
            )
        )
        (if ((== local3 0) or (<> global107 9))
            (send gEgo:ignoreControl(32))
        )
    )


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


    (method (handleEvent pEvent)
        (var gInvSaidMe)
        (if ((send pEvent:claimed()))
            return 1
        )
        return 
            (if (== (send pEvent:type()) 128)
                (if (Said('deliver>'))
                    (if (Said('/*/gull'))
                        Print(95 0)
                    )(else
                        (if (Said('/*[/fisherman,man,man,man,man]>'))
                            (if (= gInvSaidMe (send gInv:saidMe()))
                                (if ((send gEgo:has((send gInv:indexOf((= gInvSaidMe (send gInv:saidMe())))))))
                                    Print(95 1)
                                )(else
                                    Print(95 2)
                                )
                            )(else
                                Print(95 3)
                                (send pEvent:claimed(1))
                            )
                        )
                    )
                )(else
                    (if (Said('look>'))
                        (if (Said('/fish'))
                            (if ((send gEgo:has(24)))
                                (send ((Inv:at(24))):showSelf())
                            )(else
                                Print(95 4)
                            )
                        )(else
                            (if (Said('/dock'))
                                Print(95 5)
                            )(else
                                (if (Said('<under/dock'))
                                    Print(95 6)
                                )(else
                                    (if (Said('<under/water,ocean'))
                                        (if (== (send gEgo:view()) 2)
                                            Print(95 7)
                                        )(else
                                            Print(95 8)
                                        )
                                    )(else
                                        (if (Said('/barrel'))
                                            Print(95 9)
                                        )(else
                                            (if (Said('/ocean,water'))
                                                Print(95 10)
                                            )(else
                                                (if (Said('/gull,gull,gull'))
                                                    (if ((send gCast:contains(newAct)))
                                                        Print(95 11)
                                                    )(else
                                                        (send pEvent:claimed(0))
                                                    )
                                                )(else
                                                    (if (Said('/hemp'))
                                                        Print(95 12)
                                                    )(else
                                                        (if (Said('/fisherman,man,man,man,man'))
                                                            (if (== global116 1)
                                                                Print(95 13)
                                                            )(else
                                                                Print(95 14)
                                                            )
                                                        )(else
                                                            (if (Said('[<around][/room]'))
                                                                (if (== (send gEgo:view()) 2)
                                                                    Print(95 15)
                                                                )(else
                                                                    Print(95 16)
                                                                )
                                                            )
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
                (if (Said('open/barrel'))
                    Print(95 9)
                )(else
                    (if (Said('drink') or Said('get/drink'))
                        (if (== (send gEgo:view()) 2)
                            Print(95 17)
                        )(else
                            Print(95 18)
                        )
                    )(else
                        (if (Said('hop,(dive<in)'))
                            (if (== (send gEgo:view()) 2)
                                Print(95 19)
                            )(else
                                Print(95 20)
                            )
                        )(else
                            (if (Said('dive,(bathe<under)[/ocean,water]'))
                                Print(95 21)
                            )(else
                                (if (Said('bathe'))
                                    (if (== (send gEgo:view()) 2)
                                        Print(95 19)
                                    )(else
                                        Print(95 22)
                                    )
                                )(else
                                    (if (Said('get/hemp'))
                                        Print(95 23)
                                    )(else
                                        (if ((Said('fish[<enter][/!*]') or Said('capture,get/fish')) or Said('cast/pole'))
                                            (if (== global107 9)
                                                (send global2:setScript(fishing))
                                                (fishing:changeState(1))
                                            )(else
                                                Print(95 24)
                                            )
                                        )(else
                                            (if (Said('/pole>'))
                                                (if ((send gEgo:has(17)))
                                                    (if (Said('bait'))
                                                        (send pEvent:claimed(0))
                                                    )(else
                                                        (if (Said('get'))
                                                            proc0_16()
                                                        )(else
                                                            (if (Said('use'))
                                                                Print(95 25)
                                                            )
                                                        )
                                                    )
                                                )(else
                                                    (if (not (send gCast:contains(newAct_2)))
                                                        (send pEvent:claimed(1))
                                                        Print(95 26)
                                                    )(else
                                                        (if (Said('get'))
                                                            Print(95 27)
                                                        )(else
                                                            (if (Said('rob'))
                                                                Print(95 28)
                                                            )
                                                        )
                                                    )
                                                )
                                            )(else
                                                (if (Said('/gull>'))
                                                    (if (not (send gCast:contains(newAct)))
                                                        0
                                                    )(else
                                                        (if (Said('feed'))
                                                            Print(95 29)
                                                        )(else
                                                            (if (Said('kiss'))
                                                                Print(95 30)
                                                            )(else
                                                                (if (Said('converse'))
                                                                    Print(95 31)
                                                                )(else
                                                                    (if (Said('capture,get'))
                                                                        Print(95 32)
                                                                    )
                                                                )
                                                            )
                                                        )
                                                    )
                                                )(else
                                                    (if (Said('[/fisherman,man,man,man,man]>'))
                                                        (if (Said('get/*'))
                                                            (if (== global116 1)
                                                                Print(95 33)
                                                            )(else
                                                                Print(95 34)
                                                            )
                                                        )(else
                                                            (if (Said('help'))
                                                                Print(95 35)
                                                            )(else
                                                                (if (Said('kiss'))
                                                                    (if (== global116 1)
                                                                        Print(95 36)
                                                                    )(else
                                                                        Print(95 34)
                                                                    )
                                                                )(else
                                                                    (if (Said('converse'))
                                                                        (if ((send gCast:contains(newAct_2)))
                                                                            Print(95 37)
                                                                        )(else
                                                                            Print(95 38)
                                                                        )
                                                                    )
                                                                )
                                                            )
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )(else
                0
            )
    )


    (method (newRoom param1)
        = global189 0
        (send gEgo:baseSetter(0))
        (super:newRoom(param1))
    )

)
(instance fallSouth of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (proc0_10() = global189 1 = global107 0 (send ((Sound:new())):
                    number(51)
                    loop(1)
                    play()
                )
 (send gEgo:
                    illegalBits(0)
                    yStep(10)
                    setMotion(MoveTo (send gEgo:x()) + (send gEgo:y()) 34 self)
                    setPri(15)
                    view(17)
                    cel(0)
                    setCycle(End)
                )
  )
            )
            (case 1
                ((send gEgo:
                    yStep(2)
                    setPri(-1)
                )
 (send gEgo:
                    view(19)
                    loop(& (send gEgo:loop()) $0001)
                    illegalBits(32768)
                    cel(0)
                    setCycle(End self)
                )
  )
            )
            (case 2
                ((send gEgo:
                    view(8)
                    setCycle(Fwd)
                    illegalBits(32768)
                    setPri(-1)
                )
 proc0_11() = global107 0 (send gEgo:setScript(0)) )
            )
        )
    )

)
(instance fallNorth of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (proc0_10() = global107 0 (send ((Sound:new())):
                    number(51)
                    loop(1)
                    play()
                )
 (send gEgo:
                    illegalBits(0)
                    setPri(11)
                    posn((send gEgo:x()) - (send gEgo:y()) 5)
                    yStep(10)
                    view(17)
                    cel(0)
                    setCycle(End)
                    setMotion(MoveTo (send gEgo:x()) + (send gEgo:y()) 20 self)
                )
  )
            )
            (case 1
                ((send gEgo:
                    view(8)
                    setCycle(Fwd)
                    setStep(2 1)
                    setPri(-1)
                    illegalBits(32768)
                )
 proc0_11() (send gEgo:setScript(0)) )
            )
        )
    )

)
(instance fallWest of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (proc0_10() = global107 0 (send ((Sound:new())):
                    number(51)
                    loop(1)
                    play()
                )
 (send gEgo:illegalBits(0)) (send gEgo:
                    view(17)
                    setCycle(Fwd)
                    setStep(10 8)
                    cel(0)
                )
 (send gEgo:setMotion(MoveTo (- (send gEgo:x()) 30) (+ (send gEgo:y()) 20) self))  )
            )
            (case 1
                ((send gEgo:
                    view(19)
                    loop(& (send gEgo:loop()) $0001)
                    illegalBits(32768)
                    cel(0)
                    setPri(-1)
                    setCycle(End self)
                )
  )
            )
            (case 2
                ((send gEgo:
                    view(8)
                    xStep(2)
                    yStep(1)
                    setCycle(Fwd)
                )
 proc0_11() (send gEgo:setScript(0)) )
            )
        )
    )

)
(instance manActions of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((send (ScriptID(0 4)):setReal(self 15))  )
            )
            (case 1
                ((send newAct_2:
                    view(234)
                    loop(0)
                    cel(0)
                    setCycle(End self)
                )
  )
            )
            (case 2
                ((send newAct_2:
                    loop(1)
                    cel(0)
                    setCycle(End self)
                )
  )
            )
            (case 3
                ((send newAct_2:
                    view(230)
                    setCycle(Walk)
                    setMotion(MoveTo 319 146 self)
                )
 = local3 0  )
            )
            (case 4
                (= global197 global159 = global198 global158 = global199 global160 = global116 2 (send newAct_2:dispose()) = newAct_2 0 )
            )
        )
    )

)
(instance gullActions of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 1
                ((send newAct:
                    view(327)
                    cel(0)
                    loop(0)
                    setCycle(End self)
                )
  )
            )
            (case 2
                ((send newAct:
                    loop(1)
                    cel(0)
                    setCycle(Fwd)
                )
 (send newAct:setMotion(MoveTo 65526 25 self))  )
            )
            (case 3
                ((send newAct:dispose()) )
            )
        )
    )

)
(instance fishing of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 1
                ((send gEgo:baseSetter(ScriptID(0 1))) = global105 15 
                (if ((send gEgo:has(17)) and (send ((Inv:at(19))):ownedBy(666)))
                    (self:changeState(9))
                )(else
                    (if ((send gEgo:has(17)))
                        (self:changeState(19))
                    )(else
                        Print(95 39)
                        = global105 0
                        (fishing:changeState(0))
                    )
                )
 )
            )
            (case 9
                (proc0_10() (send gEgo:setMotion(MoveTo (send gEgo:x()) 144 self))  )
            )
            (case 10
                ((send gEgo:setMotion(MoveTo 189 145 self))  )
            )
            (case 11
                (Print(95 40 134 -1 25) (send gEgo:
                    view(13)
                    loop(2)
                    cel(3)
                    cycleSpeed(1)
                    setCycle(Beg self)
                )
  )
            )
            (case 12
                ((send gEgo:
                    view(12)
                    loop(0)
                    cycleSpeed(0)
                    setCycle(Fwd)
                )
 (send (ScriptID(0 4)):setReal(self 7))  )
            )
            (case 13
                (
                (if (< Random(1 100) 50)
                    (send gEgo:loop(1))
                    Print(95 41 134 -1 25)
                    (self:changeState(14))
                    (send ((Inv:at(17))):loop(0))
                )(else
                    (self:changeState(50))
                )
 )
            )
            (case 14
                ((send gEgo:
                    view(14)
                    loop(1)
                    cel(0)
                    cycleSpeed(1)
                    setCycle(End)
                )
 = seconds 4  )
            )
            (case 15
                (= global182 1 (send gEgo:
                    view(2)
                    setLoop(-1)
                    loop(1)
                    cycleSpeed(0)
                    setCycle(Walk)
                    baseSetter(0)
                )
 = global105 0 proc0_11() (send ((Inv:at(24))):moveTo(gEgo)) (send gGame:changeScore(3)) (send ((Inv:at(19))):moveTo(777)) (send global2:setScript(0))  )
            )
            (case 19
                (proc0_10() 
                (if ((<= (send gEgo:y()) 141) and (>= (send gEgo:x()) 289))
                    (send gEgo:setMotion(MoveTo (send gEgo:x()) 143 self))
                )(else
                    (self:changeState(20))
                )
 )
            )
            (case 20
                (proc0_10() (send gEgo:setMotion(MoveTo 189 145 self))  )
            )
            (case 21
                (Print(95 42 134 -1 25) (send gEgo:
                    view(13)
                    loop(1)
                    cel(3)
                    cycleSpeed(1)
                    setCycle(Beg self)
                )
  )
            )
            (case 22
                ((send gEgo:
                    view(12)
                    loop(0)
                    cycleSpeed(0)
                    setCycle(Fwd)
                )
 (send (ScriptID(0 4)):setReal(self 7))  )
            )
            (case 23
                (
                (if ((< Random(1 100) 50) and (== local12 0))
                    (send gEgo:loop(1))
                    (self:changeState(24))
                )(else
                    Print(95 43 134 -1 25)
                    (self:changeState(30))
                )
 )
            )
            (case 24
                ((send gEgo:
                    view(14)
                    loop(0)
                    cel(0)
                    cycleSpeed(1)
                    setCycle(End)
                )
 = seconds 4  )
            )
            (case 25
                (Print(95 44 134 -1 25) = local12 1 (send gEgo:
                    view(2)
                    setLoop(-1)
                    loop(1)
                    cycleSpeed(0)
                    setCycle(Walk)
                    baseSetter(0)
                )
 = global105 0 proc0_11() (send global2:setScript(0))  )
            )
            (case 30
                ((send gEgo:
                    view(13)
                    cel(0)
                    loop(1)
                    cycleSpeed(2)
                    setCycle(End)
                )
 = seconds 3  )
            )
            (case 31
                ((send gEgo:
                    view(2)
                    setLoop(-1)
                    cycleSpeed(0)
                    loop(1)
                    setCycle(Walk)
                    baseSetter(0)
                )
 = global105 0 proc0_11() (send global2:setScript(0))  )
            )
            (case 50
                ((send gEgo:
                    view(13)
                    cel(0)
                    loop(2)
                    cycleSpeed(2)
                    setCycle(End)
                )
 (send (ScriptID(0 4)):setReal(self 4))  )
            )
            (case 51
                (Print(95 45 134 -1 25) (send gEgo:
                    view(2)
                    loop(1)
                    cycleSpeed(0)
                    setCycle(Walk)
                    baseSetter(0)
                )
 = global105 0 proc0_11() (send global2:setScript(0)) )
            )
        )
    )

)
