Пример #1
0
        protected static void PlayerEnterWorld(DOLEvent e, object sender, EventArgs args)
        {
            GamePlayer player = sender as GamePlayer;

            if (player == null)
            {
                return;
            }

            Nuisances quest = player.IsDoingQuest(typeof(Nuisances)) as Nuisances;

            if (quest != null)
            {
                GameEventMgr.AddHandler(player, GamePlayerEvent.Quit, new DOLEventHandler(PlayerLeftWorld));
                GameEventMgr.AddHandler(player, GamePlayerEvent.UseSlot, new DOLEventHandler(PlayerUseSlot));
            }
        }
Пример #2
0
        protected static void PlayerEnterFairyArea(DOLEvent e, object sender, EventArgs args)
        {
            AreaEventArgs aargs  = args as AreaEventArgs;
            GamePlayer    player = aargs.GameObject as GamePlayer;
            Nuisances     quest  = player.IsDoingQuest(typeof(Nuisances)) as Nuisances;

            if (quest != null && quest.ireFairy == null && quest.Step == 1)
            {
                // player near grove
                SendSystemMessage(player, "Ire Fairies! Quick! USE your Magical Wooden Box to capture the fairies! To USE an item, right click on the item and type /use.");
                quest.CreateFairy();

                foreach (GamePlayer visPlayer in quest.ireFairy.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE))
                {
                    visPlayer.Out.SendSpellCastAnimation(quest.ireFairy, 1, 20);
                }
            }
        }
Пример #3
0
        /* This is our callback hook that will be called when the player clicks
         * on any button in the quest offer dialog. We check if he accepts or
         * declines here...
         */

        private static void CheckPlayerAbortQuest(GamePlayer player, byte response)
        {
            Nuisances quest = player.IsDoingQuest(typeof(Nuisances)) as Nuisances;

            if (quest == null)
            {
                return;
            }

            if (response == 0x00)
            {
                SendSystemMessage(player, "Good, no go out there and finish your work!");
            }
            else
            {
                SendSystemMessage(player, "Aborting Quest " + questTitle + ". You can start over again if you want.");
                quest.AbortQuest();
            }
        }
Пример #4
0
        protected static void PlayerLeftWorld(DOLEvent e, object sender, EventArgs args)
        {
            GamePlayer player = sender as GamePlayer;

            if (player == null)
            {
                return;
            }

            Nuisances quest = player.IsDoingQuest(typeof(Nuisances)) as Nuisances;

            if (quest != null)
            {
                GameEventMgr.RemoveHandler(player, GamePlayerEvent.UseSlot, new DOLEventHandler(PlayerUseSlot));
                GameEventMgr.RemoveHandler(player, GamePlayerEvent.Quit, new DOLEventHandler(PlayerLeftWorld));

                if (quest.ireFairy != null && quest.ireFairy.ObjectState == GameObject.eObjectState.Active)
                {
                    quest.ireFairy.Delete();
                }
            }
        }
Пример #5
0
        protected static void PlayerUseSlot(DOLEvent e, object sender, EventArgs args)
        {
            GamePlayer player = (GamePlayer)sender;

            Nuisances quest = (Nuisances)player.IsDoingQuest(typeof(Nuisances));

            if (quest == null)
            {
                return;
            }

            if (quest.Step == 1 && quest.ireFairy != null)
            {
                UseSlotEventArgs uArgs = (UseSlotEventArgs)args;

                InventoryItem item = player.Inventory.GetItem((eInventorySlot)uArgs.Slot);
                if (item != null && item.Id_nb == emptyMagicBox.Id_nb)
                {
                    if (player.IsWithinRadius(quest.ireFairy, 500))
                    {
                        foreach (GamePlayer visPlayer in quest.ireFairy.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE))
                        {
                            visPlayer.Out.SendSpellCastAnimation(quest.ireFairy, 1, 20);
                        }

                        SendSystemMessage(player, "You catch ire fairy in your magical wodden box!");
                        new RegionTimer(player, new RegionTimerCallback(quest.DeleteFairy), 2000);

                        ReplaceItem(player, emptyMagicBox, fullMagicBox);
                        quest.Step = 2;
                    }
                    else
                    {
                        SendSystemMessage(player, "There is nothing within the reach of the magic box that can be cought.");
                    }
                }
            }
        }
Пример #6
0
        /* This is our callback hook that will be called when the player clicks
         * on any button in the quest offer dialog. We check if he accepts or
         * declines here...
         */

        private static void CheckPlayerAcceptQuest(GamePlayer player, byte response)
        {
            // We recheck the qualification, because we don't talk to players
            // who are not doing the quest
            if (masterFrederick.CanGiveQuest(typeof(Nuisances), player) <= 0)
            {
                return;
            }

            Nuisances quest = player.IsDoingQuest(typeof(Nuisances)) as Nuisances;

            if (quest != null)
            {
                return;
            }

            if (response == 0x00)
            {
                SendReply(player, "Oh well, if you change your mind, please come back!");
            }
            else
            {
                // Check if we can add the quest!
                if (!masterFrederick.GiveQuest(typeof(Nuisances), player, 1))
                {
                    return;
                }

                masterFrederick.SayTo(player, "This magical box will help you capture whatever is making that noise. The reports indicate that the noise is the loudest to the west-northwest, near the banks of the river. Find the source of the noise Vinde. Take this box with you. Some of the other trainers seem to think it is magical in nature. I'm not so sure. USE the box in the area that is the loudest, or where you encounter trouble. See if you can capture anything.");

                // give necklace
                GiveItem(masterFrederick, player, emptyMagicBox);

                GameEventMgr.AddHandler(player, GamePlayerEvent.Quit, new DOLEventHandler(PlayerLeftWorld));
                GameEventMgr.AddHandler(player, GamePlayerEvent.UseSlot, new DOLEventHandler(PlayerUseSlot));
            }
        }
Пример #7
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 TalkToMasterFrederick(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 (masterFrederick.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;

            masterFrederick.TurnTo(player);

            // Did the player rightclick on NPC?
            if (e == GameObjectEvent.Interact)
            {
                if (quest == null)
                {
                    // Player is not doing the quest...
                    masterFrederick.SayTo(player, "My young recruit, I fear we have a growing problem on our hands. For the past several nights, citizens in Cotswold have been complaining of a constant ringing noise. It has started to keep them up at [night].");
                    return;
                }
                else
                {
                    if (quest.Step == 2)
                    {
                        masterFrederick.SayTo(player, "Vinde, you've returned, and none the worse for wear. Tell me, what did you find?");
                    }
                    else if (quest.Step == 3)
                    {
                        masterFrederick.SayTo(player, "Ire fairies! They're the worst! Well, now we know who has been causing these problems. Vinde, you've done good work here today. It is time for a reward for your [efforts].");
                    }

                    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 "night":
                        masterFrederick.SayTo(player, "It has even begun to affect the wildlife in this area. The guards can not commit any troops to finding out the cause of this ringing sound, so the responsibility falls to you Vinde. Will you help [Cotswold]?");
                        break;

                    // If the player offered his "help", we send the quest dialog now!
                    case "Cotswold":
                        player.Out.SendQuestSubscribeCommand(masterFrederick, QuestMgr.GetIDForQuestType(typeof(Nuisances)), "Will you help out Cotswold and discover who or what is making this noise?");
                        break;
                    }
                }
                else
                {
                    switch (wArgs.Text)
                    {
                    case "efforts":
                        masterFrederick.SayTo(player, "A Fighter is nothing unless he has a good weapon by his or her side. For you, a new sword is in order. Use it well Vinde. For now, I must think about what to do with these Ire Fairies, and figure out why they are here.");
                        if (quest.Step == 3)
                        {
                            quest.FinishQuest();
                            masterFrederick.SayTo(player, "Don't go far, I have need of your services again Vinde.");
                        }

                        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;
                    }
                }
            }
        }