本文整理汇总了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.
}