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


(local
    local0
    local1
    local2
    newProp_2
    newProp
    local5

)
(instance panCage of Cage
    (properties)
)
(instance panTheme of Sound
    (properties)
)
(instance public regPan of Rgn
    (properties)

    (method (init)
        (super:init())
        Load(rsVIEW 158)
        Load(rsVIEW 157)
        Load(rsVIEW 54)
        Load(rsVIEW 150)
        Load(rsVIEW 681)
        (if ((send ((Inv:at(0))):ownedBy(201)))
            = local0 157
            = local5 (+ (* (- global160 global211) 60) (- global159 global212))
            (if ((<= Random(1 100) 40) and (>= local5 2))
                (panCage:
                    left(0)
                    right(319)
                    bottom(189)
                    top((send global2:horizon()))
                    init()
                )
                = gNewAct (Act:new())
                (send gNewAct:
                    posn(Random(10 300) Random(+ (send global2:horizon()) 20 169))
                    xStep(2)
                    yStep(1)
                    setCycle(Fwd)
                    observeBlocks(panCage)
                    setScript(panActions)
                    setMotion(Wander 1500)
                    view(local0)
                    init()
                    yourself()
                )
                = newProp (Prop:new())
                (send newProp:
                    view(888)
                    cycleSpeed(1)
                    ignoreActors()
                    setCycle(Fwd)
                    init()
                )
                (panTheme:
                    number(7)
                    loop(30000)
                    play()
                )
            )(else
                = gNewAct 0
            )
        )(else
            = gNewAct 0
        )
    )


    (method (doit)
        (super:doit())
        (if ((send gCast:contains(gNewAct)))
            (if ((== (send gNewAct:view()) 158) or (== (send gNewAct:view()) 157))
                (send newProp:
                    setPri((send gNewAct:priority()))
                    x(+ (send gNewAct:x()) 8)
                    y(- (send gNewAct:y()) 22)
                )
            )
            (if (not (send gNewAct:inRect(0 0 319 219)))
                (send gNewAct:dispose())
                (if (IsObject(newProp))
                    (send newProp:dispose())
                )
                (if ((send gSounds:contains(panTheme)))
                    proc0_21(panTheme 1)
                )
            )
        )
    )


    (method (dispose)
        (send (ScriptID(0 4)):
            dispose()
            delete()
        )
        (send gSounds:eachElementDo(172))
        (super:dispose())
    )


    (method (handleEvent pEvent)
        (var gInvSaidMe)
        (if ((send pEvent:claimed()))
            return 1
        )
        return 
            (if ((== (send pEvent:type()) 128) and (send gCast:contains(gNewAct)))
                (if (Said('play/lute'))
                    (if ((send gEgo:has(9)))
                        (if (== (send gNewAct:view()) 157)
                            (send gEgo:setScript(playLute))
                            (playLute:changeState(1))
                        )(else
                            Print(514 0)
                        )
                    )(else
                        Print(800 2)
                    )
                )(else
                    (if (Said('play/flute'))
                        (if ((send gEgo:has(0)))
                            (if ((send ((Inv:at(9))):ownedBy(201)))
                                Print(514 1)
                            )(else
                                (send pEvent:claimed(0))
                            )
                        )(else
                            Print(800 2)
                        )
                    )(else
                        (if (Said('hum'))
                            Print(514 2)
                        )(else
                            (if (Said('kill/pan'))
                                Print(514 3)
                            )(else
                                (if (Said('play<with/pan'))
                                    Print(514 4)
                                )(else
                                    (if (Said('dance'))
                                        Print(514 5)
                                    )(else
                                        (if (Said('get/pan'))
                                            Print(514 6)
                                        )(else
                                            (if (Said('capture/pan'))
                                                Print(514 7)
                                            )(else
                                                (if (Said('deliver/lute'))
                                                    (if ((send gEgo:has(9)))
                                                        (if (local2)
                                                            (if (< (send gEgo:distanceTo(gNewAct)) 22)
                                                                (send ((Inv:at(9))):moveTo(201))
                                                                Print(514 8)
                                                                (send ((Inv:at(0))):moveTo(gEgo))
                                                                (send gGame:changeScore(3))
                                                                (send gEgo:setMotion(0))
                                                                (send gNewAct:
                                                                    view(158)
                                                                    setMotion(Wander 3000)
                                                                )
                                                                = local0 158
                                                                (panTheme:
                                                                    number(8)
                                                                    loop(30000)
                                                                    play()
                                                                )
                                                                (send newProp:show())
                                                            )(else
                                                                Print(800 1)
                                                            )
                                                        )(else
                                                            Print(514 9)
                                                        )
                                                    )(else
                                                        Print(800 2)
                                                    )
                                                )(else
                                                    (if (Said('deliver>'))
                                                        (if (= gInvSaidMe (send gInv:saidMe()))
                                                            (if ((send gEgo:has((send gInv:indexOf((= gInvSaidMe (send gInv:saidMe())))))))
                                                                Print(514 10)
                                                            )(else
                                                                proc0_19()
                                                            )
                                                        )(else
                                                            Print(514 11)
                                                            (send pEvent:claimed(1))
                                                        )
                                                    )(else
                                                        (if (Said('kiss'))
                                                            Print(514 12)
                                                        )(else
                                                            (if (== (send gNewAct:view()) 157)
                                                                (if (Said('look/pan'))
                                                                    Print(514 13)
                                                                )(else
                                                                    (if (Said('converse[/pan]'))
                                                                        Print(514 14)
                                                                    )(else
                                                                        (if (Said('get/flute'))
                                                                            Print(514 15)
                                                                        )(else
                                                                            (if (Said('rob/flute'))
                                                                                Print(514 16)
                                                                            )
                                                                        )
                                                                    )
                                                                )
                                                            )(else
                                                                (if (== (send gNewAct:view()) 158)
                                                                    (if (Said('get,rob/lute'))
                                                                        Print(514 17)
                                                                    )(else
                                                                        (if (Said('look/pan'))
                                                                            Print(514 18)
                                                                        )(else
                                                                            (if (Said('converse[/pan]'))
                                                                                Print(514 19)
                                                                            )
                                                                        )
                                                                    )
                                                                )(else
                                                                    (if (== (send gNewAct:view()) 150)
                                                                        (if (Said('converse[/pan]'))
                                                                            Print(514 20)
                                                                        )(else
                                                                            (if (Said('look/pan'))
                                                                                Print(514 21)
                                                                            )(else
                                                                                (if (Said('get/flute'))
                                                                                    Print(514 15)
                                                                                )
                                                                            )
                                                                        )
                                                                    )
                                                                )
                                                            )
                                                        )
                                                    )
                                                )
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )(else
                0
            )
    )

)
(instance playLute of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 1
                (proc0_10() (panTheme:dispose()) (send ((Sound:new())):
                    number(54)
                    play(self)
                )
 (send gEgo:
                    view(54)
                    setLoop(0)
                    setCycle(Fwd)
                )
 = newProp_2 (Prop:new()) (send newProp_2:
                    view(888)
                    setPri((send gEgo:priority()))
                    cycleSpeed(1)
                    setCycle(Fwd)
                    posn(+ (send gEgo:x()) 15 - (send gEgo:y()) 25)
                    init()
                )
 (send gNewAct:
                    view(150)
                    setAvoider(Avoid)
                    setCycle(Walk)
                    setMotion(Follow gEgo 55)
                )
 (send newProp:hide())  )
            )
            (case 2
                (Print(514 21 134 -1 20 166) (send gEgo:
                    view(2)
                    setLoop(-1)
                    setCycle(Walk)
                )
 
                (if (IsObject(newProp_2))
                    (send newProp_2:dispose())
                )
 proc0_3(gEgo gNewAct) = local2 1 proc0_11() )
            )
        )
    )

)
(instance panActions of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 0
                (= seconds 25  )
            )
            (case 1
                ((send gNewAct:ignoreBlocks(panCage)) )
            )
        )
    )

)
