Beispiel #1
0
		/// <summary>
		/// Reduces weapon's durability and increases its proficiency.
		/// Only updates weapon type items that are not null.
		/// </summary>
		/// <param name="attacker">Creature who's weapon is updated.</param>
		/// <param name="target">
		/// The target of the skill, used for power rating calculations.
		/// If target is null, prof will be rewarded regardless of target.
		/// </param>
		/// <param name="weapons">Weapons to update.</param>
		public static void UpdateWeapon(Creature attacker, Creature target, ProficiencyGainType profGainType, params Item[] weapons)
		{
			if (attacker == null)
				return;

			var rnd = RandomProvider.Get();

			// Add prof if no target was specified or the target is not "Weakest".
			var addProf = (target == null || attacker.GetPowerRating(target) >= PowerRating.Weak);

			foreach (var weapon in weapons.Where(a => a != null && a.IsTrainableWeapon))
			{
				// Durability
				var reduce = rnd.Next(1, 30);
				attacker.Inventory.ReduceDurability(weapon, reduce);

				// Don't add prof if weapon is broken.
				if (weapon.Durability == 0)
					addProf = false;

				// Proficiency
				if (addProf)
				{
					var amount = Item.GetProficiencyGain(attacker.Age, profGainType);
					attacker.Inventory.AddProficiency(weapon, amount);
				}
			}
		}
Beispiel #2
0
        /// <summary>
        /// Reduces weapon's durability and increases its proficiency.
        /// Only updates weapon type items that are not null.
        /// </summary>
        /// <param name="attacker">Creature who's weapon is updated.</param>
        /// <param name="target">
        /// The target of the skill, used for power rating calculations.
        /// If target is null, prof will be rewarded regardless of target.
        /// </param>
        /// <param name="weapons">Weapons to update.</param>
        public static void UpdateWeapon(Creature attacker, Creature target, ProficiencyGainType profGainType, params Item[] weapons)
        {
            if (attacker == null)
            {
                return;
            }

            var rnd = RandomProvider.Get();

            // Add prof if no target was specified or the target is not "Weakest".
            var addProf = (target == null || attacker.GetPowerRating(target) >= PowerRating.Weak);

            foreach (var weapon in weapons.Where(a => a != null && a.IsTrainableWeapon))
            {
                // Durability
                if (!ChannelServer.Instance.Conf.World.NoDurabilityLoss)
                {
                    var reduce = rnd.Next(1, 30);
                    attacker.Inventory.ReduceDurability(weapon, reduce);
                }

                // Don't add prof if weapon is broken.
                if (weapon.Durability == 0)
                {
                    addProf = false;
                }

                // Proficiency
                if (addProf)
                {
                    var amount = Item.GetProficiencyGain(attacker.Age, profGainType);
                    attacker.Inventory.AddProficiency(weapon, amount);
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Returns the amount of proficiency items gain for the given
        /// age and type.
        /// </summary>
        /// <param name="age"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static int GetProficiencyGain(int age, ProficiencyGainType type)
        {
            switch (type)
            {
                case ProficiencyGainType.Melee:
                    if (age >= 10 && age <= 12)
                        return 48;
                    else if (age >= 13 && age <= 19)
                        return 60;
                    else
                        return 72;

                case ProficiencyGainType.Ranged:
                    if (age == 10)
                        return 60;
                    else if (age >= 11 && age <= 15)
                        return 72;
                    else if (age >= 16 && age <= 19)
                        return 84;
                    else if (age >= 20 && age <= 24)
                        return 96;
                    else
                        return 108;

                case ProficiencyGainType.Gathering:
                    if (age >= 10 && age <= 15)
                        return 96;
                    else
                        return 114;

                case ProficiencyGainType.Music:
                    if (age >= 10 && age <= 15)
                        return 6;
                    else
                        return 12;

                case ProficiencyGainType.Damage:
                    if (age >= 10 && age <= 12)
                        return 16;
                    else if (age >= 13 && age <= 19)
                        return 20;
                    else
                        return 24;

                case ProficiencyGainType.Time:
                    if (age >= 10 && age <= 12)
                        return 60;
                    else if (age >= 13 && age <= 19)
                        return 75;
                    else
                        return 90;

                case ProficiencyGainType.Defend:
                    if (age >= 10 && age <= 12)
                        return 240;
                    else if (age >= 13 && age <= 19)
                        return 300;
                    else
                        return 360;

                default:
                    throw new ArgumentException("Unknown type '" + type + "'.");
            }
        }