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


C# MabiCreature.GetRndDamage方法代码示例

本文整理汇总了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);
//.........这里部分代码省略.........
开发者ID:Fuhhue,项目名称:aura_legacy,代码行数:101,代码来源:CombatMasteryHandler.cs


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