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);
        }
Exemple #2
0
        public override void Attack()
        {
            General.Momentum = 0;
            var targetProcess = new TargetProcess();

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

            ProcessLog.AttackUnit      = _ability.AttackUnit;
            ProcessLog.AttackType      = _ability.AttackType;
            ProcessLog.AttackTaget     = _ability.AttackTaget;
            ProcessLog.AbilityProperty = _ability.AbilityProperty;
            ProcessLog.AttEffectID     = _ability.EffectID1;
            ProcessLog.TargetEffectID  = _ability.EffectID2;
            ProcessLog.FntHeadID       = _ability.FntHeadID;
            ProcessLog.AbilityID       = _ability.AbilityID;
            ProccessExtendAttack();
            DoAbilityStatus(targetProcess);

            TagetGeneral.ForeachAbilityStatus(effectStatus =>
            {
                //增减技能不加入
                if (effectStatus.TotalBoutNum == effectStatus.BoutNum ||
                    (!effectStatus.IsZengyi && effectStatus.AbilityType != AbilityType.Qishi))
                {
                    if (effectStatus.BoutNum > 0)
                    {
                        targetProcess.DamageStatusList.Add(effectStatus.Copy());
                    }
                }
            });
            targetProcess.TargetStatus = TagetGeneral.BattleStatus;

            ProcessLog.TargetList.Add(targetProcess);
            ProcessLog.Momentum  = General.Momentum;
            ProcessLog.LiveNum   = General.LifeNum;
            ProcessLog.AttStatus = General.BattleStatus;
            ProcessLog.IsMove    = General.TempAbility.IsMove;
            string[] abilityTypeArray = _ability.AbilityType.Split(',');
            foreach (var s in abilityTypeArray)
            {
                General.Momentum = s.ToInt() == AbilityType.Qishi.ToInt()
                                       ? MathUtils.Addition(General.Momentum, _ability.BaseEffectNum.ToShort())
                                       : General.Momentum;
            }
        }
Exemple #3
0
 /// <summary>
 /// 伤害类型魂技
 /// </summary>
 /// <param name="targetProcess"></param>
 private void DoHarmAttack(TargetProcess targetProcess)
 {
     if (_ability.AttackType == AttackType.Harm)
     {
         int damageNum;
         if (_ability.AbilityProperty == AbilityProperty.Ability)
         {
             damageNum = GetAbilityDamageNum(TagetGeneral);
         }
         else
         {
             damageNum = GetPhysicalDamageNum(TagetGeneral);
         }
         DoTargetDefense(damageNum, targetProcess, true);
     }
 }
Exemple #4
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);
                }
            }
        }
Exemple #5
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;
        }
Exemple #6
0
        /// <summary>
        /// 处理技能效果
        /// </summary>
        /// <param name="targetProcess"></param>
        /// <param name="abilityEffectStatus"></param>
        private void ProcessAbilityEffect(TargetProcess targetProcess, AbilityEffectStatus[] abilityEffectStatus)
        {
            foreach (AbilityEffectStatus effect in abilityEffectStatus)
            {
                //立即生效技能

                //没有配置技能效果,处理普通功击
                if (effect.IsSilentStatus)
                {
                    AddDeamgeStatus(effect);
                }
                else if (effect.IsInjuredStatus)
                {
                    //计算持续伤害值
                    if (effect.BoutNum > 0)
                    {
                        if (General.TempAbility.RatioIncreaseNum > 0)
                        {
                            effect.DamageNum = (int)Math.Floor(TagetGeneral.DamageNum * General.TempAbility.RatioIncreaseNum);
                        }
                        else
                        {
                            new BaseLog().SaveLog(new Exception("技能ID:" + General.TempAbility.AbilityID + "续伤害值系数为0"));
                        }
                    }
                    AddDeamgeStatus(effect);
                }
                else if (effect.AbilityType == AbilityType.Hunluan)
                {
                    AddDeamgeStatus(effect);
                }
                else if (effect.AbilityType == AbilityType.ShengMing)
                {
                    effect.BoutNum = 1;//固定一会合
                    AddDeamgeStatus(effect);
                    //加血类不扣防御方,
                    var lifeNum = GetAbilityDamageNum(null);
                    if (effect.IsIncrease)
                    {
                        TagetGeneral.LifeNum += lifeNum;
                    }
                    else
                    {
                        TagetGeneral.LifeNum -= lifeNum;
                    }
                    TagetGeneral.LifeNum = MathUtils.Subtraction(TagetGeneral.LifeNum, 0, 0);
                    TagetGeneral.LifeNum = MathUtils.Addition(TagetGeneral.LifeNum, 0, TagetGeneral.LifeMaxNum);

                    targetProcess.LiveNum   = TagetGeneral.LifeNum;
                    targetProcess.DamageNum = effect.IsIncrease ? -lifeNum : lifeNum;//负数客户端是加血
                }
                else if (effect.AbilityType == AbilityType.Qishi)
                {
                    effect.BoutNum = 1;//固定一会合
                    AddDeamgeStatus(effect);
                    //固定值
                    var momentum = effect.BaseNum.ToShort();
                    if (effect.IsIncrease)
                    {
                        TagetGeneral.Momentum += momentum;
                    }
                    else
                    {
                        TagetGeneral.Momentum -= momentum;
                    }
                    TagetGeneral.Momentum  = MathUtils.Subtraction(TagetGeneral.Momentum, (short)0, (short)0);
                    TagetGeneral.Momentum  = MathUtils.Addition(TagetGeneral.Momentum, (short)0, CombatGeneral.MomentumOut);
                    targetProcess.Momentum = TagetGeneral.Momentum;
                    effect.DamageNum       = momentum;
                }
                else if (effect.AbilityType == AbilityType.Jueduifangyu)
                {
                    //固定伤害
                    AddDeamgeStatus(effect);
                }
                else if (effect.IsZengyi)
                {
                    //增加属性效果
                    if (effect.IsIncrease)
                    {
                        ProcessLog.DamageStatusList.Add(effect.Copy());
                        if (effect.BoutNum > 0)
                        {
                            effect.BoutNum = MathUtils.Subtraction(effect.BoutNum, 1, 0);
                        }
                        General.AddDamageStatus(effect);
                    }
                    else
                    {
                        AddDeamgeStatus(effect);
                    }
                }
            }
        }