Aura.Channel.Skills.Combat.Windmill.OnCreatureAttacks C# (CSharp) Метод

OnCreatureAttacks() приватный Метод

Handles multi-target training.
Can't be handled in OnCreatureAttack because it would be done for every single target.
private OnCreatureAttacks ( AttackerAction aAction ) : void
aAction AttackerAction
Результат void
		private void OnCreatureAttacks(AttackerAction aAction)
		{
			if (aAction.SkillId != SkillId.Windmill)
				return;

			var attackerSkill = aAction.Creature.Skills.Get(SkillId.Windmill);
			if (attackerSkill == null) return;

			var targets = aAction.Pack.GetTargets();
			var trainingIdx = 0;

			switch (attackerSkill.Info.Rank)
			{
				case SkillRank.RF: trainingIdx = 4; break;
				case SkillRank.RE: trainingIdx = 7; break;
				case SkillRank.RD: trainingIdx = 7; break;
				case SkillRank.RC: trainingIdx = 6; break;
				case SkillRank.RB: trainingIdx = 6; break;
				case SkillRank.RA: trainingIdx = 5; break;
				case SkillRank.R9: trainingIdx = 5; break;
				case SkillRank.R8: trainingIdx = 6; break;
				case SkillRank.R7: trainingIdx = 5; break;
				case SkillRank.R6: trainingIdx = 4; break;
				case SkillRank.R5: trainingIdx = 4; break;
				case SkillRank.R4: trainingIdx = 4; break;
				case SkillRank.R3: trainingIdx = 4; break;
				case SkillRank.R2: trainingIdx = 4; break;
				case SkillRank.R1: trainingIdx = 4; break;
			}

			// rF
			if (attackerSkill.Info.Rank == SkillRank.RF)
			{
				var multipleEnemies = (targets.Length >= 4);
				var multipleEnemiesDefeated = (targets.Count(a => a.IsDead) >= 4);

				if (multipleEnemies) attackerSkill.Train(trainingIdx); // Attack several enemies.
				if (multipleEnemiesDefeated) attackerSkill.Train(trainingIdx + 1); // Defeat several enemies.

				return;
			}

			// rE-D
			if (attackerSkill.Info.Rank >= SkillRank.RE && attackerSkill.Info.Rank <= SkillRank.RD)
			{
				// "When training multiple hits/kills, the player must hit four or more targets.
				// To fulfill the "kill" condition, the player must finish all four targets simultaneously.
				// At least one must be "Strong" while the rest are either lower or equal in power or else you will not receive the points."
				// http://wiki.mabinogiworld.com/view/Windmill#Training_Method
				// Apparently the enemy with the highest power rating becomes
				// the rule for the entire "group" that was killed, e.g. if
				// you kill 4 strongs and 1 awful, it doesn't count towards
				// the "several strong" training.

				var highestRating = targets.Max(a => aAction.Creature.GetPowerRating(a));

				if (highestRating == PowerRating.Normal)
				{
					if (targets.Length >= 4)
					{
						attackerSkill.Train(trainingIdx); // Attack several enemies of similar level.

						if (targets.All(a => a.IsDead))
							attackerSkill.Train(trainingIdx + 1); // Defeat several enemies of similar level.
					}
				}

				return;
			}

			// rC-1
			if (attackerSkill.Info.Rank >= SkillRank.RC && attackerSkill.Info.Rank <= SkillRank.R1)
			{
				var highestRating = targets.Max(a => aAction.Creature.GetPowerRating(a));

				if (highestRating == PowerRating.Strong)
				{
					if (targets.Length >= 4)
					{
						attackerSkill.Train(trainingIdx); // Attack several powerful enemies.

						if (targets.All(a => a.IsDead))
							attackerSkill.Train(trainingIdx + 1); // Defeat several powerful enemies.
					}
				}

				return;
			}
		}
	}