Exemplo n.º 1
0
        public static void XPGain(DOLEvent e, object sender, EventArgs args)
        {
            GamePlayer player = sender as GamePlayer;

            if (player == null || player.Guild == null)
            {
                return;
            }

            GainedExperienceEventArgs xpArgs = args as GainedExperienceEventArgs;

            if (player.Guild != null && player.Guild.BonusType == Guild.eBonusType.Experience && xpArgs.XPSource == GameLiving.eXPSource.NPC)
            {
                long bonusXP = (long)Math.Ceiling((double)xpArgs.ExpBase * ServerProperties.Properties.GUILD_BUFF_XP / 100);
                player.GainExperience(GameLiving.eXPSource.Other, bonusXP, 0, 0, 0, false);
                player.Out.SendMessage("You gain an additional " + bonusXP + " experience due to your guild's buff!", eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                player.Guild.UpdateGuildWindow();
            }
        }
        /// <summary>
        /// Called from GameEventMgr when player has gained experience.
        /// </summary>
        /// <param name="e"></param>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        public static void PlayerGainedExperience(DOLEvent e, object sender, EventArgs args)
        {
            GamePlayer player = sender as GamePlayer;
            GainedExperienceEventArgs xpArgs = args as GainedExperienceEventArgs;

            if (player == null || xpArgs == null)
            {
                return;
            }

            // Artifacts only gain XP on NPC and player kills
            if (xpArgs.XPSource != GameLiving.eXPSource.Player && xpArgs.XPSource != GameLiving.eXPSource.NPC)
            {
                return;
            }

            if (player.IsPraying)
            {
                return;
            }

            // Suffice to calculate total XP once for all artifacts.

            long xpAmount = xpArgs.ExpBase +
                            xpArgs.ExpCampBonus +
                            xpArgs.ExpGroupBonus +
                            xpArgs.ExpOutpostBonus;

            // Only currently equipped artifacts can gain experience.

            lock (player.Inventory)
            {
                foreach (InventoryItem item in player.Inventory.EquippedItems)
                {
                    if (item != null && item is InventoryArtifact)
                    {
                        ArtifactGainedExperience(player, item as InventoryArtifact, xpAmount);
                    }
                }
            }
        }