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); }
/// <summary> /// 国家战 /// </summary> /// <param name="cuser1">发起人</param> /// <param name="cuser2"></param> /// <returns></returns> public static ISingleCombat TriggerTournament(CountryUser cuser1, CountryUser cuser2) { TrumpAbilityAttack.CombatTrumpLift(cuser1.UserId); //法宝每战斗M次就扣除N点寿命 ICombatController controller = new TjxCombatController(); ISingleCombat plotCombater = controller.GetSingleCombat(CombatType.Country); plotCombater.SetAttack(new UserEmbattleQueue(cuser1.UserId, GetMagicId(cuser1.UserId), cuser1.InspirePercent, CombatType.Country)); plotCombater.SetDefend(new UserEmbattleQueue(cuser2.UserId, GetMagicId(cuser2.UserId), cuser2.InspirePercent, CombatType.Country)); return(plotCombater); }
/// <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); }
/// <summary> /// 人物属性 /// </summary> /// <param name="userID"></param> /// <param name="generalID"></param> /// <param name="abilityType"></param> /// <returns></returns> public static int GetPropertyNum(string userID, int generalID, AbilityType abilityType) { GameUser user = new PersonalCacheStruct <GameUser>().FindKey(userID); int propertyNum = 0; int powerNum = 0; //力量 int soulNum = 0; //魂力 int intellectNum = 0; //智力 int generalLv = 0; UserGeneral general = new PersonalCacheStruct <UserGeneral>().FindKey(userID, generalID); if (general != null) { generalLv = (int)general.GeneralLv; powerNum = (int)MathUtils.Addition(general.PowerNum, general.TrainingPower); soulNum = (int)MathUtils.Addition(general.SoulNum, general.TrainingSoul); intellectNum = (int)MathUtils.Addition(general.IntellectNum, general.TrainingIntellect); //公会技能加成 if (user != null && !string.IsNullOrEmpty(user.MercenariesID) && general.GeneralID == LanguageManager.GetLang().GameUserGeneralID) { powerNum = MathUtils.RoundCustom(powerNum * GetGuildAbilityNum(user.UserID, GuildAbilityType.PowerNum)).ToShort(); soulNum = MathUtils.RoundCustom(soulNum * GetGuildAbilityNum(user.UserID, GuildAbilityType.SoulNum)).ToShort(); intellectNum = MathUtils.RoundCustom(intellectNum * GetGuildAbilityNum(user.UserID, GuildAbilityType.IntellectNum)).ToShort(); } if (general.GeneralID == LanguageManager.GetLang().GameUserGeneralID) { //法宝基础属性加成 powerNum = MathUtils.Addition(powerNum, TrumpAbilityAttack.TrumpPropertyNum(userID, general.GeneralID, AbilityType.PowerNum)); soulNum = MathUtils.Addition(soulNum, TrumpAbilityAttack.TrumpPropertyNum(userID, general.GeneralID, AbilityType.SoulNum)); intellectNum = MathUtils.Addition(intellectNum, TrumpAbilityAttack.TrumpPropertyNum(userID, general.GeneralID, AbilityType.IntelligenceNum)); //法宝--技能属性转换获得的值 decimal trumpPower = TrumpAbilityAttack.ConversionPropertyNum(userID, powerNum, soulNum, intellectNum, AbilityType.PowerNum); decimal trumpsoul = TrumpAbilityAttack.ConversionPropertyNum(userID, powerNum, soulNum, intellectNum, AbilityType.SoulNum); decimal trumpintellect = TrumpAbilityAttack.ConversionPropertyNum(userID, powerNum, soulNum, intellectNum, AbilityType.IntelligenceNum); powerNum = MathUtils.Addition(trumpPower.ToInt(), powerNum); soulNum = MathUtils.Addition(trumpsoul.ToInt(), soulNum); intellectNum = MathUtils.Addition(trumpintellect.ToInt(), intellectNum); } if (abilityType == AbilityType.WuLiGongJi) { //物理攻击 propertyNum = (generalLv * powerNum * 1 / 10); } else if (abilityType == AbilityType.WuLiFangYu) { //物理防御 propertyNum = (generalLv * powerNum * 7 / 100); } else if (abilityType == AbilityType.HunJiGongJi) { //魂技攻击 propertyNum = (generalLv * soulNum * 7 / 100); } else if (abilityType == AbilityType.HunJiFangYu) { //魂技防御 propertyNum = (generalLv * soulNum * 7 / 100); } else if (abilityType == AbilityType.MoFaGongJi) { //魔法攻击 propertyNum = (generalLv * intellectNum * 7 / 100); } else if (abilityType == AbilityType.MoFaFangYu) { //魔法防御 propertyNum = (generalLv * intellectNum * 7 / 100); } } if (propertyNum.IsValid()) { return(propertyNum); } throw new ArgumentOutOfRangeException(string.Format("玩家{0}佣兵{1}属性值溢出:{2}", userID, generalID, propertyNum)); }
private static GeneralProperty GetAbilityProperty(string userID, int generalID, AbilityType abilityType) { decimal val = 0; int careerID = 0; UserGeneral ugeneral = new PersonalCacheStruct <UserGeneral>().FindKey(userID, generalID); GeneralInfo generalInfo = new ShareCacheStruct <GeneralInfo>().FindKey(generalID); if (ugeneral != null) { careerID = ugeneral.CareerID; } else if (generalInfo != null) { careerID = generalInfo.CareerID; } if (abilityType == AbilityType.WuLiGongJi || abilityType == AbilityType.WuLiFangYu || abilityType == AbilityType.HunJiGongJi || abilityType == AbilityType.HunJiFangYu || abilityType == AbilityType.MoFaGongJi || abilityType == AbilityType.MoFaFangYu) { int equNum = GetEquNum(userID, generalID, abilityType).ToInt(); int fateNum = GetFateNum(userID, generalID, abilityType).ToInt(); int propertyNum = GetPropertyNum(userID, generalID, abilityType).ToInt(); int magicNum = (int)GetEmbattleNum(userID, abilityType); int upgradeNum = GeneralUpGradeProperty(userID, generalID, abilityType).ToInt(); val = MathUtils.Addition(equNum, fateNum, int.MaxValue); val = MathUtils.Addition(val, propertyNum, int.MaxValue); val = MathUtils.Addition(val, magicNum, int.MaxValue); val = MathUtils.Addition(val, upgradeNum); //佣兵好感度数值加成 int feelNum = FeelEffectNum(userID, generalID, abilityType); val = MathUtils.Addition(val, feelNum, int.MaxValue); //法宝附加属性值 int trumpPro = (int)TrumpAbilityAttack.TrumpGeneralProperty(userID, generalID, abilityType); val = MathUtils.Addition(val, trumpPro, int.MaxValue); //附魔符属性值 int enchantNum = EnchantProprety(userID, generalID, abilityType).ToInt(); val = MathUtils.Addition(val, enchantNum); //属性转换 //val = MathUtils.Addition(val, (int)TrumpAbilityAttack.ConversionPropertyNum(userID, val, abilityType), int.MaxValue); } else if (abilityType == AbilityType.BaoJi || abilityType == AbilityType.MingZhong || abilityType == AbilityType.PoJi || abilityType == AbilityType.RenXing || abilityType == AbilityType.ShanBi || abilityType == AbilityType.GeDang || abilityType == AbilityType.BiSha) { val = GetCareerNum(careerID, abilityType); val = MathUtils.Addition(val, GetEquNum(userID, generalID, abilityType), decimal.MaxValue); val = MathUtils.Addition(val, GetFateNum(userID, generalID, abilityType), decimal.MaxValue); val = MathUtils.Addition(val, GetEmbattleNum(userID, abilityType), decimal.MaxValue); val = MathUtils.Addition(val, GeneralUpGradeProperty(userID, generalID, abilityType).ToDecimal()); //法宝附加属性值 decimal trumpPro = TrumpAbilityAttack.TrumpGeneralProperty(userID, generalID, abilityType); val = MathUtils.Addition(val, trumpPro, int.MaxValue); //附魔符属性值 decimal enchantNum = EnchantProprety(userID, generalID, abilityType); val = MathUtils.Addition(val, enchantNum); //属性转换 //val = MathUtils.Addition(val, TrumpAbilityAttack.ConversionPropertyNum(userID, val, abilityType), decimal.MaxValue); } return(new GeneralProperty() { AbilityType = abilityType, AbilityValue = val }); }