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);
        }
Example #2
0
        /// <summary>
        /// 计算伤害公式
        /// 攻击伤害 = 攻击力 - 物理防御力
        /// </summary>
        /// <param name="tagetGeneral">加血等辅助技能时可能为空值</param>
        /// <returns></returns>
        protected int GetPhysicalDamageNum(CombatGeneral tagetGeneral)
        {
            AbilityProperty property = General.AbilityProperty;

            ProcessLog.AbilityProperty = property;
            int     damageNum;
            int     attackNum;
            int     defenseNum = 0;
            decimal harmNum    = 0; //法宝属相克制伤害 --技能攻击

            attackNum = General.GetAttackNum(property);
            if (tagetGeneral != null)
            {
                harmNum    = TrumpAbilityAttack.TrumpZodiacHarm(General, tagetGeneral.UserID);
                defenseNum = tagetGeneral.GetDefenseNum(property, tagetGeneral);
                //普通攻击破防
                decimal normalAttackPoFang = TrumpAbilityAttack.GetEffect(General, AbilityType.NormalAttackPoFang);
                if (normalAttackPoFang > 0)
                {
                    ProcessLog.TrumpStatusList.Add(TrumpAbilityAttack.GetSkillprocess(AbilityType.NormalAttackPoFang, 0));
                }
                defenseNum = (int)Math.Floor(MathUtils.Subtraction(defenseNum, defenseNum * normalAttackPoFang));
            }
            General.MinDamageNum = (int)Math.Ceiling(attackNum * ConfigEnvSet.GetDouble("Combat.MinDamagePencent"));

            damageNum = MathUtils.Subtraction(attackNum, defenseNum, General.MinDamageNum);

            //加固定伤害
            damageNum = MathUtils.Addition(damageNum, General.FixedDamageNum, int.MaxValue);

            //法宝属相克制伤害 --技能攻击
            if (harmNum > 0 && !isPyharm)
            {
                damageNum = (int)(damageNum * MathUtils.Addition(1, (harmNum + General.EffectValue)));
                isPyharm  = true;
            }

            return(damageNum);
        }
Example #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;
        }