当前位置: 首页>>代码示例>>C#>>正文


C# TargetAction.Has方法代码示例

本文整理汇总了C#中TargetAction.Has方法的典型用法代码示例。如果您正苦于以下问题:C# TargetAction.Has方法的具体用法?C# TargetAction.Has怎么用?C# TargetAction.Has使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TargetAction的用法示例。


在下文中一共展示了TargetAction.Has方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnCreatureAttack

		/// <summary>
		/// Handles training based on what happened in the combat action.
		/// </summary>
		/// <param name="tAction"></param>
		private void OnCreatureAttack(TargetAction tAction)
		{
			if (!tAction.Has(TargetOptions.Critical))
				return;

			var attackerSkill = tAction.Attacker.Skills.Get(SkillId.CriticalHit);
			var targetSkill = tAction.Creature.Skills.Get(SkillId.CriticalHit);

			if (attackerSkill.Info.Rank == SkillRank.Novice)
			{
				if (tAction.Is(CombatActionType.CounteredHit2))
					attackerSkill.Train(1); // Novice -> RF
			}
			else
			{
				attackerSkill.Train(1); // Land a critical hit.

				if (tAction.Creature.IsDead)
					attackerSkill.Train(3); // Finish off with critical hit.
			}

			if (targetSkill != null && targetSkill.Info.Rank >= SkillRank.RF)
				attackerSkill.Train(2); // Learn from enemy's critical hit.
		}
开发者ID:tkiapril,项目名称:aura,代码行数:28,代码来源:CriticalHit.cs

示例2: OnCreatureAttacks

		/// <summary>
		/// Handles the majority of the skill training.
		/// </summary>
		/// <param name="obj"></param>
		private void OnCreatureAttacks(TargetAction tAction)
		{
			if (tAction.SkillId != SkillId.RangedAttack)
				return;

			var attackerSkill = tAction.Attacker.Skills.Get(SkillId.RangedAttack);
			var targetSkill = tAction.Creature.Skills.Get(SkillId.RangedAttack);
			var targetPowerRating = tAction.Attacker.GetPowerRating(tAction.Creature);
			var attackerPowerRating = tAction.Creature.GetPowerRating(tAction.Attacker);

			if (attackerSkill != null)
			{
				if (attackerSkill.Info.Rank == SkillRank.RF)
				{
					attackerSkill.Train(2); // Attack an enemy.

					if (tAction.Has(TargetOptions.KnockDown))
						attackerSkill.Train(3); // Down the enemy with continuous hit.

					if (tAction.Creature.IsDead)
						attackerSkill.Train(4); // Kill an enemy.
				}
				else if (attackerSkill.Info.Rank == SkillRank.RE)
				{
					if (targetPowerRating == PowerRating.Normal)
						attackerSkill.Train(3); // Attack a same level enemy.

					if (tAction.Has(TargetOptions.KnockDown))
					{
						attackerSkill.Train(1); // Down the enemy with continuous hit.

						if (targetPowerRating == PowerRating.Normal)
							attackerSkill.Train(4); // Down a same level enemy. 

						if (targetPowerRating == PowerRating.Strong)
							attackerSkill.Train(6); // Down a strong enemy.
					}

					if (tAction.Creature.IsDead)
					{
						attackerSkill.Train(2); // Kill an enemy.

						if (targetPowerRating == PowerRating.Normal)
							attackerSkill.Train(5); // Kill a same level enemy. 

						if (targetPowerRating == PowerRating.Strong)
							attackerSkill.Train(7); // Kill a strong enemy.
					}
				}
				else if (attackerSkill.Info.Rank == SkillRank.RD)
				{
					attackerSkill.Train(1); // Attack any enemy. 

					if (targetPowerRating == PowerRating.Normal)
						attackerSkill.Train(4); // Attack a same level enemy.

					if (tAction.Has(TargetOptions.KnockDown))
					{
						attackerSkill.Train(2); // Down the enemy with continuous hit.

						if (targetPowerRating == PowerRating.Normal)
							attackerSkill.Train(5); // Down a same level enemy. 

						if (targetPowerRating == PowerRating.Strong)
							attackerSkill.Train(7); // Down a strong enemy.
					}

					if (tAction.Creature.IsDead)
					{
						attackerSkill.Train(3); // Kill an enemy.

						if (targetPowerRating == PowerRating.Normal)
							attackerSkill.Train(6); // Kill a same level enemy. 

						if (targetPowerRating == PowerRating.Strong)
							attackerSkill.Train(8); // Kill a strong enemy.
					}
				}
				else if (attackerSkill.Info.Rank >= SkillRank.RC && attackerSkill.Info.Rank <= SkillRank.RB)
				{
					if (targetPowerRating == PowerRating.Normal)
						attackerSkill.Train(1); // Attack a same level enemy.

					if (tAction.Has(TargetOptions.KnockDown))
					{
						if (targetPowerRating == PowerRating.Normal)
							attackerSkill.Train(2); // Down a same level enemy. 

						if (targetPowerRating == PowerRating.Strong)
							attackerSkill.Train(4); // Down a strong enemy.

						if (targetPowerRating == PowerRating.Awful)
							attackerSkill.Train(6); // Down an awful enemy.
					}

					if (tAction.Creature.IsDead)
//.........这里部分代码省略.........
开发者ID:xKamuna,项目名称:aura,代码行数:101,代码来源:RangedAttack.cs

示例3: Train

		/// <summary>
		/// Trains skill based on target action.
		/// </summary>
		/// <param name="tAction"></param>
		/// <param name="attackerSkill"></param>
		protected virtual void Train(TargetAction tAction, Skill attackerSkill)
		{
			var rating = tAction.Attacker.GetPowerRating(tAction.Creature);

			if (attackerSkill.Info.Rank == SkillRank.RF)
			{
				attackerSkill.Train(1); // Attack anything.
				attackerSkill.Train(2); // Attack an enemy.

				if (tAction.Has(TargetOptions.KnockDown))
					attackerSkill.Train(3); // Knock down an enemy using combo attack.

				if (tAction.Creature.IsDead)
					attackerSkill.Train(4); // Defeat an enemy.

				return;
			}

			if (attackerSkill.Info.Rank == SkillRank.RE)
			{
				if (tAction.Has(TargetOptions.KnockDown))
					attackerSkill.Train(1); // Knock down an enemy using combo attack.

				if (tAction.Creature.IsDead)
					attackerSkill.Train(2); // Defeat an enemy.

				if (rating == PowerRating.Normal)
				{
					attackerSkill.Train(3); // Attack a similar-ranked enemy.

					if (tAction.Has(TargetOptions.KnockDown))
						attackerSkill.Train(4); // Knock down a similar-ranked enemy.

					if (tAction.Creature.IsDead)
						attackerSkill.Train(5); // Defeat a similar-ranked enemy.
				}
				else if (rating == PowerRating.Strong)
				{
					if (tAction.Has(TargetOptions.KnockDown))
						attackerSkill.Train(6); // Knock down a powerful enemy.

					if (tAction.Creature.IsDead)
						attackerSkill.Train(7); // Defeat a powerful enemy.
				}

				return;
			}

			if (attackerSkill.Info.Rank == SkillRank.RD)
			{
				attackerSkill.Train(1); // Defeat an enemy (They probably mean attack?)

				if (tAction.Has(TargetOptions.KnockDown))
					attackerSkill.Train(2); // Knock down an enemy using combo attack.

				if (tAction.Creature.IsDead)
					attackerSkill.Train(3); // Defeat an enemy.

				if (rating == PowerRating.Normal)
				{
					attackerSkill.Train(4); // Attack a similar-ranked enemy.

					if (tAction.Has(TargetOptions.KnockDown))
						attackerSkill.Train(5); // Knock down a similar-ranked enemy.

					if (tAction.Creature.IsDead)
						attackerSkill.Train(6); // Defeat a similar-ranked enemy.
				}
				else if (rating == PowerRating.Strong)
				{
					if (tAction.Has(TargetOptions.KnockDown))
						attackerSkill.Train(7); // Knock down a powerful enemy.

					if (tAction.Creature.IsDead)
						attackerSkill.Train(8); // Defeat a powerful enemy.
				}

				return;
			}

			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.Has(TargetOptions.KnockDown))
						attackerSkill.Train(2); // Knock down a similar-ranked enemy.

					if (tAction.Creature.IsDead)
						attackerSkill.Train(3); // Defeat a similar-ranked enemy.
				}
				else if (rating == PowerRating.Strong)
				{
					if (tAction.Has(TargetOptions.KnockDown))
//.........这里部分代码省略.........
开发者ID:ripxfrostbite,项目名称:aura,代码行数:101,代码来源:MagicBolt.cs

示例4: Use

		/// <summary>
		/// Handles using the skill.
		/// </summary>
		/// <param name="attacker"></param>
		/// <param name="skill"></param>
		/// <param name="targetAreaId"></param>
		/// <param name="unkInt1"></param>
		/// <param name="unkInt2"></param>
		public void Use(Creature attacker, Skill skill, long targetAreaId, int unkInt1, int unkInt2)
		{
			var range = this.GetRange(attacker, skill);
			var targets = attacker.GetTargetableCreaturesInRange(range, TargetableOptions.AddAttackRange);
			var rnd = RandomProvider.Get();

			// Create actions
			var cap = new CombatActionPack(attacker, skill.Info.Id);

			var aAction = new AttackerAction(CombatActionType.Attacker, attacker, targetAreaId);
			aAction.Set(AttackerOptions.Result);
			aAction.Stun = AttackerStun;

			cap.Add(aAction);

			foreach (var target in targets)
			{
				// Check if hit
				var hitChance = this.GetHitChance(attacker, target, skill);
				if (rnd.Next(0, 100) > hitChance)
					continue;

				target.StopMove();

				var tAction = new TargetAction(CombatActionType.TakeHit, target, attacker, skill.Info.Id);
				tAction.Set(TargetOptions.Result);
				tAction.Delay = 300;

				// Calculate damage
				var damage = this.GetDamage(attacker, skill);

				// Elementals
				damage *= attacker.CalculateElementalDamageMultiplier(target);

				// Handle skills and reductions
				CriticalHit.Handle(attacker, attacker.GetTotalCritChance(0), ref damage, tAction);
				SkillHelper.HandleDefenseProtection(target, ref damage);
				ManaShield.Handle(target, ref damage, tAction);
				HeavyStander.Handle(attacker, target, ref damage, tAction);

				// Clean Hit if not critical
				if (!tAction.Has(TargetOptions.Critical))
					tAction.Set(TargetOptions.CleanHit);

				// Take damage if any is left
				if (damage > 0)
				{
					target.TakeDamage(tAction.Damage = damage, attacker);
					SkillHelper.HandleInjury(attacker, target, damage);
				}

				// Finish if dead, knock down if not defended
				if (target.IsDead)
					tAction.Set(TargetOptions.KnockDownFinish);
				else
					tAction.Set(TargetOptions.KnockDown);

				// Anger Management
				if (!target.IsDead)
					target.Aggro(attacker);

				// Stun & knock down
				tAction.Stun = CombatMastery.GetTargetStun(attacker.AverageKnockCount, attacker.AverageAttackSpeed, true);
				target.Stability = Creature.MinStability;

				// Add action
				cap.Add(tAction);
			}

			Send.UseMotion(attacker, 10, 1);

			cap.Handle();

			Send.SkillUse(attacker, skill.Info.Id, targetAreaId, unkInt1, unkInt2);
		}
开发者ID:tkiapril,项目名称:aura,代码行数:83,代码来源:Stomp.cs

示例5: OnCreatureAttacks

		/// <summary>
		/// Handles the skill training.
		/// </summary>
		/// <param name="tAction"></param>
		private void OnCreatureAttacks(TargetAction tAction)
		{
			if (tAction.AttackerSkillId != SkillId.SupportShot)
				return;

			var skill = tAction.Attacker.Skills.Get(SkillId.SupportShot);
			if (skill == null)
				return;

			var powerRating = tAction.Attacker.GetPowerRating(tAction.Creature);

			if (skill.Info.Rank >= SkillRank.RF && skill.Info.Rank <= SkillRank.RA)
			{
				skill.Train(1); // Successfully use the skill.

				if (!tAction.IsKnockBack)
					skill.Train(2); // Successfully use Support Shot without knocking down the enemy.

				if (tAction.Has(TargetOptions.Critical))
					skill.Train(3); // Succeed in a Critical Hit with Support Shot.
			}
			else if (skill.Info.Rank == SkillRank.R9)
			{
				if (powerRating == PowerRating.Normal)
					skill.Train(1); // Successfully use the skill on a similarly ranked enemy.

				if (powerRating == PowerRating.Strong)
				{
					skill.Train(2); // Successfully use the skill on a Strong enemy.

					if (tAction.Has(TargetOptions.Critical))
						skill.Train(4); // Succeed in a Critical Hit against a Strong enemy.
				}

				if (!tAction.IsKnockBack)
					skill.Train(3); // Successfully use Support Shot without knocking down the enemy.
			}
			else if (skill.Info.Rank >= SkillRank.R8 && skill.Info.Rank <= SkillRank.R4)
			{
				if (powerRating == PowerRating.Strong)
					skill.Train(1); // Successfully use the skill on a Strong enemy.

				if (powerRating == PowerRating.Awful)
				{
					skill.Train(2); // Successfully use the skill on a Awful enemy.

					if (tAction.Has(TargetOptions.Critical))
						skill.Train(4); // Succeed in a Critical Hit against a Awful enemy.
				}

				if (!tAction.IsKnockBack)
					skill.Train(3); // Successfully use Support Shot without knocking down the enemy.
			}
			else if (skill.Info.Rank >= SkillRank.R3 && skill.Info.Rank <= SkillRank.R1)
			{
				if (powerRating == PowerRating.Awful)
					skill.Train(1); // Successfully use the skill on a Awful enemy.

				if (powerRating == PowerRating.Boss)
				{
					skill.Train(2); // Successfully use the skill on a Boss enemy.

					if (tAction.Has(TargetOptions.Critical))
						skill.Train(4); // Succeed in a Critical Hit against a Boss enemy.
				}

				if (!tAction.IsKnockBack)
					skill.Train(3); // Successfully use Support Shot without knocking down the enemy.
			}
		}
开发者ID:tkiapril,项目名称:aura,代码行数:74,代码来源:SupportShot.cs

示例6: Use

		/// <summary>
		/// Uses WM, attacking targets.
		/// </summary>
		/// <param name="attacker"></param>
		/// <param name="skill"></param>
		/// <param name="targetAreaId"></param>
		/// <param name="unkInt1"></param>
		/// <param name="unkInt2"></param>
		public void Use(Creature attacker, Skill skill, long targetAreaId, int unkInt1, int unkInt2)
		{
			var range = this.GetRange(attacker, skill);
			var targets = attacker.GetTargetableCreaturesInRange(range, true);

			// Check targets
			if (targets.Count == 0)
			{
				Send.Notice(attacker, Localization.Get("There isn't a target nearby to use that on."));
				Send.SkillUseSilentCancel(attacker);
				return;
			}

			// Create actions
			var cap = new CombatActionPack(attacker, skill.Info.Id);

			var aAction = new AttackerAction(CombatActionType.SpecialHit, attacker, skill.Info.Id, targetAreaId);
			aAction.Set(AttackerOptions.Result);

			cap.Add(aAction);

			var survived = new List<Creature>();

			foreach (var target in targets)
			{
				target.StopMove();

				var tAction = new TargetAction(CombatActionType.TakeHit, target, attacker, skill.Info.Id);
				tAction.Delay = 300; // Usually 300, sometimes 350?

				// Calculate damage
				var damage = attacker.GetRndTotalDamage();
				damage *= skill.RankData.Var1 / 100f;

				// Handle skills and reductions
				CriticalHit.Handle(attacker, attacker.GetTotalCritChance(0), ref damage, tAction);
				SkillHelper.HandleDefenseProtection(target, ref damage);
				Defense.Handle(aAction, tAction, ref damage);
				ManaShield.Handle(target, ref damage, tAction);

				// Clean Hit if not defended nor critical
				if (tAction.SkillId != SkillId.Defense && !tAction.Has(TargetOptions.Critical))
					tAction.Set(TargetOptions.CleanHit);

				// Take damage if any is left
				if (damage > 0)
					target.TakeDamage(tAction.Damage = damage, attacker);

				// Finish if dead, knock down if not defended
				if (target.IsDead)
					tAction.Set(TargetOptions.KnockDownFinish);
				else if (tAction.SkillId != SkillId.Defense)
					tAction.Set(TargetOptions.KnockDown);

				// Anger Management
				if (!target.IsDead)
					survived.Add(target);

				// Stun & knock back
				aAction.Stun = CombatMastery.GetAttackerStun(attacker.AverageKnockCount, attacker.AverageAttackSpeed, true);

				if (tAction.SkillId != SkillId.Defense)
				{
					tAction.Stun = CombatMastery.GetTargetStun(attacker.AverageKnockCount, attacker.AverageAttackSpeed, true);
					target.Stability = Creature.MinStability;
					attacker.Shove(target, KnockbackDistance);
				}

				// Add action
				cap.Add(tAction);
			}

			// Only select a random aggro if there is no aggro yet,
			// WM only aggroes one target at a time.
			if (survived.Count != 0 && attacker.Region.CountAggro(attacker) < 1)
			{
				var rnd = RandomProvider.Get();
				var aggroTarget = survived.Random();
				aggroTarget.Aggro(attacker);
			}

			// Reduce life in old combat system
			if (!AuraData.FeaturesDb.IsEnabled("CombatSystemRenewal"))
			{
				var amount = (attacker.LifeMax < 10 ? 2 : attacker.LifeMax / 10);
				attacker.ModifyLife(-amount);

				// TODO: Invincibility
			}

			// Spin it~
			Send.UseMotion(attacker, 8, 4);
//.........这里部分代码省略.........
开发者ID:RonnyZijler,项目名称:aura,代码行数:101,代码来源:Windmill.cs

示例7: CustomHitCancel

		/// <summary>
		/// Called when creature is hit while a bolt skill is active.
		/// </summary>
		/// <param name="creature"></param>
		/// <param name="tAction"></param>
		public void CustomHitCancel(Creature creature, TargetAction tAction)
		{
			var skill = creature.Skills.ActiveSkill;

			// Cancel skill on knock down, or if only one stack is left
			if (tAction.Has(TargetOptions.KnockDown) || tAction.Has(TargetOptions.KnockDown) || skill.Stacks <= 1)
			{
				creature.Skills.CancelActiveSkill();
				return;
			}

			// Reduce stack by one on hit
			skill.Stacks -= 1;
		}
开发者ID:tkiapril,项目名称:aura,代码行数:19,代码来源:ArrowRevolver.cs

示例8: Use

		/// <summary>
		/// Uses WM, attacking targets.
		/// </summary>
		/// <param name="attacker"></param>
		/// <param name="skill"></param>
		/// <param name="targetAreaId"></param>
		/// <param name="unkInt1"></param>
		/// <param name="unkInt2"></param>
		public void Use(Creature attacker, Skill skill, long targetAreaId, int unkInt1, int unkInt2)
		{
			var range = this.GetRange(attacker, skill);
			var targets = attacker.GetTargetableCreaturesInRange(range, TargetableOptions.AddAttackRange);

			// Check targets
			if (targets.Count == 0)
			{
				Send.Notice(attacker, Localization.Get("There isn't a target nearby to use that on."));
				Send.SkillUseSilentCancel(attacker);
				return;
			}

			// Create actions
			var cap = new CombatActionPack(attacker, skill.Info.Id);

			var aAction = new AttackerAction(CombatActionType.SpecialHit, attacker, targetAreaId);
			aAction.Set(AttackerOptions.Result);
			aAction.Stun = CombatMastery.GetAttackerStun(attacker.AverageKnockCount, attacker.AverageAttackSpeed, true);

			cap.Add(aAction);

			var survived = new List<Creature>();
			var rnd = RandomProvider.Get();

			// Check crit
			var crit = false;
			if (attacker.Skills.Has(SkillId.CriticalHit, SkillRank.RF))
				crit = (rnd.Next(100) < attacker.GetTotalCritChance(0));

			// Handle all targets
			foreach (var target in targets)
			{
				target.StopMove();

				var tAction = new TargetAction(CombatActionType.TakeHit, target, attacker, skill.Info.Id);
				tAction.Delay = 300; // Usually 300, sometimes 350?

				// Calculate damage
				var damage = attacker.GetRndTotalDamage();
				damage *= skill.RankData.Var1 / 100f;

				// Elementals
				damage *= attacker.CalculateElementalDamageMultiplier(target);

				// Crit bonus
				if (crit)
					CriticalHit.Handle(attacker, 100, ref damage, tAction);

				// Handle skills and reductions
				SkillHelper.HandleDefenseProtection(target, ref damage);
				SkillHelper.HandleConditions(attacker, target, ref damage);
				Defense.Handle(aAction, tAction, ref damage);
				ManaShield.Handle(target, ref damage, tAction);
				HeavyStander.Handle(attacker, target, ref damage, tAction);

				// Clean Hit if not defended nor critical
				if (tAction.SkillId != SkillId.Defense && !tAction.Has(TargetOptions.Critical))
					tAction.Set(TargetOptions.CleanHit);

				// Take damage if any is left
				if (damage > 0)
					target.TakeDamage(tAction.Damage = damage, attacker);

				// Knock down on deadly
				if (target.Conditions.Has(ConditionsA.Deadly))
				{
					tAction.Set(TargetOptions.KnockDown);
					tAction.Stun = CombatMastery.GetTargetStun(attacker.AverageKnockCount, attacker.AverageAttackSpeed, true);
				}

				// Finish if dead, knock down if not defended
				if (target.IsDead)
					tAction.Set(TargetOptions.KnockDownFinish);
				else if (tAction.SkillId != SkillId.Defense)
					tAction.Set(TargetOptions.KnockDown);

				// Anger Management
				if (!target.IsDead)
					survived.Add(target);

				// Stun and shove if not defended
				if (target.IsDead || tAction.SkillId != SkillId.Defense || target.Conditions.Has(ConditionsA.Deadly))
				{
					tAction.Stun = CombatMastery.GetTargetStun(attacker.AverageKnockCount, attacker.AverageAttackSpeed, true);
					target.Stability = Creature.MinStability;
					attacker.Shove(target, KnockbackDistance);
				}

				// Add action
				cap.Add(tAction);
			}
//.........这里部分代码省略.........
开发者ID:aura-project,项目名称:aura,代码行数:101,代码来源:Windmill.cs

示例9: OnCreatureAttacks

		/// <summary>
		/// Handles the majority of the skill training.
		/// </summary>
		/// <param name="tAction"></param>
		private void OnCreatureAttacks(TargetAction tAction)
		{
			if (tAction.AttackerSkillId != SkillId.MagnumShot)
				return;

			var attackerSkill = tAction.Attacker.Skills.Get(SkillId.MagnumShot);

			if (attackerSkill != null)
			{
				attackerSkill.Train(1); // Attack an enemy.
				if (tAction.Has(TargetOptions.Critical))
					attackerSkill.Train(2);

				if (tAction.Creature.IsDead)  // Kill an enemy.
				{
					attackerSkill.Train(3);
					if (tAction.Has(TargetOptions.Critical))
						attackerSkill.Train(4);
				}
			}
		}
开发者ID:aura-project,项目名称:aura,代码行数:25,代码来源:MagnumShot.cs

示例10: Training

		/// <summary>
		/// Trains the skill for attacker and target, based on what happened.
		/// </summary>
		/// <param name="aAction"></param>
		/// <param name="tAction"></param>
		public void Training(AttackerAction aAction, TargetAction tAction)
		{
			var attackerSkill = aAction.Creature.Skills.Get(SkillId.Counterattack);
			var targetSkill = tAction.Creature.Skills.Get(SkillId.Counterattack);

			if (attackerSkill.Info.Rank == SkillRank.RF)
			{
				attackerSkill.Train(2); // Successfully counter enemy's attack.

				if (tAction.SkillId == SkillId.Smash)
					attackerSkill.Train(4); // Counter enemy's special attack.

				if (tAction.Has(TargetOptions.Critical))
					attackerSkill.Train(5); // Counter with critical hit.
			}
			else
			{
				attackerSkill.Train(1); // Successfully counter enemy's attack.

				if (tAction.SkillId == SkillId.Smash)
					attackerSkill.Train(2); // Counter enemy's special attack.

				if (tAction.Has(TargetOptions.Critical))
					attackerSkill.Train(4); // Counter with critical hit.
			}

			if (targetSkill != null)
				targetSkill.Train(3); // Learn from the enemy's counter attack.
			else if (tAction.Creature.LearningSkillsEnabled)
				tAction.Creature.Skills.Give(SkillId.Counterattack, SkillRank.Novice); // Obtaining the Skill
		}
开发者ID:ripxfrostbite,项目名称:aura,代码行数:36,代码来源:Counterattack.cs

示例11: Use

		/// <summary>
		/// Uses the skill.
		/// </summary>
		/// <param name="attacker"></param>
		/// <param name="skill"></param>
		/// <param name="targetEntityId"></param>
		/// <returns></returns>
		public CombatSkillResult Use(Creature attacker, Skill skill, long targetEntityId)
		{
			// Get target
			var target = attacker.Region.GetCreature(targetEntityId);
			if (target == null)
				return CombatSkillResult.InvalidTarget;

			if (target.IsNotReadyToBeHit)
				return CombatSkillResult.Okay;

			// Actions
			var cap = new CombatActionPack(attacker, skill.Info.Id);

			var aAction = new AttackerAction(CombatActionType.RangeHit, attacker, skill.Info.Id, targetEntityId);
			aAction.Set(AttackerOptions.Result);
			aAction.Stun = AttackerStun;
			cap.Add(aAction);

			// Hit by chance
			var chance = attacker.AimMeter.GetAimChance(target);
			var rnd = RandomProvider.Get();
			if (rnd.NextDouble() * 100 < chance)
			{
				aAction.Set(AttackerOptions.KnockBackHit2);

				var tAction = new TargetAction(CombatActionType.TakeHit, target, attacker, skill.Info.Id);
				tAction.Set(TargetOptions.Result | TargetOptions.CleanHit);
				tAction.Stun = TargetStun;
				cap.Add(tAction);

				// Damage
				var damage = this.GetDamage(attacker, skill);

				// More damage with fire arrow
				if (attacker.Temp.FireArrow)
					damage *= FireBonus;

				// Critical Hit
				var critShieldReduction = (target.LeftHand != null ? target.LeftHand.Data.DefenseBonusCrit : 0);
				var critChance = attacker.GetRightCritChance(target.Protection + critShieldReduction);
				CriticalHit.Handle(attacker, critChance, ref damage, tAction);

				var maxDamage = damage; //Damage without Defense and Protection
				// Subtract target def/prot
				SkillHelper.HandleDefenseProtection(target, ref damage);

				// Defense
				Defense.Handle(aAction, tAction, ref damage);

				// Mana Shield
				ManaShield.Handle(target, ref damage, tAction, maxDamage);

				// Deal with it!
				if (damage > 0)
					target.TakeDamage(tAction.Damage = damage, attacker);

				// TODO: We have to calculate knockback distance right
				// TODO: Target with Defense and shield shouldn't be knocked back
				attacker.Shove(target, KnockBackDistance);

				// Aggro
				target.Aggro(attacker);

				tAction.Set(TargetOptions.KnockDownFinish);

				if (target.IsDead)
				{
					aAction.Set(AttackerOptions.KnockBackHit1);
					tAction.Set(TargetOptions.Finished);
				}

				var weapon = attacker.RightHand;
				var critSkill = attacker.Skills.Get(SkillId.CriticalHit);
				if (skill.Info.Rank >= SkillRank.R5 && weapon != null && weapon.Data.SplashRadius != 0 && weapon.Data.SplashAngle != 0)
				{
					ICollection<Creature> targets = attacker.GetTargetableCreaturesInCone(weapon != null ? (int)weapon.Data.SplashRadius : 200, weapon != null ? (int)weapon.Data.SplashAngle : 20);
					foreach (var splashTarget in targets)
					{
						if (splashTarget != target)
						{
							if (splashTarget.IsNotReadyToBeHit)
								continue;
							TargetAction tSplashAction = new TargetAction(CombatActionType.TakeHit, splashTarget, attacker, skill.Info.Id);
							tSplashAction.Set(TargetOptions.Result | TargetOptions.CleanHit);
							splashTarget.Stun = TargetStun;

							// Base damage
							var damageSplash = this.GetDamage(attacker, skill);

							// Critical Hit

							if (critSkill != null && tAction.Has(TargetOptions.Critical))
							{
//.........这里部分代码省略.........
开发者ID:xKamuna,项目名称:aura,代码行数:101,代码来源:MagnumShot.cs

示例12: Use

        public CombatSkillResult Use(Creature attacker, Skill skill, long targetEntityId)
        {
            if (attacker.IsStunned)
                return CombatSkillResult.Okay;

            var target = attacker.Region.GetCreature(targetEntityId);
            if (target == null)
                return CombatSkillResult.Okay;

            if (!attacker.GetPosition().InRange(target.GetPosition(), attacker.AttackRangeFor(target)))
                return CombatSkillResult.OutOfRange;

            attacker.StopMove();
            var targetPosition = target.StopMove();

            var rightWeapon = attacker.Inventory.RightHand;
            var leftWeapon = attacker.Inventory.LeftHand;
            var magazine = attacker.Inventory.Magazine;
            var dualWield = (rightWeapon != null && leftWeapon != null);
            var maxHits = (byte)(dualWield ? 2 : 1);
            int prevId = 0;

            for (byte i = 1; i <= maxHits; ++i)
            {
                var weapon = (i == 1 ? rightWeapon : leftWeapon);

                var cap = new CombatActionPack(attacker, skill.Info.Id);
                var aAction = new AttackerAction(CombatActionType.Hit, attacker, skill.Info.Id, targetEntityId);
                var tAction = new TargetAction(CombatActionType.TakeHit, target, attacker, skill.Info.Id);
                cap.Add(aAction, tAction);

                cap.Hit = i;
                cap.MaxHits = maxHits;
                cap.PrevId = prevId;
                prevId = cap.Id;

                aAction.Set(AttackerOptions.Result);
                if (dualWield)
                    aAction.Set(AttackerOptions.DualWield);

                var damage = attacker.GetRndDamage(weapon);
                tAction.Damage = damage;

                target.TakeDamage(tAction.Damage, attacker);

                if (!target.IsDead)
                {
                    target.KnockBack += this.GetKnockBack(weapon) / maxHits;
                    if (target.KnockBack >= 100 && target.Is(RaceStands.KnockBackable))
                        tAction.Set(tAction.Has(TargetOptions.Critical) ? TargetOptions.KnockDown : TargetOptions.KnockBack);
                }
                else
                {
                    tAction.Set(TargetOptions.FinishingKnockDown);
                }

                if (tAction.IsKnockBack)
                {
                    var newPos = attacker.GetPosition().GetRelative(targetPosition, KnockBackDistance);

                    Position intersection;
                    if (target.Region.Collissions.Find(targetPosition, newPos, out intersection))
                        newPos = targetPosition.GetRelative(intersection, -50);

                    target.SetPosition(newPos.X, newPos.Y);

                    aAction.Set(AttackerOptions.KnockBackHit2);

                    cap.MaxHits = cap.Hit;
                }

                aAction.Stun = this.GetAttackerStun(weapon, tAction.IsKnockBack);
                tAction.Stun = this.GetTargetStun(weapon, tAction.IsKnockBack);

                cap.Handle();

                if (tAction.IsKnockBack)
                    break;
            }

            return CombatSkillResult.Okay;
        }
开发者ID:pie3467,项目名称:aura,代码行数:82,代码来源:CombatMastery.cs


注:本文中的TargetAction.Has方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。