/// <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); }
/// <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; }
/// <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); }
public bool Doing() { List <EmbattleQueue> queueList = GetPriorityQueue(); if (queueList.Count != 2) { return(false); } EmbattleQueue roleA = queueList[0]; EmbattleQueue roleD = queueList[1]; //原因:空阵BUG if (roleA.GeneralCount == 0 && roleD.GeneralCount == 0) { new BaseLog().SaveLog("战斗双方佣兵不存在"); return(false); } if (roleA.Role == EmbattleRole.RoleA) { if (roleA.GeneralCount > 0 && roleD.GeneralCount == 0) { return(true); } if (roleA.GeneralCount == 0 && roleD.GeneralCount > 0) { return(false); } } else if (roleA.Role == EmbattleRole.RoleD) { if (roleA.GeneralCount > 0 && roleD.GeneralCount == 0) { return(false); } if (roleA.GeneralCount == 0 && roleD.GeneralCount > 0) { return(true); } } queueList.ForEach(item => { var general = (CombatGeneral)item.NextGeneral(); if (general != null) { general.SelfAbilityInfoList.ForEach(SelfAbility => { SelfAbilityEffect selfAbilityEffect = new SelfAbilityEffect(); selfAbilityEffect.GeneralID = general.GeneralID; selfAbilityEffect.EffectID1 = SelfAbility.EffectID1; selfAbilityEffect.FntHeadID = SelfAbility.FntHeadID; selfAbilityEffect.IsIncrease = SelfAbility.IsIncrease; selfAbilityEffect.Position = general.Position; selfAbilityEffect.Role = item.Role.ToShort(); processContainer.SelfAbilityEffectList.Add(selfAbilityEffect); }); } }); //原因:闪避高时死锁 bool isCombatOut = false; int index = 0; while (roleA.HasCombat() && roleD.HasCombat()) { if (index >= MaxCount) { isCombatOut = true; //防止死锁 new BaseLog().SaveLog(string.Format("[{0}]战斗超出最大回合数,判攻方输", _combatType)); break; } //设置重新一轮 roleA.ResetGeneralQueue(); roleD.ResetGeneralQueue(); DoSingle(queueList); index++; } foreach (var item in priorityList) { if (item.Number > BoutNum) { BoutNum = item.Number; } //恢复血量 double resumeLife = ConfigEnvSet.GetDouble("Combat.ResumeLifeNum"); //领土战直接恢复100% if (_combatType == CombatType.Country && item.IsOver) { resumeLife = 1; } if ((_combatType == CombatType.Country && item.IsOver) || (_combatType != CombatType.Country && item.IsOver)) { if (item.Role == EmbattleRole.RoleA) { DoResumeLife(processContainer.AttackList, resumeLife); } else { DoResumeLife(processContainer.DefenseList, resumeLife); } } } ; //超出判断攻方输 if (isCombatOut && roleA.Role == EmbattleRole.RoleA) { return(false); } if (isCombatOut && roleA.Role == EmbattleRole.RoleD) { return(true); } return(!priorityList.Find(m => m.Role == EmbattleRole.RoleA).IsOver); }