Aura.Channel.World.Entities.Creature.GetPowerRating C# (CSharp) Method

GetPowerRating() public method

Returns the power rating (Weak, Boss, etc) of compareCreature towards creature.
public GetPowerRating ( Creature compareCreature ) : PowerRating
compareCreature Creature Creature to compare to
return PowerRating
		public PowerRating GetPowerRating(Creature compareCreature)
		{
			var cp = this.CombatPower;
			var otherCp = compareCreature.CombatPower;

			var result = PowerRating.Boss;

			if (otherCp < cp * 0.8f) result = PowerRating.Weakest;
			else if (otherCp < cp * 1.0f) result = PowerRating.Weak;
			else if (otherCp < cp * 1.4f) result = PowerRating.Normal;
			else if (otherCp < cp * 2.0f) result = PowerRating.Strong;
			else if (otherCp < cp * 3.0f) result = PowerRating.Awful;

			// Weaken condition
			if (this.Conditions.Has(ConditionsA.Weaken))
			{
				var levels = 1;
				var wkn_lv = this.Conditions.GetExtraField(31, "WKN_LV");
				if (wkn_lv != null)
					levels = (byte)wkn_lv;

				result += levels;
			}

			if (result > PowerRating.Boss)
				result = PowerRating.Boss;

			return result;
		}

Usage Example

Example #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);
				}
			}
		}
All Usage Examples Of Aura.Channel.World.Entities.Creature::GetPowerRating