Ejemplo n.º 1
0
        /* This is the method we declared as callback for the hooks we set to
         * NPC. It will be called whenever a player right clicks on NPC
         * or when he whispers something to him.
         */

        protected static void TalkToDalikor(DOLEvent e, object sender, EventArgs args)
        {
            //We get the player from the event arguments and check if he qualifies
            GamePlayer player = ((SourceEventArgs)args).Source as GamePlayer;

            if (player == null)
            {
                return;
            }

            if (dalikor.CanGiveQuest(typeof(Nuisances), player) <= 0)
            {
                return;
            }

            //We also check if the player is already doing the quest
            Nuisances quest = player.IsDoingQuest(typeof(Nuisances)) as Nuisances;

            dalikor.TurnTo(player);
            //Did the player rightclick on NPC?
            if (e == GameObjectEvent.Interact)
            {
                if (quest == null)
                {
                    //Player is not doing the quest...
                    dalikor.SayTo(player, "Recruit Eeinken. I'm afraid we have a [serious problem] on our hands.");
                    return;
                }
                else
                {
                    if (quest.Step == 2)
                    {
                        dalikor.SayTo(player, "Welcome back recruit. Did you find out what was making all that racket?");
                    }
                    else if (quest.Step == 3)
                    {
                        dalikor.SayTo(player, "Hrm...Fallen Askefruer. This is what has been causing us our problems? Interesting. I want to thank you recruit for your hard work in helping us solve this problem. A [reward] is in store for you I think.");
                    }
                    return;
                }
            }
            // The player whispered to NPC (clicked on the text inside the [])
            else if (e == GameLivingEvent.WhisperReceive)
            {
                WhisperReceiveEventArgs wArgs = (WhisperReceiveEventArgs)args;
                if (quest == null)
                {
                    //Do some small talk :)
                    switch (wArgs.Text)
                    {
                    case "serious problem":
                        dalikor.SayTo(player, "There has been this noise that has been keeping the residents of Mularn up at night. I haven't been able to locate the source of the noise, neither have any of the guards. I was hoping you could try to [find] the noise.");
                        break;

                    //If the player offered his "help", we send the quest dialog now!
                    case "find":
                        player.Out.SendQuestSubscribeCommand(dalikor, QuestMgr.GetIDForQuestType(typeof(Nuisances)), "Will you help out Mularn and discover who or what is making this noise?");
                        break;
                    }
                }
                else
                {
                    switch (wArgs.Text)
                    {
                    case "reward":
                        dalikor.SayTo(player, "Yes, I think this will do quite nicely. Here you are Eeinken. Use it well, and I'm sure it will last you your first few seasons anyhow. Be sure to come and speak with me when you are ready for more adventure.");
                        if (quest.Step == 3)
                        {
                            quest.FinishQuest();
                            dalikor.SayTo(player, "Don't go far, I have need of your services again Eeinken.");
                        }
                        break;

                    case "abort":
                        player.Out.SendCustomDialog("Do you really want to abort this quest, \nall items gained during quest will be lost?", new CustomDialogResponse(CheckPlayerAbortQuest));
                        break;
                    }
                }
            }
        }