public override void Attack()
        {
            TargetProcess targetProcess = new TargetProcess();

            targetProcess.GeneralID = TagetGeneral.GeneralID;
            targetProcess.Position  = TagetGeneral.Position.ToShort();
            targetProcess.Role      = TagetRole;
            targetProcess.LiveNum   = TagetGeneral.LifeNum;
            targetProcess.Momentum  = TagetGeneral.Momentum;

            ProccessExtendAttack();
            int     damageNum  = GetPhysicalDamageNum(TagetGeneral);
            decimal hitPercent = 0;
            bool    isHit      = General.TriggerHitPercent(TagetGeneral, out hitPercent);

            ProcessLog.AddPercent(1, hitPercent);
            if (isHit)
            {
                targetProcess.IsShanBi = false;
                //普通攻击\防御加气势
                General.Momentum = MathUtils.Addition(General.Momentum, MomentumAttack, short.MaxValue);
                if (!TagetGeneral.IsJueduifangyuStatus)
                {
                    TagetGeneral.Momentum = MathUtils.Addition(TagetGeneral.Momentum, MomentumDefense, short.MaxValue);
                }
                DoTargetDefense(damageNum, targetProcess, false);
                //攻击加血
                decimal attackLife = TrumpAbilityAttack.GetEffect(General, AbilityType.AttackLife);
                if (attackLife > 0)
                {
                    ProcessLog.TrumpStatusList.Add(TrumpAbilityAttack.GetSkillprocess(AbilityType.AttackLife, -(int)(damageNum * attackLife)));
                    General.LifeNum = (int)Math.Floor(MathUtils.Addition(General.LifeNum, damageNum * attackLife, General.LifeMaxNum));
                }

                //反伤
                decimal fangShang = TrumpAbilityAttack.GetEffect(TagetGeneral, AbilityType.FanShang);
                if (fangShang > 0)
                {
                    int num = (int)(damageNum * fangShang);
                    targetProcess.TrumpStatusList.Add(TrumpAbilityAttack.GetSkillprocess(AbilityType.FanShang, num));
                    General.LifeNum = (int)Math.Floor(MathUtils.Subtraction(General.LifeNum, damageNum * fangShang));
                }
            }
            else
            {
                targetProcess.IsShanBi = true;
                TagetGeneral.TriggerShanBi();
            }
            targetProcess.Momentum     = TagetGeneral.Momentum;
            targetProcess.TargetStatus = TagetGeneral.BattleStatus;
            ProcessLog.Momentum        = General.Momentum;
            ProcessLog.LiveNum         = General.LifeNum;
            ProcessLog.AttStatus       = General.BattleStatus;
            ProcessLog.IsMove          = General.IsMove;
            ProcessLog.TargetList.Add(targetProcess);
        }
Beispiel #2
0
        private void DoAbilityStatus(TargetProcess targetProcess)
        {
            //处理技能伤害
            decimal hitPercent;
            bool    isHit = General.TriggerHitPercent(TagetGeneral, out hitPercent);

            AbilityEffectStatus[] tempList = General.AbilityEffectList;
            decimal effectHit   = General.TempAbility.HitPercent; //技能命中概率
            bool    isEffectHit = IsProcessHit(tempList);         //是否要处理命中

            ProcessLog.AddPercent(1, hitPercent);
            if (isEffectHit && isHit)
            {
                targetProcess.IsShanBi = false;
                DoHarmAttack(targetProcess);


                //处理技能效果
                if (effectHit == 0 || RandomUtils.IsHit(effectHit))
                {
                    ProcessAbilityEffect(targetProcess, tempList);
                }
            }
            else if (isEffectHit)
            {
                targetProcess.IsShanBi = true;
            }
            else
            {
                //处理技能效果
                if (effectHit == 0 || RandomUtils.IsHit(effectHit))
                {
                    ProcessAbilityEffect(targetProcess, tempList);
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// 目标防御处理
        /// </summary>
        /// <param name="damageNum">伤害值</param>
        /// <param name="targetProcess"></param>
        /// <param name="isAbility">是否是技能伤害</param>
        protected void DoTargetDefense(int damageNum, TargetProcess targetProcess, bool isAbility)
        {
            //城市公会争斗战疲劳值
            var fatigue = General.Fatigue * GameConfigSet.Fatigue;

            if (fatigue > 0 && General.UserStatus == UserStatus.FightCombat)
            {
                damageNum = (int)Math.Floor(damageNum * (MathUtils.Subtraction(1, fatigue)));
            }

            //生命低于x%,战力加成
            double inspire = (double)TrumpAbilityAttack.GetEffect(General, AbilityType.Furious);

            if (inspire > 0)
            {
                ProcessLog.TrumpStatusList.Add(TrumpAbilityAttack.GetSkillprocess(AbilityType.Furious, 0));
                damageNum = (int)Math.Floor(damageNum * (1 + inspire));
            }

            //鼓舞加成伤害
            if (General.InspirePercent > 0)
            {
                damageNum = (int)Math.Floor(damageNum * (1 + General.InspirePercent));
            }

            //是否有爆击
            decimal baojiPercent;
            bool    isBaoji = General.TriggerBaojiPercent(TagetGeneral, out baojiPercent);

            ProcessLog.AddPercent(2, baojiPercent);
            if (isBaoji)
            {
                targetProcess.IsBaoji = true;
                damageNum             = (int)Math.Floor(damageNum * (1 + BaojiAttack + General.BishaNum));
                //暴击加成
                decimal baojiJiaCheng = TrumpAbilityAttack.GetEffect(General, AbilityType.BaoJiJiaCheng);
                if (baojiJiaCheng > 1)
                {
                    ProcessLog.TrumpStatusList.Add(TrumpAbilityAttack.GetSkillprocess(AbilityType.BaoJiJiaCheng, 0));
                    damageNum = (int)Math.Floor(damageNum * baojiJiaCheng);
                }

                //被暴击减免
                decimal baoJiReduce = TrumpAbilityAttack.GetEffect(TagetGeneral, AbilityType.IsBaoJiReduce);
                if (baoJiReduce < 1 && baoJiReduce > 0)
                {
                    targetProcess.TrumpStatusList.Add(TrumpAbilityAttack.GetSkillprocess(AbilityType.IsBaoJiReduce, 0));
                    damageNum = (int)Math.Floor(damageNum * baoJiReduce);
                }

                if (damageNum >= 0)
                {
                    damageNum = MathUtils.Subtraction(damageNum, 0, General.MinDamageNum);
                }
                else
                {
                    damageNum = -MathUtils.Subtraction(damageNum, 0, General.MinDamageNum);
                }
                //爆击职业加成气势
                CareerAdditionInfo addition = new ShareCacheStruct <CareerAdditionInfo>().FindKey(General.CareerID, AbilityType.BaoJi);
                if (addition != null && !isAbility)
                {
                    General.Momentum = MathUtils.Addition(General.Momentum, addition.MomentumNum.ToShort(), short.MaxValue);
                }
            }

            //排除静默和混乱不能触发格档
            bool isTriggerGedang = TagetGeneral.IsSilentStatus || TagetGeneral.IsHunluanStatus;


            //先触发绝对防御  法宝破盾技能为开启时触发绝对防御
            if (TagetGeneral.IsJueduifangyuStatus)
            {
                if (TrumpAbilityAttack.AttackPoDun(General, AbilityType.AttackPoDun))
                {
                    ProcessLog.TrumpStatusList.Add(TrumpAbilityAttack.GetSkillprocess(AbilityType.AttackPoDun, 0));
                }
                else
                {
                    damageNum = JueduiDefenseDamage;
                }
            }
            else if (!isTriggerGedang)
            {
                //是否产生格挡[?]
                decimal gedangPercent;
                var     fangjiNum = 0;
                var     isGedang  = TagetGeneral.TriggerGeDangPercent(General, out gedangPercent);
                ProcessLog.AddPercent(3, gedangPercent);
                if (isGedang)
                {
                    targetProcess.IsMove   = TagetGeneral.IsAttrMove;
                    targetProcess.IsGeDang = true;
                    damageNum = (int)Math.Floor(damageNum * GedangAttackPercent);
                    if (damageNum >= 0)
                    {
                        damageNum = MathUtils.Subtraction(damageNum, 0, General.MinDamageNum);
                    }
                    else
                    {
                        damageNum = -MathUtils.Subtraction(damageNum, 0, General.MinDamageNum);
                    }
                    if (TagetGeneral.CareerType != CareerType.Mofashi &&
                        TagetGeneral.CareerType != CareerType.Shenqiangshou)
                    {
                        AbilityProperty property = General.AbilityProperty;
                        //普通攻击力的50%
                        int attackNum    = TagetGeneral.GetAttackNum(property);
                        int defenseNum   = General.GetDefenseNum(property, TagetGeneral);
                        int minDamageNum = (int)Math.Ceiling(attackNum * ConfigEnvSet.GetDouble("Combat.MinDamagePencent"));

                        fangjiNum = MathUtils.Subtraction(attackNum, defenseNum, 0);
                        fangjiNum = (int)Math.Floor(fangjiNum * GedangAttackPercent);
                        fangjiNum = MathUtils.Subtraction(fangjiNum, 0, minDamageNum);

                        //没死才可扣反击伤害
                        if (TagetGeneral.LifeNum > damageNum)
                        {
                            General.TriggerDamageNum(fangjiNum);
                            ProcessLog.DamageNum       += fangjiNum;
                            ProcessLog.LiveNum          = General.LifeNum;
                            ProcessLog.AttStatus        = General.BattleStatus;
                            targetProcess.IsBack        = true;
                            targetProcess.BackDamageNum = fangjiNum;
                        }
                    }

                    //格挡职业加成气势
                    if (!isAbility)
                    {
                        TagetGeneral.TriggerGeDang();
                    }
                }
            }
            //扣物理攻击伤害
            TagetGeneral.TriggerDamageNum(damageNum);
            targetProcess.DamageNum = damageNum;
            //解除静默状态
            TagetGeneral.RemoveSilentStatus();

            if (TagetGeneral.IsOver)
            {
                //复活
                decimal resurrect = TrumpAbilityAttack.GetEffect(TagetGeneral, AbilityType.Resurrect);
                if (resurrect > 0)
                {
                    targetProcess.TrumpStatusList.Add(TrumpAbilityAttack.GetSkillprocess(AbilityType.Resurrect, -(int)Math.Floor(TagetGeneral.LifeMaxNum * resurrect)));
                    TagetGeneral.LifeNum = (int)Math.Floor(TagetGeneral.LifeMaxNum * resurrect);
                }
                else
                {
                    TrumpAbilityAttack.GeneralOverTrumpLift(TagetGeneral.UserID, TagetGeneral.GeneralID);  //佣兵战斗死亡扣除N点寿命
                    targetProcess.TrumpStatusList = new List <SkillInfo>();
                }
            }

            //记录日志
            targetProcess.TargetStatus = TagetGeneral.BattleStatus;
            targetProcess.Momentum     = TagetGeneral.Momentum;
            targetProcess.LiveNum      = TagetGeneral.LifeNum;
            TargetProcess = targetProcess;
        }