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


(local
    local0
    local1
    gEgoOnControl
    local3
    newAct
    newProp_4
    local6[2]
    newProp
    newProp_2
    newProp_3
    local11
    local12
    local13

)
(instance fallSound of Sound
    (properties)
)
(instance fisherCage of Cage
    (properties
        top 137
        bottom 149
        right 231
    )
)
(instance door of Prop
    (properties)

    (method (cue)
        (self:stopUpd())
        proc0_11()
        (send global2:newRoom(42))
    )

)
(instance waves of List
    (properties)
)
(instance wave1 of Prop
    (properties)
)
(instance wave2 of Prop
    (properties)
)
(instance wave3 of Prop
    (properties)
)
(instance public Room7 of Rm
    (properties
        picture 7
    )

    (method (init)
        (if (global100)
            = picture 107
        )
        = north 1
        = south 13
        = east 8
        = west 95
        = horizon 86
        = global101 0
        (send gEgo:edgeHit(0))
        (super:init())
        (self:setRegions(503 504))
        Load(rsVIEW 2)
        Load(rsVIEW 5)
        Load(rsVIEW 6)
        Load(rsVIEW 7)
        Load(rsVIEW 8)
        Load(rsVIEW 17)
        Load(rsVIEW 19)
        Load(rsVIEW 681)
        Load(rsVIEW 18)
        Load(rsSOUND 80)
        Load(rsSOUND 51)
        Load(rsSOUND 300)
        (wave1:
            isExtra(1)
            view(667)
            loop(0)
            cel(0)
            posn(98 85)
            setPri(0)
            ignoreActors()
            cycleSpeed(3)
            init()
        )
        (wave2:
            isExtra(1)
            view(667)
            loop(1)
            cel(0)
            posn(97 110)
            setPri(0)
            ignoreActors()
            cycleSpeed(3)
            init()
        )
        (wave3:
            isExtra(1)
            view(667)
            loop(2)
            cel(0)
            posn(79 137)
            setPri(0)
            ignoreActors()
            cycleSpeed(3)
            init()
        )
        = newProp (Prop:new())
        = newProp_2 (Prop:new())
        = newProp_3 (Prop:new())
        (send newProp:
            isExtra(1)
            view(667)
            loop(3)
            cel(0)
            posn(11 169)
            setPri(0)
            ignoreActors()
            setCycle(Fwd)
            cycleSpeed(2)
            init()
        )
        (send newProp_2:
            isExtra(1)
            view(667)
            loop(5)
            cel(0)
            posn(103 167)
            setPri(0)
            ignoreActors()
            setCycle(Fwd)
            cycleSpeed(2)
            init()
        )
        (send newProp_3:
            isExtra(1)
            view(667)
            loop(4)
            cel(0)
            posn(117 178)
            setPri(0)
            ignoreActors()
            setCycle(Fwd)
            cycleSpeed(2)
            init()
        )
        (waves:add(wave1 wave2 wave3))
        (wave1:setScript(waveActions))
        = newProp_4 (Prop:new())
        (send newProp_4:
            isExtra(1)
            view(625)
            loop(1)
            cel(0)
            x(200)
            y(20)
            setCycle(Fwd)
            cycleSpeed(1)
            init()
        )
        (if (not global100)
            (door:
                view(601)
                loop(0)
                cel(0)
                x(219)
                y(140)
                setPri(9)
                ignoreActors()
                init()
                stopUpd()
            )
        )(else
            (door:
                view(601)
                loop(1)
                cel(0)
                x(219)
                y(140)
                setPri(9)
                ignoreActors()
                init()
                stopUpd()
            )
        )
        (if (== global116 2)
            (if (< (= local12 (+ (+ (* 3600 (- global160 global199)) (* 60 (- global159 global197))) (- global158 global198))) 40)
                (send (= newAct (Act:new())):view(230))
                (if (<= local12 12)
                    = local13 40
                )(else
                    (if (< local12 20)
                        = local13 120
                    )(else
                        = local13 166
                    )
                )
                (send newAct:
                    posn(local13 145)
                    setPri(13)
                    loop(0)
                    setCycle(Walk)
                    xStep(2)
                    yStep(1)
                    setScript(fishWalkHouse)
                    init()
                )
                (send newAct:baseSetter(ScriptID(0 1)))
            )(else
                = global116 3
            )
        )
        (send gEgo:observeControl(32768 16384 1024))
        (if (<= (send gEgo:y()) (+ horizon 1))
            (send gEgo:y((+ horizon 2)))
        )
        (if (((== gPicture 0) or (== gPicture 8)) or (== (send gEgo:view()) 2))
            = global105 0
        )
        (switch (global105)
            (case 0
                (
                (switch (gPicture)
                    (case 13
                        (
                        (if (< (send gEgo:x()) 164)
                            (send gEgo:posn(170 188))
                        )(else
                            (send gEgo:posn(304 188))
                        )
 )
                    )
                    (case 1
                        (
                        (if (> (send gEgo:x()) 277)
                            (send gEgo:posn(143 (+ horizon 2)))
                        )(else
                            (send gEgo:posn(113 (+ horizon 2)))
                        )
 )
                    )
                    (case 42
                        ((send gEgo:
                            view(2)
                            loop(1)
                            posn(212 141)
                            xStep(2)
                            yStep(1)
                        )
  )
                    )
                    (case 95
                        (
                        (if (== global107 9)
                            (send gEgo:
                                view(2)
                                illegalBits(32768)
                                observeControl(128 1024)
                                posn(1 143)
                            )
                        )(else
                            (send gEgo:posn(1 (send gEgo:y())))
                        )
 )
                    )
                    (case 8
                        (
                        (if (< (send gEgo:y()) 125)
                            (send gEgo:x(280))
                        )(else
                            (send gEgo:x(317))
                        )
 
                        (if (<= (send gEgo:y()) (+ horizon 1))
                            (send gEgo:y((+ horizon 2)))
                        )
 
                        (if ((send gEgo:inRect(193 129 319 157)))
                            (send gEgo:setPri(12))
                        )
 )
                    )
                )
  )
            )
            (case 1
                (
                (switch (gPicture)
                    (case 13
                        ((send gEgo:posn(189 186))  )
                    )
                    (case 1
                        ((send gEgo:posn(93 (+ horizon 2))) )
                    )
                )
  )
            )
            (case 2
                (
                (switch (gPicture)
                    (case 13
                        ((send gEgo:posn(137 186))  )
                    )
                    (case 1
                        ((send gEgo:posn(88 (+ horizon 2))) )
                    )
                )
  )
            )
            (case 3
                (
                (switch (gPicture)
                    (case 13
                        ((send gEgo:posn(105 185))  )
                    )
                    (case 1
                        ((send gEgo:posn(73 (+ horizon 2))) )
                    )
                )
  )
            )
            (case 4
                (
                (switch (gPicture)
                    (case 95
                        ((send gEgo:x(2))  )
                    )
                    (case 13
                        ((send gEgo:posn(42 185))  )
                    )
                    (case 1
                        ((send gEgo:posn(20 (+ horizon 2))) )
                    )
                )
 )
            )
        )
        (send gEgo:
            xStep(2)
            yStep(1)
            init()
            viewer(water)
        )
        (send gEgo:y((& (send gEgo:y()) $fffe)))
        (fisherCage:init())
    )


    (method (doit)
        (super:doit())
        = gEgoOnControl (send gEgo:onControl())
        (if ((send gEgo:inRect(65533 0 27 189)) and (<> global107 9))
            (send gEgo:view(8))
        )
        (if ((& (send gEgo:onControl(1)) $0040) and (== global107 9))
            (send gEgo:observeControl(16384))
            (send gEgo:ignoreControl(128))
            (send gEgo:setPri(-1))
            = global107 0
        )
        (if ((& (send gEgo:onControl(1)) $0020) and (<> global107 9))
            (send gEgo:setPri(13))
            (send gEgo:
                illegalBits(32768)
                observeControl(1024)
            )
            (send gEgo:observeControl(128))
            = global107 9
        )
        (if (== (send global2:script()) 0)
            (if (<> global107 9)
                (if ((send gEgo:inRect(103 157 219 189)))
                    (send gEgo:setPri(15))
                )(else
                    (if ((send gEgo:inRect(193 129 319 157)))
                        (send gEgo:setPri(12))
                    )(else
                        (if ((send gEgo:inRect(80 125 157 158)))
                            (send gEgo:setPri(8))
                        )(else
                            (send gEgo:setPri(-1))
                        )
                    )
                )
            )
            (if (((== global105 0) and (& gEgoOnControl $1000)) and (> (send gEgo:heading()) 135))
                (self:setScript(fallRocks))
            )(else
                (if (((== global105 0) and (& gEgoOnControl $1000)) and (<= (send gEgo:heading()) 135))
                    (send gEgo:setPri(-1))
                )(else
                    (if (& gEgoOnControl $2000)
                        (if (((<> global107 9) and (> (send gEgo:heading()) 90)) and (< (send gEgo:heading()) 270))
                            (send gEgo:setPri(-1))
                        )(else
                            (send gEgo:setPri(12))
                        )
                    )(else
                        (if (& gEgoOnControl $0100)
                            (if (<> global107 9)
                                (if ((> (send gEgo:heading()) 90) and (< (send gEgo:heading()) 270))
                                    (send gEgo:setPri(12))
                                )(else
                                    (send gEgo:setPri(-1))
                                )
                            )
                        )(else
                            (if (== global107 9)
                                (if (& gEgoOnControl $0010)
                                    (self:setScript(fallNorth))
                                )(else
                                    (if (& gEgoOnControl $0004)
                                        (self:setScript(fallSouth))
                                    )
                                )
                            )
                        )
                    )
                )
            )
        )
    )


    (method (dispose)
        (send gSounds:eachElementDo(172))
        (send gEgo:setPri(-1))
        (waves:dispose())
        (super:dispose())
    )


    (method (handleEvent pEvent)
        (var gInvSaidMe)
        (if ((send pEvent:claimed()))
            return 1
        )
        return 
            (if (== (send pEvent:type()) 128)
                (if (Said('get/fisherman'))
                    (if (== global116 2)
                        Print(7 0)
                    )(else
                        Print(7 1)
                    )
                )(else
                    (if (Said('get/pole'))
                        (if ((send gCast:contains(newAct)))
                            Print(7 2)
                        )(else
                            Print(7 3)
                        )
                    )(else
                        (if (Said('rob/pole'))
                            (if ((send gCast:contains(newAct)))
                                Print(7 4)
                            )(else
                                Print(7 3)
                            )
                        )(else
                            (if (Said('kiss'))
                                (if (== global116 2)
                                    Print(7 5)
                                )(else
                                    Print(7 6)
                                )
                            )(else
                                (if (Said('deliver>'))
                                    (if (= gInvSaidMe (send gInv:saidMe()))
                                        (if ((send gEgo:has((send gInv:indexOf((= gInvSaidMe (send gInv:saidMe())))))))
                                            (if (== global116 2)
                                                Print(7 7)
                                            )(else
                                                Print(7 8)
                                            )
                                        )(else
                                            proc0_19()
                                        )
                                    )
                                )(else
                                    (if (Said('help/fisherman'))
                                        Print(7 9)
                                    )(else
                                        (if ((Said('look/around') or Said('look/room')) or Said('look[<around][/!*]'))
                                            Print(7 10)
                                        )(else
                                            (if (Said('look>'))
                                                (if (Said('/anchor'))
                                                    Print(7 11)
                                                )(else
                                                    (if (Said('/cottage'))
                                                        Print(7 12)
                                                    )(else
                                                        (if (Said('<under/dock'))
                                                            Print(7 13)
                                                        )(else
                                                            (if (Said('/door'))
                                                                Print(7 14)
                                                            )(else
                                                                (if (Said('/window'))
                                                                    (if ((((send gEgo:inRect(185 126 207 140)) or (send gEgo:inRect(230 141 256 153))) or (send gEgo:inRect(270 140 315 151))) or (send gEgo:inRect(204 129 233 148)))
                                                                        Print(7 15)
                                                                    )(else
                                                                        Print(800 1)
                                                                    )
                                                                )(else
                                                                    (if (Said('/dock'))
                                                                        Print(7 16)
                                                                    )(else
                                                                        (if (Said('/fisherman'))
                                                                            (if (== global116 2)
                                                                                Print(7 17)
                                                                            )(else
                                                                                Print(7 3)
                                                                            )
                                                                        )(else
                                                                            (if (Said('/grass'))
                                                                                Print(7 18)
                                                                            )
                                                                        )
                                                                    )
                                                                )
                                                            )
                                                        )
                                                    )
                                                )
                                            )(else
                                                (if (Said('get/anchor'))
                                                    Print(7 19)
                                                )(else
                                                    (if (Said('break/window'))
                                                        Print(7 20)
                                                    )(else
                                                        (if (Said('break/door'))
                                                            Print(7 21)
                                                        )(else
                                                            (if (Said('open/window'))
                                                                Print(7 22)
                                                            )(else
                                                                (if (Said('close/door'))
                                                                    Print(7 23)
                                                                )(else
                                                                    (if (Said('converse[/fisherman,fisherman,fisherman,fisherman,fisherman]'))
                                                                        (if (== global116 2)
                                                                            Print(7 24)
                                                                        )(else
                                                                            (send pEvent:claimed(0))
                                                                        )
                                                                    )(else
                                                                        (if (Said('unlatch/door'))
                                                                            (if (not global100)
                                                                                Print(7 25)
                                                                            )(else
                                                                                Print(7 26)
                                                                            )
                                                                        )(else
                                                                            (if (Said('bang/door'))
                                                                                (if ((send gEgo:inRect(204 129 233 148)))
                                                                                    (if (not global100)
                                                                                        Print(7 27)
                                                                                    )(else
                                                                                        Print(7 28)
                                                                                    )
                                                                                )(else
                                                                                    Print(800 1)
                                                                                )
                                                                            )(else
                                                                                (if (Said('open/door'))
                                                                                    (if (<> (door:cel()) 0)
                                                                                        Print(7 29)
                                                                                    )(else
                                                                                        (if ((send gEgo:inRect(204 129 233 148)))
                                                                                            (if (not global100)
                                                                                                proc0_10()
                                                                                                (send gEgo:loop(0))
                                                                                                (send ((Sound:new())):
                                                                                                    number(300)
                                                                                                    loop(1)
                                                                                                    play(door)
                                                                                                )
                                                                                                (door:
                                                                                                    ignoreActors()
                                                                                                    setCycle(End)
                                                                                                )
                                                                                            )(else
                                                                                                Print(7 26)
                                                                                            )
                                                                                        )(else
                                                                                            Print(800 1)
                                                                                        )
                                                                                    )
                                                                                )
                                                                            )
                                                                        )
                                                                    )
                                                                )
                                                            )
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )(else
                0
            )
    )


    (method (newRoom param1)
        proc0_11()
        (send gEgo:
            setPri(-1)
            illegalBits(32768)
        )
        (if (== global116 2)
            = global116 3
        )
        (super:newRoom(param1))
    )

)
(instance water of Script
    (properties)

    (method (doit)
        (if ((<> local0 (= local1 (send gEgo:onControl(1)))) and (<> global107 9))
            = local0 local1
            (send gEgo:setCycle(Walk))
            (switch (local1)
                (case 1
                    = global105 0
                    (send gEgo:view(2))
                )
                (case 2048
                    (send gEgo:observeControl(16384))
                    = global105 1
                    (send gEgo:view(5))
                )
                (case 512
                    = global105 2
                    (send gEgo:view(6))
                )
                (case 8
                    (send gEgo:view(7))
                    = global105 3
                )
                (case 2
                    (send gEgo:view(8))
                    = global105 4
                    (send gEgo:setCycle(Fwd))
                )
            )
        )
    )

)
(instance fallSouth of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (proc0_10() (send ((Sound:new())):
                    number(51)
                    loop(1)
                    play()
                )
 (send gEgo:
                    viewer(0)
                    illegalBits(0)
                    yStep(9)
                    setMotion(MoveTo (send gEgo:x()) + (send gEgo:y()) 35 self)
                    view(17)
                    cel(0)
                    setCycle(End)
                )
  )
            )
            (case 1
                (= global107 0 (send gEgo:
                    yStep(1)
                    setPri(-1)
                )
 (send gEgo:
                    view(19)
                    loop(& (send gEgo:loop()) $0001)
                    cel(0)
                    setCycle(End self)
                )
  )
            )
            (case 2
                (proc0_11() (send gEgo:
                    viewer(water)
                    illegalBits(32768)
                    observeControl(1024)
                )
 (send global2:setScript(0)) )
            )
        )
    )

)
(instance fallNorth of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (proc0_10() (send ((Sound:new())):
                    number(51)
                    loop(1)
                    play()
                )
 (send gEgo:
                    viewer(0)
                    illegalBits(0)
                    setPri(11)
                    posn((send gEgo:x()) - (send gEgo:y()) 5)
                    yStep(8)
                    view(17)
                    setCel(0)
                    setCycle(End)
                    setMotion(MoveTo (send gEgo:x()) + (send gEgo:y()) 10 self)
                )
  )
            )
            (case 1
                ((send gEgo:
                    yStep(1)
                    setPri(-1)
                    loop(3)
                    illegalBits(32768)
                    observeControl(1024)
                    viewer(water)
                )
 = global107 0 (send global2:setScript(0)) proc0_11() )
            )
        )
    )

)
(instance fallRocks of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (proc0_10() (send gEgo:
                    viewer(0)
                    view(17)
                    illegalBits(0)
                    setPri(14)
                    xStep(10)
                    yStep(4)
                    setCycle(Fwd)
                    setMotion(MoveTo 173 186 self)
                )
 (fallSound:
                    number(51)
                    loop(1)
                    play()
                )
  )
            )
            (case 1
                ((send gEgo:
                    xStep(2)
                    yStep(1)
                    view(18)
                    loop(0)
                    setCycle(Fwd)
                )
 = global107 0 = seconds 5 (send ((Sound:new())):
                    number(80)
                    loop(1)
                    play()
                )
  )
            )
            (case 2
                ((send gEgo:
                    illegalBits(32768)
                    observeControl(1024)
                    setCycle(Walk)
                    loop(1)
                    view(2)
                    cycleSpeed(0)
                    viewer(water)
                )
 (send global2:setScript(0)) proc0_11() )
            )
        )
    )

)
(instance fishWalkHouse of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((send newAct:setMotion(MoveTo 207 140 self))  )
            )
            (case 1
                ((send newAct:setPri(10)) (door:setCycle(End self)) (send ((Sound:new())):
                    number(300)
                    loop(1)
                    play()
                )
  )
            )
            (case 2
                ((send newAct:setMotion(MoveTo 226 134 self))  )
            )
            (case 3
                ((send newAct:setMotion(MoveTo 255 134 self))  )
            )
            (case 4
                ((door:
                    ignoreActors(0)
                    setCycle(Beg self)
                )
 = global116 3 (send newAct:dispose())  )
            )
            (case 5
                ((door:stopUpd()) )
            )
        )
    )

)
(instance waveActions of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (= local11 0 (while (< local11 (waves:size()))(send ((View:new())):
                        view((send ((waves:at(local11))):view()))
                        loop((send ((waves:at(local11))):loop()))
                        cel(0)
                        setPri(0)
                        ignoreActors()
                        x((send ((waves:at(local11))):x()))
                        y((send ((waves:at(local11))):y()))
                        init()
                        addToPic()
                        yourself()
                    )
 ++local11  ) = local11 0 (self:changeState(1))  )
            )
            (case 1
                ((send ((waves:at(local11))):
                    cel(0)
                    show()
                    setCycle(End self)
                )
  )
            )
            (case 2
                ((send ((waves:at(local11))):hide()) 
                (if (< local11 (- (waves:size()) 1))
                    ++local11
                )(else
                    = local11 0
                )
 (waveActions:changeState(1)) )
            )
        )
    )

)
