public GetPowerRating ( Creature compareCreature ) : PowerRating | ||
compareCreature | Creature | Creature to compare to |
return | PowerRating |
/// <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); } } }
/// <summary> /// Reduces weapon's durability and increases its proficiency. /// Only updates weapon type items that are not null. /// </summary> /// <param name="creature"></param> /// <param name="weapon"></param> public static void UpdateWeapon(Creature attacker, Creature target, params Item[] weapons) { if (attacker == null) return; var rnd = RandomProvider.Get(); foreach (var weapon in weapons.Where(a => a != null && a.IsTrainableWeapon)) { // Durability if (!ChannelServer.Instance.Conf.World.NoDurabilityLoss) { var reduce = rnd.Next(1, 30); // Half dura loss if blessed if (weapon.IsBlessed) reduce = Math.Max(1, reduce / 2); weapon.Durability -= reduce; Send.ItemDurabilityUpdate(attacker, weapon); } // Proficiency // Only if the weapon isn't broken and the target is not "Weakest". if (weapon.Durability != 0 && attacker != null && attacker.GetPowerRating(target) >= PowerRating.Weak) { short prof = 0; if (attacker.Age >= 10 && attacker.Age <= 12) prof = 48; else if (attacker.Age >= 13 && attacker.Age <= 19) prof = 60; else prof = 72; weapon.Proficiency += prof; Send.ItemExpUpdate(attacker, weapon); } } }
/// <summary> /// Handles Sharp Mind training. /// </summary> /// <param name="skillUser"></param> /// <param name="target"></param> public static void Train(Creature skillUser, Creature target, bool success) { if (!success) return; var targetSkill = target.Skills.Get(SkillId.SharpMind); if (targetSkill == null) return; var rating = target.GetPowerRating(skillUser); var skillRank = targetSkill.Info.Rank; if (skillRank >= SkillRank.Novice && skillRank <= SkillRank.RB) targetSkill.Train(1); // Successfully notice an enemy's skill. if (skillRank >= SkillRank.RF && skillRank <= SkillRank.RB && rating == PowerRating.Normal) targetSkill.Train(2); // Successfully notice a same level enemy's skill. if (skillRank >= SkillRank.RD && skillRank <= SkillRank.RB && rating == PowerRating.Strong) targetSkill.Train(3); // Successfully notice a strong enemy's skill. if (skillRank == SkillRank.RB && rating == PowerRating.Awful) targetSkill.Train(4); // Successfully notice an awful enemy's skill. }