Exemple #1
0
        /// <summary>
        /// This method needs to be implemented in each task.
        /// It is the core of the task. The global event hook of the GamePlayer.
        /// This method will be called whenever a GamePlayer with this task
        /// fires ANY event!
        /// </summary>
        /// <param name="e">The event type</param>
        /// <param name="sender">The sender of the event</param>
        /// <param name="args">The event arguments</param>
        public override void Notify(DOLEvent e, object sender, EventArgs args)
        {
            // Filter only the events from task owner
            if (sender != m_taskPlayer)
                return;

            if (CheckTaskExpired())
            {
                return;
            }

            GamePlayer player = m_taskPlayer;

            // Check if the mob killed = players task mob
            if (e == GameLivingEvent.EnemyKilled)
            {
                EnemyKilledEventArgs gArgs = (EnemyKilledEventArgs)args;
                GameLiving target = gArgs.Target;
                if (ServerProperties.Properties.TASK_GIVE_RANDOM_ITEM == false)
                {
                    if (((KillTask)player.Task).MobName == target.Name)
                    {
                        ((KillTask)player.Task).MobKilled = true;
                        player.Out.SendMessage("You must now return to " + target.Name + " to recieve your reward!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    }
                }
                else
                {
                    // check wether the right mob was killed
                    if (target.Name != MobName)
                        return;

                    int lowestCon = int.MaxValue;
                    lock (target.XPGainers.SyncRoot)
                    {
                        if (target.XPGainers.Keys.Count == 0)
                        {
                            return;
                        }
                        foreach (GameObject gainer in target.XPGainers.Keys)
                        {
                            if (gainer is GamePlayer)
                            {
                                if (gainer.Level <= GameLiving.NoXPForLevel.Length)
                                {
                                    if (target.Level <= GameLiving.NoXPForLevel[gainer.Level])
                                    {
                                        lowestCon = -3;
                                    }
                                }
                                else
                                {
                                    int con = (int)gainer.GetConLevel(target);
                                    if (con < lowestCon)
                                    {
                                        lowestCon = con;
                                    }
                                }
                            }
                        }
                    }

                    // The following lines allow the GM to drop the task item
                    if (player.Client.Account.PrivLevel != 1)
                        lowestCon = 0;

                    //Only add task Loot if not killing grays
                    if (lowestCon >= -2)
                    {
                        ArrayList Owners = new ArrayList();
                        if (player.Group == null)
                        {
                            Owners.Add(m_taskPlayer);
                        }
                        else
                        {
                            ICollection<GamePlayer> group = m_taskPlayer.Group.GetPlayersInTheGroup();
                            foreach (GamePlayer p in group)
                            {
                                if (p.Task != null && p.Task.GetType() == typeof(KillTask))
                                {
                                    if (((KillTask)p.Task).MobName == target.Name)
                                        Owners.Add(p);
                                }
                            }
                        }

                        if (Owners.Count > 0)
                        {
                            ArrayList dropMessages = new ArrayList();
                            InventoryItem itemdrop = GenerateItem(ItemName, 1, ObjectModels[ItemIndex]);
                            WorldInventoryItem droppeditem = new WorldInventoryItem(itemdrop);
                            for (int a = 0; a < Owners.Count; a++)
                            {
                                droppeditem.AddOwner((GameObject)Owners[a]);
                            }
                            droppeditem.Name = itemdrop.Name;
                            droppeditem.Level = 1;
                            droppeditem.X = target.X;
                            droppeditem.Y = target.Y;
                            droppeditem.Z = target.Z;
                            droppeditem.CurrentRegion = target.CurrentRegion;
                            droppeditem.AddToWorld();
                            if (dropMessages.Count > 0)
                            {
                                foreach (GamePlayer visiblePlayer in target.GetPlayersInRadius(WorldMgr.INFO_DISTANCE))
                                {
                                    foreach (string str in dropMessages)
                                    {
                                        visiblePlayer.Out.SendMessage(str, eChatType.CT_Loot, eChatLoc.CL_SystemWindow);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else if (e == GameLivingEvent.InteractWith)
            {
                if (((KillTask)player.Task).MobKilled == true)
                {
                    InteractWithEventArgs myargs = (InteractWithEventArgs)args;
                    if (myargs.Target.Name == ((KillTask)player.Task).RecieverName)
                    {
                        player.Out.SendMessage(myargs.Target.Name + " says, *Good work " + player.Name + ". Here is your reward as promised.*", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        FinishTask();
                    }
                }
            }
            else if (e == GamePlayerEvent.GiveItem && ServerProperties.Properties.TASK_GIVE_RANDOM_ITEM == true)
            {
                GiveItemEventArgs gArgs = (GiveItemEventArgs)args;
                GameLiving target = gArgs.Target as GameLiving;
                InventoryItem item = gArgs.Item;

                if (player.Task.RecieverName == target.Name && item.Name == player.Task.ItemName)
                {
                    player.Inventory.RemoveItem(item);
                    InventoryLogging.LogInventoryAction(player, target, eInventoryActionType.Quest, item.Template, item.Count);
                    player.Out.SendMessage(target.Name + " says, *Good work " + player.Name + ". Here is your reward as promised.*", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    FinishTask();
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Do the combine.
        /// </summary>
        /// <param name="target"></param>
        /// <param name="effectiveness"></param>
        public override void ApplyEffectOnTarget(GameLiving target, double effectiveness)
        {
            GamePlayer player = Caster as GamePlayer;

            if (player == null)
            {
                return;
            }

            InventoryItem useItem = player.UseItem;

            if (useItem == null || !ArtifactMgr.IsArtifactScroll(useItem))
            {
                return;
            }

            WorldInventoryItem combinedScroll = WorldInventoryItem.CreateFromTemplate("artifact_scroll");

            if (combinedScroll == null)
            {
                return;
            }

            combinedScroll.AddOwner(player);
            combinedScroll.Name      = useItem.Name;
            combinedScroll.Item.Name = useItem.Name;

            var backpack = player.Inventory.GetItemRange(eInventorySlot.FirstBackpack, eInventorySlot.LastBackpack);

            ArrayList removeItems = new ArrayList();

            removeItems.Add(useItem);
            bool combinesToBook = false;

            foreach (InventoryItem item in backpack)
            {
                if (item == null)
                {
                    continue;
                }

                if (ArtifactMgr.CanCombine(combinedScroll.Item, item))
                {
                    combinedScroll = ArtifactMgr.CombineScrolls(combinedScroll.Item, item, ref combinesToBook);
                    removeItems.Add(item);
                    if (combinesToBook)
                    {
                        break;
                    }
                }
            }

            player.Out.SendSpellEffectAnimation(player, player, 1, 0, false, 1);

            Artifact artifact = ArtifactMgr.GetArtifact(combinedScroll.Item);

            if (artifact == null)
            {
                log.Warn(String.Format("Missing artifact for item '{0}'", combinedScroll.Name));
            }
            else
            {
                String receiveMessage = (combinesToBook)
                                        ? artifact.MessageReceiveBook
                                        : artifact.MessageReceiveScrolls;
                player.Out.SendMessage(String.Format(receiveMessage, combinedScroll.Name, useItem.Name),
                                       eChatType.CT_Skill, eChatLoc.CL_SystemWindow);
            }

            if (player.ReceiveItem(player, combinedScroll))
            {
                foreach (InventoryItem item in removeItems)
                {
                    player.Inventory.RemoveItem(item);
                    InventoryLogging.LogInventoryAction(player, "(ARTIFACT;CombineScrolls)", eInventoryActionType.Quest, item.Template, item.Count);
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// This method needs to be implemented in each task.
        /// It is the core of the task. The global event hook of the GamePlayer.
        /// This method will be called whenever a GamePlayer with this task
        /// fires ANY event!
        /// </summary>
        /// <param name="e">The event type</param>
        /// <param name="sender">The sender of the event</param>
        /// <param name="args">The event arguments</param>
        public override void Notify(DOLEvent e, object sender, EventArgs args)
        {
            // Filter only the events from task owner
            if (sender != m_taskPlayer)
            {
                return;
            }

            if (CheckTaskExpired())
            {
                return;
            }

            GamePlayer player = m_taskPlayer;

            // Check if the mob killed = players task mob
            if (e == GameLivingEvent.EnemyKilled)
            {
                EnemyKilledEventArgs gArgs  = (EnemyKilledEventArgs)args;
                GameLiving           target = gArgs.Target;
                if (ServerProperties.Properties.TASK_GIVE_RANDOM_ITEM == false)
                {
                    if (((KillTask)player.Task).MobName == target.Name)
                    {
                        ((KillTask)player.Task).MobKilled = true;
                        player.Out.SendMessage("You must now return to " + target.Name + " to recieve your reward!", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    }
                }
                else
                {
                    // check wether the right mob was killed
                    if (target.Name != MobName)
                    {
                        return;
                    }

                    int lowestCon = int.MaxValue;
                    lock (target.XPGainers.SyncRoot)
                    {
                        if (target.XPGainers.Keys.Count == 0)
                        {
                            return;
                        }
                        foreach (GameObject gainer in target.XPGainers.Keys)
                        {
                            if (gainer is GamePlayer)
                            {
                                if (gainer.Level <= GameLiving.NoXPForLevel.Length)
                                {
                                    if (target.Level <= GameLiving.NoXPForLevel[gainer.Level])
                                    {
                                        lowestCon = -3;
                                    }
                                }
                                else
                                {
                                    int con = (int)gainer.GetConLevel(target);
                                    if (con < lowestCon)
                                    {
                                        lowestCon = con;
                                    }
                                }
                            }
                        }
                    }

                    // The following lines allow the GM to drop the task item
                    if (player.Client.Account.PrivLevel != 1)
                    {
                        lowestCon = 0;
                    }

                    //Only add task Loot if not killing grays
                    if (lowestCon >= -2)
                    {
                        ArrayList Owners = new ArrayList();
                        if (player.Group == null)
                        {
                            Owners.Add(m_taskPlayer);
                        }
                        else
                        {
                            ICollection <GamePlayer> group = m_taskPlayer.Group.GetPlayersInTheGroup();
                            foreach (GamePlayer p in group)
                            {
                                if (p.Task != null && p.Task.GetType() == typeof(KillTask))
                                {
                                    if (((KillTask)p.Task).MobName == target.Name)
                                    {
                                        Owners.Add(p);
                                    }
                                }
                            }
                        }

                        if (Owners.Count > 0)
                        {
                            ArrayList          dropMessages = new ArrayList();
                            InventoryItem      itemdrop     = GenerateItem(ItemName, 1, ObjectModels[ItemIndex]);
                            WorldInventoryItem droppeditem  = new WorldInventoryItem(itemdrop);
                            for (int a = 0; a < Owners.Count; a++)
                            {
                                droppeditem.AddOwner((GameObject)Owners[a]);
                            }
                            droppeditem.Name          = itemdrop.Name;
                            droppeditem.Level         = 1;
                            droppeditem.Position      = target.Position;
                            droppeditem.CurrentRegion = target.CurrentRegion;
                            droppeditem.AddToWorld();
                            if (dropMessages.Count > 0)
                            {
                                foreach (GamePlayer visiblePlayer in target.GetPlayersInRadius(WorldMgr.INFO_DISTANCE))
                                {
                                    foreach (string str in dropMessages)
                                    {
                                        visiblePlayer.Out.SendMessage(str, eChatType.CT_Loot, eChatLoc.CL_SystemWindow);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else if (e == GameLivingEvent.InteractWith)
            {
                if (((KillTask)player.Task).MobKilled == true)
                {
                    InteractWithEventArgs myargs = (InteractWithEventArgs)args;
                    if (myargs.Target.Name == ((KillTask)player.Task).RecieverName)
                    {
                        player.Out.SendMessage(myargs.Target.Name + " says, *Good work " + player.Name + ". Here is your reward as promised.*", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                        FinishTask();
                    }
                }
            }
            else if (e == GamePlayerEvent.GiveItem && ServerProperties.Properties.TASK_GIVE_RANDOM_ITEM == true)
            {
                GiveItemEventArgs gArgs  = (GiveItemEventArgs)args;
                GameLiving        target = gArgs.Target as GameLiving;
                InventoryItem     item   = gArgs.Item;

                if (player.Task.RecieverName == target.Name && item.Name == player.Task.ItemName)
                {
                    player.Inventory.RemoveItem(item);
                    InventoryLogging.LogInventoryAction(player, target, eInventoryActionType.Quest, item.Template, item.Count);
                    player.Out.SendMessage(target.Name + " says, *Good work " + player.Name + ". Here is your reward as promised.*", eChatType.CT_System, eChatLoc.CL_SystemWindow);
                    FinishTask();
                }
            }
        }