/// <summary> /// 获取防御力(物,魂,魔)+ 触发的技能加成 /// </summary> /// <returns></returns> public int GetDefenseNum(AbilityProperty property, CombatGeneral tagetGeneral) { var DefenseRatio = ConfigEnvSet.GetDecimal("Combat.DefenseRatio"); int defenseNum = 0; switch (property) { case AbilityProperty.Physical: bool tType = false; decimal tpLvPercent = GetLvPercent(tagetGeneral, out tType); defenseNum = IsMonster ? PhyDefenseNum : (int)Math.Floor(this.PowerNum * this.Lv * DefenseRatio); defenseNum = MathUtils.Addition(defenseNum, ExtraDefense.WuliNum, int.MaxValue); defenseNum = (int)Math.Floor(TriggerAbilityEffectNum(AbilityType.WuLiFangYu, defenseNum)); if (!tType) { defenseNum = MathUtils.Subtraction(defenseNum, (tpLvPercent * defenseNum).ToInt()); } else { defenseNum = MathUtils.Addition(defenseNum, (tpLvPercent * defenseNum).ToInt()); } defenseNum = MathUtils.Addition(defenseNum, ExtraDefense.AdditionWuliNum * defenseNum).ToInt(); break; case AbilityProperty.Ability: defenseNum = IsMonster ? AbiDefenseNum : (int)Math.Floor(this.SoulNum * this.Lv * DefenseRatio); defenseNum = MathUtils.Addition(defenseNum, ExtraDefense.HunjiNum, int.MaxValue); defenseNum = (int)Math.Floor(TriggerAbilityEffectNum(AbilityType.HunJiFangYu, defenseNum)); defenseNum = MathUtils.Addition(defenseNum, ExtraDefense.AdditionHunjiNum * defenseNum).ToInt(); break; case AbilityProperty.Magic: defenseNum = IsMonster ? MagDefenseNum : (int)Math.Floor(this.IntellectNum * this.Lv * DefenseRatio); defenseNum = MathUtils.Addition(defenseNum, ExtraDefense.MofaNum, int.MaxValue); defenseNum = (int)Math.Floor(TriggerAbilityEffectNum(AbilityType.MoFaFangYu, defenseNum)); defenseNum = MathUtils.Addition(defenseNum, ExtraDefense.AdditionMofaNum * defenseNum).ToInt(); break; default: break; } if (!defenseNum.IsValid()) { defenseNum = 0; } return(defenseNum); }
/// <summary> /// 触发爆击概率 /// </summary> /// <param name="tagetGeneral"></param> /// <param name="baojiPercent"></param> /// <returns></returns> public bool TriggerBaojiPercent(CombatGeneral tagetGeneral, out decimal baojiPercent) { bool tType = false; decimal tpLvPercent = GetLvPercent(tagetGeneral, out tType); baojiPercent = this.BaojiNum + TriggerAbilityEffectNum(AbilityType.BaoJi, 1); decimal renxingPercent = tagetGeneral.RenxingNum + tagetGeneral.TriggerAbilityEffectNum(AbilityType.RenXing, 1); baojiPercent = MathUtils.Subtraction(baojiPercent, renxingPercent, 0); if (!tType) { baojiPercent = MathUtils.Addition(baojiPercent, tpLvPercent); } else { baojiPercent = MathUtils.Subtraction(baojiPercent, tpLvPercent, 0); } return(RandomUtils.IsHit(baojiPercent)); }
/// <summary> /// 等级差压制 /// </summary> /// <param name="tagetGeneral"></param> /// <param name="tType">False:攻击方等级高,True:被攻击方等级高</param> /// <returns></returns> private decimal GetLvPercent(CombatGeneral tagetGeneral, out bool tType) { tType = false; var lvrate = ConfigEnvSet.GetDecimal("Combat.LvPercentRate"); var subLv = 0; if (tagetGeneral.Lv > this.Lv) { tType = true; subLv = MathUtils.Subtraction(tagetGeneral.Lv, this.Lv, (short)0); } else { subLv = MathUtils.Subtraction(this.Lv, tagetGeneral.Lv, (short)0); } var val = subLv * lvrate; return(val); }
/// <summary> /// 触发格挡概率 /// </summary> /// <param name="tagetGeneral"></param> /// <param name="gedangPercent"></param> /// <returns></returns> public bool TriggerGeDangPercent(CombatGeneral tagetGeneral, out decimal gedangPercent) { //原因:等级压制 bool tType = false; decimal tpLvPercent = GetLvPercent(tagetGeneral, out tType); gedangPercent = this.GedangNum + TriggerAbilityEffectNum(AbilityType.GeDang, 1); decimal pojiNumPercent = tagetGeneral.PojiNum + tagetGeneral.TriggerAbilityEffectNum(AbilityType.PoJi, 1); if (!tType) { pojiNumPercent = MathUtils.Subtraction(pojiNumPercent, tpLvPercent); } else { pojiNumPercent = MathUtils.Addition(pojiNumPercent, tpLvPercent); } gedangPercent = MathUtils.Subtraction(gedangPercent, pojiNumPercent, 0); return(RandomUtils.IsHit(gedangPercent)); }
/// <summary> /// 触发命中概率 /// </summary> /// <param name="general"></param> /// <param name="tpLvPercent"></param> /// <param name="percent"></param> /// <returns></returns> public bool TriggerHitPercent(CombatGeneral tagetGeneral, out decimal hitPercent) { //int tType = 0; //decimal tpLvPercent = GetLvPercent(tagetGeneral, out tType); hitPercent = HitNum + TriggerAbilityEffectNum(AbilityType.MingZhong, 1); decimal shanbiPercent = tagetGeneral.ShanbiNum + tagetGeneral.TriggerAbilityEffectNum(AbilityType.ShanBi, 1); hitPercent = MathUtils.Subtraction(hitPercent, shanbiPercent, 0); //原因:增加最小概率 decimal minHitNum = ConfigEnvSet.GetDecimal("Combat.MinHitPercent"); if (minHitNum == 0) { minHitNum = (decimal)0.4; } if (hitPercent < minHitNum) { hitPercent = minHitNum; } return(RandomUtils.IsHit(hitPercent)); }