예제 #1
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);
        }
예제 #2
0
        /// <summary>
        /// 计算技能伤害公式,不产生负数
        /// </summary>
        /// <param name="tagetGeneral"></param>
        /// <returns></returns>
        protected int GetAbilityDamageNum(CombatGeneral tagetGeneral)
        {
            string traceStr = string.Empty;
            int    damageNum;
            int    attackNum;
            int    defenseNum = 0;

            decimal         harmNum  = 0; //法宝属相克制伤害 --技能攻击
            AbilityProperty property = General.AbilityProperty;

            ProcessLog.AbilityProperty = property;
            attackNum = General.GetAttackNum(AbilityProperty.Ability) + General.GetAttackNum(property);
            if (tagetGeneral != null)
            {
                //法宝属相克制伤害 --技能攻击
                harmNum = TrumpAbilityAttack.TrumpZodiacHarm(General, tagetGeneral.UserID);

                defenseNum = tagetGeneral.GetDefenseNum(AbilityProperty.Ability, tagetGeneral) + tagetGeneral.GetDefenseNum(property, tagetGeneral);
            }
            General.MinDamageNum = (int)Math.Ceiling(attackNum * ConfigEnvSet.GetDouble("Combat.MinDamagePencent"));
            damageNum            = MathUtils.Subtraction(attackNum, defenseNum, General.MinDamageNum);

            decimal ratioNum = General.TempAbility.RatioNum > 0 ? General.TempAbility.RatioNum : 1;

            damageNum = (int)Math.Floor(damageNum * ratioNum); //计算伤害系数
            //气势加成=气势/{100-(气势-100)*2/3}*100%
            if (General != null)
            {
                var qishiNum = General.Momentum == 0 ? (short)100 : General.Momentum;
                traceStr += "qishiNum:" + qishiNum;
                decimal qishiPercent = (decimal)qishiNum / 100;
                traceStr += "qishiPercent:" + qishiNum;
                damageNum = (int)Math.Floor(damageNum * qishiPercent);
                traceStr += "damageNum:" + qishiNum;
                //加固定伤害
                damageNum = MathUtils.Addition(damageNum, General.FixedDamageNum, int.MaxValue);
                traceStr += "FixedDamageNum:" + qishiNum;
            }
            //技能伤害,负数是增加,
            //damageNum = General != null && General.Ability.IsIncrease ? -damageNum : damageNum;
            if (damageNum == 0)
            {
                new BaseLog().SaveLog(new Exception("释放技能:" + General.TempAbility.AbilityName + General.TempAbility.AbilityID + "伤害为0,Trace:" + traceStr));
            }
            if (damageNum < General.MinDamageNum)
            {
                damageNum = General.MinDamageNum;
            }
            //法宝属相克制伤害 --技能攻击
            if (!isharm && harmNum > 0)
            {
                damageNum = (int)(damageNum * MathUtils.Addition(1, harmNum));
                isharm    = true;
            }
            //魂技等级与自身魂技加成

            int     abilityID   = General.TempAbility != null ? General.TempAbility.AbilityID : 0;
            decimal effectValue = AbilityDispose.GetAbilityEffect(General.UserID, General.GeneralID, abilityID);

            if (effectValue > 0)
            {
                damageNum = MathUtils.ToCeilingInt(damageNum * MathUtils.Addition(1, (effectValue)));
            }
            return(damageNum);
        }