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


(local
    local0
    local1
    local2
    newView
    newAct

)
(instance public gfReg of Rgn
    (properties)

    (method (init)
        Load(rsVIEW 336)
        Load(rsVIEW 337)
        (super:init())
        (switch (gGNewPropX)
            (case 33
                (= local1 198 = local0 155  )
            )
            (case 34
                (= local1 172 = local0 133  )
            )
            (case 35
                (= local1 126 = local0 144  )
            )
            (case 39
                (= local1 224 = local0 113  )
            )
            (case 40
                (= local1 241 = local0 117  )
            )
            (case 41
                (= local1 102 = local0 109 )
            )
        )
        (if (< Random(1 100) 75)
            = local2 (+ Random(1 3) 32)
        )(else
            = local2 (+ Random(1 3) 38)
        )
        (if ((send ((Inv:at(8))):ownedBy(888)))
            (send ((Inv:at(8))):moveTo(local2))
        )
        (if ((send ((Inv:at(8))):ownedBy(gGNewPropX)))
            (send (= newView (View:new())):
                view(514)
                posn(local1 local0)
                loop(0)
                cel(0)
                init()
                stopUpd()
            )
        )
        (if ((<= Random(1 100) 40) and (> local1 0))
            = newAct (Act:new())
            (send newAct:
                view(336)
                moveSpeed(1)
                cycleSpeed(1)
                setCycle(Walk)
                setMotion(Wander 30000)
                illegalBits(65534)
                posn(local1 - local0 4)
                init()
                setScript(peacockActions)
                setStep(1 1)
            )
        )
    )


    (method (doit)
        (if ((send gCast:contains(newAct)) and not (send newAct:inRect(65526 50 329 199)))
            (send newAct:dispose())
        )
    )


    (method (dispose)
        (send gTimers:eachElementDo(172 192))
        (super:dispose())
    )


    (method (handleEvent pEvent)
        (if ((send pEvent:claimed()))
            return 1
        )
        return 
            (if (== (send pEvent:type()) 128)
                (if (Said('look>'))
                    (if (Said('/beach,beach'))
                        (if ((send ((Inv:at(8))):ownedBy(gGNewPropX)))
                            Print(505 0)
                        )(else
                            Print(505 1)
                        )
                    )(else
                        (if (Said('/feather'))
                            (if ((send gCast:contains(newView)))
                                Print(505 2)
                            )(else
                                (if ((send gEgo:has(8)))
                                    (send ((Inv:at(8))):showSelf())
                                )(else
                                    Print(505 3)
                                )
                            )
                        )(else
                            (if (Said('/tamir'))
                                Print(505 4)
                            )(else
                                (if (Said('<in,under/ocean,water'))
                                    (if (<> (send gEgo:view()) 2)
                                        Print(505 5)
                                    )(else
                                        Print(505 6)
                                    )
                                )(else
                                    (if (Said('/ocean,water'))
                                        Print(505 7)
                                    )(else
                                        (if (Said('/dirt') or Said('<down'))
                                            (if ((send ((Inv:at(8))):ownedBy(gGNewPropX)))
                                                Print(505 0)
                                            )(else
                                                (if ((>= gGNewPropX 36) and (<= gGNewPropX 38))
                                                    Print(505 8)
                                                )(else
                                                    Print(505 9)
                                                )
                                            )
                                        )(else
                                            (if (Said('/boulder'))
                                                Print(505 10)
                                            )(else
                                                (if (Said('/forest'))
                                                    Print(505 11)
                                                )(else
                                                    (if (Said('/grass'))
                                                        Print(505 12)
                                                    )(else
                                                        (if (Said('/bush'))
                                                            Print(505 13)
                                                        )(else
                                                            (if (Said('/flora'))
                                                                Print(505 14)
                                                            )(else
                                                                (if (Said('/blossom'))
                                                                    Print(505 15)
                                                                )(else
                                                                    (if (Said('/garden'))
                                                                        Print(505 16)
                                                                    )(else
                                                                        (if (Said('/castle'))
                                                                            Print(505 17)
                                                                        )(else
                                                                            (if (Said('/peacock'))
                                                                                (if ((send gCast:contains(newAct)))
                                                                                    Print(505 18)
                                                                                )(else
                                                                                    Print(505 19)
                                                                                )
                                                                            )(else
                                                                                (if (Said('/bird'))
                                                                                    (if ((send gCast:contains(newAct)))
                                                                                        Print(505 18)
                                                                                    )(else
                                                                                        (send pEvent:claimed(0))
                                                                                    )
                                                                                )
                                                                            )
                                                                        )
                                                                    )
                                                                )
                                                            )
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )(else
                    (if (Said('climb/forest'))
                        Print(505 20)
                    )(else
                        (if (Said('converse>'))
                            (if (Said('/peacock'))
                                (if ((send gCast:contains(newAct)))
                                    Print(505 21)
                                )(else
                                    Print(505 19)
                                )
                            )(else
                                (if (Said('/bird'))
                                    (if ((send gCast:contains(newAct)))
                                        Print(505 21)
                                    )(else
                                        (send pEvent:claimed(0))
                                    )
                                )
                            )
                        )(else
                            (if (Said('get/feather'))
                                (if ((send ((Inv:at(8))):ownedBy(gGNewPropX)))
                                    (if (< (send gEgo:distanceTo(newView)) 15)
                                        (send gEgo:get(8))
                                        (send gGame:changeScore(2))
                                        (send gEgo:setScript(getFeather))
                                    )(else
                                        Print(800 1)
                                    )
                                )(else
                                    (if ((send gEgo:has(8)))
                                        (send pEvent:claimed(0))
                                    )(else
                                        Print(505 22)
                                    )
                                )
                            )(else
                                (if (Said('get/blossom'))
                                    Print(505 23)
                                )(else
                                    (if (Said('get,capture/peacock'))
                                        (if ((send gCast:contains(newAct)))
                                            Print(505 24)
                                        )(else
                                            Print(505 3)
                                        )
                                    )(else
                                        (if (Said('get,capture/bird,parrot'))
                                            Print(505 25)
                                        )(else
                                            (if (Said('kiss'))
                                                (if ((send gCast:contains(newAct)))
                                                    Print(505 26)
                                                )(else
                                                    (send pEvent:claimed(0))
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )(else
                0
            )
    )

)
(instance getFeather of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (proc0_10() (send gEgo:view(21)) proc0_3(gEgo newView) (send gEgo:setCycle(End self))  )
            )
            (case 1
                ((send gEgo:setCycle(Beg self)) = global182 1 (send newView:dispose())  )
            )
            (case 2
                ((send gEgo:
                    view(2)
                    setScript(0)
                    setCycle(Walk)
                )
 proc0_11() )
            )
        )
    )

)
(instance peacockActions of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((send (ScriptID(0 4)):setReal(self Random(10 40)))  )
            )
            (case 1
                ((send newAct:
                    view(337)
                    setLoop(0)
                    setMotion(0)
                    cel(0)
                    setCycle(End self)
                )
  )
            )
            (case 2
                ((send (ScriptID(0 4)):setReal(self 4))  )
            )
            (case 3
                ((send newAct:setCycle(Beg self))  )
            )
            (case 4
                ((send newAct:
                    view(336)
                    setLoop(-1)
                    setCycle(Walk)
                    setMotion(Wander 30000)
                )
 (self:changeState(0)) )
            )
        )
    )

)
