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


(local
    local0[2]
    local2
    local3
    newProp
    newProp_2
    newProp_3

)
(instance ogreTheme of Sound
    (properties)
)
(instance public Room10 of Rm
    (properties
        picture 10
    )

    (method (init)
        = north 4
        = south 16
        = east 11
        = west 9
        = horizon 72
        = global101 0
        = global189 1
        (if (global100)
            = picture 110
        )
        (super:init())
        (self:setRegions(508 517))
        Load(rsVIEW 250)
        Load(rsVIEW 78)
        Load(rsVIEW 79)
        Load(rsVIEW 681)
        (switch (gPicture)
            (case 16
                (
                (if (< (send gEgo:x()) 63)
                    (send gEgo:posn(63 187))
                )(else
                    (send gEgo:posn((send gEgo:x()) 187))
                )
 )
            )
            (case 4
                (
                (if (< (send gEgo:x()) 200)
                    (send gEgo:posn(205 (+ horizon 2)))
                )(else
                    (send gEgo:posn((send gEgo:x()) (+ horizon 2)))
                )
 )
            )
        )
        = newProp (Prop:new())
        (send newProp:
            view(626)
            loop(0)
            cel(0)
            posn(233 26)
            setPri(0)
            setCycle(Fwd)
            cycleSpeed(3)
            init()
        )
        (if (((== gPicture 4) and gNewAct) and not (send gEgo:has(33)))
            = gNewAct (Act:new())
            (send gNewAct:
                posn(202 85)
                view(250)
                xStep(6)
                yStep(2)
                setCycle(Walk)
                ignoreActors()
                init()
            )
            = local2 0
            (self:setScript(ogreActions))
            (ogreActions:changeState(1))
        )(else
            (if (((<= Random(1 100) 40) and not gNewAct) and (<> global165 4))
                = gNewAct (Act:new())
                (send gNewAct:
                    posn(19 182)
                    view(250)
                    xStep(6)
                    yStep(2)
                    setCycle(Walk)
                    ignoreActors()
                    init()
                )
                (self:setScript(ogreActions))
            )(else
                = gNewAct 0
            )
        )
        (if (== global165 4)
            = global165 5
        )
        (send gEgo:
            view(2)
            init()
        )
        (if (not global100)
            (if (< Random(1 100) 50)
                = newProp_2 (Prop:new())
                (send newProp_2:
                    view(342)
                    loop(5)
                    cel(1)
                    posn(146 11)
                    setPri(14)
                    setScript(bird1Actions)
                    init()
                )
            )
            (if (< Random(1 100) 50)
                = newProp_3 (Prop:new())
                (send newProp_3:
                    view(342)
                    loop(4)
                    cel(1)
                    posn(65 55)
                    setPri(14)
                    setScript(bird2Actions)
                    init()
                )
            )
        )
    )


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


    (method (handleEvent pEvent)
        (if ((send pEvent:claimed()))
            return 1
        )
        return 
            (if ((== (send pEvent:type()) 128) and Said('look>'))
                (if (Said('/cottage'))
                    Print(10 0)
                )(else
                    (if (Said('[<around][/room]'))
                        Print(10 1)
                    )
                )
            )(else
                0
            )
    )


    (method (newRoom param1)
        = global189 0
        (send gTimers:eachElementDo(172 192))
        (if ((send gCast:contains(gNewAct)))
            = gGNewActY (send gNewAct:y())
        )
        (super:newRoom(param1))
    )

)
(instance ogreActions of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (= seconds Random(1 6)  )
            )
            (case 1
                (
                (if (== local2 0)
                    = local2 1
                    (ogreTheme:
                        number(5)
                        loop(-1)
                        play()
                    )
                    (send gNewAct:
                        setAvoider((Avoid:new()))
                        ignoreActors()
                        setMotion(Chase gEgo 6 self)
                    )
                    = global189 1
                )
 )
            )
            (case 2
                (proc0_10() (send gEgo:hide()) (send gNewAct:
                    view(78)
                    cel(0)
                    setCycle(End self)
                )
  )
            )
            (case 3
                ((ogreTheme:dispose()) (ogreTheme:
                    number(6)
                    loop(1)
                    play(self)
                )
 Print(10 2) (send gNewAct:
                    view(79)
                    setCycle(Walk)
                    setMotion(MoveTo 200 80)
                )
  )
            )
            (case 4
                (= global127 1 )
            )
        )
    )

)
(instance bird1Actions of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((send newProp_2:setCycle(Fwd)) = seconds Random(1 12)  )
            )
            (case 1
                ((send newProp_2:
                    setCycle(0)
                    cel(0)
                )
 = seconds Random(1 8)  )
            )
            (case 2
                ((self:changeState(0)) )
            )
        )
    )

)
(instance bird2Actions of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                ((send newProp_3:setCycle(Fwd)) = seconds Random(1 12)  )
            )
            (case 1
                ((send newProp_3:
                    cel(0)
                    setCycle(0)
                )
 = seconds Random(1 8)  )
            )
            (case 2
                ((self:changeState(0)) )
            )
        )
    )

)
