本文整理汇总了C#中Aura.World.World.MabiCreature.GetRndDamage方法的典型用法代码示例。如果您正苦于以下问题:C# MabiCreature.GetRndDamage方法的具体用法?C# MabiCreature.GetRndDamage怎么用?C# MabiCreature.GetRndDamage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Aura.World.World.MabiCreature
的用法示例。
在下文中一共展示了MabiCreature.GetRndDamage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UseCombat
public override SkillResults UseCombat(MabiCreature attacker, ulong targetId, MabiSkill skill)
{
var target = WorldManager.Instance.GetCreatureById(targetId);
if (target == null)
return SkillResults.InvalidTarget;
if (!WorldManager.InRange(attacker, target, (uint)(attacker.RaceInfo.AttackRange + 50)))
return SkillResults.OutOfRange;
if (attacker.IsStunned)
return SkillResults.AttackStunned;
attacker.StopMove();
target.StopMove();
// Check counter
var counter = CombatHelper.TryCounter(target, attacker);
if (counter != SkillResults.None)
return SkillResults.Okay;
uint prevCombatActionId = 0;
var rnd = RandomProvider.Get();
var rightHand = attacker.RightHand;
var leftHand = attacker.LeftHand;
if (leftHand != null && !leftHand.IsOneHandWeapon)
leftHand = null;
var sAction = new AttackerAction(CombatActionType.Hit, attacker, skill.Id, targetId);
sAction.Options |= AttackerOptions.Result;
if (rightHand != null && leftHand != null)
sAction.Options |= AttackerOptions.DualWield;
// Do this for two weapons, break if there is no second hit.
for (byte i = 1; i <= 2; ++i)
{
var weapon = (i == 1 ? rightHand : leftHand);
var atkSpeed = CombatHelper.GetAverageAttackSpeed(attacker);
var cap = new CombatActionPack(attacker, skill.Id);
cap.PrevCombatActionId = prevCombatActionId;
cap.Hit = i;
cap.HitsMax = (byte)(sAction.Has(AttackerOptions.DualWield) ? 2 : 1);
var tAction = new TargetAction(CombatActionType.TakeHit, target, attacker, skill.Id);
cap.Add(sAction, tAction);
// Damage
{
var damage = attacker.GetRndDamage(weapon);
var protection = target.Protection;
// Crit
if (CombatHelper.TryAddCritical(attacker, ref damage, attacker.CriticalChanceAgainst(target)))
tAction.Options |= TargetOptions.Critical;
// Def/Prot
CombatHelper.ReduceDamage(ref damage, target.DefenseTotal, protection);
// Mana Shield
tAction.ManaDamage = CombatHelper.DealManaDamage(target, ref damage);
// Deal Life Damage
if (damage > 0)
target.TakeDamage(tAction.Damage = damage);
}
// Killed?
if (target.IsDead)
{
tAction.Options |= TargetOptions.FinishingKnockDown;
attacker.Stun = sAction.StunTime = CombatHelper.GetStunSource(atkSpeed, tAction.IsKnock);
}
else
{
// Defense
if (target.HasSkillLoaded(SkillConst.Defense))
{
tAction.Type = CombatActionType.Defended;
tAction.SkillId = SkillConst.Defense;
target.Stun = tAction.StunTime = 1000;
attacker.Stun = sAction.StunTime = 2500;
}
// Normal hit
else
{
// Knock back
if (target.RaceInfo.Is(RaceStands.KnockBackable))
{
target.KnockBack += CombatHelper.GetKnockDown(weapon) / cap.HitsMax;
if (target.KnockBack >= CombatHelper.LimitKnockBack)
{
// Knock down if critical
tAction.Options |= (tAction.Has(TargetOptions.Critical) ? TargetOptions.KnockDown : TargetOptions.KnockBack);
}
}
attacker.Stun = sAction.StunTime = CombatHelper.GetStunSource(atkSpeed, tAction.IsKnock);
target.Stun = tAction.StunTime = CombatHelper.GetStunTarget(atkSpeed, tAction.IsKnock);
//.........这里部分代码省略.........