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


(local
    newAct_4
    local1[3]
    newAct
    newAct_2
    newAct_3
    newView
    newProp
    local9

)
(instance public Room42 of Rm
    (properties
        picture 42
        style 16
    )

    (method (init)
        Load(rsVIEW 513)
        Load(rsVIEW 243)
        Load(rsVIEW 241)
        Load(rsVIEW 242)
        Load(rsVIEW 240)
        (super:init())
        = global101 1
        (if ((send gEgo:has(1)))
            = local9 1
        )
        (send gEgo:
            view(4)
            loop(0)
            setStep(4 1)
            illegalBits(32768)
            setPri(-1)
            posn(63 126)
            init()
        )
        (send (= newProp (Prop:new())):
            view(513)
            posn(133 85)
            setLoop(2)
            ignoreActors(1)
            init()
            cycleSpeed(1)
            setCycle(Fwd)
        )
        (if ((send gEgo:has(1)))
            (send ((View:new())):
                view(513)
                loop(0)
                cel(2)
                posn(181 94)
                addToPic()
            )
            (send (= newAct (Act:new())):
                view(241)
                loop(0)
                setCycle(Fwd)
                x(200)
                y(118)
                illegalBits(0)
                init()
                setScript(doBread)
            )
            (send ((View:new())):
                view(513)
                loop(3)
                cel(0)
                posn(82 155)
                addToPic()
            )
        )(else
            (if ((== global116 3) and (<> (send ((send gInv:at(1))):owner()) 42))
                (send (= newAct (Act:new())):
                    view(240)
                    illegalBits(0)
                    loop(2)
                    posn(84 133)
                    ignoreActors(1)
                    init()
                    setPri(12)
                    setScript(wifeTalk)
                )
            )(else
                (send (= newAct (Act:new())):
                    view(240)
                    loop(3)
                    illegalBits(0)
                    posn(84 133)
                    ignoreActors(1)
                    init()
                    setPri(12)
                    setScript(wifeTalk)
                )
            )
            (send (= newAct_2 (Act:new())):
                view(240)
                loop(4)
                cel(1)
                illegalBits(0)
                posn(84 154)
                init()
                setPri(12)
            )
            (chairBlock:
                top(- (send newAct_2:y()) 5)
                bottom(+ (send newAct_2:y()) 5)
                left(- (send newAct_2:x()) 13)
                right(+ (send newAct_2:x()) 15)
                init()
            )
            (send gEgo:observeBlocks(chairBlock))
        )
        (if (== global116 3)
            (send ((View:new())):
                view(513)
                loop(0)
                cel(2)
                posn(181 94)
                addToPic()
            )
            (send (= newAct_3 (Act:new())):
                view(235)
                loop(0)
                cel(0)
                ignoreActors(1)
                illegalBits(0)
                posn(130 136)
                init()
                setPri(12)
                setScript(fishermanSit)
            )
            (send (= newView (View:new())):
                view(235)
                loop(2)
                cel(0)
                posn(129 158)
                init()
                stopUpd()
                setPri(12)
            )
            (if (== (send ((send gInv:at(17))):owner()) 204)
                (send (= newAct_4 (Act:new())):
                    view(513)
                    loop(1)
                    cel(0)
                    illegalBits(0)
                    posn(223 116)
                    init()
                    stopUpd()
                    ignoreActors(1)
                )
            )
        )(else
            (send ((View:new())):
                view(513)
                loop(3)
                cel(1)
                posn(138 162)
                addToPic()
            )
        )
    )


    (method (doit)
        (if (& (send gEgo:onControl(0)) $0040)
            (send gEgo:loop(1))
            Animate((send gCast:elements()) 0)
            (send global2:newRoom(7))
        )
        (super:doit())
    )


    (method (handleEvent pEvent)
        (var gInvSaidMe)
        (if ((send pEvent:claimed()))
            return 1
        )
        return 
            (if (== (send pEvent:type()) 128)
                (if (Said('look[<around][/room,room,place]'))
                    (if (local9)
                        Print(Format(@global300 42 0 
                                (if (not (send gCast:contains(newAct_3)))
                                    "You see a tired-looking woman kneading bread at the counter."
                                )(else
                                    (if (not (send gEgo:has(17)))
                                        "You see the old fisherman at the table, and his wife kneading bread at the counter. The fisherman's fishing pole has been set in the corner."
                                    )(else
                                        (if (not (send gEgo:has(1)))
                                            "You see the old fisherman at the table, and his wife kneading bread at the counter. Since your generous gift of the diamonds, however, her grouchy look has been replaced by one of contentment."
                                        )(else
                                            " "
                                        )
                                    )
                                )
))
                    )(else
                        Print(Format(@global300 42 0 
                                (if (not (send gCast:contains(newAct_3)))
                                    "You see a tired-looking woman knitting at the table."
                                )(else
                                    (if (not (send gEgo:has(17)))
                                        "The fisherman's worn and tattered wife sits at the table with her husband, talking. The fisherman's pole has been set into the corner."
                                    )(else
                                        (if (not (send gEgo:has(1)))
                                            "The fisherman's worn and tattered wife sits at the table with her husband, talking. Since your generous gift of the diamonds, however, her grouchy look has been replaced by one of contentment."
                                        )(else
                                            " "
                                        )
                                    )
                                )
))
                    )
                )(else
                    (if ((send gCast:contains(newAct_3)) and Said('/person'))
                        Print(42 1)
                    )(else
                        (if (Said('/people'))
                            (if ((send gCast:contains(newAct_3)))
                                Print(42 1)
                            )(else
                                Print(42 2)
                            )
                        )(else
                            (if (Said('look>'))
                                (if (Said('/fishwife,person'))
                                    (if (local9)
                                        (if (not (send gEgo:has(17)))
                                            Print(42 3)
                                        )(else
                                            (if (not (send gEgo:has(1)))
                                                Print(42 4)
                                            )
                                        )
                                    )(else
                                        (if (<> global116 3)
                                            Print(42 5)
                                        )(else
                                            (if (== (send ((send gInv:at(1))):owner()) 42)
                                                Print(42 6)
                                            )(else
                                                Print(42 7)
                                            )
                                        )
                                    )
                                )(else
                                    (if (Said('/dough[<bread]'))
                                        Print(42 8)
                                    )(else
                                        (if (Said('<under/table'))
                                            Print(42 9)
                                        )(else
                                            (if (Said('/table'))
                                                Print(42 10)
                                            )(else
                                                (if (Said('/chair'))
                                                    Print(42 11)
                                                )(else
                                                    (if (Said('<under/bed'))
                                                        Print(42 12)
                                                    )(else
                                                        (if (Said('/bed'))
                                                            Print(42 13)
                                                        )(else
                                                            (if (Said('/stove'))
                                                                Print(42 14)
                                                            )(else
                                                                (if (Said('/window'))
                                                                    (if ((send gEgo:inRect(14 127 52 140)) or (send gEgo:inRect(66 110 88 119)))
                                                                        Print(42 15)
                                                                    )(else
                                                                        (if ((send gEgo:inRect(236 118 261 139)))
                                                                            Print(42 16)
                                                                        )(else
                                                                            Print(800 1)
                                                                        )
                                                                    )
                                                                )(else
                                                                    (if (Said('/door'))
                                                                        Print(42 17)
                                                                    )(else
                                                                        (if (Said('/wall'))
                                                                            Print(42 18)
                                                                        )(else
                                                                            (if (Said('/dirt') or Said('<down'))
                                                                                Print(42 19)
                                                                            )(else
                                                                                (if (Said('/pole'))
                                                                                    (if ((== global116 3) and (== (send ((send gInv:at(17))):owner()) 204))
                                                                                        Print(42 20)
                                                                                    )(else
                                                                                        (if ((send gEgo:has(17)))
                                                                                            (send pEvent:claimed(0))
                                                                                        )(else
                                                                                            Print(42 21)
                                                                                        )
                                                                                    )
                                                                                )(else
                                                                                    (if (Said('/fisherman'))
                                                                                        (if (<> global116 3)
                                                                                            Print(42 22)
                                                                                        )(else
                                                                                            (if (not local9)
                                                                                                Print(42 23)
                                                                                            )(else
                                                                                                (if (== (send ((send gInv:at(1))):owner()) 42)
                                                                                                    Print(42 24)
                                                                                                )(else
                                                                                                    Print(42 25)
                                                                                                )
                                                                                            )
                                                                                        )
                                                                                    )(else
                                                                                        (if (Said('/caldron,kettle,coffee'))
                                                                                            Print(42 26)
                                                                                        )(else
                                                                                            (if (Said('/fish'))
                                                                                                (if (not (send gEgo:has(24)))
                                                                                                    Print(42 27)
                                                                                                )(else
                                                                                                    (send pEvent:claimed(0))
                                                                                                )
                                                                                            )(else
                                                                                                (if (Said('/shelf'))
                                                                                                    Print(42 28)
                                                                                                )(else
                                                                                                    (if (Said('/can'))
                                                                                                        Print(42 29)
                                                                                                    )(else
                                                                                                        (if (Said('/knitting,knitting'))
                                                                                                            (if ((== (send newAct:view()) 240) and (== (send newAct:loop()) 3))
                                                                                                                Print(42 30)
                                                                                                            )(else
                                                                                                                Print(42 31)
                                                                                                            )
                                                                                                        )
                                                                                                    )
                                                                                                )
                                                                                            )
                                                                                        )
                                                                                    )
                                                                                )
                                                                            )
                                                                        )
                                                                    )
                                                                )
                                                            )
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )(else
                                (if (Said('chew/dough'))
                                    Print(42 32)
                                )(else
                                    (if (Said('rob/pole'))
                                        (if ((== (send ((send gInv:at(17))):owner()) 204) and (== global116 3))
                                            Print(42 33)
                                        )(else
                                            (if ((send ((send gInv:at(17))):ownedBy(gEgo)))
                                                Print(800 0)
                                            )(else
                                                Print(42 21)
                                            )
                                        )
                                    )(else
                                        (if (Said('kiss>'))
                                            (if (Said('[/!*]'))
                                                (if (== global116 3)
                                                    Print(42 34)
                                                )(else
                                                    Print(42 35)
                                                )
                                            )(else
                                                (if (Said('/fishwife,person'))
                                                    Print(42 35)
                                                )(else
                                                    (if (Said('/fisherman'))
                                                        (if (== global116 3)
                                                            Print(42 36)
                                                        )(else
                                                            Print(42 37)
                                                        )
                                                    )
                                                )
                                            )
                                        )(else
                                            (if (Said('help'))
                                                Print(42 38)
                                            )(else
                                                (if (Said('converse/fishwife,person') or ((< (send gEgo:distanceTo(newAct)) 50) and Said('converse[/!*]')))
                                                    (if (== (send ((send gInv:at(1))):owner()) 42)
                                                        (wifeTacoDoco2:cue())
                                                    )(else
                                                        (if ((send gCast:contains(newAct_3)))
                                                            (wifeTacoDoco1:cue())
                                                        )(else
                                                            (wifeTacoDoco:cue())
                                                        )
                                                    )
                                                )(else
                                                    (if (Said('converse/fisherman') or (((send gCast:contains(newAct_3)) and (< (send gEgo:distanceTo(newAct_3)) 50)) and Said('converse[/!*]')))
                                                        (if (== global116 3)
                                                            (if (== (send ((send gInv:at(1))):owner()) 42)
                                                                (fishermanTacoDoco1:cue())
                                                            )(else
                                                                (fishermanTacoDoco2:cue())
                                                            )
                                                        )(else
                                                            Print(42 39)
                                                        )
                                                    )(else
                                                        (if (Said('converse[/!*]'))
                                                            (if ((send gCast:contains(newAct_3)))
                                                                Print(42 40)
                                                            )(else
                                                                (if (== (send ((send gInv:at(1))):owner()) 42)
                                                                    (wifeTacoDoco2:cue())
                                                                )(else
                                                                    (if ((send gCast:contains(newAct_3)))
                                                                        (wifeTacoDoco1:cue())
                                                                    )(else
                                                                        (wifeTacoDoco:cue())
                                                                    )
                                                                )
                                                            )
                                                        )(else
                                                            (if (Said('close,open/door'))
                                                                Print(42 41)
                                                            )(else
                                                                (if (Said('sit'))
                                                                    Print(42 42)
                                                                )(else
                                                                    (if (Said('lay,sleep[<down,on,in]') or Said('get<in,on,in/bed'))
                                                                        Print(42 13)
                                                                    )(else
                                                                        (if (Said('drink,get/coffee,cup'))
                                                                            Print(42 43)
                                                                        )(else
                                                                            (if (Said('deliver>'))
                                                                                (if ((< (send gEgo:distanceTo(newAct)) 20) or ((send gCast:contains(newAct_3)) and (< (send gEgo:distanceTo(newView)) 30)))
                                                                                    (if ((= gInvSaidMe (send gInv:saidMe())) and (send gEgo:has((send gInv:indexOf((= gInvSaidMe (send gInv:saidMe())))))))
                                                                                        (if ((== (send gInv:indexOf(gInvSaidMe)) 1) and (== global116 3))
                                                                                            (if (< (send gEgo:distanceTo(newAct)) 25)
                                                                                                Print(42 44)
                                                                                            )(else
                                                                                                Print(42 45)
                                                                                            )
                                                                                            (send gEgo:put(1 42))
                                                                                            (send newAct:setScript(givePole))
                                                                                        )(else
                                                                                            (if (== global116 3)
                                                                                                Print(42 46)
                                                                                            )(else
                                                                                                Print(42 47)
                                                                                            )
                                                                                        )
                                                                                    )(else
                                                                                        (if (gInvSaidMe)
                                                                                            Print(800 2)
                                                                                        )(else
                                                                                            Print(42 48)
                                                                                        )
                                                                                        (send pEvent:claimed(1))
                                                                                    )
                                                                                )(else
                                                                                    Print(800 1)
                                                                                    (send pEvent:claimed(1))
                                                                                )
                                                                            )(else
                                                                                (if (Said('get,rob>'))
                                                                                    (if (Said('/knitting'))
                                                                                        Print(42 49)
                                                                                    )(else
                                                                                        (if (Said('/pole'))
                                                                                            (if ((== (send ((send gInv:at(17))):owner()) 204) and (== global116 3))
                                                                                                Print(42 50)
                                                                                            )(else
                                                                                                (if ((send ((send gInv:at(17))):ownedBy(gEgo)))
                                                                                                    Print(42 51)
                                                                                                )(else
                                                                                                    Print(42 21)
                                                                                                )
                                                                                            )
                                                                                        )(else
                                                                                            (if (Said('/dough'))
                                                                                                Print(42 52)
                                                                                            )(else
                                                                                                (if (Said('/fishwife,person'))
                                                                                                    Print(42 53)
                                                                                                )(else
                                                                                                    (if (Said('/fisherman'))
                                                                                                        (if (== global116 3)
                                                                                                            Print(42 54)
                                                                                                        )
                                                                                                    )(else
                                                                                                        (if (Said('/caldron'))
                                                                                                            Print(42 55)
                                                                                                        )(else
                                                                                                            (if (Said('/can'))
                                                                                                                Print(42 56)
                                                                                                            )(else
                                                                                                                (if (Said('/fish'))
                                                                                                                    Print(42 57)
                                                                                                                )
                                                                                                            )
                                                                                                        )
                                                                                                    )
                                                                                                )
                                                                                            )
                                                                                        )
                                                                                    )
                                                                                )(else
                                                                                    (if (Said('create/bed'))
                                                                                        Print(42 58)
                                                                                    )
                                                                                )
                                                                            )
                                                                        )
                                                                    )
                                                                )
                                                            )
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )(else
                0
            )
    )

)
(instance doBread of Script
    (properties)

    (method (init param1)
        (super:init(param1))
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((Timer:setReal(self 5))  )
            )
            (case 1
                ((send newAct:setLoop(1)) (Timer:setReal(self 3))  )
            )
            (case 2
                ((send newAct:setLoop(0)) = state -1 (self:cue()) )
            )
        )
    )

)
(instance givePole of Script
    (properties)

    (method (init param1)
        (super:init(param1))
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((send gEgo:setMotion(0)) proc0_10() 
                (if ((send gEgo:inRect(185 115 239 124)))
                    (send gEgo:setMotion(MoveTo (send gEgo:x()) 125))
                )
 (send newAct:
                    view(242)
                    loop(0)
                    cel(0)
                    setAvoider((Avoid:new()))
                    setCycle(Walk)
                    setMotion(MoveTo 223 118 self)
                )
  )
            )
            (case 1
                (proc0_3(gEgo newAct) (send newAct_4:dispose()) (send newAct:
                    view(243)
                    setLoop(-1)
                    cel(0)
                    setMotion(Chase gEgo 20 self)
                )
  )
            )
            (case 2
                ((send gEgo:get(17)) (send gGame:changeScore(3)) = global182 1 (send newAct:
                    view(242)
                    loop(0)
                    cel(0)
                    setMotion(MoveTo 200 118 self)
                )
  )
            )
            (case 3
                (proc0_11() (send newAct:
                    view(241)
                    setAvoider(0)
                    loop(0)
                    setCycle(Fwd)
                    setScript(doBread)
                )
 )
            )
        )
    )

)
(instance wifeTalk of Script
    (properties)

    (method (init param1)
        (super:init(param1))
        (send client:cycleSpeed(1))
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((send client:setCycle(Fwd)) (send (ScriptID(0 4)):setReal(self 2))  )
            )
            (case 1
                (= state -1 (send client:
                    cel(0)
                    setCycle(0)
                )
 
                (if (== (send client:loop()) 3)
                    (send (ScriptID(0 4)):setReal(self 1))
                )(else
                    (send (ScriptID(0 4)):setReal(self 5))
                )
 )
            )
        )
    )

)
(instance fishermanSit of Script
    (properties)

    (method (init param1)
        (super:init(param1))
        (send client:cycleSpeed(2))
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((send client:
                    loop(0)
                    cel(0)
                    setCycle(Fwd)
                )
 (Timer:setReal(self 3))  )
            )
            (case 1
                ((send client:
                    loop(1)
                    cel(0)
                    setCycle(End self)
                )
  )
            )
            (case 2
                ((Timer:setReal(self 2))  )
            )
            (case 3
                (= state -1 (send client:setCycle(Beg)) (Timer:setReal(self 10)) )
            )
        )
    )

)
(instance wifeTacoDoco of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (
                (if (global206)
                    (self:cue())
                    return 
                )
 Print(42 59) = global206 1  )
            )
            (case 1
                (
                (if (> global206 1)
                    (self:cue())
                    return 
                )
 Print(42 60) = global206 2  )
            )
            (case 2
                (= state 1 Print(42 61) )
            )
        )
    )

)
(instance wifeTacoDoco1 of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (
                (if (global206)
                    (self:cue())
                    return 
                )
 Print(42 62) = global206 1  )
            )
            (case 1
                (= state 0 Print(42 63) )
            )
        )
    )

)
(instance wifeTacoDoco2 of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (
                (if (< global206 0)
                    (self:cue())
                    return 
                )
 = global206 -1 Print(42 64)  )
            )
            (case 1
                (= state 0 Print(Format(@global300 42 65 
                        (if (== (send newAct:view()) 241)
                            "kneading the bread"
                        )(else
                            "knitting"
                        )
)) )
            )
        )
    )

)
(instance fishermanTacoDoco1 of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (Print(42 66)  )
            )
            (case 1
                (= state 0 Print(42 67) )
            )
        )
    )

)
(instance fishermanTacoDoco2 of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (Print(42 68)  )
            )
            (case 1
                (Print(42 69)  )
            )
            (case 2
                (= state 1 Print(42 70) )
            )
        )
    )

)
(instance chairBase of Code
    (properties)

    (method (doit param1)
        (send param1:brTop((- (send param1:y()) 5)))
        (send param1:brLeft((- (send param1:x()) 16)))
        (send param1:brBottom((+ (send param1:y()) 1)))
        (send param1:brRight((+ (send param1:x()) 5)))
    )

)
(instance chairBlock of Blk
    (properties)
)
