Ejemplo n.º 1
0
 /// <summary>
 /// Calculate the XP gained towards the next level (in percent).
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public static int GetXPGainedForLevel(InventoryArtifact item)
 {
     if (item != null)
     {
         int level = GetCurrentLevel(item);
         if (level < 10)
         {
             double xpGained = item.Experience - m_xpForLevel[level];
             double xpNeeded = m_xpForLevel[level + 1] - m_xpForLevel[level];
             return((int)(xpGained * 100 / xpNeeded));
         }
     }
     return(0);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Determine artifact level from total XP.
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public static int GetCurrentLevel(InventoryArtifact item)
 {
     if (item != null)
     {
         for (int level = 10; level >= 0; --level)
         {
             if (item.Experience >= m_xpForLevel[level])
             {
                 return(level);
             }
         }
     }
     return(0);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Get the cooldown for this artifact.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public static int GetReuseTimer(InventoryArtifact item)
        {
            if (item == null)
            {
                return(0);
            }

            String artifactID = GetArtifactIDFromItemID(item.Id_nb);

            lock (m_artifacts)
            {
                if (!m_artifacts.ContainsKey(artifactID))
                {
                    log.Warn(String.Format("Can't find artifact for ID '{0}'", artifactID));
                    return(0);
                }

                Artifact artifact = m_artifacts[artifactID];
                return(artifact.ReuseTimer);
            }
        }
Ejemplo n.º 4
0
		/// <summary>
		/// Called when an artifact has gained experience.
		/// </summary>
		/// <param name="player"></param>
		/// <param name="item"></param>
		/// <param name="xpAmount"></param>
		private static void ArtifactGainedExperience(GamePlayer player, InventoryArtifact item, long xpAmount)
		{
			if (player == null || item == null)
				return;
			
			long artifactXPOld = item.Experience;

			// Can't go past level 10, but check to make sure we are level 10 if we have the XP
			if (artifactXPOld >= m_xpForLevel[10])
			{
				while (item.ArtifactLevel < 10)
				{
					player.Out.SendMessage(String.Format("Your {0} has gained a level!", item.Name), eChatType.CT_Important, eChatLoc.CL_SystemWindow);
					item.OnLevelGained(player, item.ArtifactLevel + 1);
				}

				return;
			}

			if (player.Guild != null && player.Guild.BonusType == Guild.eBonusType.ArtifactXP)
			{
				long xpBonus = (long)(xpAmount * ServerProperties.Properties.GUILD_BUFF_ARTIFACT_XP * .01);
				xpAmount += xpBonus;
				player.Out.SendMessage(string.Format("Your {0} gains additional experience due to your guild's buff!", item.Name), eChatType.CT_Important, eChatLoc.CL_SystemWindow);

			}

			// All artifacts share the same XP table, we make them level
			// at different rates by tweaking the XP rate.

			int xpRate;

			lock (m_artifacts)
			{
				Artifact artifact = m_artifacts[item.ArtifactID];
				if (artifact == null)
					return;
				xpRate = artifact.XPRate;
			}

			long artifactXPNew = (long)(artifactXPOld + (xpAmount * xpRate) / ServerProperties.Properties.ARTIFACT_XP_RATE);
			item.Experience = artifactXPNew;

			player.Out.SendMessage(String.Format("Your {0} has gained experience.", item.Name), eChatType.CT_Important, eChatLoc.CL_SystemWindow);

			// Now let's see if this artifact has gained a new level yet.

			for (int level = 1; level <= 10; ++level)
			{
				if (artifactXPNew < m_xpForLevel[level])
					break;

				if (artifactXPOld > m_xpForLevel[level])
					continue;

				player.Out.SendMessage(String.Format("Your {0} has gained a level!", item.Name), eChatType.CT_Important, eChatLoc.CL_SystemWindow);
				item.OnLevelGained(player, level);
			}
		}
Ejemplo n.º 5
0
		/// <summary>
		/// What this artifact gains XP from.
		/// </summary>
		/// <param name="item"></param>
		/// <returns></returns>
		public static String GetEarnsXP(InventoryArtifact item)
		{
			return "Slaying enemies and monsters found anywhere.";
		}
Ejemplo n.º 6
0
		/// <summary>
		/// Calculate the XP gained towards the next level (in percent).
		/// </summary>
		/// <param name="item"></param>
		/// <returns></returns>
		public static int GetXPGainedForLevel(InventoryArtifact item)
		{
			if (item != null)
			{
				int level = GetCurrentLevel(item);
				if (level < 10)
				{
					double xpGained = item.Experience - m_xpForLevel[level];
					double xpNeeded = m_xpForLevel[level + 1] - m_xpForLevel[level];
					return (int)(xpGained * 100 / xpNeeded);
				}
			}
			return 0;
		}
Ejemplo n.º 7
0
		/// <summary>
		/// Determine artifact level from total XP.
		/// </summary>
		/// <param name="item"></param>
		/// <returns></returns>
		public static int GetCurrentLevel(InventoryArtifact item)
		{
			if (item != null)
			{
				for (int level = 10; level >= 0; --level)
					if (item.Experience >= m_xpForLevel[level])
						return level;
			}
			return 0;
		}
Ejemplo n.º 8
0
		/// <summary>
		/// Get the cooldown for this artifact.
		/// </summary>
		/// <param name="item"></param>
		/// <returns></returns>
		public static int GetReuseTimer(InventoryArtifact item)
		{
			if (item == null)
				return 0;

			String artifactID = GetArtifactIDFromItemID(item.Id_nb);
			lock (m_artifacts)
			{
				if (!m_artifacts.ContainsKey(artifactID))
				{
					log.Warn(String.Format("Can't find artifact for ID '{0}'", artifactID));
					return 0;
				}

				Artifact artifact = m_artifacts[artifactID];
				return artifact.ReuseTimer;
			}
		}
Ejemplo n.º 9
0
        /// <summary>
        /// Called when an artifact has gained experience.
        /// </summary>
        /// <param name="player"></param>
        /// <param name="item"></param>
        /// <param name="xpAmount"></param>
        private static void ArtifactGainedExperience(GamePlayer player, InventoryArtifact item, long xpAmount)
        {
            if (player == null || item == null)
            {
                return;
            }

            long artifactXPOld = item.Experience;

            // Can't go past level 10, but check to make sure we are level 10 if we have the XP
            if (artifactXPOld >= m_xpForLevel[10])
            {
                while (item.ArtifactLevel < 10)
                {
                    player.Out.SendMessage(String.Format("Your {0} has gained a level!", item.Name), eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                    item.OnLevelGained(player, item.ArtifactLevel + 1);
                }

                return;
            }

            if (player.Guild != null && player.Guild.BonusType == Guild.eBonusType.ArtifactXP)
            {
                long xpBonus = (long)(xpAmount * ServerProperties.Properties.GUILD_BUFF_ARTIFACT_XP * .01);
                xpAmount += xpBonus;
                player.Out.SendMessage(string.Format("Your {0} gains additional experience due to your guild's buff!", item.Name), eChatType.CT_Important, eChatLoc.CL_SystemWindow);
            }

            // All artifacts share the same XP table, we make them level
            // at different rates by tweaking the XP rate.

            int xpRate;

            lock (m_artifacts)
            {
                Artifact artifact = m_artifacts[item.ArtifactID];
                if (artifact == null)
                {
                    return;
                }
                xpRate = artifact.XPRate;
            }

            long artifactXPNew = (long)(artifactXPOld + (xpAmount * xpRate) / ServerProperties.Properties.ARTIFACT_XP_RATE);

            item.Experience = artifactXPNew;

            player.Out.SendMessage(String.Format("Your {0} has gained experience.", item.Name), eChatType.CT_Important, eChatLoc.CL_SystemWindow);

            // Now let's see if this artifact has gained a new level yet.

            for (int level = 1; level <= 10; ++level)
            {
                if (artifactXPNew < m_xpForLevel[level])
                {
                    break;
                }

                if (artifactXPOld > m_xpForLevel[level])
                {
                    continue;
                }

                player.Out.SendMessage(String.Format("Your {0} has gained a level!", item.Name), eChatType.CT_Important, eChatLoc.CL_SystemWindow);
                item.OnLevelGained(player, level);
            }
        }
Ejemplo n.º 10
0
 /// <summary>
 /// What this artifact gains XP from.
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public static String GetEarnsXP(InventoryArtifact item)
 {
     return("Slaying enemies and monsters found anywhere.");
 }