Aura.Channel.Skills.Combat.Windmill.OnCreatureAttack C# (CSharp) Method

OnCreatureAttack() private method

Handles WM training
private OnCreatureAttack ( TargetAction tAction ) : void
tAction TargetAction
return void
		private void OnCreatureAttack(TargetAction tAction)
		{
			if (tAction.AttackerSkillId != SkillId.Windmill)
				return;

			var attackerSkill = tAction.Attacker.Skills.Get(SkillId.Windmill);
			if (attackerSkill == null) return;

			var rating = tAction.Attacker.GetPowerRating(tAction.Creature);
			var targets = tAction.Pack.GetTargets();

			var multipleEnemies = targets.Length >= 4;
			var multipleEnemiesDefeated = targets.Count(a => a.IsDead) >= 4;

			// rF-D, 1-2
			if (attackerSkill.Info.Rank >= SkillRank.RF && attackerSkill.Info.Rank <= SkillRank.RD)
			{
				attackerSkill.Train(1); // Attack an enemy.
				if (tAction.Creature.IsDead)
					attackerSkill.Train(2); // Defeat an enemy.
			}

			// rF, 3-5
			if (attackerSkill.Info.Rank == SkillRank.RF)
			{
				if (tAction.Attacker.Stability <= CounterStability)
					attackerSkill.Train(3); // Counterattack with Windmill.

				if (multipleEnemies) attackerSkill.Train(4); // Attack several enemies.
				if (multipleEnemiesDefeated) attackerSkill.Train(5); // Defeat several enemies.
			}

			// rE-D, 3-8
			if (attackerSkill.Info.Rank >= SkillRank.RE && attackerSkill.Info.Rank <= SkillRank.RD)
			{
				if (rating == PowerRating.Normal)
				{
					attackerSkill.Train(3); // Attack a similar ranked enemy.
					if (tAction.Creature.IsDead)
						attackerSkill.Train(4); // Defeat a similar ranked enemy.
				}

				if (rating == PowerRating.Strong && tAction.Creature.IsDead)
					attackerSkill.Train(5); // Defeat a powerful enemy.

				if (tAction.Attacker.Stability <= CounterStability)
					attackerSkill.Train(6); // Counterattack with Windmill.
			}

			// rC-B
			if (attackerSkill.Info.Rank >= SkillRank.RC && attackerSkill.Info.Rank <= SkillRank.RB)
			{
				if (rating == PowerRating.Normal)
				{
					attackerSkill.Train(1); // Attack a similar ranked enemy.
					if (tAction.Creature.IsDead)
						attackerSkill.Train(2); // Defeat a similar ranked enemy.
				}

				if (rating == PowerRating.Strong && tAction.Creature.IsDead)
					attackerSkill.Train(3); // Defeat a powerful enemy.

				if (rating == PowerRating.Awful && tAction.Creature.IsDead)
					attackerSkill.Train(4); // Defeat a very powerful enemy.

				if (tAction.Attacker.Stability <= CounterStability)
					attackerSkill.Train(5); // Counterattack with Windmill.
			}

			// rA-9
			if (attackerSkill.Info.Rank >= SkillRank.RA && attackerSkill.Info.Rank <= SkillRank.R9)
			{
				if (rating == PowerRating.Normal && tAction.Creature.IsDead)
					attackerSkill.Train(1); // Defeat a similar ranked enemy.

				if (rating == PowerRating.Strong && tAction.Creature.IsDead)
					attackerSkill.Train(2); // Defeat a powerful enemy.

				if (rating == PowerRating.Awful && tAction.Creature.IsDead)
					attackerSkill.Train(3); // Defeat a very powerful enemy.

				if (tAction.Attacker.Stability <= CounterStability)
					attackerSkill.Train(4); // Counterattack with Windmill.
			}
			
			// r8
			if (attackerSkill.Info.Rank == SkillRank.R8)
			{
				if (rating == PowerRating.Normal && tAction.Creature.IsDead)
					attackerSkill.Train(1); // Defeat a similar ranked enemy.

				if (rating == PowerRating.Strong && tAction.Creature.IsDead)
					attackerSkill.Train(2); // Defeat a powerful enemy.

				if (rating == PowerRating.Awful && tAction.Creature.IsDead)
					attackerSkill.Train(3); // Defeat a very powerful enemy.

				if (rating == PowerRating.Boss && tAction.Creature.IsDead)
					attackerSkill.Train(4); // Defeat a boss-level enemy.
					
				if (tAction.Attacker.Stability <= CounterStability)
					attackerSkill.Train(5); // Counterattack with Windmill.
			}

			// r7
			if (attackerSkill.Info.Rank == SkillRank.R7)
			{
				if (rating == PowerRating.Normal && tAction.Creature.IsDead)
					attackerSkill.Train(1); // Defeat a similar ranked enemy.

				if (rating == PowerRating.Strong && tAction.Creature.IsDead)
					attackerSkill.Train(2); // Defeat a powerful enemy.

				if (rating == PowerRating.Awful && tAction.Creature.IsDead)
					attackerSkill.Train(3); // Defeat a very powerful enemy.

				if (rating == PowerRating.Boss && tAction.Creature.IsDead)
					attackerSkill.Train(4); // Defeat a boss-level enemy.
			}

			// r6-1
			if (attackerSkill.Info.Rank >= SkillRank.R6 && attackerSkill.Info.Rank <= SkillRank.R1)
			{
				if (rating == PowerRating.Strong && tAction.Creature.IsDead)
					attackerSkill.Train(1); // Defeat a powerful enemy.

				if (rating == PowerRating.Awful && tAction.Creature.IsDead)
					attackerSkill.Train(2); // Defeat a very powerful enemy.

				if (rating == PowerRating.Boss && tAction.Creature.IsDead)
					attackerSkill.Train(3); // Defeat a boss-level enemy.
			}
		}