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


(local
    local0
    local1
    newProp
    newAct
    local4
    gEgoViewer

)
(instance public swampReg of Rgn
    (properties)

    (method (init)
        Load(rsVIEW 5)
        Load(rsVIEW 6)
        Load(rsVIEW 7)
        Load(rsVIEW 10)
        Load(rsVIEW 372)
        Load(rsVIEW 377)
        Load(rsVIEW 193)
        Load(rsVIEW 680)
        Load(rsVIEW 370)
        = local0 0
        (send gEgo:viewer(swamp))
        (super:init())
    )


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


    (method (handleEvent pEvent)
        (if ((send pEvent:claimed()))
            return 1
        )
        return 
            (if (== (send pEvent:type()) 128)
                (if (Said('bathe,dive,wade[<enter][/ocean]'))
                    Print(513 0)
                )(else
                    (if (((Said('enter/fish') or Said('fish[/!*]')) or Said('capture/fish')) or Said('cast/pole'))
                        Print(513 1)
                    )(else
                        (if (Said('get/water'))
                            Print(513 2)
                        )(else
                            (if (Said('drink') or Said('get/drink'))
                                (if (== (send gEgo:view()) 2)
                                    (if ((((& (= local4 proc0_2(gEgo 12)) $0008) or (& local4 $0800)) or (& local4 $0002)) or (& local4 $0200))
                                        = gGEgoScript (send gEgo:script())
                                        (send gEgo:setScript(drinking))
                                    )(else
                                        Print(800 1)
                                    )
                                )(else
                                    Print(513 3)
                                )
                            )(else
                                (if (Said('look<in/water'))
                                    Print(513 4)
                                )(else
                                    (if (Said('look,climb/boulder<[gray]'))
                                        Print(513 5)
                                    )(else
                                        (if (Said('look>'))
                                            (if (Said('/water'))
                                                Print(513 6)
                                            )(else
                                                (if (Said('/cliff'))
                                                    Print(513 7)
                                                )(else
                                                    (if (Said('/dirt'))
                                                        Print(513 8)
                                                    )(else
                                                        (if (Said('/tuft'))
                                                            Print(513 9)
                                                        )(else
                                                            (if (Said('/grass'))
                                                                Print(513 10)
                                                            )(else
                                                                (if (Said('/bush'))
                                                                    Print(513 11)
                                                                )(else
                                                                    (if (Said('/flora'))
                                                                        Print(513 12)
                                                                    )(else
                                                                        (if (Said('/blossom'))
                                                                            Print(513 13)
                                                                        )(else
                                                                            (if (Said('/forest'))
                                                                                Print(513 14)
                                                                            )
                                                                        )
                                                                    )
                                                                )
                                                            )
                                                        )
                                                    )
                                                )
                                            )
                                        )(else
                                            (if (Said('climb,cross/cliff'))
                                                Print(513 15)
                                            )(else
                                                (if (Said('get/blossom'))
                                                    Print(513 13)
                                                )(else
                                                    (if (Said('dennis/crown') or Said('place/crown'))
                                                        (if ((send gEgo:inRect(115 149 274 181)) and (== gGNewPropX 78))
                                                            Print(513 16)
                                                        )(else
                                                            (if (<> (send gEgo:view()) 2)
                                                                Print(513 17)
                                                            )(else
                                                                (if ((send gEgo:has(10)))
                                                                    (swamp:changeState(20))
                                                                )(else
                                                                    Print(800 2)
                                                                )
                                                            )
                                                        )
                                                    )(else
                                                        (if (Said('detach/crown') or Said('get<off/crown'))
                                                            (if (== global105 13)
                                                                (swamp:changeState(30))
                                                            )(else
                                                                Print(513 18)
                                                            )
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )(else
                0
            )
    )

)
(instance swamp of Script
    (properties)

    (method (doit)
        (super:doit())
        = local0 (= local1 (send gEgo:onControl(1)))
        (if ((== global105 12) and (== global132 0))
            (switch (local1)
                (case 1
                    (send gEgo:
                        illegalBits(32768)
                        view(2)
                    )
                )
                (case 2048
                    (send gEgo:
                        illegalBits(33792)
                        view(5)
                    )
                )
                (case 512
                    (send gEgo:
                        illegalBits(33792)
                        view(6)
                    )
                )
                (case 8
                    (send gEgo:
                        illegalBits(33792)
                        view(7)
                    )
                )
                (case 2
                    (self:changeState(1))
                )
            )
        )(else
            (if (== global105 13)
                (if (== (send gEgo:mover()) 0)
                    (send gEgo:cel(0))
                )
                (switch (local1)
                    (case 1
                        (send gEgo:
                            illegalBits(49152)
                            view(372)
                        )
                    )
                    (case 2048
                        (send gEgo:
                            illegalBits(32768)
                            view(377)
                        )
                    )
                    (case 512
                        (send gEgo:
                            illegalBits(32768)
                            view(377)
                        )
                    )
                    (case 8
                        (send gEgo:
                            view(377)
                            illegalBits(32768)
                        )
                    )
                    (case 2
                        (self:changeState(10))
                    )
                    (case 1024
                        (send gEgo:
                            illegalBits(32768)
                            view(372)
                        )
                    )
                    (default 
                        (send gEgo:
                            illegalBits(50176)
                            view(377)
                        )
                    )
                )
            )
        )
    )


    (method (changeState newState)
        (switch (= state newState)
            (case 1
                (proc0_10() = global105 0 (send gEgo:
                    illegalBits(1)
                    view(73)
                    cel(0)
                    loop(& (send gEgo:loop()) $0001)
                    cycleSpeed(2)
                    setCycle(End self)
                )
  )
            )
            (case 2
                ((send gEgo:hide()) Print(513 19) Print(513 20) (Timer:setReal(self 5))  )
            )
            (case 3
                (= global127 1  )
            )
            (case 10
                (proc0_10() = global105 0 = newAct (Act:new()) (send newAct:
                    view(193)
                    posn((send gEgo:x()) - (send gEgo:y()) 5)
                    loop(0)
                    cel(0)
                    ignoreActors()
                    setCycle(End self)
                    init()
                )
 (send ((Sound:new())):
                    number(47)
                    play()
                )
  )
            )
            (case 11
                ((send gEgo:hide()) = global105 0 (send newAct:
                    loop(1)
                    cel(0)
                    setCycle(End self)
                )
  )
            )
            (case 12
                ((send newAct:
                    loop(2)
                    cel(0)
                    setCycle(Fwd)
                )
 (Timer:setReal(self 4))  )
            )
            (case 13
                (Print(513 21 134 -1 20) (send newAct:
                    cel(0)
                    loop(3)
                    setCycle(End self)
                )
  )
            )
            (case 14
                ((send newAct:dispose()) (Timer:setReal(self 5))  )
            )
            (case 15
                (= global127 1  )
            )
            (case 20
                (proc0_10() (send gSounds:eachElementDo(172)) (send ((Sound:new())):
                    number(59)
                    play()
                )
 = newProp (Prop:new()) (send newProp:
                    posn((send gEgo:x()) (send gEgo:y()))
                    setPri(+ (send gEgo:priority()) 1)
                    view(680)
                    cel(0)
                    loop(0)
                    ignoreActors()
                    setCycle(CT 5 1 self)
                    init()
                )
  )
            )
            (case 21
                ((send newProp:setCycle(End self)) = global105 13 (send gEgo:observeControl(16384)) (send gEgo:view(370))  )
            )
            (case 22
                ((Timer:setReal(self 3)) (send newProp:dispose())  )
            )
            (case 23
                ((send gEgo:
                    view(372)
                    setCycle(Walk)
                )
 proc0_11()  )
            )
            (case 30
                (proc0_10() (send gSounds:eachElementDo(172)) (send ((Sound:new())):
                    number(59)
                    play()
                )
 = newProp (Prop:new()) (send newProp:
                    posn((send gEgo:x()) (send gEgo:y()))
                    setPri(+ (send gEgo:priority()) 1)
                    view(680)
                    cel(0)
                    loop(0)
                    ignoreActors()
                    setCycle(CT 5 1 self)
                    init()
                )
  )
            )
            (case 31
                ((send newProp:setCycle(End self)) = global105 12 (send gEgo:
                    view(2)
                    ignoreControl(16384)
                    setCycle(Walk)
                )
 proc0_11()  )
            )
            (case 32
                ((send newProp:dispose()) )
            )
        )
    )

)
(instance drinking of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (proc0_10() = gEgoViewer (send gEgo:viewer()) (send gEgo:
                    viewer(0)
                    view(21)
                    cel(0)
                    setCycle(End self)
                )
  )
            )
            (case 1
                (= global120 Print(513 22 134 -1 20 172) (Timer:setReal(self 4))  )
            )
            (case 2
                ((send gEgo:setCycle(Beg self))  )
            )
            (case 3
                (proc0_23() (send gEgo:
                    view(2)
                    setCycle(Walk)
                )
 (send gEgo:
                    viewer(gEgoViewer)
                    script(gGEgoScript)
                )
 proc0_11() )
            )
        )
    )

)
