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


(local
    local0
    local1

)
(instance thisSong of Sound
    (properties)
)
(instance public notes of Prop
    (properties)

    (method (cue)
        (notes:dispose())
    )

)
(instance public regMinstrel of Rgn
    (properties)

    (method (init)
        Load(rsVIEW 171)
        Load(rsVIEW 681)
        (super:init())
        (if ((((== gGNewPropX 13) and (== global118 1)) or ((== gGNewPropX 14) and (== global118 2))) or ((== gGNewPropX 19) and (== global118 3)))
            (send gNewAct:setScript(minstrelActions))
            (notes:
                view(888)
                ignoreActors()
                cycleSpeed(1)
                setCycle(Fwd)
                posn(+ (send gNewAct:x()) 16 - (send gNewAct:y()) 20)
                init()
            )
            (thisSong:
                number(19)
                play(minstrelActions)
            )
            (minstrelActions:changeState(1))
        )
        = global189 1
    )


    (method (dispose)
        (send gSounds:eachElementDo(172))
        (send (ScriptID(0 4)):
            dispose()
            delete()
        )
        (send (ScriptID(0 5)):
            dispose()
            delete()
        )
        (send (ScriptID(0 6)):
            dispose()
            delete()
        )
        = global189 0
        (thisSong:dispose())
        (super:dispose())
    )


    (method (handleEvent pEvent)
        (var gInvSaidMe)
        (super:handleEvent(pEvent))
        (if ((send pEvent:claimed()))
            return 1
        )
        return 
            (if ((== (send pEvent:type()) 128) and (send gCast:contains(gNewAct)))
                (if (Said('get/man'))
                    Print(516 0)
                )(else
                    (if (Said('kiss'))
                        Print(516 1)
                    )(else
                        (if (Said('deliver>'))
                            (if ((send ((Inv:at(18))):ownedBy(gEgo)) and Said('/book'))
                                (if (>= (send gEgo:distanceTo(gNewAct)) 20)
                                    Print(516 2)
                                )(else
                                    (send gSounds:eachElementDo(172))
                                    Print(516 3)
                                    Print(516 4)
                                    (send ((Inv:at(18))):moveTo(203))
                                    = global182 1
                                    (send ((Inv:at(9))):moveTo(gEgo))
                                    (send gGame:changeScore(3))
                                    (minstrelActions:changeState(10))
                                )
                            )(else
                                (if ((= gInvSaidMe (send gInv:saidMe())) and (send gEgo:has((send gInv:indexOf((= gInvSaidMe (send gInv:saidMe())))))))
                                    Print(516 5)
                                )(else
                                    (send pEvent:claimed(0))
                                )
                            )
                        )(else
                            (if (Said('rob/lute'))
                                Print(516 6)
                            )(else
                                (if (Said('look/man'))
                                    (if ((send ((Inv:at(18))):ownedBy(203)))
                                        (if ((send gCast:contains(gNewAct)))
                                            Print(516 7)
                                        )(else
                                            Print(516 8)
                                        )
                                    )(else
                                        Print(516 9)
                                    )
                                )(else
                                    (if (Said('converse[/man]'))
                                        (if ((send ((Inv:at(9))):ownedBy(203)))
                                            ++global184
                                            (send gSounds:eachElementDo(172))
                                            (if (> global184 4)
                                                = local1 Random(2 4)
                                            )(else
                                                = local1 global184
                                            )
                                            (switch (local1)
                                                (case 1
                                                    Print(516 10)
                                                    Print(516 11)
                                                    (thisSong:
                                                        number(17)
                                                        play(minstrelActions)
                                                    )
                                                )
                                                (case 2
                                                    Print(516 12)
                                                    (thisSong:
                                                        number(16)
                                                        play(minstrelActions)
                                                    )
                                                )
                                                (case 3
                                                    Print(516 13)
                                                    (thisSong:
                                                        number(15)
                                                        play(minstrelActions)
                                                    )
                                                )
                                                (case 4
                                                    Print(516 14)
                                                    (thisSong:
                                                        number(18)
                                                        play(minstrelActions)
                                                    )
                                                )
                                            )
                                            (minstrelActions:changeState(1))
                                        )(else
                                            (if ((send gCast:contains(gNewAct)))
                                                Print(516 15)
                                            )(else
                                                (send pEvent:claimed(0))
                                            )
                                        )
                                    )(else
                                        (if (Said('get/lute'))
                                            (if ((send ((Inv:at(9))):ownedBy(203)))
                                                Print(516 16)
                                            )(else
                                                Print(516 17)
                                            )
                                        )(else
                                            (if (Said('hum/'))
                                                Print(516 18)
                                            )
                                        )
                                    )
                                )
                            )
                        )
                    )
                )
            )(else
                0
            )
    )

)
(instance minstrelActions of Script
    (properties)

    (method (changeState newState)
        (switch (= state newState)
            (case 1
                ((notes:
                    show()
                    setPri((send gNewAct:priority()))
                )
 (send gNewAct:
                    cycleSpeed(1)
                    setCycle(Fwd)
                )
  )
            )
            (case 2
                ((send gNewAct:
                    setCycle(0)
                    cel(0)
                )
 (notes:hide())  )
            )
            (case 10
                ((notes:hide()) (send gNewAct:
                    view(173)
                    cel(0)
                    loop(0)
                    cycleSpeed(2)
                    setCycle(Fwd)
                )
 = global118 -1 (send (ScriptID(0 6)):setReal(self 4))  )
            )
            (case 11
                ((send gNewAct:
                    view(171)
                    cel(0)
                    loop(2)
                    xStep(2)
                    cycleSpeed(0)
                    yStep(1)
                    setAvoider(Avoid)
                    setCycle(Walk)
                )
 
                (switch (gGNewPropX)
                    (case 13
                        ((send gNewAct:setMotion(MoveTo 329 125 self))  )
                    )
                    (case 14
                        ((send gNewAct:setMotion(MoveTo 329 136 self))  )
                    )
                    (case 19
                        ((send gNewAct:setMotion(MoveTo 329 125 self)) )
                    )
                )
  )
            )
            (case 12
                ((send gNewAct:setScript(0)) (send gNewAct:dispose()) )
            )
        )
    )

)
