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


C# Unit.CalcCritDamage方法代码示例

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


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

示例1: DoSpellDamage

		/// <summary>
		/// Does spell-damage to this Unit
		/// </summary>
		public void DoSpellDamage(Unit attacker, SpellEffect effect, int dmg)
		{
			DamageSchool school;
			if (effect != null)
			{
				school = GetLeastResistant(effect.Spell);
				if (effect.Spell.DamageIncreasedByAP)
				{
					int ap;
					if (effect.Spell.IsRangedAbility)
					{
						ap = TotalRangedAP;
					}
					else
					{
						ap = TotalMeleeAP;
					}

					dmg += (ap + 7) / 14;	// round
				}
			}
			else
			{
				school = DamageSchool.Physical;
			}

			if (IsEvading || IsImmune(school) || IsInvulnerable || !IsAlive)
			{
				return;
			}

			var action = attacker != null ? attacker.m_DamageAction : m_DamageAction;
			if (action == null || action.IsInUse)
			{
				// currently in use
				action = new DamageAction(attacker);
			}
			else
			{
				action.Attacker = attacker;
				action.HitFlags = 0;
				action.VictimState = 0;
				action.Weapon = null;
			}

			if (effect != null)
			{
				action.UsedSchool = school;
				action.Schools = effect.Spell.SchoolMask;
				action.IsDot = effect.IsPeriodic;
			}
			else
			{
				action.UsedSchool = DamageSchool.Physical;
				action.Schools = DamageSchoolMask.Physical;
				action.IsDot = false;
			}

			action.Damage = dmg;
			action.ResistPct = GetResistChancePct(this, action.UsedSchool);

			action.Victim = this;

			if (attacker != null)
			{
				attacker.AddDamageMods(action);

				if (effect != null && !action.IsDot && !effect.Spell.AttributesExB.HasFlag(SpellAttributesExB.CannotCrit) &&
					attacker.CalcSpellCritChance(this, action.UsedSchool, action.ResistPct, effect.Spell) > Utility.Random(0f, 100f))
				{
					action.Damage = attacker.CalcCritDamage(action.ActualDamage, this, effect).RoundInt();
					action.IsCritical = true;
				}
				else
				{
					action.IsCritical = false;
				}
			}


			action.Absorbed = Absorb(action.UsedSchool, action.Damage);
			action.Resisted = (int)Math.Round(action.Damage * action.ResistPct / 100);
			action.Blocked = 0; // TODO: Deflect
			action.SpellEffect = effect;

			//TODO: figure this out: However, when spells do only damage, it's not just a full hit or full miss situation. Pure damage spells can be resisted for 0%, 25%, 50%, 75%, or 100% of their regular damage. 

			DoRawDamage(action);
			CombatLogHandler.SendMagicDamage(action);
			action.OnFinished();
			//Your average resistance can still be anywhere betweeen 0% and 75%. If your average resistance is maxed out, then there's a really good chance of having 75% of the spell's damage be resisted. 
			//There's also a fairly good chance of having 100% of the spell's damage be resisted, a slightly lower chance of 50% of its damage being resisted, a small chances of only 25%, or even 0% of the damage being resisted. 
			//It's a weighted average. Visualize it as a bell curve around your average resistance.
		}
开发者ID:WCellFR,项目名称:WCellFR,代码行数:97,代码来源:Unit.Combat.cs


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